Transactions
將觀看錢包與區塊鏈連接
我已經創建了手錶錢包
Wallet wallet = Wallet.fromWatchingKeyB58(params, tPub, DeterministicHierarchy.BIP32_STANDARDISATION_TIME_SECS);
我如何將它與我正在使用 WalletAppKit 類的區塊鍊鍊接kit = new WalletAppKit(params, walletFile, APP_NAME); kit.startAsync(); kit.awaitRunning();
之後,我在 PeerGroup 中添加了錢包,
kit.peerGroup().addWallet(wallet)
然後我列印了錢包的地址,System.out.println(kit.wallet().currentReceiveAddress());
但這個地址和System.out.println(wallet.currentReceiveAddress());
這個地址不一樣。我正在為此使用bitcoinj,我已經發送了多個交易wallet.currentReceiveAddress()
但沒有收到任何交易,我不知道我在這裡做錯了什麼,請幫忙!
我已經通過覆蓋 WalletAppkit 的方法來做到這一點,現在它工作正常,這裡是程式碼範例。
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()); } }); }