Author

Topic: Explaination UTXO (Read 187 times)

legendary
Activity: 990
Merit: 1108
April 04, 2022, 09:58:35 AM
#11
No, he sends to Gloria and Rustie in a single transaction. As you noted, that makes more sense than doing 2 individual payments since you only pay once and only create one change output.

Note that doing it in two transactions also leaves you with only one unspent change output.
legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
April 04, 2022, 07:13:58 AM
#10
Here's alternative illustration with horizontal tree diagram. If the node doesn't have child (also called leaf node), it means unspent and vice versa.

Code:
Rustie    TX1    Derrick   TX2    Gloria
UTXO A  -------> UTXO B  -------> UTXO D
100 BTC    |     50 BTC     |     25 BTC
           |                |
           |     Rustie     |     Rustie
           |---> UTXO C     |---> UTXO E
                 50 BTC     |     15 BTC
                            |
                            |     Derrick
                            |---> UTXO F
                                  10 BTC

Code:
Rustie    TX1    Derrick   TX2    Gloria
UTXO A  -------> UTXO B  -------> UTXO D
100 BTC    |     50 BTC     |     25 BTC
           |                |
           |     Rustie     |     Derrick   TX3    Rustie
           |---> UTXO C     |---> UTXO E  -------> UTXO F
                 50 BTC           25 BTC     |     15 BTC
                                             |
                                             |     Derrick
                                             |---> UTXO G
                                                   10 BTC
hero member
Activity: 882
Merit: 5834
not your keys, not your coins!
April 03, 2022, 05:24:16 PM
#9
I think I've almost got it now.
Many thanks for the drawing - it makes it clear.

But ... since Derrick (starting with 50 BTC) makes 2 transactions, why there is only one change?
Is this wrong?
Derrick sends 25 BTC to Gloria - and will get 25 BTC change.
Derrick sends 15 BTC to Rustie - and will get 10 BTC change.
No, he sends to Gloria and Rustie in a single transaction. As you noted, that makes more sense than doing 2 individual payments since you only pay once and only create one change output.

Do keep in mind that you can never spend only part of a UTXO. You always need to spend it completely; hence the need for change outputs.
hero member
Activity: 1106
Merit: 912
Not Your Keys, Not Your Bitcoin
April 03, 2022, 02:29:11 PM
#8
Thanks, unfortunately I still don't understand how it works.

I thought there are 5 UTXO ...

1) Rustie creates one output of 50 BTC which belongs to Derrick (UTXO 1) and another output of 50 BTC as change to himself (UTXO 2).
2) Derrick creates one output of 25 BTC which belongs to Gloria (UTXO 3), one output of 15 BTC to Rustie (UTXO 4) and another one of 10 BTC as change to himself (UTXO 5).

You're are complicating a transaction that is very simple. You should know that a UTXO will get consumed as input in every transaction and a change will be returned as part of the output transactions.

Derick has 50btc, it gets consumed  as a single input with 3 outputs transaction( 25 BTC to Gloria, 15 BTC to Rustie and 10 BTC as change)
legendary
Activity: 2268
Merit: 18711
April 03, 2022, 02:25:23 PM
#7
But ... since Derrick (starting with 50 BTC) makes 2 transactions, why there is only one change?
Is this wrong?
Derrick sends 25 BTC to Gloria - and will get 25 BTC change.
Derrick sends 15 BTC to Rustie - and will get 10 BTC change.
Derrick could either make a single transaction spending the 50 BTC UTXO with 3 outputs (25 to Gloria, 15 to Rustie, 10 as change), or Derrick could make two transactions with 2 outputs each (first transaction spending the 50 BTC UTXO with 25 to Gloria and 25 as change, followed by a second transaction spending the 25 BTC change UTXO with 15 to Rustie and 10 as change). The final outcome is the same regardless - Gloria has one UTXO with 25 BTC, Rustie has one UTXO with 15 BTC, and Derrick has one UTXO with 10 BTC (change).

