Re: Can commit conflicting txs

2017-08-30 Thread Pierre
After some debugging, I can now see that the maybeCommit function doesn't 
work as I thought it would.

The behaviour I was observing seems to be done on purpose: it is possible 
to commit two conflicted transactions. Since it is kind of 
counter-intuitive, maybe adding a note to the javadoc  would help?

Andreas, would you be willing to consider a PR adding a failOnConflict 
boolean to the maybeCommit function? Something like that:

/**
 * Calls {@link Wallet#commitTx} if tx is not already in the pending pool
 *
 * @param tx The transaction which is being committed to the wallet
 * @param failOnConflict If true, an attempt at committing a transaction that 
double spends an existing pending
 *   tx will fail. Otherwise the tx will be added to the 
wallet and to the pending pool,
 *   and conflicting txes will have their status updated to 
{@link ConfidenceType#IN_CONFLICT}
 * @return true if the tx was added to the wallet, or false otherwise if it was 
already in the pending pool
 * @throws VerificationException
 */
public boolean maybeCommitTx(Transaction tx, Boolean failOnConflict) throws 
VerificationException {


Or can you recommend some other way of achieving the same goal?

Cheers,

Pierre

Le mardi 29 août 2017 23:11:39 UTC+2, Pierre a écrit :
>
>
> This is a follow up to https://github.com/bitcoinj/bitcoinj/issues/1442.
>
> > A while ago we added a new confidence type, IN_CONFLICT. That means two 
> (or more?) pending transactions are in conflict and not all of them will be 
> confirmed (but all of them *could*). I assume this is what you're seeing. 
> To be sure, have a look at the transaciton confidence of tx1 and tx2 after 
> your program run. And also maybe test this on master and on release-0.14?
>
> Yes the confidence of both transactions is indeed IN_CONFLICT, but this is 
> actually what I wanted to avoid. My question was really: why doesn't the 
> second wallet.maybeCommitTx(tx2) return false? Isn't that the whole purpose 
> of this function?
>
> Context: we use this in the Eclair implementation of the Lightning 
> network. When creating a channel, one party needs to first build a "funding 
> tx", then exchange some information with the other party (mainly: build a 
> cross signed tx that spends the not-yet-published funding tx), which takes 
> time and opens a window for concurrency issues when several channels are 
> created at the same time. What I was hoping is that I would know, before 
> publishing the second tx, that its input was already spent, so I could 
> cleanly handle this instead of just waiting for one of the txes to 
> eliminate the other one.
>
> Thanks,
>
> Pierre
>

-- 
You received this message because you are subscribed to the Google Groups 
"bitcoinj" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bitcoinj+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Sync too low when using BitCoinJ to create and host own wallet

2017-08-30 Thread Andreas Schildbach
What do you mean by 3rd party API? What does that API do? Bitcoinj is
designed to use the Bitcoin P2P protocol.


On 08/30/2017 04:12 AM, Alex Yang wrote:
> What I need is to create the wallet and just call 3rd party APIs to make
> the transactions.
> 
> In this case,  Do we need to set up a bitcoin node or we can just use
> bitcoinj to create a wallet and then use 3rd party APIs(The APIs will
> handle the sync etc.)? 
> 
> 在 2017年8月28日星期一 UTC+8下午11:00:25,Andreas Schildbach写道:
> 
> You will need at least one node to sync from, typically Bitcoin Core or
> some fork of it. PeerGroup automatically discovers peers and
> connects to
> a number of them.
> 
> 
> On 08/28/2017 10:57 AM, Alex Yang wrote:
> > Thanks Andreas! Do we need to install and run bitcoin-core or we just
> > need to set up the checkpointing?
> >
> > 在 2017年8月28日星期一 UTC+8下午2:38:51,Andreas Schildbach写道:
> >
> > See this document on how set up checkpointing:
> >
> > https://bitcoinj.github.io/speeding-up-chain-sync
> 
> >  >
> >
> >
> > On 08/27/2017 07:22 PM, Alex Yang wrote:
> > > I need to use BitcoinJ to create and host wallet on my own
> website.
> > > However, it keeps downloading blocks and the sync seems taking
> > forever.
> > > I need to be able to create a wallet within a few seconds.
> > >
> > > Could anyone please advice what should i do to optimize the
> sync
> > time?
> > >
> > > |ECKey key = new ECKey(); Address addressFromKey =
> > key.toAddress(params);
> > > Wallet wallet = new Wallet(params); wallet.importKey(key); File
> > > blockFile = new File(“/tmp/bitcoinblocks”); BlockStore
> blockStore
> > = new
> > > MemoryBlockStore(params); BlockChain chain = new
> > > BlockChain(params,blockStore); PeerGroup peerGroup = new
> > > PeerGroup(params, chain); peerGroup.addPeerDiscovery(new
> > > DnsDiscovery(params)); peerGroup.addWallet(wallet);
> > peerGroup.start();
> > > peerGroup.downloadedBlockChain(); |
> > >
> > > --
> > > You received this message because you are subscribed to the
> Google
> > > Groups "bitcoinj" group.
> > > To unsubscribe from this group and stop receiving emails
> from it,
> > send
> > > an email to bitcoinj+u...@googlegroups.com
> > > .
> > > For more options, visit https://groups.google.com/d/optout
> 
> >  >.
> >
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "bitcoinj" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send
> > an email to bitcoinj+u...@googlegroups.com
> > .
> > For more options, visit https://groups.google.com/d/optout
> .
> 
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "bitcoinj" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to bitcoinj+unsubscr...@googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups 
"bitcoinj" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bitcoinj+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.