watch-only wallet with bitcoin-cli

2

i'm trying to see all tx hashes and the balance for an address i don't own:

$ bitcoin-cli importaddress 1M43pksKTGpBd8J8XzjStjgnX5vie1kpYA
$ # wait 5 minutes while bitcoind presumably scans all txs
$ # for this address
$ bitcoin-cli getbalance 1M43pksKTGpBd8J8XzjStjgnX5vie1kpYA
0.00000000

bitcoind claims this address has no balance while blockchain.info currently shows a final balance of 0.00993754 BTC

why is this not working?

however the listunspent command appears to list the unspent transactions correctly:

$ bitcoin-cli listunspent 1M43pksKTGpBd8J8XzjStjgnX5vie1kpYA
[
    {
        "txid" : "0fdcdeff329b91fb9888720c958d550c39716f92abec4e5b6ff7c53a22bb31c2",
        "vout" : 0,
        "address" : "1M43pksKTGpBd8J8XzjStjgnX5vie1kpYA",
        "account" : "",
        "scriptPubKey" : "76a914dbf61ed2ce1def33a34d89ab7b05ccc25d9cf02288ac",
        "amount" : 0.00010000,
        "confirmations" : 3608,
        "spendable" : false
    },
    {
        "txid" : "db1beb183808e8b41064405d43bd6c684874b5f328bfb565c4e16cc2baaa0d18",
        "vout" : 1,
        "address" : "1M43pksKTGpBd8J8XzjStjgnX5vie1kpYA",
        "account" : "",
        "scriptPubKey" : "76a914dbf61ed2ce1def33a34d89ab7b05ccc25d9cf02288ac",
        "amount" : 0.00983754,
        "confirmations" : 4459,
        "spendable" : false
    }
]

adding up the funds here: 0.00983754 + 0.00010000 = 0.00993754 matches the blockchain.info figure. maybe getbalance only shows spendable funds?

mulllhausen

Posted 2015-06-20T04:55:53.373

Reputation: 1 533

Answers

1

Try getbalance "*" 0 true.

help of getbalance says: getbalance ( "account" minconf includeWatchonly )

Jonas Schnelli

Posted 2015-06-20T04:55:53.373

Reputation: 5 465

i was hoping for balances denominated by address instead of a single number for all addresses. still, cheers for the answer :)mulllhausen 2015-06-20T09:27:52.573

If you like to aggregate by address, you can use bitcoin-cli getreceivedbyaddress "<adr>" 0Jonas Schnelli 2015-06-20T10:14:42.910

good to know thanks. but this isn't quite the same as a balance - its the total received but does not subtract spent coinsmulllhausen 2015-06-20T12:52:00.760

That is intentional. Addresses are intended to be one-use destinations for payments, and getreceivedbyaddress can tell you whether the expected amount has been paid to it. Apart from that, all coins in the wallet are treated as belonging to the wallet and not to individual addresses, which is simpler to reason about that about individual addresses, especially when change outputs move coins are for privacy reasons.Pieter Wuille 2015-06-20T14:04:08.713