Selter (OP)
Newbie
Offline
Activity: 3
Merit: 12
|
|
April 03, 2022, 05:20:20 PM |
|
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
|
|
|
|
BlackHatCoiner
Legendary
Online
Activity: 1526
Merit: 7398
Farewell, Leo
|
|
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) |
|
- 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.
|
. .BLACKJACK ♠ FUN. | | | ███▄██████ ██████████████▀ ████████████ █████████████████ ████████████████▄▄ ░█████████████▀░▀▀ ██████████████████ ░██████████████ █████████████████▄ ░██████████████▀ ████████████ ███████████████░██ ██████████ | | CRYPTO CASINO & SPORTS BETTING | | │ | | │ | ▄▄███████▄▄ ▄███████████████▄ ███████████████████ █████████████████████ ███████████████████████ █████████████████████████ █████████████████████████ █████████████████████████ ███████████████████████ █████████████████████ ███████████████████ ▀███████████████▀ ███████████████████ | | .
|
|
|
|
Selter (OP)
Newbie
Offline
Activity: 3
Merit: 12
|
|
April 03, 2022, 05:39:50 PM |
|
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
Online
Activity: 1526
Merit: 7398
Farewell, Leo
|
|
April 03, 2022, 05:46:56 PM Last edit: April 03, 2022, 06:14:40 PM by BlackHatCoiner |
|
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: (Unspent) 25 BTC ┌──────► Gloria │ │ (Spent) │(Unspent) 50 BTC │15 BTC ┌─────► Derrick ───────►├──────► Rustie │ │ │ │ Rustie───────►│ │ │ │ │ └──────► Change │ 10 BTC └─────► Change (Unspent) 50 BTC (Unspent)
Total unspent: 4
|
. .BLACKJACK ♠ FUN. | | | ███▄██████ ██████████████▀ ████████████ █████████████████ ████████████████▄▄ ░█████████████▀░▀▀ ██████████████████ ░██████████████ █████████████████▄ ░██████████████▀ ████████████ ███████████████░██ ██████████ | | CRYPTO CASINO & SPORTS BETTING | | │ | | │ | ▄▄███████▄▄ ▄███████████████▄ ███████████████████ █████████████████████ ███████████████████████ █████████████████████████ █████████████████████████ █████████████████████████ ███████████████████████ █████████████████████ ███████████████████ ▀███████████████▀ ███████████████████ | | .
|
|
|
|
Selter (OP)
Newbie
Offline
Activity: 3
Merit: 12
|
|
April 03, 2022, 06:13:13 PM |
|
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
Online
Activity: 1526
Merit: 7398
Farewell, Leo
|
|
April 03, 2022, 06:30:29 PM Last edit: April 03, 2022, 06:53:03 PM by BlackHatCoiner |
|
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. (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)
|
. .BLACKJACK ♠ FUN. | | | ███▄██████ ██████████████▀ ████████████ █████████████████ ████████████████▄▄ ░█████████████▀░▀▀ ██████████████████ ░██████████████ █████████████████▄ ░██████████████▀ ████████████ ███████████████░██ ██████████ | | CRYPTO CASINO & SPORTS BETTING | | │ | | │ | ▄▄███████▄▄ ▄███████████████▄ ███████████████████ █████████████████████ ███████████████████████ █████████████████████████ █████████████████████████ █████████████████████████ ███████████████████████ █████████████████████ ███████████████████ ▀███████████████▀ ███████████████████ | | .
|
|
|
|
o_e_l_e_o
In memoriam
Legendary
Offline
Activity: 2268
Merit: 18565
|
|
April 03, 2022, 07:25:23 PM |
|
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
|
|
April 03, 2022, 07:29:11 PM |
|
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
|
|
April 03, 2022, 10:24:16 PM |
|
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.
|
|
|
|
ABCbits
Legendary
Offline
Activity: 2884
Merit: 7509
Crypto Swap Exchange
|
|
April 04, 2022, 12:13:58 PM Last edit: April 05, 2022, 09:23:03 AM by ETFbitcoin Merited by vapourminer (1), n0nce (1) |
|
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. 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
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
|
|
|
|
tromp
Legendary
Offline
Activity: 980
Merit: 1088
|
|
April 04, 2022, 02:58:35 PM |
|
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.
|
|
|
|
|