익명 20:08

Are UTXOS added to the UTXO set instantly after a transaction is created or afte...

Are UTXOS added to the UTXO set instantly after a transaction is created or after the transaction is mined?

If a UTXO is not added to the UTXO set before transaction is mined, how is a chain of unconfirmed transactions created? Where are the inputs taken from?

PS: I am making a blockchain from scratch. It would be really helpful if you can explain the transaction implementation considering all the possible cases.



Top Answer/Comment:

Bitcoin Core maintains the set of unconfirmed transactions it knows about in the mempool. The mempool data structure tracks which UTXOs are consumed and created by those unconfirmed transactions. When a new transaction comes in, it will find outputs either in the UTXO set, or in the pending outputs in the mempool.

Naturally, any transaction that gets included in a block must only spend UTXOs that were created before it is spending them. Thus, any parent transactions must appear in the block before a corresponding child transaction.

상단 광고의 [X] 버튼을 누르면 내용이 보입니다