Skip to content

Feature Request: API to lookup address balance, total_received via addrIndex #949

Open
@dan-da

Description

I am in need of an API that leverages the addrIndex to return summarized address data for multiple addresses in a single call.

Both blockchain.info and blockr provide this capability, but I'm hoping for a solution that can be run privately inhouse.

Here is an example call from bc.info: (docs)

https://blockchain.info/multiaddr?active=$address|$address

{
    "addresses":[
    {
        "hash160":"641ad5051edd97029a003fe9efb29359fcee409d",
        "address":"1A8JiWcwvpY7tAopUkSnGuEYHmzGYfZPiq",
        "n_tx":4,
        "total_received":1401000000,
        "total_sent":1000000,
        "final_balance":1400000000
    },

    {
        "hash160":"ddbeb8b1a5d54975ee5779cf64573081a89710e5",
        "address":"1MDUoxL1bGvMxhuoDYx6i11ePytECAk9QK",
        "n_tx":0,
        "total_received":0,
        "total_sent":0,
        "final_balance":0
    }
}

The blockr api is similar, and docs are here.

If I'm not mistaken, the btcd addrIndex only keeps a list of transactions. So it will still be necessary to loop through all the transactions when performing a lookup. For lookup performance, the index would store total_received, total_sent, final_balance... but I guess that is not presently the case and would require more storage. Also, I know that total_sent is kind of a fuzzy concept given the way bitcoin transactions work.

@Roasbeef would you care to comment on how best to implement? I figured it would basically be a matter of copying the basics of searchrawtransaction API, deserializing all transactions, and summing the amounts. Or is there a more efficient way to do it?

I might work on it myself at some point if/when I find some time. Or if someone else wishes to, all the better!

The particular use case I have in mind is for my HD wallet discovery tool. It's a general purpose api though.

I just added support within the tool to make use of btcd as a data source via searchrawtransactions, but the reports have missing data and the lookups are slow compared to bc.info and blockr. hoping to remedy that!

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions