Author

Topic: bitcoin-cli listtransactions not working for watch-only address (Read 2360 times)

legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
Have you tried a "listunspent" (assuming there are UXTOs for the watch only address)?

(I've had no issues using that command with watch only addresses)
jr. member
Activity: 30
Merit: 1
Quote
Someone may be able to advise better, but just adding the address won't make bitcoind find all historical transactions, you may have to rescan/reindex to get them, which takes time!

Quote
OP, you have to re-scan/re-index.  When you import an address, it only sees transactions that happen after you imported it, because as it downloads the blockchain, while it does save the entire blockchain, it only saves in your wallet file data that it knows is relevant to your wallet.  So if there were past transactions for an imported address, you have to rescan.

rescanning is what the final argument of importaddress is for:

Code:
$ bitcoin-cli help importaddress
importaddress "address" ( "label" rescan )

Adds an address or script (in hex) that can be watched as if it were in your wallet but cannot be used to spend.

Arguments:
1. "address"          (string, required) The address
2. "label"            (string, optional, default="") An optional label
3. rescan               (boolean, optional, default=true) Rescan the wallet for transactions

if you look at my first post you will see i used the linux "time" command - it took 41 minutes and 59 seconds to import this watch-only address and still failed.
hero member
Activity: 793
Merit: 1026
OP, you have to re-scan/re-index.  When you import an address, it only sees transactions that happen after you imported it, because as it downloads the blockchain, while it does save the entire blockchain, it only saves in your wallet file data that it knows is relevant to your wallet.  So if there were past transactions for an imported address, you have to rescan.  Then as it rescans it will see data for the new imported address that it now deems relevant, and that will be saved and available for you to query, after the rescan completes.
sr. member
Activity: 412
Merit: 287
Someone may be able to advise better, but just adding the address won't make bitcoind find all historical transactions, you may have to rescan/reindex to get them, which takes time!

If you want to start digging around, the source code for importaddress is here: https://github.com/bitcoin/bitcoin/blob/master/src/wallet/rpcdump.cpp#L154
jr. member
Activity: 30
Merit: 1
should i submit a bug report? i wish my knowledge of c++ was better - i could investigate by actually stepping through the code
jr. member
Activity: 30
Merit: 1
i just want to see transaction hashes for account "1GkktBuJ6Pr51WEJe5ZzyNvMYaMDFjwyDk". but like i said at the start, its not working:

i'm having no luck getting bitcoin-cli listtransactions to work for a watch-only address:

Code:
# pick a random address to watch from blockchain.info:
$ addr=1GkktBuJ6Pr51WEJe5ZzyNvMYaMDFjwyDk
$ time bitcoin-cli importaddress $addr "$addr" true
real    41m59.505s
user    0m0.004s
sys 0m0.004s
$ bitcoin-cli listtransactions "$addr" 100 0 true
[
]
$ bitcoin-cli getinfo
{
    "version" : 100200,
    "protocolversion" : 70002,
    "walletversion" : 60000,
    "balance" : 0.00000000,
    "blocks" : 384806,
    "timeoffset" : 0,
    "connections" : 8,
    "proxy" : "",
    "difficulty" : 65848255179.70261383,
    "testnet" : false,
    "keypoololdest" : 1381701523,
    "keypoolsize" : 101,
    "paytxfee" : 0.00000000,
    "relayfee" : 0.00001000,
    "errors" : ""
}

its only producing an empty list, but blockchain.info shows 6 transactions for this address. is it broken or am i doing something wrong?
staff
Activity: 4242
Merit: 8672
You're asking about account "" but you imported the address in account "1GkktBuJ6Pr51WEJe5ZzyNvMYaMDFjwyDk".
staff
Activity: 3458
Merit: 6793
Just writing some code
This is a little confusing. I just tried and imported the address as watching only. List transactions did return  some transactions, but not all gave me the receiving  transactions.
jr. member
Activity: 30
Merit: 1
The empty quotes were not optional, the account name field is missing in your example of trying it.

right, but it still doesn't show me the transactions for that watch-only address:

Code:
$ bitcoin-cli listtransactions "" 99999 0 true | grep 1GkktBuJ6Pr51WEJe5ZzyNvMYaMDFjwyDk


ie the output is blank. i'm fairly certain it is watching this address though:

Code:
$ bitcoin-cli listaddressgroupings
[
 [
        [
            "1GkktBuJ6Pr51WEJe5ZzyNvMYaMDFjwyDk",
            0.00000000,
            "1GkktBuJ6Pr51WEJe5ZzyNvMYaMDFjwyDk"
        ]
    ]
]
staff
Activity: 4242
Merit: 8672
The empty quotes were not optional, the account name field is missing in your example of trying it.
jr. member
Activity: 30
Merit: 1
Listtransactions does not work by address. It works by accounts. The command should instead be
Code:
bitcoin-cli listtransactions 100 0 true
Since this command has no defined account, it will list all the transactions for all the addresses in your wallet.

have you tried running this? when i run it i get the following:

Code:
$ bitcoin-cli listtransactions 100 0 true
error: {"code":-1,"message":"value is type bool, expected int"}
jr. member
Activity: 30
Merit: 1
i know that - that's why i made an account with the name of an address:

Code:
$ addr=1GkktBuJ6Pr51WEJe5ZzyNvMYaMDFjwyDk
$ time bitcoin-cli importaddress $addr "$addr" true

i could just as well have done:

Code:
$ addr=1GkktBuJ6Pr51WEJe5ZzyNvMYaMDFjwyDk
$ time bitcoin-cli importaddress $addr "bob" true
$ bitcoin-cli listtransactions "bob" 100 0 true

and it would be the same. also note that the results of listaddressgroupings confirm this:

Code:
$ bitcoin-cli listaddressgroupings
[
 [
        [
            "1GkktBuJ6Pr51WEJe5ZzyNvMYaMDFjwyDk",
            0.00000000,
            "1GkktBuJ6Pr51WEJe5ZzyNvMYaMDFjwyDk"
        ]
    ]
]
staff
Activity: 3458
Merit: 6793
Just writing some code
Listtransactions does not work by address. It works by accounts. The command should instead be
Code:
bitcoin-cli listtransactions "" 100 0 true
Since this command has no defined account, it will list all the transactions for all the addresses in your wallet.

EDIT: Sorry, typo. Forgot the quotes.
jr. member
Activity: 30
Merit: 1
i'm having no luck getting bitcoin-cli listtransactions to work for a watch-only address:

Code:
# pick a random address to watch from blockchain.info:
$ addr=1GkktBuJ6Pr51WEJe5ZzyNvMYaMDFjwyDk
$ time bitcoin-cli importaddress $addr "$addr" true
real    41m59.505s
user    0m0.004s
sys 0m0.004s
$ bitcoin-cli listtransactions "$addr" 100 0 true
[
]
$ bitcoin-cli getinfo
{
    "version" : 100200,
    "protocolversion" : 70002,
    "walletversion" : 60000,
    "balance" : 0.00000000,
    "blocks" : 384806,
    "timeoffset" : 0,
    "connections" : 8,
    "proxy" : "",
    "difficulty" : 65848255179.70261383,
    "testnet" : false,
    "keypoololdest" : 1381701523,
    "keypoolsize" : 101,
    "paytxfee" : 0.00000000,
    "relayfee" : 0.00001000,
    "errors" : ""
}

its only producing an empty list, but blockchain.info shows 6 transactions for this address. is it broken or am i doing something wrong?
Jump to: