<p>It's due to confirmation times and there's nothing you can do about it. Until a payment confirms, its outputs are not spendable because you cannot be sure the payment will in fact confirm. This includes the "change" outputs from a transaction. You could try to keep a large pool of available unspent outputs available.</p>

<p>Update: The behavior you're describing is not unusual. Until a transaction gets included in a block, it's stuck at zero confirmations. Each payment you make takes one or more of your unspent outputs and consumes it, producing a new unspent output back to you for the "change".</p>

<p>Say you have two unspent outputs, one for 1 Bitcoin and one for 0.4 Bitcoins and you need to make a payment of 1.2 Bitcoins to someone. You make a payment that takes in both your unspent outputs, sends 1.2 Bitcoins to the recipient, and the remaining 0.2 Bitcoins back to you. At the moment, the only Bitcoins you have are that 0.2 Bitcoin "change" output, and it's not yet confirmed.</p>

CC BY-SA 3.0
2015-10-27T13:24:14.613Z
Thank you for the answer @David Schwartz ! I understand your point but on a successful sessions that I mentioned in the question, everything is normal - in both wallets, transactions are on the history list, even if they have 0 confirmations and balance is correct (exactly balance - (amount + fee)). I observed the wallets history and i noticed other thing. I will edit the question with the additional information.
NafetzD
CC BY-SA 3.0
2015-10-27T17:17:19.333Z
That's caused by the particular pattern of unspent outputs you happen to start with.
David Schwartz
CC BY-SA 3.0
2015-10-30T14:37:25.160Z
Hello, David! I realized that this behavior is normal because when transaction get confirmed, tx history in the wallet is correct. I think the problem is that a minute is not enough for transaction to enter into the blockchain because I tried to send coins with sendCoinsWaitBroadcast method and realize that time for the transaction to enter block chain vary. Sometimes enter immediately, sometimes for like 10-20-30 sec, and sometimes exceeds the minute limit and job breaks and when it's in waiting state wallet balance is 0. I guess i must think about providing more time or something.
NafetzD
CC BY-SA 3.0
2015-10-30T14:50:13.487Z
@NafetzD You just have to do something sane when the job breaks, like try it again later.
David Schwartz
CC BY-SA 3.0
2015-10-26T23:11:14.610Z
2015-10-27T20:45:30.060Z
2015-10-27T20:45:30.060Z
David Schwartz
<p>I have a JavaWebApp wich uses bitcoinj 0.13.2 for sending bitcoins from a wallet to a particular address in a <code>TimerTask</code>. When the job starts, every minute I send 10000 satoshis to the address. The fee of the transaction is 1000 satoshis. Transaction confirmations are 0.</p>

<p>The problem is that I randomly get <code> InsufficientMoneyException </code>, although there are a lot more funds than 11000 available in the wallet , wich are needed for the transactions.</p>

<p>For example I have successfuly completed 1 job for 30 minutes after that i start another to a different address and on the third transaction i got the exception. Even if the fee is more than 1000 or confirmations set > 0, I can't understand how balance like: 0.10720419 BTC (10720419 satoshis) can be exhausted with two transactions for 10000 satoshis(i tried even with wallet which have balance of 9.43673481 BTC (943673481 satoshis) and it has been exhausted with several transactions too)?</p>

<p>When the transaction is complete everything is normal and the available balance is correct, so i can start another transaction but that can take a lot more time than a minute. I can't understand the reason why so many coins are reserved(unavailable).</p>

<p>If its due confirmations or fees, is there any workaround so transaction per minute goal can be achieved?</p>

<p>I use TestNet3 for testing</p>

<p>I use <code>walletKit.wallet().sendCoins(walletKit.peerGroup(), to, Coin.valueOf(amount))</code> for sending coins.</p>

<p>Before transaction that trigger the exception, previous one are in kind of stuck state - it appears only in sender tx history and stuck on 0 notifications for like 1-2 hours. When it receive 1 confirmation it appears on the receiver wallet tx history with 0 confirmation and with other create date(time).Tx.ID is same. I cant understand the reason for this behavior !? At the moment in wallets tx history i got :</p>

<p>sender: date - 10/27/2015 11:35 amount - 0.0001 fee - 0.00001 conf - 3 tx.id:8eee2f5e92edc0ba8ab656e9364646507158fa91f74364815c7b36ecac7fdd69;</p>

<p>receiver: 10/27/2015 13:52 amount - 0.0001 fee - 0.00001 conf - 0 tx.id:8eee2f5e92edc0ba8ab656e9364646507158fa91f74364815c7b36ecac7fdd69.</p>

