Bitcoin Forum
May 05, 2024, 04:27:43 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Is there a way to get unspent outputs of an arbitrary address using bitcoind?  (Read 1947 times)
DeathAndTaxes (OP)
Donator
Legendary
*
Offline Offline

Activity: 1218
Merit: 1079


Gerald Davis


View Profile
July 26, 2014, 06:34:56 PM
 #1

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?
1714883263
Hero Member
*
Offline Offline

Posts: 1714883263

View Profile Personal Message (Offline)

Ignore
1714883263
Reply with quote  #2

1714883263
Report to moderator
1714883263
Hero Member
*
Offline Offline

Posts: 1714883263

View Profile Personal Message (Offline)

Ignore
1714883263
Reply with quote  #2

1714883263
Report to moderator
1714883263
Hero Member
*
Offline Offline

Posts: 1714883263

View Profile Personal Message (Offline)

Ignore
1714883263
Reply with quote  #2

1714883263
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714883263
Hero Member
*
Offline Offline

Posts: 1714883263

View Profile Personal Message (Offline)

Ignore
1714883263
Reply with quote  #2

1714883263
Report to moderator
1714883263
Hero Member
*
Offline Offline

Posts: 1714883263

View Profile Personal Message (Offline)

Ignore
1714883263
Reply with quote  #2

1714883263
Report to moderator
1714883263
Hero Member
*
Offline Offline

Posts: 1714883263

View Profile Personal Message (Offline)

Ignore
1714883263
Reply with quote  #2

1714883263
Report to moderator
Envrin
Sr. Member
****
Offline Offline

Activity: 318
Merit: 251



View Profile
July 26, 2014, 06:48:26 PM
 #2

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.

azeteki
Member
**
Offline Offline

Activity: 96
Merit: 10

esotericnonsense


View Profile WWW
July 26, 2014, 09:25:41 PM
 #3

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.

gmaxwell
Moderator
Legendary
*
expert
Online Online

Activity: 4158
Merit: 8382



View Profile WWW
July 26, 2014, 09:40:32 PM
 #4

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.
dexX7
Legendary
*
Offline Offline

Activity: 1106
Merit: 1024



View Profile WWW
July 27, 2014, 07:21:35 AM
 #5

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")'.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!