<p>All Bitcoin balances are held in separate uniquely identifiable <em>unspent transaction outputs</em> (<a href="/questions/tagged/utxo" class="s-tag post-tag" title="show questions tagged &#39;utxo&#39;" aria-label="show questions tagged &#39;utxo&#39;" rel="tag" aria-labelledby="tag-utxo-tooltip-container" data-tag-menu-origin="Unknown">utxo</a>). Transaction outputs are uniquely identified by their <em>outpoint</em> which is composed from the identifier of the transaction that created the output and the position in the transaction’s outputs (<code>txid:output_position</code>).
When you create a transaction, you spend one or more UTXOs and create one or more UTXOs.</p>
<p>In this scenario, it sounds like you have your balance in a single UTXO that is spent by both transactions. Since each transaction output can only be spent once, these two transactions are in conflict. Only one of them can be included in the best chain. Assuming that both transactions have roughly the same transaction weight, miners would prefer the second transaction as the higher feerate would translate to the miner collecting a drastically higher fee. Once the second transaction is confirmed (included in a block), the first transaction would appear invalid to any nodes, because the UTXO consumed by the input is no longer available. If the first transaction is included in a block before the miner sees the second, the second would be invalid.</p>

CC BY-SA 4.0
2024-11-26T21:10:23.607Z
Wouldn't the UTXO be different since I'm sending to two different addresses?
Myzel394
CC BY-SA 4.0
2024-11-27T00:08:09.343Z
No, the UTXO is consumed as an input. It is the same UTXO regardless of whatever outputs are created in the transaction in which that UTXO is referenced as an input. A UTXO used as an input is a reference like `TXID 123...987 Output No. 7` pointing to an unsent output of an  *older* transaction
RedGrittyBrick
CC BY-SA 4.0
2024-12-02T16:03:37.893Z
I’ve expanded my answer to hopefully clarify that the conflict arises from the wallet starting with a single UTXO that is spent by both transactions.
Murch
CC BY-SA 4.0
2024-11-26T20:58:51.683Z
2024-12-02T16:02:56.227Z
2024-12-02T16:02:56.227Z
Murch
<p>Let's say you got 1 BTC. And you do the following:</p>
<ul>
<li>Send a transaction of 1 BTC to address A; fee: 1 sat/byte</li>
</ul>
<p>If you'd only calculate what's in the blockchain, you'd still have a balance of 1 BTC. But if you also include the mempool you'd have a balance of 0.</p>
<p>Am I now able to send a second transaction, such as:</p>
<ul>
<li>1 BTC to address B, fee: 1000 sat/byte</li>
</ul>
<p>The second transaction would likely be confirmed first; what would then happen to the first one? Would it simply be lost since now I don't have enough balance anymore?</p>

<utxo><doublespend><balance>
Do miners calculate the balance including the mempool?
Myzel394
# Do miners calculate the balance including the mempool?

(Asked by: username_0 on 2024-11-26)

Let's say you got 1 BTC. And you do the following:

* Send a transaction of 1 BTC to address A; fee: 1 sat/byte

If you'd only calculate what's in the blockchain, you'd still have a balance of 1 BTC. But if you also include the mempool you'd have a balance of 0.

Am I now able to send a second transaction, such as:

* 1 BTC to address B, fee: 1000 sat/byte

The second transaction would likely be confirmed first; what would then happen to the first one? Would it simply be lost since now I don't have enough balance anymore?

**Tags:** utxo, doublespend, balance


---

## 1 answers

### Answer by username_1 on 2024-11-26. Score: 2

All Bitcoin balances are held in separate uniquely identifiable *unspent transaction outputs* ([utxo](/questions/tagged/utxo "show questions tagged 'utxo'")). Transaction outputs are uniquely identified by their *outpoint* which is composed from the identifier of the transaction that created the output and the position in the transaction’s outputs (`txid:output_position`).
When you create a transaction, you spend one or more UTXOs and create one or more UTXOs.

In this scenario, it sounds like you have your balance in a single UTXO that is spent by both transactions. Since each transaction output can only be spent once, these two transactions are in conflict. Only one of them can be included in the best chain. Assuming that both transactions have roughly the same transaction weight, miners would prefer the second transaction as the higher feerate would translate to the miner collecting a drastically higher fee. Once the second transaction is confirmed (included in a block), the first transaction would appear invalid to any nodes, because the UTXO consumed by the input is no longer available. If the first transaction is included in a block before the miner sees the second, the second would be invalid.

> **Comments:**
> **username_0**: Wouldn't the UTXO be different since I'm sending to two different addresses?  
> **username_2**: No, the UTXO is consumed as an input. It is the same UTXO regardless of whatever outputs are created in the transaction in which that UTXO is referenced as an input. A UTXO used as an input is a reference like `TXID 123...987 Output No. 7` pointing to an unsent output of an  *older* transaction  
> **username_1**: I’ve expanded my answer to hopefully clarify that the conflict arises from the wallet starting with a single UTXO that is spent by both transactions.  

---

