<p><em>As per the comments on OP’s question</em></p>

<p>Since you made a copy of the wallet.dat file (which is an HD format), both addresses will be under the control of (both copies of) your wallet. Hence, both UTXOs will be listed when calling the <code>listunspent</code> command, as each wallet is able to spend both UTXOs. </p>

<p>If you used a <strong>new</strong> wallet to generate a new address, and send some funds to it, then the <code>listunspent</code> command should function as you originally expected, as your bitcoin core wallet would not control the address you spent coins too (it would only control the change address). </p>

CC BY-SA 4.0
2018-07-19T08:42:10.167Z
2018-07-19T08:42:10.167Z
chytrik
<p>I have an address on the testnet. I started out with 1.3 btc. I then sent 0.5 btc to another address. My balance is now 0.8. OK, that makes sense.</p>

<p>I expect now to have one UTXO which was the 0.8 in change from the previous transaction. But when I run listunspent, I see I have two UTXOs. The balance is correct, but it seems I have two outputs.</p>

<pre><code>[
  {
    "txid": 
   "321dab633022a33c3a49b4aab4b13d3c431771ae9402746dbb6dcc21be5fd603",
    "vout": 1,
    "address": "2N4wJG7gs1mVXeMkX2MCuyekZUCSzrW7CjT",
    "redeemScript": "0014221f8d76c5b85e979055e54ac97a0cada38bc4e9",
    "scriptPubKey": "a914803d96c7e19e4a568764f9912fa54499f814cd8e87",
    "amount": 0.79999834,
    "confirmations": 119,
    "spendable": true,
    "solvable": true,
    "safe": true
  }
]
</code></pre>

<p>When I run gettxout with the txid and vout 0, the first transaction UTXO is 0.5.</p>

<pre><code>{
  "bestblock": 
  "0000000000000043a1abc3cf9c778d3adeb417488019a507da871db9df74ffad",
  "confirmations": 119,
  "value": 0.50000000,
  "scriptPubKey": {
     "asm": "OP_HASH160 a43f8a90f292b6be0b487556ac357709a5e86480 OP_EQUAL",
     "hex": "a914a43f8a90f292b6be0b487556ac357709a5e8648087",
     "reqSigs": 1,
     "type": "scripthash",
     "addresses": [
       "2N8Dgvfmgs4fNCi7QatLZJR8ArvhPpMPW8P"
     ]
  },
  "coinbase": false
}
</code></pre>

<p>And when I run gettxout with vout 1, the second transaction UTXO is 0.799 (0.8) which is the balance.</p>

<pre><code>{
  "bestblock": 
  "0000000000000043a1abc3cf9c778d3adeb417488019a507da871db9df74ffad",
  "confirmations": 119,
  "value": 0.79999834,
  "scriptPubKey": {
    "asm": "OP_HASH160 803d96c7e19e4a568764f9912fa54499f814cd8e OP_EQUAL",
    "hex": "a914803d96c7e19e4a568764f9912fa54499f814cd8e87",
    "reqSigs": 1,
    "type": "scripthash",
    "addresses": [
      "2N4wJG7gs1mVXeMkX2MCuyekZUCSzrW7CjT"
  ]
},
"coinbase": false
</code></pre>

<p>}</p>

<p>And according to this: <a href="https://bitcoin.stackexchange.com/questions/48504/how-to-check-if-an-output-has-been-spent">How to check if an output has been spent?</a></p>

<p>If gettxout returns something, then the output is unspent.</p>

<p>Why do I have two unspent outputs with the first one in the same amount that I sent to another address?</p>

CC BY-SA 4.0
2018-07-19T07:42:26.650Z
Does your wallet control both addresses? `2N4wJG...` and `2N8Dgv...`? If so, it makes sense that both UTXOs would be listed with `listunspent`
chytrik
CC BY-SA 4.0
2018-07-19T08:19:33.277Z
Ok, that's probably it.

What I did as an exercise is I made two copies of wallet.dat: sending.dat and receiving.dat. I then had a test faucet send some btc to sending.dat. I then sent btc from sending.dat to receiving.dat. What you see in my original question were the two UTXOs for sending.dat.

