Bitcoin Forum
April 16, 2024, 07:52:35 AM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Explaination UTXO  (Read 166 times)
Selter (OP)
Newbie
*
Offline Offline

Activity: 3
Merit: 12


View Profile
April 03, 2022, 05:20:20 PM
Merited by o_e_l_e_o (4), BlackHatCoiner (3), vapourminer (2), pooya87 (1), ABCbits (1), DdmrDdmr (1)
 #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
No Gods or Kings. Only Bitcoin
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
BlackHatCoiner
Legendary
*
Offline Offline

Activity: 1484
Merit: 7208


Farewell, Leo


View Profile
April 03, 2022, 05:27:36 PM
Last edit: April 03, 2022, 05:44:36 PM by BlackHatCoiner
Merited by pooya87 (2), ABCbits (2), hosseinimr93 (1)
 #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.

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
Selter (OP)
Newbie
*
Offline Offline

Activity: 3
Merit: 12


View Profile
April 03, 2022, 05: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).
BlackHatCoiner
Legendary
*
Offline Offline

Activity: 1484
Merit: 7208


Farewell, Leo


View Profile
April 03, 2022, 05:46:56 PM
Last edit: April 03, 2022, 06:14:40 PM by BlackHatCoiner
Merited by pooya87 (4), o_e_l_e_o (4), ABCbits (3), vapourminer (2), DdmrDdmr (1), n0nce (1)
 #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

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
Selter (OP)
Newbie
*
Offline Offline

Activity: 3
Merit: 12


View Profile
April 03, 2022, 06: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.
BlackHatCoiner
Legendary
*
Offline Offline

Activity: 1484
Merit: 7208


Farewell, Leo


View Profile
April 03, 2022, 06:30:29 PM
Last edit: April 03, 2022, 06:53:03 PM by BlackHatCoiner
Merited by ABCbits (1)
 #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)

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
o_e_l_e_o
In memoriam
Legendary
*
Offline Offline

Activity: 2268
Merit: 18504


View Profile
April 03, 2022, 07: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.
Cookdata
Hero Member
*****
Offline Offline

Activity: 910
Merit: 875


Not Your Keys, Not Your Bitcoin


View Profile
April 03, 2022, 07: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)

n0nce
Hero Member
*****
Offline Offline

Activity: 882
Merit: 5814


not your keys, not your coins!


View Profile WWW
April 03, 2022, 10: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.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
ABCbits
Legendary
*
Offline Offline

Activity: 2842
Merit: 7368


Crypto Swap Exchange


View Profile
April 04, 2022, 12:13:58 PM
Last edit: April 05, 2022, 09:23:03 AM by ETFbitcoin
Merited by vapourminer (1), n0nce (1)
 #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

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
tromp
Legendary
*
Offline Offline

Activity: 974
Merit: 1076


View Profile
April 04, 2022, 02:58:35 PM
 #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.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!