这是钱包、区块和 PeerGroup 的初始化:
Wallet wallet = new Wallet(params, KeyChainGroup.createBasic(params));
BlockChain chain = new BlockChain(params, wallet, new MemoryBlockStore(params));
PeerGroup peerGroup = new PeerGroup(params, chain);
peerGroup.addWallet(wallet);
peerGroup.start();
这是交易代码:
Address targetAddress = Address.fromString(params,"mxRLrEdaPKyts9CvaVhphTLqZe3xpdNJjM");
Wallet.SendResult result = wallet.sendCoins(peerGroup, targetAddress,
Coin.valueOf(100000));
peerGroup.broadcastTransaction(result.tx);
但是当我运行程序时,我遇到了这个错误:
Exception in thread "main" org.bitcoinj.core.InsufficientMoneyException: Insufficient money, missing 0.001 BTC
at org.bitcoinj.wallet.Wallet.calculateFee(Wallet.java:5070)
at org.bitcoinj.wallet.Wallet.completeTx(Wallet.java:4165)
at org.bitcoinj.wallet.Wallet.sendCoinsOffline(Wallet.java:3962)
at org.bitcoinj.wallet.Wallet.sendCoins(Wallet.java:4029)
at org.bitcoinj.wallet.Wallet.sendCoins(Wallet.java:3998)
at com.example.blockchainwallet.BitcoinUtils.main(BitcoinUtils.java:30)