2

This is driving me nuts. Through trial-and-error, asking numerous people and attempting to read endless articles and manuals, I've come to the conclusion that the "transactions" listed by listsinceblock are quite misleading.

They are not transactions at all?

The "txid" field is not unique, for example. It is only unique when coupled with the mysterious "vout" field, which can apparently be 0 or 1.

This, coupled with the multiple different "categories" (besides receive and send) really make me confused and worried that my Bitcoin Core-based payment system is somehow fundamentally broken.

Can somebody please explain to me once and for all why vout exists and why txid is not unique? And what does this mean in practice? Is this because a "Bitcoin payment" can be made in multiple different "sub-transactions"? I never was able to understand the purpose of that, and it's making me beyond confused.

Would love to get this straightened out now that I'm actually close to actually launching a Bitcoin service!

1
1

vout is the 0 based output index. It can be more than just 0 or 1, but those tend to be the most common because people don't make transactions with lots of outputs.

To understand vout, you must understand how Bitcoin transactions actually work. A Bitcoin transaction consumes transaction outputs as inputs, and creates transaction outputs. It can consume multiple transaction outputs, and create multiple transaction outputs. Furthermore, these transaction outputs can be consumed by different transactions, so each one needs to be able to be uniquely identified. So a unique identifier contains two items: the transaction id to identify the transaction an output belongs to, and an index to point to the position in the list of outputs in that particular transaction.

That index is what the vout is. As with many things in computer science, it is a 0 based counter so the first item is at index 0, the second at 1, and so on.

listsinceblock, listtransactions, and some other RPCs in Bitcoin Core don't actually list Bitcoin transactions. Rather they list the logical transaction - the one that humans tend to think of. This is because a single Bitcoin transaction can both send Bitcoin away from you, and allow you to receive Bitcoin.

In a single Bitcoin transaction, you can be consuming your own transaction outputs, so the transaction is sending your Bitcoin away. However not all transactions contain inputs from the same person. This transaction could involve another person who has their own transaction outputs as inputs to this transaction. And perhaps they are creating an output that you would be able to spend. So this transaction is also sending Bitcoin to you. This single Bitcoin transaction would then consist of two logical transactions - one where you are sending, and one where you are receiving.

This can often occur with change outputs, but the software should not be showing you those as it is smart enough to hide them and not consider them as a distinct logical transaction. Change outputs are when a transaction output is created by you that sends the Bitcoin back to yourself. They exist because a transaction output must be spent in full, but often the amount you are actually sending does not exactly match the exact amount of the output your are spending. So you must create an output that sends the remainder back to yourself.

1

Bitcoin funds are tracked in Unspent Transaction Outputs (UTXO). Whenever you send bitcoins, your wallet software declares which specific UTXOs get spent and creates new UTXOs to assign the funds to the paid parties. Even in the simplest case, a transaction usually creates two new outputs: one to pay the receiver of the payment and one to reassign the left over change to the sender.

As a transaction can have multiple outputs, the txid is not sufficient to uniquely identify UTXOs. However, since the order of the outputs in a transaction is fixed and each position can only appear once, a UTXO can be uniquely identified by the transaction that created it plus the position in the output list. vout is the index of a UTXO in the transaction's output list. We call txid:vout the outpoint of a UTXO.

enter image description here

In this annotated screenshot from blockstream.info, you see transaction 39b6bcf049fbfba73c2e594327cafd4f93b1c23979e138d4c56ab3b7d04172ad. It spends one UTXO, the 5th output (vout: 4, we start counting at 0) of transaction cc90096df338a6894aeef47043b995942758a1dfe52e579560e39730602a7ca4, and creates seven new UTXOs identified as 39b6bc…4172ad:0 through 39b6bc…4172ad:6.

listsinceblock only tells you about the output that facilitated a payment to or from your wallet. When receiving, that's the output that credited your wallet, when sending, it shows the output that paid the receiver.

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.