我正在嘗試學習bitcoinj API,並且已經編寫了下面的測試代碼。我上創建一個帳戶:使用bitcoinj檢查錢包餘額
所以可以使用假硬幣和測試發送/接收。當我登錄到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);
}
}
你會得到,如果你聯繫誰支持真實那API更好地支持檢查bitcoinj平衡。 – keshlam