does bitcoin-cli have any functionality to get all tx hashes for a given address (ie the txs that either send or receive funds from the given address). listtransactions
sounds like it should do what i want, but when i run it like so then i get no results:
# pick a random address to watch from blockchain.info:
$ addr=1GkktBuJ6Pr51WEJe5ZzyNvMYaMDFjwyDk
# create a watch-only account for this address, with the account name
# being the address itself, for convenience:
$ 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" : 384809,
"timeoffset" : 0,
"connections" : 8,
"proxy" : "",
"difficulty" : 65848255179.70261383,
"testnet" : false,
"keypoololdest" : 1381701523,
"keypoolsize" : 101,
"paytxfee" : 0.00000000,
"relayfee" : 0.00001000,
"errors" : ""
}
as you can see, it takes 42 minutes to scan the blockchain for this watch-only address, so its not something i want to do often. and its only producing an empty list, whereas blockchain.info shows there are 6 transactions.
why is this not working? is this not the intended functionality of bitcoin-cli listtransactions
?
update
listtransactions
is supposed to display transactions from watch-only addresses:
$ bitcoin-cli help listtransactions
listtransactions ( "account" count from includeWatchonly)
Returns up to 'count' most recent transactions skipping the first 'from' transactions for account 'account'.
Arguments:
- "account" (string, optional) The account name. If not included, it will list all transactions for all accounts.
If "" is set, it will list transactions for the default account.
- count (numeric, optional, default=10) The number of transactions to return
- from (numeric, optional, default=0) The number of transactions to skip
- includeWatchonly (bool, optional, default=false) Include transactions to watchonly addresses (see 'importaddress')
...
...
...
txindex 1
in the conf file. But it looks like I was wrong and you actually don't need to do that. https://github.com/bitcoin/bitcoin/pull/4045 (they mention listtransactions ignores watch only on purpose there.) – Jannes Nov 23 '15 at 09:52listtransactions
isincludeWatchonly
. please see my update in the question. – mulllhausen Nov 23 '15 at 11:48importaddress
? I'm pretty sure it won't search the whole blockchain for older transactions. (It might if you hadtxindex=1
, but I'm not sure if that affects this.) – Jannes Nov 23 '15 at 12:40importaddress
is for - it scans the blockchain. and that's why it took 41 minutes and 59 seconds :p – mulllhausen Nov 23 '15 at 13:02