So I'm guessing that because I made copies of wallet.dat, all the resulting addresses I created actually belong to the same wallet?
Bastien
CC BY-SA 4.0
2018-07-19T08:33:26.363Z
Yes, the addresses belong to the same wallet. It was the same file copied, and with Bitcoin Core's HD wallets, the same addresses and private keys will always be generated with those wallet files.
Ava Chow
<transactions><utxo><balance><output>
I seem to have too many unspent outputs for my given balance. What am I missing?
Bastien
# I seem to have too many unspent outputs for my given balance. What am I missing?

(Asked by: username_0 on 2018-07-19)

I have an address on the testnet. I started out with 1.3 btc. I then sent 0.5 btc to another address. My balance is now 0.8. OK, that makes sense.

I expect now to have one UTXO which was the 0.8 in change from the previous transaction. But when I run listunspent, I see I have two UTXOs. The balance is correct, but it seems I have two outputs.

```
[
  {
    "txid": 
   "321dab633022a33c3a49b4aab4b13d3c431771ae9402746dbb6dcc21be5fd603",
    "vout": 1,
    "address": "2N4wJG7gs1mVXeMkX2MCuyekZUCSzrW7CjT",
    "redeemScript": "0014221f8d76c5b85e979055e54ac97a0cada38bc4e9",
    "scriptPubKey": "a914803d96c7e19e4a568764f9912fa54499f814cd8e87",
    "amount": 0.79999834,
    "confirmations": 119,
    "spendable": true,
    "solvable": true,
    "safe": true
  }
]

```

When I run gettxout with the txid and vout 0, the first transaction UTXO is 0.5.

```
{
  "bestblock": 
  "0000000000000043a1abc3cf9c778d3adeb417488019a507da871db9df74ffad",
  "confirmations": 119,
  "value": 0.50000000,
  "scriptPubKey": {
     "asm": "OP_HASH160 a43f8a90f292b6be0b487556ac357709a5e86480 OP_EQUAL",
     "hex": "a914a43f8a90f292b6be0b487556ac357709a5e8648087",
     "reqSigs": 1,
     "type": "scripthash",
     "addresses": [
       "2N8Dgvfmgs4fNCi7QatLZJR8ArvhPpMPW8P"
     ]
  },
  "coinbase": false
}

```

And when I run gettxout with vout 1, the second transaction UTXO is 0.799 (0.8) which is the balance.

```
{
  "bestblock": 
  "0000000000000043a1abc3cf9c778d3adeb417488019a507da871db9df74ffad",
  "confirmations": 119,
  "value": 0.79999834,
  "scriptPubKey": {
    "asm": "OP_HASH160 803d96c7e19e4a568764f9912fa54499f814cd8e OP_EQUAL",
    "hex": "a914803d96c7e19e4a568764f9912fa54499f814cd8e87",
    "reqSigs": 1,
    "type": "scripthash",
    "addresses": [
      "2N4wJG7gs1mVXeMkX2MCuyekZUCSzrW7CjT"
  ]
},
"coinbase": false

```

}

And according to this: [How to check if an output has been spent?](https://bitcoin.stackexchange.com/questions/48504/how-to-check-if-an-output-has-been-spent)

If gettxout returns something, then the output is unspent.

Why do I have two unspent outputs with the first one in the same amount that I sent to another address?

**Tags:** transactions, utxo, balance, output

> **Comments:**
> **username_1**: Does your wallet control both addresses? `2N4wJG...` and `2N8Dgv...`? If so, it makes sense that both UTXOs would be listed with `listunspent`  
> **username_0**: Ok, that's probably it.  What I did as an exercise is I made two copies of wallet.dat: sending.dat and receiving.dat. I then had a test faucet send some btc to sending.dat. I then sent btc from sending.dat to receiving.dat. What you see in my original question were the two UTXOs for sending.dat.  So I'm guessing that because I made copies of wallet.dat, all the resulting addresses I created actually belong to the same wallet?  
> **username_2**: Yes, the addresses belong to the same wallet. It was the same file copied, and with Bitcoin Core's HD wallets, the same addresses and private keys will always be generated with those wallet files.  

---

## 1 answers

### Answer by username_1 on 2018-07-19. Score: 1 | Accepted answer

*As per the comments on OP’s question*

Since you made a copy of the wallet.dat file (which is an HD format), both addresses will be under the control of (both copies of) your wallet. Hence, both UTXOs will be listed when calling the `listunspent` command, as each wallet is able to spend both UTXOs.

If you used a **new** wallet to generate a new address, and send some funds to it, then the `listunspent` command should function as you originally expected, as your bitcoin core wallet would not control the address you spent coins too (it would only control the change address).


---

