Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: qrius1111 on November 22, 2015, 01:19:48 PM



Title: bitcoin-cli listtransactions not working for watch-only address
Post by: qrius1111 on November 22, 2015, 01:19:48 PM
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?


Title: Re: bitcoin-cli listtransactions not working for watch-only address
Post by: achow101 on November 22, 2015, 03:08:14 PM
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.


Title: Re: bitcoin-cli listtransactions not working for watch-only address
Post by: qrius1111 on November 22, 2015, 09:08:51 PM
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"
        ]
    ]
]


Title: Re: bitcoin-cli listtransactions not working for watch-only address
Post by: qrius1111 on November 22, 2015, 09:18:18 PM
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"}


Title: Re: bitcoin-cli listtransactions not working for watch-only address
Post by: gmaxwell on November 22, 2015, 10:41:00 PM
The empty quotes were not optional, the account name field is missing in your example of trying it.


Title: Re: bitcoin-cli listtransactions not working for watch-only address
Post by: qrius1111 on November 22, 2015, 10:48:29 PM
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"
        ]
    ]
]


Title: Re: bitcoin-cli listtransactions not working for watch-only address
Post by: achow101 on November 22, 2015, 11:08:08 PM
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.


Title: Re: bitcoin-cli listtransactions not working for watch-only address
Post by: gmaxwell on November 23, 2015, 02:34:42 AM
You're asking about account "" but you imported the address in account "1GkktBuJ6Pr51WEJe5ZzyNvMYaMDFjwyDk".


Title: Re: bitcoin-cli listtransactions not working for watch-only address
Post by: qrius1111 on November 23, 2015, 02:42:00 AM
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?


Title: Re: bitcoin-cli listtransactions not working for watch-only address
Post by: qrius1111 on November 28, 2015, 04:16:22 AM
should i submit a bug report? i wish my knowledge of c++ was better - i could investigate by actually stepping through the code


Title: Re: bitcoin-cli listtransactions not working for watch-only address
Post by: fbueller on December 02, 2015, 05:59:53 AM
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


Title: Re: bitcoin-cli listtransactions not working for watch-only address
Post by: luv2drnkbr on December 08, 2015, 10:38:38 AM
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.


Title: Re: bitcoin-cli listtransactions not working for watch-only address
Post by: qrius1111 on January 21, 2016, 06:43:17 AM
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.


Title: Re: bitcoin-cli listtransactions not working for watch-only address
Post by: CIYAM on January 21, 2016, 06:50:12 AM
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)