0

I am readying the documentation at https://bitcoinj.github.io/working-with-the-wallet and I am not sure what I am missing.

Suppose I create a wallet, get its receive address and save wallet using saveToFileStream(OutputStream). Then I send bitcoins to my address, while my wallet is not running and I do not have a WalletEventListener listening for changes. I can then restore my wallet using loadFromFileStream(InputStream) to restore my wallet. How do I find transactions that may have been made and my new balance?

4

1 回答 1

2

您需要将您的钱包与区块链同步。最简单的选择可能是使用 WalletAppKit:

// for test net
NetworkParameters networkParameters = TestNet3Params.get();
// given the path to your wallet is "<walletFolderPath>/<walletFilePrefix>.wallet"
WalletAppKit kit = new WalletAppKit(networkParameters, new File(walletFolderPath), walletFilePrefix);
// start syncing with the blockchain
kit.startAsync();
// wait until syncing is done
kit.awaitRunning();

如果您不想使用 WalletAppKit,您也可以更“手动”连接到区块链,如 Bitcoinj here官方示例之一的第二部分所示

于 2019-09-22T10:18:17.293 回答