1

When im trying to get balance of remote address I'm getting an error, this address not exists on my wallet and I want to follow her balance.

This is what I tried:

bitcoin-cli getreceivedbyaddress "1FJhBusrEHPZVTey5Q7zb3ZND86nYWrNV2" 0

And this is the error that I'm getting:

error code: -4
error message:
Address not found in wallet

I know that this address is not existing in my wallet but i do want to follow her balance.

1 Answer 1

2

You can use the command bitcoin-cli importaddress to watch addresses that your wallet does not control. This command will generally require a rescan of the chain, which can take some time depending on your computational resources.

Note that if you happen to know which blocks contain transactions related to the address in question, you can turn off the rescan when importing the address, and then separately run a rescanblockchain command to only search the necessary blocks. This can greatly reduce the rescan time.

Here is a dump of bitcoin-cli help importaddress, running bitcoin-core v0.17.0.1.

importaddress "address" ( "label" rescan p2sh )

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

Arguments:
1. "address"          (string, required) The Bitcoin address (or hex-encoded script)
2. "label"            (string, optional, default="") An optional label
3. rescan               (boolean, optional, default=true) Rescan the wallet for transactions
4. p2sh                 (boolean, optional, default=false) Add the P2SH version of the script as well

Note: This call can take over an hour to complete if rescan is true, during that time, other rpc calls
may report that the imported address exists but related transactions are still missing, leading to temporarily incorrect/bogus balances and unspent outputs until rescan completes.
If you have the full public key, you should call importpubkey instead of this.

Note: If you import a non-standard raw script in hex form, outputs sending to it will be treated
as change, and not show up in many RPCs.

Examples:

Import an address with rescan
> bitcoin-cli importaddress "myaddress"

Import using a label without rescan
> bitcoin-cli importaddress "myaddress" "testing" false

As a JSON-RPC call
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "importaddress", "params": ["myaddress", "testing", false] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.