Is there a JSON-RPC method for retrieving all transactions for a given address?

1

I mean something like listtransactions method but with parameter .

ikirachen

Posted 2013-10-30T08:34:31.763

Reputation: 13

Answers

1

This would be nice but, no, there isn't a way to do this. The simplest way to accumulate this information is to call listtransactions or listunspent for a list of transactions in your account.

After receiving the list, filter for the needed information. It is worth mentioning the listunspent RPC call. This can cut down on a lot of returned data if you are only interested in the incoming transactions that make up your current balance.

RLH

Posted 2013-10-30T08:34:31.763

Reputation: 2 062

I know this is essentially pyramids answer, however, I wanted to explicitly mention that this isn't possible with the current client. Furthermore, if you plan on filtering this yourself, and you only need tx's associated with your current wallet value, listunspent will save you a lot of data to parse.RLH 2013-10-30T12:31:30.840

1

You can't do this with bitcoind through RPC command, but there are tools available on the internet that will do this for you. For example, blockexplorer has a query specifically for this purpose. If you want to see how it's done, check out line 724 of app_stats.inc:

// This RELIES on the fact that only address transactions will be sent/received
$result = SQL("SELECT encode(blocks.hash, 'hex') AS block, 
                      encode(transactions.hash, 'hex') AS tx, 
                      blocks.number AS blocknum, 
                      blocks.time AT TIME ZONE 'UTC' AS time, 
                      transactions.id AS tid, 
                      transactions.raw AS rawtx

               FROM inputs JOIN transactions ON (inputs.tx = transactions.hash) 
                           JOIN blocks ON (inputs.block = blocks.hash)

               WHERE inputs.type = 'Address' AND 
                     blocks.number>$1 AND inputs.hash160 IN ($addresses)

               UNION 

               SELECT encode(blocks.hash, 'hex') AS block, 
                      encode(transactions.hash, 'hex') AS tx, 
                      blocks.number AS blocknum, 
                      blocks.time AT TIME ZONE 'UTC' AS time, 
                      transactions.id AS tid, 
                      transactions.raw AS rawtx

               FROM outputs JOIN transactions ON (outputs.tx = transactions.hash) 
                            JOIN blocks ON (outputs.block = blocks.hash)

               WHERE outputs.type = 'Address' AND 
                     blocks.number>$1 AND 
                     outputs.hash160 IN ($addresses) 

               ORDER BY tid;", $blocklimit);

bvpx

Posted 2013-10-30T08:34:31.763

Reputation: 1 052