Closed GoogleCodeExporter closed 9 years ago
Ok, I've looked into it a bit... It might be right that the blockstore keeps a
pointer, but the wallet needs a second pointer.
Starting a BlockChain (the one that connects a blockstore and a wallet) should
sync both pointers. A peer download should update the blockstore and currently
connected wallets...
I'll try to build an experimental patch.
Original comment by rtreffer@gmail.com
on 26 Jun 2011 at 11:43
I think the actual issue here is that you are expected to flush the wallet to
disk quite frequently and the code doesn't help you do that.
Generally, BitCoinJ is a very low level library and it assumes too much
knowledge of how Bitcoin works. I'd like to see it get easier to use, eg, by
changing how wallet persistence works so the wallet can save itself rather than
relying on the API user.
Original comment by hearn@google.com
on 27 Jun 2011 at 9:35
Hmm, I don't think my lost coins problem is related to not saving the wallet.
I am saving just after the wallet is created the first time, onCoinsReceived(),
onReorganize() and after sendCoins(). Is there any other case I need to cover?
Original comment by andreas....@gmail.com
on 27 Jun 2011 at 12:25
>Is there any other case I need to cover?
Yes. If your wallet receives a transaction that spends some of your BTC you
will not get an onCoinsReceived(). In general we should have an
OnWalletChanged() event, which would allow you to save the wallet, or we should
have an automatic wallet save where the wallet owns an OutputStream factory so
it can automatically save. Issue #38 has a brief discussion on when to save the
wallet.
Original comment by jan.mol...@gmail.com
on 26 Jul 2011 at 9:10
> If your wallet receives a transaction that spends some of your BTC you will
not get an onCoinsReceived().
Does this mean I always need to save the wallet when the application ends,
because there could have been changes I did not notice?
This would be bad news, because there is no "onDestroy()" on Android
applications.
Original comment by andreas....@gmail.com
on 26 Jul 2011 at 11:49
I believe that the wallet should store a pointer to the last block processed
from the chain. On startup, we should scan all blocks in the chain that are
newer than that and also handle re-org if the last-processed block is no longer
on the best chain.
Original comment by mi...@google.com
on 14 Oct 2011 at 8:25
Original comment by mi...@google.com
on 14 Oct 2011 at 8:27
Original comment by hearn@google.com
on 8 Jan 2013 at 4:41
Over time this has got a lot easier - the wallet autosaves itself these days,
and the example apps show how to register a VM shutdown hook to do a save when
Java is shutting down. You still have to do a little bit of setup yourself, but
it's harder for transactions to go walkies due to the wallet not being saved at
the right times.
Original comment by hearn@google.com
on 31 Mar 2013 at 1:31
Original issue reported on code.google.com by
rtreffer@gmail.com
on 26 Jun 2011 at 11:34