Bitcoin Forum
January 29, 2026, 07:57:14 PM *
News: Community awards 2025
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Quest to Understand UTXO functionality  (Read 76 times)
hmbdofficial (OP)
Member
**
Offline Offline

Activity: 84
Merit: 13


View Profile
Today at 08:26:55 AM
Merited by Mia Chloe (1)
 #1

What really happens technically if a transaction attempts to spend the UTXO that has already been spent and how do the node identifies and invalidate such during the mempool and block validation
Is it just enough that spent UTXO are destroyed and no trace of them in the mempoo afterwards?
Charles-Tim
Legendary
*
Offline Offline

Activity: 2170
Merit: 6172


Leading Crypto Sports Betting & Casino Platform


View Profile
Today at 08:36:09 AM
Merited by Mia Chloe (1)
 #2

If bitcoin has been used in a transaction, you can not use the same bitcoin in another transaction unless it is the one that has already been spent which the receiver can also send to another person or sent to his another bitcoin address.

But if an unconfirmed transaction is valid before but double spent with replace-by-fee, the transaction will be replaced by another transaction, rendering the old unconfirmed transaction invalid.

..Stake.com..   ▄████████████████████████████████████▄
   ██ ▄▄▄▄▄▄▄▄▄▄            ▄▄▄▄▄▄▄▄▄▄ ██  ▄████▄
   ██ ▀▀▀▀▀▀▀▀▀▀ ██████████ ▀▀▀▀▀▀▀▀▀▀ ██  ██████
   ██ ██████████ ██      ██ ██████████ ██   ▀██▀
   ██ ██      ██ ██████  ██ ██      ██ ██    ██
   ██ ██████  ██ █████  ███ ██████  ██ ████▄ ██
   ██ █████  ███ ████  ████ █████  ███ ████████
   ██ ████  ████ ██████████ ████  ████ ████▀
   ██ ██████████ ▄▄▄▄▄▄▄▄▄▄ ██████████ ██
   ██            ▀▀▀▀▀▀▀▀▀▀            ██ 
   ▀█████████▀ ▄████████████▄ ▀█████████▀
  ▄▄▄▄▄▄▄▄▄▄▄▄███  ██  ██  ███▄▄▄▄▄▄▄▄▄▄▄▄
 ██████████████████████████████████████████
▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄
█  ▄▀▄             █▀▀█▀▄▄
█  █▀█             █  ▐  ▐▌
█       ▄██▄       █  ▌  █
█     ▄██████▄     █  ▌ ▐▌
█    ██████████    █ ▐  █
█   ▐██████████▌   █ ▐ ▐▌
█    ▀▀██████▀▀    █ ▌ █
█     ▄▄▄██▄▄▄     █ ▌▐▌
█                  █▐ █
█                  █▐▐▌
█                  █▐█
▀▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀█
▄▄█████████▄▄
▄██▀▀▀▀█████▀▀▀▀██▄
▄█▀       ▐█▌       ▀█▄
██         ▐█▌         ██
████▄     ▄█████▄     ▄████
████████▄███████████▄████████
███▀    █████████████    ▀███
██       ███████████       ██
▀█▄       █████████       ▄█▀
▀█▄    ▄██▀▀▀▀▀▀▀██▄  ▄▄▄█▀
▀███████         ███████▀
▀█████▄       ▄█████▀
▀▀▀███▄▄▄███▀▀▀
..PLAY NOW..
ABCbits
Legendary
*
Offline Offline

Activity: 3500
Merit: 9629



View Profile
Today at 08:45:38 AM
Merited by d5000 (1)
 #3

Node will check whether any UTXO in a TX actually exist on its UTXO set/database. But since the UTXO already spend, node would know the TX attempt to spend non-exist UTXO or UTXO that already spend.

███████████████████████████
███████▄████████████▄██████
████████▄████████▄████████
███▀█████▀▄███▄▀█████▀███
█████▀█▀▄██▀▀▀██▄▀█▀█████
███████▄███████████▄███████
███████████████████████████
███████▀███████████▀███████
████▄██▄▀██▄▄▄██▀▄██▄████
████▄████▄▀███▀▄████▄████
██▄███▀▀█▀██████▀█▀███▄███
██▀█▀████████████████▀█▀███
███████████████████████████
.
.Duelbits PREDICT..
█████████████████████████
█████████████████████████
███████████▀▀░░░░▀▀██████
██████████░░▄████▄░░████
█████████░░████████░░████
█████████░░████████░░████
█████████▄▀██████▀▄████
████████▀▀░░░▀▀▀▀░░▄█████
██████▀░░░░██▄▄▄▄████████
████▀░░░░▄███████████████
█████▄▄█████████████████
█████████████████████████
█████████████████████████
.
.WHERE EVERYTHING IS A MARKET..
█████
██
██







