I'm try get pending balance from wallet, but results do not match with pending transactions? Thanks for advice!
1 Answer
Edit: I don't think there's a method to do that, but this should do the same thing:
// calculate balance, only include transactions that are not in a block
List<TransactionOutput> candidates = wallet.calculateAllSpendCandidates(false, false);
Coin value = Coin.ZERO;
for (TransactionOutput out : candidates) {
if(out.getParentTransaction().getAppearsInHashes() == null) {
// Not seen in any block that we know of
value = value.add(out.getValue());
}
}
-
I want to get only pending amount, Wallet.getBalance() returns the available amount. Wallet.getBalance(Wallet.BalanceType.ESTIMATED) returns a total amount (available + pending). In theory total amount - available amount = pending amount, but this result not match with amount that I send to test. Commented Jul 23, 2015 at 17:23
-
@AnderAcosta Gotcha. Let me check the source to see if what you're looking for is possible. Commented Jul 23, 2015 at 17:42
-
-
I'm using this: Coin pending = Coin.ZERO; for (Transaction transaction : wallet.getPendingTransactions()) { pending = pending.add(transaction.getValueSentToMe(wallet)); } I test your code and comparate the values, this returns the same value of your code Commented Jul 23, 2015 at 18:41
-
I think found a error. When I get the pending transactions , I get one, according blockchain.info has more than 1000 confirmations , but in the wallet , this transaction is in pending state. I checked the downloaded blocks and is synchronized with the blockchain . It may be a bug of bitcoinJ? This is the transaction: blockchain.info/tx/… Commented Jul 24, 2015 at 9:07