As BHC has pointed out above, making two transactions instead of one will just cost a little more in fees.
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
April 03, 2022, 01:30:29 PM
#6
Since Derrick (starting with 50 BTC) makes 2 transactions, why there is only one change?
Is this wrong?
Derrick can either split their 50 BTC output to 3 outputs or to 2, one of which will be split to 2 again. It wouldn't benefit him, though, because he'd have to pay more in fees as he'd have made an extra transaction. See diagram to understand the difference.

Code:
                                    (Unspent)
                                       25 BTC
                                      ┌──────► Gloria
                                      │
                                      │
              (Spent)                 │
               50 BTC                 │                                 (Unspent)
              ┌─────► Derrick ───────►│                                 15 BTC
              │                       │                                ┌───────► Rustie
              │                       │
                               │
Rustie───────►│                       │
                               │
              │                       │
                               │
              │                       └──────► Derrick's change ──────►│
              │                        25 BTC
                         │
              └─────► Change          (Spent)
                        │
               50 BTC
                                                 │
              (Unspent)                                                └───────► Derrick's change
                                                                        10 BTC
                                                                       (Unspent)


(Sorry for the awful drawing, I can't fix it ATM)
newbie
Activity: 3
Merit: 12
April 03, 2022, 01:13:13 PM
#5
I think I've almost got it now.
Many thanks for the drawing - it makes it clear.

But ... since Derrick (starting with 50 BTC) makes 2 transactions, why there is only one change?
Is this wrong?
Derrick sends 25 BTC to Gloria - and will get 25 BTC change.
Derrick sends 15 BTC to Rustie - and will get 10 BTC change.
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
April 03, 2022, 12:46:56 PM
#4
I thought there are 5 UTXO ...
There are 5 outputs, 4 of which are unspent. Once Derrick spends their 50 BTC output and creates 3 UTXOs, they'll have essentially added 3 UTXOs to the set and removed 1.

Edit: See drawing:
Code:
                                     (Unspent)
                                       25 BTC
                                      ┌──────► Gloria
                                      │
                                      │
              (Spent)                 │(Unspent)
               50 BTC                 │15 BTC
              ┌─────► Derrick ───────►├──────► Rustie
              │                       │
              │                       │
Rustie───────►│                       │
              │                       │
              │                       └──────► Change
              │                        10 BTC
              └─────► Change         (Unspent)
               50 BTC
              (Unspent)

Total unspent: 4
newbie
Activity: 3
Merit: 12
April 03, 2022, 12:39:50 PM
#3
Thanks, unfortunately I still don't understand how it works.

I thought there are 5 UTXO ...

1) Rustie creates one output of 50 BTC which belongs to Derrick (UTXO 1) and another output of 50 BTC as change to himself (UTXO 2).
2) Derrick creates one output of 25 BTC which belongs to Gloria (UTXO 3), one output of 15 BTC to Rustie (UTXO 4) and another one of 10 BTC as change to himself (UTXO 5).
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
April 03, 2022, 12:27:36 PM
#2
  • Rustie creates one output of 50 BTC which belongs to Derrick and another output of 50 BTC as change to himself.
  • Derrick creates one output of 25 BTC which belongs to Gloria, one output of 15 BTC to Rustie and another one of 10 BTC as change to himself.
  • There are 4 UTXOs left.

Each time you spend a UTXO you create at least another UTXO[1]. You can split a UTXO to several as shown in the second step.

[1] Assuming you don't use OP_RETURN to burn them provably. These transactions aren't included in the UTXO set.
newbie
Activity: 3
Merit: 12
April 03, 2022, 12:20:20 PM
#1
Hi there,

Can someone please explain the UTXO logic - why is 4 the result?

Rustie has 100 bitcoins stored in one UTXO. Derrick and Gloria both have 0 bitcoins. Rustie sends 50 to Derrick, who then sends 25 to Gloria and 15 back to Rustie. How many unique (spendable) UTXOs are left?

Thanks in advance,
Selter
Jump to: