1

We have a bitcoin core client running on a production machine. This machine cannot have the private key so each address is added as watch only.

So far it has worked perfectly, but recently we need to display the btc amount that is waiting confirmation and the amount that is confirmed (at least 1 confirmation)

bitcoin-rpc getbalance * 0 true
bitcoin-rpc getunconfirmedbalance

these are the two methods that I've found online that should work, but they are not working.

getbalance returns only the confirmed amount and getunconfirmedbalance returns always 0

How can I get the unconfirmed balance on a watch only wallet?

1

You can use the getbalances command. It will return all of the balances belonging to the wallet, including ones the wallet can sign for, watch only things, trusted (confirmed transactions and unconfirmed change), and immature coinbase outputs.

Here is the help output for it.

getbalances
Returns an object with all balances in BTC.

Result:
{
    "mine": {                        (object) balances from outputs that the wallet can sign
      "trusted": xxx                 (numeric) trusted balance (outputs created by the wallet or confirmed outputs)
      "untrusted_pending": xxx       (numeric) untrusted pending balance (outputs created by others that are in the mempool)
      "immature": xxx                (numeric) balance from immature coinbase outputs
      "used": xxx                    (numeric) (only present if avoid_reuse is set) balance from coins sent to addresses that were previously spent from (potentially privacy violating)
    },
    "watchonly": {                   (object) watchonly balances (not present if wallet does not watch anything)
      "trusted": xxx                 (numeric) trusted balance (outputs created by the wallet or confirmed outputs)
      "untrusted_pending": xxx       (numeric) untrusted pending balance (outputs created by others that are in the mempool)
      "immature": xxx                (numeric) balance from immature coinbase outputs
    },
}
  • getbalances not longer works: via rpc JSONRPCError ({"code"=>-32601, "message"=>"Method not found"}) via bitcoin-cli Method not found – Nicos Karalis Jul 16 at 18:50
  • Forgot to mention, I'm using Bitcoin Core Daemon version v0.18.0.0-g2472733a24a9364e4c6233ccd04166a26a68cc65 – Nicos Karalis Jul 16 at 19:09
  • 1
    getbalances in new in master; it isn't in any released version yet. – Pieter Wuille Jul 16 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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