I want to use RPC to get all historical transactions of an address

The following content was written by linuxqq on June 23, 2020, 03:07:38 PM in the thread I want to use RPC to get all historical transactions of an address. All content is owned by the author of the bitcointalk.org post. (original)


I want to use RPC to get all historical transactions of an address,I have synchronized the full node on my computer. Below is the configuration of my bitcoin.conf

Code:
blockfilterindex=1
datadir=/opt/bitcoin/bitcoin-data
dbcache=10240
txindex=1
reindex=1
rpcuser=xxx
rpcpassword=xxx
daemon=1
server=1
rest=1
rpcbind=0.0.0.0:8332
rpcallowip=0.0.0.0/0
deprecatedrpc=accounts

But the result I return using listtransactions is empty
Code:
root@ubuntu:/opt/bitcoin/bitcoin-data# bitcoin-cli listtransactions “1L671pxzdY9dzEayZ9yEfUVWAoGsq99PoC”
[]

I don’t know what I did wrong, I just want to synchronize a full node locally, can query all historical transaction records of any specified address, thank you for your help


The following content was written by BrewMaster on June 23, 2020, 03:52:44 PM in the thread I want to use RPC to get all historical transactions of an address. All content is owned by the author of the bitcointalk.org post. (original)


can query all historical transaction records of any specified address, thank you for your help

that is not possible with the way a full node (like bitcoin core)stores the blockchain because the blocks and their transactions are not sorted based on addresses so that you could easily search for address historical transactions.

you’ll have to either rescan the entire blockchain for each address, which takes a lot of time or use another tool to index the blockchain based on addresses like what block explorers do then search it.

The following content was written by linuxqq on June 24, 2020, 01:16:27 AM in the thread I want to use RPC to get all historical transactions of an address. All content is owned by the author of the bitcointalk.org post. (original)


So do I still need my own database to store transaction records at these addresses?

The following content was written by DaveF on June 24, 2020, 01:20:35 AM in the thread I want to use RPC to get all historical transactions of an address. All content is owned by the author of the bitcointalk.org post. (original)


So do I still need my own database to store transaction records at these addresses?
Yes.
There are some long and complicated ways around it, but none are simple.
If you want to get the information without going to a public explorer, there are many open source ones that you can use.

https://github.com/iquidus/explorer
https://github.com/bitpay/bitcore

-Dave

The following content was written by domob on June 24, 2020, 05:20:31 AM in the thread I want to use RPC to get all historical transactions of an address. All content is owned by the author of the bitcointalk.org post. (original)


As others have already pointed out, this is not possible (at least not easily) with Bitcoin Core alone.  As an alternative to block explorers already mentioned, you can also run ElectrumX (https://github.com/kyuupichan/electrumx) to generate and maintain a database indexed by address.  Once synced up, ElectrumX allows you to query exactly for the data you want.

The following content was written by linuxqq on July 09, 2020, 03:57:37 AM in the thread I want to use RPC to get all historical transactions of an address. All content is owned by the author of the bitcointalk.org post. (original)


Thank you very much for your reply. Maybe I don’t have a special understanding of the principles of Bitcoin, but I’m working hard to learn. I currently read the electrumx rosksdb directly. It seems that electrumx stores scripthash, but I want to get all the wallet addresses, a lot of BTC explorer How did they get the wallet address? electrumx’s database does not store scriptPubKey

The following content was written by ETFbitcoin on July 09, 2020, 01:38:29 PM in the thread I want to use RPC to get all historical transactions of an address. All content is owned by the author of the bitcointalk.org post. (original)


Thank you very much for your reply. Maybe I don’t have a special understanding of the principles of Bitcoin, but I’m working hard to learn. I currently read the electrumx rosksdb directly. It seems that electrumx stores scripthash, but I want to get all the wallet addresses, a lot of BTC explorer How did they get the wallet address? electrumx’s database does not store scriptPubKey

1. ElectrumX store hash of the scriptPubKey (according to https://electrumx.readthedocs.io/en/latest/protocol-basics.html#script-hashes)
2. You’re not supposed to read the DB directly, but use JSON-RPC to get information you need

IMO it’s easier to use another bitcoin block explorer which have API with option to get balance/transaction of an address (without obtaining scriptPubKey or script hash first)

Subscribe our latest updates

Don't miss out. Be the first one to know when a new guide or tool comes out.

Subscription Form

Support Us ❤

Creating learning material requires a lot of time and resources. So if you appreciate what we do, send us a tip to bc1qm02xguzxxhk7299vytrt8sa8s6fkns2udf8gjj. Thanks!