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.
  • I found this link github.com/bitcoinj/bitcoinj/blob/master/examples/src/main/java/…. it takes so long time but nothing heppend. – Aaditya Paliwal Apr 11 '18 at 10:35
  • 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. Dec 5 '18 at 13:13
0

I think this example can help you, to synchronize the wallet

https://github.com/bitcoinj/bitcoinj/blob/master/examples/src/main/java/org/bitcoinj/examples/RefreshWallet.java

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.