Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: marley on June 11, 2014, 10:17:00 PM



Title: How could I back scan the ledger to find a transaction to a specific address?
Post by: marley on June 11, 2014, 10:17:00 PM
How could I do this in the bitcoin client?
Are there any API to search for transactions?
I'm not interested on how to do this manually, but instead on how to add this as a feature in the bitcoin client.


Title: Re: How could I back scan the ledger to find a transaction to a specific address?
Post by: DannyHamilton on June 11, 2014, 10:56:48 PM
How could I do this in the bitcoin client?

Are there any API to search for transactions?

Set txindex=1 in the bitcoin.conf file.
Run the client with -reindex


For every number between 1 and the current block height:

    getblockhash [index]
    getblock [blockhash]

    For each transactionID returned by getblock

        getrawtransaction [transactionID]
        decoderawtransaction [rawtransaction]

        For each output in the JSON vout[] array

            Compare the value associated with the "addresses" tag to see if it matches the address you are looking for.


You can write a program to do this if you don't want to do it manually.