我正在尝试学习 bitcoinj API,并且我已经编写了下面的测试代码。我创建了一个帐户:
所以我可以使用假币并测试发送/接收。当我登录该 URL 时,我的帐户显示了 14 个假 BTC。但是,我下面的代码表明我有 0 个硬币。有人可以帮我理解我错过了什么吗?我都使用了getBalance
,getWatchedBalance
但没有运气。
public class CheckBalance {
public static void main(String[] args) throws Exception {
// This line makes the log output more compact and easily read, especially when using the JDK log adapter.
BriefLogFormatter.init();
// Figure out which network we should connect to. Each one gets its own set of files.
final NetworkParameters params = TestNet3Params.get();
final String filePrefix = "forwarding-service-testnet";
// Parse the address given as the first parameter.
final Address forwardingAddress = new Address(params, "bogusHash"); //note, I replace bogusHash when I really run
// Start up a basic app using a class that automates some boilerplate.
final WalletAppKit kit = new WalletAppKit(params, new File("."), filePrefix);
// Download the block chain and wait until it's done.
kit.startAndWait();
System.out.println("You have : " +kit.wallet().getWatchedBalance() + " bitcoins");
System.exit(0);
}
}