<p>I'm running bitcoind <code>bitcoind -regtest</code> and want to send BTC to <code>bcrt1qxhx5gq5gwaju2lh0pxnp7qpn4685cwvst4ql45</code> segwit address.</p>
<p>Why listunspent returns empty list after sending somebtc to segwit address?</p>
<p>Check sender has enough bitcoin</p>
<pre><code>➜  bin ./bitcoin-cli -regtest getbalance
20.17930334
</code></pre>
<p>Send BTC</p>
<pre><code>➜  bin ./bitcoin-cli -regtest sendtoaddress bcrt1qxhx5gq5gwaju2lh0pxnp7qpn4685cwvst4ql45 15.1
eb5e0047c3c37ad6f020e34febb52da276817196063ba2efc5860aa59f92cff4
</code></pre>
<p>Get TX</p>
<pre><code>➜  bin ./bitcoin-cli -regtest gettransaction eb5e0047c3c37ad6f020e34febb52da276817196063ba2efc5860aa59f92cff4
{
  &quot;amount&quot;: -15.10000000,
  &quot;fee&quot;: -0.00044248,
  &quot;confirmations&quot;: 101,
  &quot;blockhash&quot;: &quot;17e269809ab17fb41813f401fc8342a036c18509eb33504e8da87c82c9759e4f&quot;,
  &quot;blockheight&quot;: 2858,
  &quot;blockindex&quot;: 2,
  &quot;blocktime&quot;: 1681583966,
  &quot;txid&quot;: &quot;eb5e0047c3c37ad6f020e34febb52da276817196063ba2efc5860aa59f92cff4&quot;,
  &quot;walletconflicts&quot;: [
  ],
  &quot;time&quot;: 1681583928,
  &quot;timereceived&quot;: 1681583928,
  &quot;bip125-replaceable&quot;: &quot;no&quot;,
  &quot;details&quot;: [
    {
      &quot;address&quot;: &quot;bcrt1qxhx5gq5gwaju2lh0pxnp7qpn4685cwvst4ql45&quot;,
      &quot;category&quot;: &quot;send&quot;,
      &quot;amount&quot;: -15.10000000,
      &quot;vout&quot;: 1,
      &quot;fee&quot;: -0.00044248,
      &quot;abandoned&quot;: false
    }
  ],
  &quot;hex&quot;: &quot;020000000001fd8c020628c3940819bf09b7d2383de51bf6dd8b03fb0ad58fdfc98d85bdf34aec96470000000000feffffff85abf943b973ab67bb3fc88ab922c36b3dd2c2ad61d84d5
</code></pre>
<p>Generate blocks for confirmation</p>
<pre><code>➜  bin ./bitcoin-cli -regtest -generate 101                                                  

{
  &quot;address&quot;: &quot;bcrt1qkg54v3hqj4gpl9k0x8evlft3df2cuxetrr6e8l&quot;,
....
</code></pre>
<p>Get UTXOs for the address</p>
<pre><code>➜  bin ./bitcoin-cli -regtest listunspent 0 999999 &quot;[\&quot;bcrt1qxhx5gq5gwaju2lh0pxnp7qpn4685cwvst4ql45\&quot;]&quot;

[
]
</code></pre>
<p>Why listunspent returns empty list, even. after transmission.</p>
<p>Best</p>

CC BY-SA 4.0
2023-04-15T19:13:56.830Z
Is `bcrt1qxhx5gq5gwaju2lh0pxnp7qpn4685cwvst4ql45` *your* address (e.g what does `getaddressinfo` say about it?)? `listunspent` is a wallet RPC, it queries your own wallet for UTXOs. If you want non-wallet UTXO lookup, use `gettxout` (though that works by txid:idx, not by address).
Pieter Wuille
CC BY-SA 4.0
2023-04-15T19:29:12.477Z
Thank you! Missed that nuance. How can I get UTXO's of an address to build a tx?
att
CC BY-SA 4.0
2023-04-15T19:33:55.193Z
Import them in the wallet first, so it tracks them for you. Then `listunspent` and even higher-level transaction building RPCs will work just fine. Bitcoin Core has no functionality for indexing transactions or UTXOs by address, though you can use `scantxoutset` which will just search through the entire UTXO set for entries matching a given output descriptor (which may include an address).
Pieter Wuille
CC BY-SA 4.0
2023-04-15T20:02:06.290Z
I've been struggling to get UTXOs from the RPC. So that's the reason most examples use external APIs to get UTXOs. Thanks
att
<segregated-witness><bitcoin-cli><regtest><sendtoaddress>
bitcoin-cli listunspent returns empty list
att
# bitcoin-cli listunspent returns empty list

(Asked by: username_0 on 2023-04-15)

I'm running bitcoind bitcoind -regtest and want to send BTC to bcrt1qxhx5gq5gwaju2lh0pxnp7qpn4685cwvst4ql45 segwit address.
Why listunspent returns empty list after sending somebtc to segwit address?
Check sender has enough bitcoin
➜  bin ./bitcoin-cli -regtest getbalance
20.17930334

Send BTC
➜  bin ./bitcoin-cli -regtest sendtoaddress bcrt1qxhx5gq5gwaju2lh0pxnp7qpn4685cwvst4ql45 15.1
eb5e0047c3c37ad6f020e34febb52da276817196063ba2efc5860aa59f92cff4

Get TX
➜  bin ./bitcoin-cli -regtest gettransaction eb5e0047c3c37ad6f020e34febb52da276817196063ba2efc5860aa59f92cff4
{
  "amount": -15.10000000,
  "fee": -0.00044248,
  "confirmations": 101,
  "blockhash": "17e269809ab17fb41813f401fc8342a036c18509eb33504e8da87c82c9759e4f",
  "blockheight": 2858,
  "blockindex": 2,
  "blocktime": 1681583966,
  "txid": "eb5e0047c3c37ad6f020e34febb52da276817196063ba2efc5860aa59f92cff4",
  "walletconflicts": [
  ],
  "time": 1681583928,
  "timereceived": 1681583928,
  "bip125-replaceable": "no",
  "details": [
    {
      "address": "bcrt1qxhx5gq5gwaju2lh0pxnp7qpn4685cwvst4ql45",
      "category": "send",
      "amount": -15.10000000,
      "vout": 1,
      "fee": -0.00044248,
      "abandoned": false
    }
  ],
  "hex": "020000000001fd8c020628c3940819bf09b7d2383de51bf6dd8b03fb0ad58fdfc98d85bdf34aec96470000000000feffffff85abf943b973ab67bb3fc88ab922c36b3dd2c2ad61d84d5

Generate blocks for confirmation
➜  bin ./bitcoin-cli -regtest -generate 101                                                  

{
  "address": "bcrt1qkg54v3hqj4gpl9k0x8evlft3df2cuxetrr6e8l",
....

Get UTXOs for the address
➜  bin ./bitcoin-cli -regtest listunspent 0 999999 "[\"bcrt1qxhx5gq5gwaju2lh0pxnp7qpn4685cwvst4ql45\"]"

[
]

Why listunspent returns empty list, even. after transmission.
Best

**Tags:** segregated-witness, bitcoin-cli, regtest, sendtoaddress

> **Comments:**
> **username_1**: Is `bcrt1qxhx5gq5gwaju2lh0pxnp7qpn4685cwvst4ql45` *your* address (e.g what does `getaddressinfo` say about it?)? `listunspent` is a wallet RPC, it queries your own wallet for UTXOs. If you want non-wallet UTXO lookup, use `gettxout` (though that works by txid:idx, not by address).  
> **username_0**: Thank you! Missed that nuance. How can I get UTXO's of an address to build a tx?  
> **username_1**: Import them in the wallet first, so it tracks them for you. Then `listunspent` and even higher-level transaction building RPCs will work just fine. Bitcoin Core has no functionality for indexing transactions or UTXOs by address, though you can use `scantxoutset` which will just search through the entire UTXO set for entries matching a given output descriptor (which may include an address).  
> **username_0**: I've been struggling to get UTXOs from the RPC. So that's the reason most examples use external APIs to get UTXOs. Thanks  

---

## 0 answers

