Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wallet balance always 0 after restore wallet from seed #78

Open
KimJinRyul opened this issue Sep 6, 2018 · 2 comments
Open

Wallet balance always 0 after restore wallet from seed #78

KimJinRyul opened this issue Sep 6, 2018 · 2 comments

Comments

@KimJinRyul
Copy link

KimJinRyul commented Sep 6, 2018

Hello
I've developing some bitcoin cash wallet app on android with this bitcoinj.cash library.
I've some problems with restoring wallet from seed.
I restored wallet I had created in other wallet app (handcash) and there are some BCH.
but restored wallet shows always has a zero balance.

If I send some bch to this newly restored wallet, It will be displayed as successful and it will be displayed with another wallet app(handcash) that I already have.

The newly restored wallet only shows transactions that occurred after it was restored....

how can I fix this issue?

here is the code that i've tried

NetworkParameters parameters = null;
if(walletAppKit == null || !walletAppKit.isRunning()) {
            if(BuildConfig.MAINNET)
                parameters = MainNetParams.get();
            else
                parameters = TestNet3Params.get();

            File walletDir = getFilesDir();
            walletAppKit = new WalletAppKit(parameters, walletDir, WALLET_NAME) {
                @Override
                protected void onSetupCompleted() {
                        wallet().allowSpendingUnconfirmedTransactions();;
                        wallet().addCoinsReceivedEventListener(BitcoinService.this);
                        wallet().addCoinsSentEventListener(BitcoinService.this);
                        walletAppKit.setDownloadListener(new DownloadProgressTracker() {
                            @Override
                            protected void progress(double pct, int blocksSoFar, Date date) {
                                super.progress(pct, blocksSoFar, date);
                                // progressing....
                            }
                        });
                }
            };
            walletAppKit.setBlockingStartup(false);
            walletAppKit.setAutoSave(true);
            walletAppKit.setUserAgent(getString(R.string.app_name), BuildConfig.VERSION_NAME);
            if (mnemonicCode != null) {
                   try {
                        DeterministicSeed seed = new DeterministicSeed(mnemonicCode, null, "", MnemonicCode.BIP39_STANDARDISATION_TIME_SECS);
                        walletAppKit.restoreWalletFromSeed(seed);
                    } catch (UnreadableWalletException e) {
                        e.printStackTrace();
                    }
                }
            }
            walletAppKit.startAsync();
}
@KimJinRyul
Copy link
Author

KimJinRyul commented Sep 7, 2018

It's finally get all of balances when block chain sync completed...
I've used MnemonicCode.BIP39_STANDARDISATION_TIME_SECS for default creationtime....
and it takes over several hours even with good WIFI netwrok condition.
is there any way to sync start from recent block?

@HashEngineering
Copy link
Collaborator

You can sync from a later block if the wallet, keychain or seed has a more recent creation time. If your app creates a wallet with a random seed then the creation time is known. However the mnemonic phrase has no creation time, unless you let the use enter that in addition to the seed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants