...to obtain total unconfirmed balance.
I am needing this frequently, so this might be useful for other people, too.
...to obtain total unconfirmed balance.
I am needing this frequently, so this might be useful for other people, too.
Conflicts:
src/rpcserver.cpp
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/6027b460e40e7769930d0e89f18f011fa0f6c262 for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.
What do you need this for?
Unconfirmed balances are very dangerous things.....
In one project that is working both with unconfirmed and raw transactions I need to monitor the unconfirmed funds in the hot wallet. First I tried approaches like
confirmed = bitcoind_api.getbalance('*', 1)
inc_unconfirmed = bitcoind_api.getbalance('*', 0)
unconfirmed = inc_unconfirmed - confirmed
and several variations. But this was not working like intended. If I remember correctly the problem was that outgoing transactions, while being unconfirmed, are still taken into account with the getbalance methods, leading to wrong results. Compared with messing around with the getbalance method (including the non-intuitive account handling...) the new "getunconfirmedbalance" method seems quite straightforward and does exactly what it says.
I still don't understand what, at a high level, you were trying to accomplish. It sounds like maybe you should be using -walletnotify instead of polling getbalance.
The unconfirmed balance is shown in the GUI, so in a way it makes sense to expose it on the RPC as well.
And this looks like a pretty sane and minimal code addition as these things go.
But indeed, relying on it to see if funds have arrived is dangerous.
Thanks for your comments. I am running a site that works a lot with unconfirmed transactions, raw transactions and a very custom coin control implementation, so I am aware of the risks involved. The highlevel usecase i need this for is very simple. I have a job running every few minutes that collects from bitcoind both confirmed and unconfirmed balance. If any of the values is outside a certain threshhold I am getting notified to investigate or take measures. I just could not get the unconfirmed balance reliable with the existing rpc "getbalance" command, while this pull request makes it very easy :)
I've got a feeling I'm going to regret this... but ACK.
ACK