<p>Edit: I don't think there's a method to do that, but this should do the same thing:</p>

<pre><code>// calculate balance, only include transactions that are not in a block
List&lt;TransactionOutput&gt; 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());
    }
}
</code></pre>

CC BY-SA 3.0
2015-07-23T17:23:44.793Z
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.
Ander Acosta
CC BY-SA 3.0
2015-07-23T17:42:06.317Z
@AnderAcosta Gotcha. Let me check the source to see if what you're looking for is possible.
Nick ODell
CC BY-SA 3.0
2015-07-23T17:56:39.523Z
@AnderAcosta See edit.
Nick ODell
CC BY-SA 3.0
2015-07-23T18:41:20.037Z
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
Ander Acosta
CC BY-SA 3.0
2015-07-24T09:07:52.143Z
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: https://blockchain.info/tx/282fdbc7139669cad97468949285ccf102f289f54f0dc3d9a6653448bab41192
Ander Acosta
CC BY-SA 3.0
2015-07-24T10:51:39.420Z
As I supposed , the transaction was pending had not been included as confirmed in the wallet , I erased the blockStore and returned to synchronize the wallet from the beginning. The transaction became confirmed once synchronized the wallet. Your code works! Thanks!!
Ander Acosta
CC BY-SA 3.0
2015-07-23T16:55:25.270Z
2015-07-23T17:55:55.943Z
2015-07-23T17:55:55.943Z
Nick ODell
<p>I'm try get pending balance from wallet, but results do not match with pending transactions? Thanks for advice!</p>

<bitcoinj><balance>
How to get pending balance in with bitcoinj?
Ander Acosta
# How to get pending balance in with bitcoinj?

(Asked by: username_0 on 2015-07-23)

I'm try get pending balance from wallet, but results do not match with pending transactions? Thanks for advice!

**Tags:** bitcoinj, balance


---

## 1 answers

### Answer by username_1 on 2015-07-23. Score: 0 | Accepted 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());
    }
}

```

> **Comments:**
> **username_0**: 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.  
> **username_1**: @username_0 Gotcha. Let me check the source to see if what you're looking for is possible.  
> **username_1**: @username_0 See edit.  
> **username_0**: 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  
> **username_0**: 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: https://blockchain.info/tx/282fdbc7139669cad97468949285ccf102f289f54f0dc3d9a6653448bab41192  
> **username_0**: As I supposed , the transaction was pending had not been included as confirmed in the wallet , I erased the blockStore and returned to synchronize the wallet from the beginning. The transaction became confirmed once synchronized the wallet. Your code works! Thanks!!  

---

