3

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 !?

1 Answer 1

1

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.

4
  • 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
    Commented Oct 27, 2015 at 13:24
  • That's caused by the particular pattern of unspent outputs you happen to start with. Commented Oct 27, 2015 at 17:17
  • 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
    Commented Oct 30, 2015 at 14:37
  • @NafetzD You just have to do something sane when the job breaks, like try it again later. Commented Oct 30, 2015 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.