██
██
██████
Will Bitcoin hit $200,000
before January 1st 2027?

    No @1.15         Yes @6.00    
█████
██
██







██
██
██████

  CHECK MORE > 
Zaguru12
Legendary
*
Offline Offline

Activity: 1316
Merit: 1162



View Profile WWW
Today at 09:07:05 AM
Merited by Mia Chloe (1)
 #4

Just as ABCbits has put it out, we can say that each UTXO must belong to a UTXO set, this is like a database and all the full nodes stores this database. and once spend it’s actual removed and the technicality of bitcoin is that every outputs (UTXO) are referenced in inputs as unspent and that is when the nodes actually validates the UTXO.  The only transaction that doesn’t have an input is a coinbase transaction

It should be understand that there is a transaction lock on each UTXO and each of this lock at tied to the users public key hash. So if the transaction is actually spent, the New UTXO will be now tied to the recipients script hash or public key hash and can he only spent by that public key’s private key.

In simplicity each outputs is linked to a input of subsequent transaction while an output is linked to a previous inputs too

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

  ▄██████████▄
  ████████████  ▄▄▄
  █  ██  ██  █   █
  █  ██  ██  █▄▄▄█
  █  ██  ██  █▀▀
  ▀▀▀▀▀▀▀▀▀▀▀▀
 ▄▄▄▄▄▄▄▄▄▄▄▄▄▄
████████████████
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀

  Slots 
    FREE RAINS
.EVERY 30 MINS.
.

  ▄▄▄▄▄▄▄▄▄▄▄
▄█████████████▄
     █████
███████████████
     █████
▄▄▄▄▄█████▄▄▄▄▄
 ▀███████████▀
   ▀▀▀▀█▀▀▀▀
    ▄▄▄█▄▄▄

Live Games
300K
MONTHLY 
RACE
50K
WORTH OF 
CHALLENGES
.REGISTER >.
bitmover
Legendary
*
Offline Offline

Activity: 2926
Merit: 7263


Trêvoid █ No KYC-AML Crypto Swaps


View Profile WWW
Today at 01:06:52 PM
Merited by Mia Chloe (1)
 #5

Node will check whether any UTXO in a TX actually exist on its UTXO set/database. But since the UTXO already spend, node would know the TX attempt to spend non-exist UTXO or UTXO that already spend.

Just to expand this answer a bit.

If a node tries to include a transaction with an UTXO which is already spent, marking it as a valid transaction,  this node will get banned by other other nodes , as it is not following consensus rules.

In the end, transaction wont get propagated even if you control a corrupted node. If the block gets mined with an invalid transaction,  it will be ignored by the other node (like a fork which doesnt follow consensus rules)


███████▄▄███▄███▄
███▄▄████████▌██
▄█████████████▐██▌
██▄███████████▌█▌
███████▀██████▐▌█
██████████████▌▌▐
████████▄███████▐▐
█████████████████
███████████████▄██▄
██████████████▀▀▀
█████▀███▀▀▀

▄▄▄██████▄▄▄███████▄▄▄
███████████████████████████
███▌█████▀███▌█████▀▀███████████▄▄▄▄▄▄▄▄
███▌█████▄███▌█████▄███▐███████████████████▄
▐████████████▀███████▄██████████▀▀▀▀▀▀▀▀████▀
▐████████████▄██▄███████████▌█████████▄████▀
▐█████████▀█████████▌█████████████▄▄████▀
██████████▄███████████▐███▌██▄██████▀
██████████████▀███▐███▌██████████████████████
████▀██████▀▀█████████▌███▀▀▀▀███▀▀▀▀▀▀▀████▌
 
      P R E M I E R   B I T C O I N   C A S I N O   &   S P O R T S B O O K      

█▀▀









▀▀▀

▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

  98%  
RTP

 
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

▀▀█









▀▀▀

█▀▀









▀▀▀

▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

 HIGH 
ODDS

 
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

▀▀█









▀▀▀
 
..PLAY NOW..
She shining
Member
**
Offline Offline

Activity: 274
Merit: 75

My oH My


View Profile
Today at 02:54:36 PM
 #6

It is identified because it's not in the UTXO set where only unspent transactions are found. So if it's not there then it means it has already be spent. The spent output is consumed and removed from the UTXO set and the transaction creates a new output( New UTXO).

......................................... Silence is also an answer....................
d5000
Legendary
*
Offline Offline

Activity: 4536
Merit: 10191


Decentralization Maximalist


View Profile
Today at 05:24:31 PM
Merited by bitmover (2), Mia Chloe (2)
 #7

