Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: x86txt on August 05, 2019, 08:47:06 PM



Title: Get All Transactions Sent to a Specific Address?
Post by: x86txt on August 05, 2019, 08:47:06 PM
I run a full bitcoind node with txindex=1 enabled. Is there a way for me to pull all transactions sent to a specific address? I'm trying to automate a script to count the number (not amount, just number) of donations to this address.


Title: Re: Get All Transactions Sent to a Specific Address?
Post by: achow101 on August 05, 2019, 09:35:19 PM
No. What you want is an address index. Bitcoin Core does not have an address index. The transaction index is not an address index.


Title: Re: Get All Transactions Sent to a Specific Address?
Post by: darosior on August 06, 2019, 09:13:07 AM
I run a full bitcoind node with txindex=1 enabled. Is there a way for me to pull all transactions sent to a specific address? I'm trying to automate a script to count the number (not amount, just number) of donations to this address.
You can using libbitcoin : https://github.com/libbitcoin/libbitcoin-explorer/wiki/bx-fetch-history. IBD is suboptimal though.


Title: Re: Get All Transactions Sent to a Specific Address?
Post by: legendster on August 06, 2019, 06:32:34 PM
Now I am not a dev but isn' there a btcd to look up local arbitrary addresses? And doesn't it also have an address index unlike bitcoind? Just enable it in the config by adding addrindex to a line and do an API lookup in the searchrawtransactions should enable OP to get all txs sent to a particular address.


Also there are external things like:
https://github.com/runeksvendsen/blockchain-restful-address-index
https://github.com/bitcoinjs/indexd


Correct me if I am wrong guys.. I only have masternode hosting experience of shitty btc forks


Title: Re: Get All Transactions Sent to a Specific Address?
Post by: danda on August 11, 2019, 05:05:41 AM
Various answers to this question.

1. bitcoind does not currently have an address index, but may be getting one "soon".  See this pull request (https://github.com/bitcoin/bitcoin/pull/14053).

2. There are at least a couple patches to bitcoind that add an address index.  But then you've gotta build your own bitcoind and keep it maintained over time.  fun.

3. There are at least two 3rd party block explorer solutions that build off bitcoind's data without requiring a custom bitcoind.  I'm aware of esplora (https://github.com/Blockstream/esplora) by Blockstream and bitcore-node (https://github.com/bitpay/bitcore/tree/master/packages/bitcore-node) by (cough) Bitpay, which apparently is replacing Insight (https://github.com/bitpay/insight).

4. btcd has an address index and an API called searchrawtransactions that is optimized with a  (https://github.com/btcsuite/btcd/pull/516)filter to weed out unrelated vin/vout.  This is the best combination of privacy and efficiency that I've found, but with a lengthy setup.

5. Various online block explorers offer APIs to search by address.  Some even can search multiple addresses at the same time.  But of course you lose privacy calling them with your addresses.   I've been keeping a list (https://github.com/dan-da/bitprices#blockchain-api-provider-notes) of some of these.

6. my tool, bitprices (https://github.com/dan-da/bitprices) can use btcd locally or any of the explorer APIs, and can also round-robin between them so no single service gets all your wallet addresses.  If/when bitcoind offers a suitable index+api I will support it also.  There is also a web frontend (https://mybitprices.info/).