How to get all income transactions of an address?

2

1

I want to get list of all address's income transactions since the genesis block

import requests, json

rpcPort = 8332
rpcUser = '[removed]'
rpcPassword = '[removed]'

#Accessing the RPC local server
serverURL = 'http://' + rpcUser + ':' + rpcPassword + '@localhost:' + str(rpcPort)

headers = {'content-type': 'application/json'}
payload = json.dumps({"method": 'listunspent', "params": [0, 999999, ['1KuWLoZuoJgz3N6sLoAwGth9XGm8YuFTGt']], "jsonrpc": "2.0"})
response = requests.post(serverURL, headers=headers, data=payload)
print(response.text)

it returns

{"result":[],"error":null,"id":null}

But according to https://blockchain.info/address/1KuWLoZuoJgz3N6sLoAwGth9XGm8YuFTGt there are a lot of transactions. How to get list of address-related transactions without private key? Can I add address not owned by me to local account to achieve transactions by getreceivedbyaddress command?

Vassily Vorobyov

Posted 2017-09-25T10:16:20.830

Reputation: 135

Answers

2

Can I add address not owned by me to local account to achieve transactions by getreceivedbyaddress command?

No, bitcoind only keeps track of transactions related to your wallet, not all transactions. So to do this, you can add a specific address as a watch only address to your wallet if you don't have the private key, and then rescan to find relevant transactions for it, but that will usually take a while.

MeshCollider

Posted 2017-09-25T10:16:20.830

Reputation: 8 735

okay, how can I add a watch only address to my wallet?Vassily Vorobyov 2017-09-25T10:43:27.727

You can use the importaddress RPC: https://bitcoin.org/en/developer-reference#importaddress

MeshCollider 2017-09-25T10:51:10.800

Ok, I've used it, but importing works so slowly? Is there really no other ways to achive same speed as it achived at blockchain.info?Vassily Vorobyov 2017-09-25T15:20:31.437

2No, blockchain keeps its own database of transactions and everything, it doesn't query bitcoind every timeMeshCollider 2017-09-25T22:10:29.170