connect watching wallet with blockchain

0

i have created watch wallet
Wallet wallet = Wallet.fromWatchingKeyB58(params, tPub, DeterministicHierarchy.BIP32_STANDARDISATION_TIME_SECS); How can i link this with block chain i am using WalletAppKit class

kit = new WalletAppKit(params, walletFile, APP_NAME);
kit.startAsync(); kit.awaitRunning();

after that i add wallet in PeerGroup kit.peerGroup().addWallet(wallet) after that i print address of a wallet System.out.println(kit.wallet().currentReceiveAddress()); but this address and System.out.println(wallet.currentReceiveAddress()); this is not same. i am using bitcoinj for this, i have sent multiple transaction on wallet.currentReceiveAddress() but did not receive any of them, i don't know what i am doing wrong here, kindly help!

Zombie

Posted 2018-04-25T15:22:33.117

Reputation: 528

Answers

0

i have done this by overriding methods of WalletAppkit and its working fine now, here is code sample for this.

  kit = new WalletAppKit(params, walletFile, APP_NAME) {
            @Override
            protected Wallet createWallet() {
                System.out.println("I am here");
                Wallet wallet = Wallet.fromWatchingKeyB58(params, tPub, DeterministicHierarchy.BIP32_STANDARDISATION_TIME_SECS);
                return wallet;
            }
@Override
        protected void onSetupCompleted() {
            super.onSetupCompleted();
            System.out.println(kit.wallet().currentReceiveAddress());
            System.out.println(kit.wallet().getTotalReceived().toFriendlyString());
            txHistory();

            kit.wallet().addEventListener(new AbstractWalletEventListener() {
                @Override
                public void onWalletChanged(Wallet wallet) {
                    System.out.println(kit.wallet().getTotalReceived());
                }
            });
        }

Zombie

Posted 2018-04-25T15:22:33.117

Reputation: 528