If a node tries to include a transaction with an UTXO which is already spent, marking it as a valid transaction,  this node will get banned by other other nodes , as it is not following consensus rules.
This afaik only happens if the UTXO was already spent in a previous block, i.e. the "spending transaction" was already confirmed by a miner.

The real difficulty for nodes is to know to order double spends occurring in the same block. Let's imagine we have transaction X spending the same UTXO than transaction Y, and both are created only few milliseconds one after another. Let's say the person trying to double spend wants to damage a person or service in Australia who accepts 0-confirmation transactions, so they broadcast transaction X targeting specifically several nodes in Australia, hoping that the victim sees it first. At the same time they broadcast double spend Y to nodes close to many mining pools, e.g. in the US. So the Australian potential victim node "sees" transaction X and discards transaction Y, but most US miners do the opposite and include transaction Y instead, because they didn't see in their UTXO set that transaction X happened (as it is still unconfirmed and they received it after transaction Y).

As this is something that can happen all the time due to the latency between different networks (and more so if they're far away one from another, like in the example) I believe nodes won't ban another node for trying to broadcast an unconfirmed double spend. They simply check if the transaction is consistent with their own UTXO set, and if not, they discard it.

Of course this "attack" is very unlikely to succeed, because it is unlikely that somebody really accepts a 0 confirmation transaction, and latency issues tend to improve with network speed. But it shows that the "chain state" and thus the "UTXO set" are always a local phenomenon, and all nodes manage it independently. This means in double spend cases nodes can't really see which transaction is the "valid" one, until a miner includes and thus confirms one of both transactions.

███████████████████████████
███████▄████████████▄██████
████████▄████████▄████████
███▀█████▀▄███▄▀█████▀███
█████▀█▀▄██▀▀▀██▄▀█▀█████
███████▄███████████▄███████
███████████████████████████
███████▀███████████▀███████
████▄██▄▀██▄▄▄██▀▄██▄████
████▄████▄▀███▀▄████▄████
██▄███▀▀█▀██████▀█▀███▄███
██▀█▀████████████████▀█▀███
███████████████████████████
.
.Duelbits PREDICT..
█████████████████████████
█████████████████████████
███████████▀▀░░░░▀▀██████
██████████░░▄████▄░░████
█████████░░████████░░████
█████████░░████████░░████
█████████▄▀██████▀▄████
████████▀▀░░░▀▀▀▀░░▄█████
██████▀░░░░██▄▄▄▄████████
████▀░░░░▄███████████████
█████▄▄█████████████████
█████████████████████████
█████████████████████████
.
.WHERE EVERYTHING IS A MARKET..
█████
██
██







██
██
██████
Will Bitcoin hit $200,000
before January 1st 2027?

    No @1.15         Yes @6.00    
█████
██
██







██
██
██████

  CHECK MORE > 
Mia Chloe
Legendary
*
Offline Offline

Activity: 966
Merit: 2006


Contact me for your designs...


View Profile
Today at 06:13:40 PM
 #8

What really happens technically if a transaction attempts to spend the UTXO that has already been spent and how do the node identifies and invalidate such during the mempool and block validation
Is it just enough that spent UTXO are destroyed and no trace of them in the mempoo afterwards?
The bitcoin network is a public ledger meaning they will publicly be marked as spent. During the process of broadcasting and , validation and even confirmation, nodes use a time stamp and witness and a few other data that all confirms the coins are authentic, haven't been spent before and have an origin.

Every coin spent or unspent must have a valid origin and once you've spent it once you can't spend it anymore because publicily it's origin is already marked as spent.

███████████████████████████
███████▄████████████▄██████
████████▄████████▄████████
███▀█████▀▄███▄▀█████▀███
█████▀█▀▄██▀▀▀██▄▀█▀█████
███████▄███████████▄███████
███████████████████████████
███████▀███████████▀███████
████▄██▄▀██▄▄▄██▀▄██▄████
████▄████▄▀███▀▄████▄████
██▄███▀▀█▀██████▀█▀███▄███
██▀█▀████████████████▀█▀███
███████████████████████████
.
.Duelbits PREDICT..
█████████████████████████
█████████████████████████
███████████▀▀░░░░▀▀██████
██████████░░▄████▄░░████
█████████░░████████░░████
█████████░░████████░░████
█████████▄▀██████▀▄████
████████▀▀░░░▀▀▀▀░░▄█████
██████▀░░░░██▄▄▄▄████████
████▀░░░░▄███████████████
█████▄▄█████████████████
█████████████████████████
█████████████████████████
.
.WHERE EVERYTHING IS A MARKET..
█████
██
██







██
██
██████
Will Bitcoin hit $200,000
before January 1st 2027?

    No @1.15         Yes @6.00    
█████
██
██







██
██
██████

  CHECK MORE > 
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!