Bitcoin Forum
May 25, 2024, 04:24:31 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: bitcoin-cli listtransactions not working for watch-only address  (Read 2341 times)
qrius1111 (OP)
Newbie
*
Offline Offline

Activity: 30
Merit: 0


View Profile
November 22, 2015, 01:19:48 PM
 #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?
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3402
Merit: 6657


Just writing some code


View Profile WWW
November 22, 2015, 03:08:14 PM
Last edit: November 22, 2015, 09:21:09 PM by knightdk
 #2

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.

qrius1111 (OP)
Newbie
*
Offline Offline

Activity: 30
Merit: 0


View Profile
November 22, 2015, 09:08:51 PM
 #3

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"
        ]
    ]
]
qrius1111 (OP)
Newbie
*
Offline Offline

Activity: 30
Merit: 0


View Profile
November 22, 2015, 09:18:18 PM
 #4

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"}
gmaxwell
Moderator
Legendary
*
expert
Offline Offline

Activity: 4186
Merit: 8426



View Profile WWW
November 22, 2015, 10:41:00 PM
 #5

The empty quotes were not optional, the account name field is missing in your example of trying it.
qrius1111 (OP)
Newbie
*
Offline Offline

Activity: 30
Merit: 0


View Profile
November 22, 2015, 10:48:29 PM
 #6

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"
        ]
    ]
]
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3402
Merit: 6657


Just writing some code


View Profile WWW
November 22, 2015, 11:08:08 PM
 #7

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.

gmaxwell
Moderator
Legendary
*
expert
Offline Offline

Activity: 4186
Merit: 8426



View Profile WWW
November 23, 2015, 02:34:42 AM
 #8

You're asking about account "" but you imported the address in account "1GkktBuJ6Pr51WEJe5ZzyNvMYaMDFjwyDk".
qrius1111 (OP)
Newbie
*
Offline Offline

Activity: 30
Merit: 0


View Profile
November 23, 2015, 02:42:00 AM
 #9

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?
qrius1111 (OP)
Newbie
*
Offline Offline

Activity: 30
Merit: 0


View Profile
November 28, 2015, 04:16:22 AM
 #10

should i submit a bug report? i wish my knowledge of c++ was better - i could investigate by actually stepping through the code
fbueller
Sr. Member
****
Offline Offline

Activity: 412
Merit: 275


View Profile
December 02, 2015, 05:59:53 AM
 #11

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

Bitwasp Developer.
luv2drnkbr
Hero Member
*****
Offline Offline

Activity: 793
Merit: 1016



View Profile
December 08, 2015, 10:38:38 AM
 #12

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.

qrius1111 (OP)
Newbie
*
Offline Offline

Activity: 30
Merit: 0


View Profile
January 21, 2016, 06:43:17 AM
 #13

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.
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1078


Ian Knowles - CIYAM Lead Developer


View Profile WWW
January 21, 2016, 06:50:12 AM
 #14

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)

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!