Add rpc command 'getunconfirmedbalance'... #3369

pull TripleSpeeder wants to merge 1 commits into bitcoin:master from TripleSpeeder:master changing 3 files +11 −0
  1. TripleSpeeder commented at 5:56 PM on December 8, 2013: contributor

    ...to obtain total unconfirmed balance.

    I am needing this frequently, so this might be useful for other people, too.

  2. Add rpc command 'getunconfirmedbalance' to obtain total unconfirmed balance
    Conflicts:
    	src/rpcserver.cpp
    6027b460e4
  3. BitcoinPullTester commented at 6:20 PM on December 8, 2013: none

    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.

  4. gavinandresen commented at 12:31 AM on December 9, 2013: contributor

    What do you need this for?

    Unconfirmed balances are very dangerous things.....

  5. TripleSpeeder commented at 8:37 AM on December 9, 2013: contributor

    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.

  6. gavinandresen commented at 8:58 AM on December 9, 2013: contributor

    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.

  7. laanwj commented at 8:08 AM on December 10, 2013: member

    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.

  8. TripleSpeeder commented at 4:39 PM on December 10, 2013: contributor

    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 :)

  9. gavinandresen commented at 11:46 PM on December 10, 2013: contributor

    I've got a feeling I'm going to regret this... but ACK.

  10. jgarzik commented at 11:59 PM on December 12, 2013: contributor

    ACK

  11. laanwj referenced this in commit 23981b1f47 on Dec 20, 2013
  12. laanwj merged this on Dec 20, 2013
  13. laanwj closed this on Dec 20, 2013

  14. Bushstar referenced this in commit 0fa2e14065 on Apr 8, 2020
  15. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 21:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me