Bitcoin Client API-RPC: Efficient way to list transactions from a list of addresses

1

1

In the API CallList: https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list

You can pass an address as a parameter to "listtransactions" to get the latest list of transactions from an address. What if I would like to get the most recent 25 transactions from a list of 20 addresses. Does this mean I have to make the "listtransactions" call 20 times and then sort the end results?

Calling the API endpoint 20 times is fine, my problem is that if we needed to do pagination that will become very unmanageable very quickly, because it is really hard to determine what is transactions 26-50 from 20 different addresses

Thank you

EDIT: I found that BlockchainInfo offers a very convenient endpoint for this:

https://blockchain.info/api/blockchain_api

Endpoint: http://blockchain.info/multiaddr?active=$address|$address (Multiple addresses divided by |) However, this only returns "txs":[--Latest 50 Transactions--] and, this does not allow you to do an offset (for example, to get transaction 51-100)

samol

Posted 2013-11-28T07:25:11.820

Reputation: 123

If you found an answer to your question please post it as an answer. Only use edits to clarify your question.Stéphane Gimenez 2013-11-28T11:50:39.237

@StéphaneGimenez, thanks for the notice. Although, I didn't find an answer to my question. I found a partial solution that does not address my needs.samol 2013-11-28T20:17:33.160

Answers

3

The most efficient way to get a list of transactions from multiple addresses is to store every wallet transaction in a database locally, something like MySQL or MongoDB, and then run your queries on that database.

You can sync your local database with the Bitcoin wallet via RPC by periodically calling listsinceblock() and keeping track of the last block or by running the client with the optional -walletnotify parameter to run a script to notify your database of new transactions.

Be careful with -walletnotify however. It will be called twice for every transaction and if you have a lot of transactions, it can happen a lot. So make sure the command -walletnotify calls doesn't use a lot of CPU/RAM.

Bitlab.co

Posted 2013-11-28T07:25:11.820

Reputation: 724