Author

Topic: Is there a way to get unspent outputs of an arbitrary address using bitcoind? (Read 1970 times)

legendary
Activity: 1106
Merit: 1026
There is Sipa's original address indexed branch which allows to list all transactions associated with an address: https://github.com/bitcoin/bitcoin/pull/2802

This branch is kept up to date by jmcorgan: https://github.com/jmcorgan/bitcoin/tree/addrindex

I wrapped an RPC call around it to explicitly list unspents from any address ("listallunspent"): https://github.com/dexX7/bitcoin/tree/master-addrindex-extended#rpc-commands

The later is also exposed via: http://redeem.bitwatch.co

And there is of course blockchain.info's API as well as insight (https://github.com/bitpay/insight), if I'm not mistaken.

You may also be successful by queriying the Electrum servers - this can be done via the Electrum client console with 'getaddressunspent("1address")'.
staff
Activity: 4284
Merit: 8808
b) is not implemented. I believe there is an -addrindex patch out there somewhere which you may find useful.
There is, sipa wrote it but has kind of disowned it after seeing the really non-scalable things it encourages.  Bitcoin core will likely support such a thing some day, but probably only after pruning is in production so that the true costs of operating this way (>30GB disk space currently, and growing) is more obvious.
member
Activity: 96
Merit: 10
esotericnonsense
For custom application development it would be nice to use bitcoind as a node only.  Bitcoind supports "no wallet" parameter and txns can be created rather easily using createrawtransaction, signrawtransaction, and sendrawtransaction.  Unless i am missing something there is no easy way to find the unspent outputs of an arbitrary address.  For now lets ignore non-P2SH/P2PkH outputs.

listunspent only returns unspent outputs for addresses in the wallet.

All the necessary information is in the UTXO (chainstate folder) it just is not accessible from RPC.  Am I missing something?

It is indeed in the UTXO db, however, the UTXO db is keyed by txid.

In order for bitcoind to query it for arbitrary addresses it would have to do one of two things:

a) Crawl every tx
b) Produce another DB keyed by address or pubkey and allow that to be queried

a) would be far too time consuming; there are tens of millions of unspent outputs I believe.
b) is not implemented. I believe there is an -addrindex patch out there somewhere which you may find useful.
sr. member
Activity: 318
Merit: 251
Am I missing something?

Don't think so.  Write some software, and run a watch-only wallet.  After you generate some addresses, scan all transactions and blocks for outputs (deposits) coming into them.  Then keep track of the outgoing spends, which will give you the new inputs to use (ie. change address).  Use bloom filters if desired.

donator
Activity: 1218
Merit: 1079
Gerald Davis
For custom application development it would be nice to use bitcoind as a node only.  Bitcoind supports "no wallet" parameter and txns can be created rather easily using createrawtransaction, signrawtransaction, and sendrawtransaction.  Unless i am missing something there is no easy way to find the unspent outputs of an arbitrary address.  For now lets ignore non-P2SH/P2PkH outputs.

listunspent only returns unspent outputs for addresses in the wallet.

All the necessary information is in the UTXO (chainstate folder) it just is not accessible from RPC.  Am I missing something?
Jump to: