How to get unspents for a specified bitcoin address?

5

4

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 ?

Hassan Mehmood

Posted 2015-04-27T15:43:18.547

Reputation: 183

Answers

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.

Anonymous

Posted 2015-04-27T15:43:18.547

Reputation: 10 054

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

RealSteel

Posted 2015-04-27T15:43:18.547

Reputation: 169

2OP is asking about arbitrary addresses, not just those in his wallet.Pieter Wuille 2017-10-31T06:40:03.957

oh.. my mistake :)
hope this might help people who are looking to get unspent from the wallet addresses.
RealSteel 2017-11-03T07:04:54.003

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.

Akshay Dev

Posted 2015-04-27T15:43:18.547

Reputation: 23

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

Nick ODell

Posted 2015-04-27T15:43:18.547

Reputation: 26 536

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 ? @NickHassan Mehmood 2015-04-27T17:54:26.193

2@HassanMehmood Doesn't exist. Use bitcoin-abe or electrum server or blockchain.info instead.Nick ODell 2015-04-27T18:22:13.257

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 2015-04-29T15:31:03.967

@HassanMehmood You need to rerun with rescan. http://bitcoin.stackexchange.com/questions/22199/what-exactly-did-bitcoin-qt-rescan-reindex-do/22224#22224

Nick ODell 2015-04-29T18:21:53.380

I did rerun with rescan, but still getting empty list.. @NickHassan Mehmood 2015-04-29T18:59:09.940

@HassanMehmood Are there any unspents at that address? Has the rescan finished?Nick ODell 2015-04-29T19:04:07.413

Yup, There are some unspents, This is the address "31zeoskE8zeyQARFEVzwJzsp7GQpLn5zhF" and I started the server using bitcoind.exe -daemon -rescan -debugnet -printtoconsoleHassan Mehmood 2015-04-29T19:14:54.237

And Yes i think the rescan is finished!Hassan Mehmood 2015-04-29T19:20:13.383

but still getting empty list. :/Hassan Mehmood 2015-04-29T19:20:40.700

Now I sent some btc to one of other addresses that are showing me while running command "getaddressesbyaccount". and after that i run the cmd "listunspent 0" so it shows that transaction.

But after that I again send some btc to my mulisig address which I have added using addmultisigadress cmd. But listunspent not showing any unspent related to multisig ? Why ? – Hassan Mehmood 2015-04-29T19:37:28.250

1addmultisigaddress 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 2017-10-31T06:39:18.130

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.

moshaholo

Posted 2015-04-27T15:43:18.547

Reputation: 575

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 timesHassan Mehmood 2015-04-29T17:40:09.903

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

Robert McCone

Posted 2015-04-27T15:43:18.547

Reputation: 104

https://chain.com is also very good and easy to use! but i was trying not to use any 3rd party APIs.Hassan Mehmood 2015-04-29T07:57:18.963

@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 2015-04-30T22:17:11.687