Bitcoin UTXO

A bitcoin transaction has a list of inputs and a list of outputs as you can see below:

graph LR transaction["Transaction: txid"] input1["Input 1: Output transaction used / unlocking script"] input1 --> transaction input2["Input 2: Output transaction used / unlocking script"] input2 --> transaction input3["Input 3: Output transaction used / unlocking script"] input3 --> transaction output1["Output 1: Locking script / amount of bitcoins locked"] transaction --> output1 output2["Output 2: Locking script / amount of bitcoins locked"] transaction --> output2

When you want to create a transaction, you start with one or several output transaction that wasn’t used. It what we call an UTXO (Unspent Transaction Output), that is to say an unspent transaction output that can be used as an input in a new transaction.

So, let’s say someone locked some Bitcoins for you in the second output of the transaction we have seen before. This means that you somehow have the private key that can be used to create the unlocking script of that UTXO.

There is now at least one UTXO in the blockchain that you can use to create your transaction. You can create the input transaction with:

  • The txid of the transaction that created the UTXO.
  • The index of the output we want to use in the UTXO transaction (second output in our example).
  • An unlocking script that you can generate with your private key.

And you create one output with:

  • The amount of bitcoin that will be locked in that new output.
  • A locking script where you can set the condition you require to use that new UTXO!

An important point to remember is that you must spend the whole UTXO, you cannot use only a part of it.