5

I want to access unspent data of a specific bitcoin address.

I am trying this command

bitcoin-cli -regtest listunspent "some bitcoin address"

But I am always getting an empty list. I am using local bitcoind server on windows 7.

What should I do or use any function for getting desired output ?

9

listunspent only displays information about addresses which are currently part of your wallet. Bitcoin Core does not maintain indexes of unspent outputs for addresses you do not own, and will simply return a blank set if you attempt to query for them.

1

In order to get the list unspent of a specific bitcoin address( not belongs to your wallet), you must first import the address to wallet using importaddress This RPC does not require the private key of that address. Note that this will cause the program to rescan the entire blockchain, which will take several minutes.

now you can use the listunspent call to get the UTXO.

1

As mentioned here, you can first get the addresses of an account using getaddressesbyaccount and then list all the unspent of those addresses using

bitcoin-cli listunspent 6 9999999 "[\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\",\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\"]"  

where 6 and 9999999 are the min and max confirmations

  • 2
    OP is asking about arbitrary addresses, not just those in his wallet. – Pieter Wuille Oct 31 '17 at 6:40
  • oh.. my mistake :) hope this might help people who are looking to get unspent from the wallet addresses. – RealSteel Nov 3 '17 at 7:04
0

Other options, beyond what Nick mentioned, are to either use the toshi.io API:

toshi.io - API - utxo's for address

Or run your own toshi node:

toshi.io

  • chain.com is also very good and easy to use! but i was trying not to use any 3rd party APIs. – Hassan Mehmood Apr 29 '15 at 7:57
  • @HassanMehmood if running the toshi node locally isn't something you want either (it consumes well over 200GB of space) then you could run bitcoin core with txindex enabled. You'd then have to parse the blockchain and build and keep up a database of utxo yourself. As others have pointed out, if you just want a bitcoin-cli argument for this, it doesn't exist. – Robert McCone Apr 30 '15 at 22:17
0

Unspent data appears in Unspent List only after SIX confirmations.

Try this command,

bitcoin-cli -regtest listunspent "some bitcoin address" 0

It will show all the unspent transactions.

  • I am running the same command but getting empty list in response. I first generated and added a multisig address using "addultisigaddress" command and call listunspent. But in result i always get an empty list though I sent some satoshis to this address 2 times – Hassan Mehmood Apr 29 '15 at 17:40
0

Assuming the addresses are in your wallet, you're looking for listreceivedbyaddress. That will give you back this:

Returns an array of objects containing:

  • "address" : receiving address
  • "account" : the account of the receiving address
  • "amount" : total amount received by the address
  • "confirmations" : number of confirmations of the most recent transaction included
  • "txids" : a list of transaction IDs that you can pass to gettransaction in order to see the full transaction.

(Source.)

  • Yup, But if i want to get unspents of an address which is not a part of my wallet ? than what function should i use ? @Nick – Hassan Mehmood Apr 27 '15 at 17:54
  • 2
    @HassanMehmood Doesn't exist. Use bitcoin-abe or electrum server or blockchain.info instead. – Nick ODell Apr 27 '15 at 18:22
  • Hey, from answers, I added one my multisig add using this command "addmultisigaddress". and sent some satoshis to this address. but I am still getting empty list after calling :listunspent" ??? – Hassan Mehmood Apr 29 '15 at 15:31
  • @HassanMehmood You need to rerun with rescan. bitcoin.stackexchange.com/questions/22199/… – Nick ODell Apr 29 '15 at 18:21
  • 1
    addmultisigaddress is not enough to make the wallet treat the address as its own; you also need to have all of the private keys. If you want to treat an address as yours regardless of keys, use importaddress. – Pieter Wuille Oct 31 '17 at 6:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.