Open Polve opened 5 years ago
Hi,
It’s possible to query the UTXO set of an address this way: api.blockchair.com/{:chain}/outputs?q=recipient({:address}),is_spent(false)
Additionally please see #188 (there’s a rarely occurring bug in this filter).
But I think a good idea would be to also add api.blockchair.com/{:chain}/dashboards/address/{:address}/utxo
, api.blockchair.com/{:chain}/dashboards/addresses/{:address1},{:address2}.../utxo
, and api.blockchair.com/{:chain}/dashboards/xpub/{:xpub}/utxo
endpoints in case someone needs the UTXO set of a set of addresses.
It turned out that this feature was somewhat fast to implement. It’s not in production yet (we’ll be testing it and schedule to one of the next updates), but here’s how it will look like.
E.g. api.blockchair.com/bitcoin/dashboards/addresses/192kkZSRQHrS4dnBoPGgoYB6WeC1HXyYZe,17iyRRXBHJKbv5DKPPkttWewm3CHdNPGQd
will yield:
So there will be no need for a separate request, the utxo data will be available in the utxo
array. This will work for the following endpoints:
api.blockchair.com/{:chain}/dashboards/address/{:address}
api.blockchair.com/{:chain}/dashboards/addresses/{:address1}[,{:address2}…]
api.blockchair.com/{:chain}/dashboards/xpub/{:[xyz]pub}
Each UTXO element will contain
I’ll ask some of our API users to review that.
That's great!
The only thing I would ask, when querying multiple addresses, is in the UTXO element to know also the address related to that utxo otherwise we will need another query to know which one is (that's needed for correct signing)
@Polve, I think that’s absolutely reasonable.
This feature is now available for general access, please see the changelog for v.2.0.26: https://github.com/Blockchair/Blockchair.Support/blob/master/API.md
We’ve also made an easy way to iterate through the results.
CC @Polve @thecreation @torzikup @vserpokryl
@Har01d why scriptPubKey (script_hex) property is not in UTXO? It is absolutely required for bitcoin cash transaction signing.
@vserpokryl, it’s available in the addresses
array:
(https://api.blockchair.com/bitcoin/dashboards/addresses/192kkZSRQHrS4dnBoPGgoYB6WeC1HXyYZe,17iyRRXBHJKbv5DKPPkttWewm3CHdNPGQd
)
I see no reason to duplicate scripts into the utxo
array.
would be great if there was transaction_count per address
@andkom, please open a separate feature request for that. I think it’s possible to implement that, but what are the use cases?
I found no easy way to get a list of unspents for a certain address, i.e. the result of a call similar to this one on insight:
https://domain.ext/api/addrs/addr1,addr2/utxo
The only way I found is starting from an address, and if it has unspent_output_count > 0 check all his transactions, then cycle for every output of each transaction, and if recipient is the same one we are looking for, and is_spent is false then keep the index.
Not very handy (and a lot of load on your server): is there a simpler way?