novitski / bitcoinj

Automatically exported from code.google.com/p/bitcoinj
Apache License 2.0
0 stars 0 forks source link

wallet.getBalance returns 0 BTC although it has BTC. #410

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello , when i first time download h2 or spV blockstore , i got valid wallet 
balance but after i restarting app i got 0 BTC shown when i call 
wallet.getBalance ? 

on first download
        Iterable<WalletTransaction> walletTransactions = wallet.getWalletTransactions();
        for (WalletTransaction walletTransaction : walletTransactions) {
            final Transaction transaction = walletTransaction.getTransaction();
            System.out.println(transaction);
        }
code goes inside for loop and shows all transactions on wallet.
But when i restart app when i got 0 BTC shown, the code is not entering into 
for loop.

Seems like my Blockstore doesnt have my transactions?
how can i force download wallet transactions to blockstore?
or is this a bug ?

My wallet address : 16asoo6WymyQjSUUtjtPWizP2dptM1eh8C
as shown here :
http://blockchain.info/tr/address/16asoo6WymyQjSUUtjtPWizP2dptM1eh8C
my wallet is not 0 BTC

Original issue reported on code.google.com by kadir.ba...@gmail.com on 23 May 2013 at 8:11

GoogleCodeExporter commented 9 years ago
"Your" transactions are saved in your wallet, not the block store. Did you save 
(and restore) the wallet?

See http://code.google.com/p/bitcoinj/wiki/WorkingWithTheWallet

Original comment by andreas....@gmail.com on 23 May 2013 at 8:29

GoogleCodeExporter commented 9 years ago
i checked docs but 
wallet.clearTransaction(0);
deletes all transactions inside wallet but its not downloading back from 
current block store.
Seems like i need to redownload 6+ GB for restoring a wallet ?

Original comment by kadir.ba...@gmail.com on 23 May 2013 at 8:49

GoogleCodeExporter commented 9 years ago
Resetting your wallet (aka Replaying your blockchain) is a bit tricky. You need 
to shutdown all Peer(Group)s, remove your block store file and remove all 
transactions from your wallet. Then you start up your Peer(Group) again.

You can use checkpoints and fast-catchup to make download (both initial and 
replay) dramatically faster, but its not strictly necessary and can be seen as 
an optimization.

Original comment by andreas....@gmail.com on 23 May 2013 at 9:04

GoogleCodeExporter commented 9 years ago
can you give code sample for restoring wallet as an example on git ?
it is very important for bitcoinj.

Original comment by kadir.ba...@gmail.com on 23 May 2013 at 6:51

GoogleCodeExporter commented 9 years ago
Have a look at ToyWallet from the examples or WalletTool from tools.

Can we take support cases like yours to the bitcoinj mailing list? The issue 
tracker is not an appropriate place for this.

Original comment by andreas....@gmail.com on 23 May 2013 at 8:43