<p>I am new in bitcoinj and bitcoins at all but that seems very unusual and i really want to figure out the reason for this behavior !?</p>

<testnet><bitcoinj><java>
Bitcoin transactions reserve more coins than needed
NafetzD
# Bitcoin transactions reserve more coins than needed

(Asked by: username_0 on 2015-10-26)

I have a JavaWebApp wich uses bitcoinj 0.13.2 for sending bitcoins from a wallet to a particular address in a `TimerTask`. When the job starts, every minute I send 10000 satoshis to the address. The fee of the transaction is 1000 satoshis. Transaction confirmations are 0.

The problem is that I randomly get  `InsufficientMoneyException` , although there are a lot more funds than 11000 available in the wallet , wich are needed for the transactions.

For example I have successfuly completed 1 job for 30 minutes after that i start another to a different address and on the third transaction i got the exception. Even if the fee is more than 1000 or confirmations set > 0, I can't understand how balance like: 0.10720419 BTC (10720419 satoshis) can be exhausted with two transactions for 10000 satoshis(i tried even with wallet which have balance of 9.43673481 BTC (943673481 satoshis) and it has been exhausted with several transactions too)?

When the transaction is complete everything is normal and the available balance is correct, so i can start another transaction but that can take a lot more time than a minute. I can't understand the reason why so many coins are reserved(unavailable).

If its due confirmations or fees, is there any workaround so transaction per minute goal can be achieved?

I use TestNet3 for testing

I use `walletKit.wallet().sendCoins(walletKit.peerGroup(), to, Coin.valueOf(amount))` for sending coins.

Before transaction that trigger the exception, previous one are in kind of stuck state - it appears only in sender tx history and stuck on 0 notifications for like 1-2 hours. When it receive 1 confirmation it appears on the receiver wallet tx history with 0 confirmation and with other create date(time).Tx.ID is same. I cant understand the reason for this behavior !? At the moment in wallets tx history i got :

sender: date - 10/27/2015 11:35 amount - 0.0001 fee - 0.00001 conf - 3 tx.id:8eee2f5e92edc0ba8ab656e9364646507158fa91f74364815c7b36ecac7fdd69;

receiver: 10/27/2015 13:52 amount - 0.0001 fee - 0.00001 conf - 0 tx.id:8eee2f5e92edc0ba8ab656e9364646507158fa91f74364815c7b36ecac7fdd69.

I am new in bitcoinj and bitcoins at all but that seems very unusual and i really want to figure out the reason for this behavior !?

**Tags:** testnet, bitcoinj, java


---

## 1 answers

### Answer by username_1 on 2015-10-26. Score: 1 | Accepted answer

It's due to confirmation times and there's nothing you can do about it. Until a payment confirms, its outputs are not spendable because you cannot be sure the payment will in fact confirm. This includes the "change" outputs from a transaction. You could try to keep a large pool of available unspent outputs available.

Update: The behavior you're describing is not unusual. Until a transaction gets included in a block, it's stuck at zero confirmations. Each payment you make takes one or more of your unspent outputs and consumes it, producing a new unspent output back to you for the "change".

Say you have two unspent outputs, one for 1 Bitcoin and one for 0.4 Bitcoins and you need to make a payment of 1.2 Bitcoins to someone. You make a payment that takes in both your unspent outputs, sends 1.2 Bitcoins to the recipient, and the remaining 0.2 Bitcoins back to you. At the moment, the only Bitcoins you have are that 0.2 Bitcoin "change" output, and it's not yet confirmed.

> **Comments:**
> **username_0**: Thank you for the answer @username_1 ! I understand your point but on a successful sessions that I mentioned in the question, everything is normal - in both wallets, transactions are on the history list, even if they have 0 confirmations and balance is correct (exactly balance - (amount + fee)). I observed the wallets history and i noticed other thing. I will edit the question with the additional information.  
> **username_1**: That's caused by the particular pattern of unspent outputs you happen to start with.  
> **username_0**: Hello, username_1! I realized that this behavior is normal because when transaction get confirmed, tx history in the wallet is correct. I think the problem is that a minute is not enough for transaction to enter into the blockchain because I tried to send coins with sendCoinsWaitBroadcast method and realize that time for the transaction to enter block chain vary. Sometimes enter immediately, sometimes for like 10-20-30 sec, and sometimes exceeds the minute limit and job breaks and when it's in waiting state wallet balance is 0. I guess i must think about providing more time or something.  
> **username_1**: @username_0 You just have to do something sane when the job breaks, like try it again later.  

---

