<p>There is no &quot;the&quot; UTXO set.</p>
<p>The UTXO set model is a way of thinking about the state of the Bitcoin blockchain, and something that guides development. But it is generally not materialized as an actual data structure in its entirety, and there isn't just a single one.</p>
<p>Internally in Bitcoin Core, UTXO sets are represented by the abstract <code>CCoinsView</code> class. There are multiple implementations for it:</p>
<ul>
<li>one that's backed by an on-disk database.</li>
<li>one that's backed by a set of cached in-memory changes on top of another UTXO set (used to represent the UTXO set of the currently-active blockchain).</li>
<li>one that's backed by the mempool on top of another</li>
</ul>
<p>When validating loose transactions that are being relayed and accepted into the mempool, the mempool's UTXO set is used (which consists of all UTXOs in the currently active block, plus implicitly all outputs from mempool transactions added, plus implicitly all inputs from mempool transactions deleted).</p>
<p>When validating a block, the UTXO set corresponding to the currently active block is used, which does not include the implicit changes due to the mempool.</p>
<hr />
<p>To answer your questions:</p>
<blockquote>
<p>Will the 5btc output be deducted(locked to B's address) from the utxo set while the txn is in the mempool(unconfirmed)?</p>
</blockquote>
<p>From the mempool's implicitly-defined UTXO set, yes. From the blockchain's UTXO set, no.</p>
<blockquote>
<p>If no, can A again use the 5BTC from the utxo set?</p>
</blockquote>
<p>That's unrelated to how the database is modeled, but governed by mempool replacement policies. Using RBF (replace-by-fee) it is in some cases possible to replace a mempool transaction with a higher-feerate one. This happens before validation against the mempool's UTXO set happens.</p>

CC BY-SA 4.0
2024-10-29T21:28:00.273Z
2024-10-30T15:19:19.330Z
2024-10-30T15:19:19.330Z
Pieter Wuille
<p>Bitcoin Core nodes keep track both of the UTXO set and the unconfirmed transactions in their mempool. When a UTXO is spent, generally the owners can spend it again, but that creates a conflicting transaction. Only one of the two transactions can be included in a block. If both transactions are broadcast, the first will be replaced by the second if the second transaction both pays a sufficiently higher total fee and a sufficiently higher feerate.</p>

CC BY-SA 4.0
2024-10-29T21:25:55.563Z
2024-10-29T21:25:55.563Z
Murch
<p>Let's say A has an output of 5 BTC in the UTXO set. He creates a transaction where he uses the 5 BTC to send to B. Now the unconfirmed transaction goes to the mempool. Will the 5 BTC output be deducted (locked to B's address) from the UTXO set while the transaction is in the mempool (unconfirmed)? If no, can A again use the 5 BTC from the UTXO set (double-spending?)?</p>

<transactions><unconfirmed-transactions><utxo><mempool><utxo-set>
Does an unconfirmed transaction lock UTXOs?
Ashank
# Does an unconfirmed transaction lock UTXOs?

(Asked by: username_0 on 2024-10-29)

Let's say A has an output of 5 BTC in the UTXO set. He creates a transaction where he uses the 5 BTC to send to B. Now the unconfirmed transaction goes to the mempool. Will the 5 BTC output be deducted (locked to B's address) from the UTXO set while the transaction is in the mempool (unconfirmed)? If no, can A again use the 5 BTC from the UTXO set (double-spending?)?

**Tags:** transactions, unconfirmed-transactions, utxo, mempool, utxo-set


---

## 2 answers

### Answer by username_1 on 2024-10-29. Score: 3

There is no "the" UTXO set.

The UTXO set model is a way of thinking about the state of the Bitcoin blockchain, and something that guides development. But it is generally not materialized as an actual data structure in its entirety, and there isn't just a single one.

Internally in Bitcoin Core, UTXO sets are represented by the abstract `CCoinsView` class. There are multiple implementations for it:

* one that's backed by an on-disk database.
* one that's backed by a set of cached in-memory changes on top of another UTXO set (used to represent the UTXO set of the currently-active blockchain).
* one that's backed by the mempool on top of another

When validating loose transactions that are being relayed and accepted into the mempool, the mempool's UTXO set is used (which consists of all UTXOs in the currently active block, plus implicitly all outputs from mempool transactions added, plus implicitly all inputs from mempool transactions deleted).

When validating a block, the UTXO set corresponding to the currently active block is used, which does not include the implicit changes due to the mempool.

---

To answer your questions:

> Will the 5btc output be deducted(locked to B's address) from the utxo set while the txn is in the mempool(unconfirmed)?

From the mempool's implicitly-defined UTXO set, yes. From the blockchain's UTXO set, no.

> If no, can A again use the 5BTC from the utxo set?

That's unrelated to how the database is modeled, but governed by mempool replacement policies. Using RBF (replace-by-fee) it is in some cases possible to replace a mempool transaction with a higher-feerate one. This happens before validation against the mempool's UTXO set happens.


---

### Answer by username_2 on 2024-10-29. Score: 0

Bitcoin Core nodes keep track both of the UTXO set and the unconfirmed transactions in their mempool. When a UTXO is spent, generally the owners can spend it again, but that creates a conflicting transaction. Only one of the two transactions can be included in a block. If both transactions are broadcast, the first will be replaced by the second if the second transaction both pays a sufficiently higher total fee and a sufficiently higher feerate.


---

