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?
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?
2N4wJG...
and2N8Dgv...
? If so, it makes sense that both UTXOs would be listed withlistunspent