BitcoinJ : Balance and Transaction are not showing in wallet after restoring wallet from MnemonicCode

0

0

I have created a wallet with the help of WalletAppKit on Android and did some transaction in it.

Now what I try to do is, restoring that wallet from mnemonic code (BIP39). It also returns the Wallet object but it doesn't contain the transactions.

Here is the link ref https://bitcoinj.github.io/working-with-the-wallet#seeds-and-mnemonic-codes which describe the working with mnemonic code and seeds.

It also says "now sync the restored wallet as described below" but I never found any way to sync it.

DeterministicSeed seed = wallet.getKeyChainSeed();
println("Seed words are: " + Joiner.on(" ").join(seed.getMnemonicCode()));
println("Seed birthday is: " + seed.getCreationTimeSeconds());

String seedCode = "yard impulse luxury drive today throw farm pepper survey wreck glass federal";
long creationtime = 1409478661L;
DeterministicSeed seed = new DeterministicSeed(seedCode, null, "", creationtime);
Wallet restoredWallet = Wallet.fromSeed(params, seed);
// now sync the restored wallet as described below.

Aaditya Paliwal

Posted 2018-04-11T05:49:07.757

Reputation: 1

I found this link https://github.com/bitcoinj/bitcoinj/blob/master/examples/src/main/java/org/bitcoinj/examples/RestoreFromSeed.java. it takes so long time but nothing heppend.

Aaditya Paliwal 2018-04-11T10:35:46.940

Yes, that part is critical. It need to parse all historical transactions to check which ones are spendable by HD keys which are derivable from your wallet. This will take a while as includes the entire chain. The backed-up wallet doesn't know which keys or transactions were previously received, so it has to iterate through all child key indices, until it finds the index where the previous wallet stopped generating children keys (a gap of 20 unused hd keys). For each child key, it will derive the public key hash, and search for those while parsing the chain to determine whether it was used.James C. 2018-12-05T13:13:27.000

Answers

0

Jose Luis Estevez

Posted 2018-04-11T05:49:07.757

Reputation: 21