bitpay / insight-api

The bitcoin blockchain API powering Insight
https://github.com/bitpay/insight
590 stars 1.04k forks source link

Get Multiple Address Balances #583

Open MelbourneDeveloper opened 6 years ago

MelbourneDeveloper commented 6 years ago

Currently, it's possible to get "Unspent Outputs for Multiple Addresses". But, it's not possible to get the balances for multiple addresses with a transaction count or total received.

I'm building an app that sits across multiple coins. Many of the coins' API are Insight based which is great because the protocol the same for all coins. However, I have to retrieve address balances one by one which is very chatty, and some APIs have a rate limit so it's easy to eat that up with multiple addresses.

My app is based on Trezor. For each coin, It gets three addresses from the Trezor. That's six addresses in total because change addresses are also checked. If at least one of those addresses is not unused, it will move to the next three addresses. The app will continue until it has checked three addresses in a row that have been proven to be empty (no transactions at all). This means that there will be at least six calls to insight-api/addr - usually twelve.

The good news is that insight-api/addr returns pointers to transaction ids. So, this means that even if the balance of the address is zero, I can see if the address has ever been used. It also has totalReceived and totalSent which tells me if the address has been used or not.

It would be good if the API implemented something like this:

https://[address]/insight-api/addrs/[address1],[address2]/addressinfo

The call would not have to include all the same information that insight-api/addr already returns. All it needs is:

or

dan-da commented 6 years ago

I need this for hd-wallet-addrs also. The tool presently supports using insight as a data provider but is dog slow. The default is to query up to gap-limit (20) for both receive and change addresses, so that's minimum 40 requests to /addr.

fyi, at least two other api providers already provide multi-addr lookups: blockchain.info and btc.com. But they are not open source to my knowledge, and thus users must sacrifice privacy to use them.