Author

Topic: I want to use RPC to get all historical transactions of an address (Read 238 times)

legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
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)
jr. member
Activity: 34
Merit: 6
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
legendary
Activity: 1135
Merit: 1166
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.
legendary
Activity: 3500
Merit: 6320
Crypto Swap Exchange
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
jr. member
Activity: 34
Merit: 6
So do I still need my own database to store transaction records at these addresses?
legendary
Activity: 2114
Merit: 1293
There is trouble abrewing
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.
jr. member
Activity: 34
Merit: 6
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

Jump to: