Skip to main content
edited tags
Link
Murch
  • 77.8k
  • 35
  • 190
  • 641
Source Link

How is the UTXOs of each partially-spent TxIn determined?

My current understanding of a transaction is as follows:

  1. a transaction (Tx) can have multiple inputs (which are previous unspent transactions = UTXOs), let's call them the TxIn
  2. a Tx can have multiple outputs (which thus become UTXOs before they will themselves become spent by being used as TxIn), let's call them the TxOut
  3. the TxOut have a specific order N in the transaction: TxOut[0], TxOut[1], etc.
  4. each TxIn references the number N which corresponds to the index of the TxOut referred to in point 3 above, so this makes the link between a specific TxIn and a specific TxOut
  5. each TxOut specifies a specific bitcoin amount (which represents the UTXO amount that can be later spent)
  6. each TxOut references one or multiple (in the case of MultiSig) bitcoin addresses (public keys) that can spend the amount
  7. however, and this is what I don't understand, the TxIn does NOT specify the amount of bitcoins that are used

If the TxIn does not specify the amount that is used, how do we determine the spent amount for each TxIn, and thus the UTXO of the part of the TxIn that remains unspent?

Example, a transaction with 2 inputs and one output (assuming no fees):

  • TxIn[0] whose UTXO before spending is 1 BTC
  • TxIn[1] whose UTXO before spending is 1 BTC
  • TxOut[0] whose value is 1.5 BTC

How do we know which TxIn, and how much of which, was spent?

  • was it TxIn[0] for 0.75 and TxIn[1] for 0.75?
  • was it TxIn[0] for 0.5 and TxIn[1] for 1?

What am I missing? Because given the above, it is not possible to determine the spent proportion of each input.