Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dan-da opened this issue May 22, 2017 · 4 comments
Open

Comments

@dan-da
Copy link
Contributor

dan-da commented May 22, 2017

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!

@jackzampolin
Copy link

Can you elaborate on the reports have missing data?

@winteraz
Copy link

@dan-da did you find a reliable node to provide that data? I find myself in the same situation, I need to get transaction data in batch for a HD wallet I'm developing.

@dan-da
Copy link
Contributor Author

dan-da commented Sep 15, 2019

@jackzampolin I meant that the reports generated by my tool are presently missing fields for total_received and balance because searchrawtransactions does not provide total_received and total_spent fields per address. Also, for performance reasons I am specifying count=1, such that only a single tx is returned. If I were willing to retrieve list of all tx (possibly thousands per addr) then I could calc these myself, this is true. I may add an option for that.

Regardless it is horribly inefficient to be making a call to retrieve N transactions for a single address vs a call to receive summarized info for multiple addresses, which is what this request is about.

@dan-da
Copy link
Contributor Author

dan-da commented Sep 15, 2019

@winteraz I have notes about different API providers here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants