<p>I skimmed the article you're quoting from, its description of the basic mechanics of a blockchain system is misleading and the section &quot;Dealing with Double Spending&quot; has some really strange ideas about how Bitcoin works. (The description of mining is alright.) Perhaps a site that is a bit more focused on the topic would be a better source to read.</p>
<p>Let's start from the top:</p>
<blockquote>
<p>The blockchain which undergirds a digital currency like bitcoin is not able to prevent double-spending on its own. Rather, all of the different transactions involving the relevant cryptocurrency are posted to the blockchain, where they are separately verified and protected by a confirmation process.</p>
</blockquote>
<p>This makes it sound as if multiple conflicting transactions spending the same funds could be posted into the blockchain in parallel and that conflict would then get sussed out by some &quot;confirmation process&quot;. However, the validity of transactions is assessed before they get included in the blockchain. If a block includes any invalid data, it's going to be rejected by the other network participants.  All but one out of a set of conflicting transactions are eliminated before they get into the blockchain.</p>
<blockquote>
<p>Details about the identities of the buyer and seller in any transaction are protected by high-level encryption, which also protects the ledger from tampering by outside sources.</p>
</blockquote>
<p>There is no encryption used in the Bitcoin protocol anywhere. Bitcoin uses <em>public-key cryptography</em> to let users prove that they're authorized to spend funds and prevent tampering with the transactions. The only information about &quot;buyers&quot; and &quot;sellers&quot; is the transaction itself: how much money was transferred, when that occurred, and what exact script mechanics were used. While the addresses involved in the transaction are pseudonyms for the participants, there is no &quot;identity information encrypted&quot; in Bitcoin transactions about senders and receivers. The practice of chain analysis allows observers to make guesses as to what addresses belong together, but no identity information on the owners of addresses is stored anywhere in the Bitcoin network. Most service providers at the edge of the network offering exchange or wallet services do KYC and AML of their customers, though, and do share that data with companies practicing chain surveillance.</p>
<blockquote>
<p>You could attempt to do this by sending the same BTC to two separate bitcoin wallet addresses. Both of these transactions will then go into the pool of unconfirmed transactions.</p>
</blockquote>
<p>Yes, but even when there are multiple conflicting transactions submitted to the network, nodes will generally¹ only <a href="https://bitcoin.stackexchange.com/q/25236/5406">forward the first</a> conflicting transaction they see and drop all subsequent ones.</p>
<blockquote>
<p>The first transaction would be approved via the confirmation mechanism and then verified into the subsequent block. […] If both transactions are pulled from the pool for confirmation simultaneously, the transaction with the highest number of confirmations will be included in the blockchain, while the other one will be discarded.</p>
</blockquote>
<p>A blockchain is a data structure consisting of a chain of blocks. It doesn't have an agenda. It's the body of rules that constitute how said blockchain is written and verified that make things interesting. A block that includes multiple transactions spending the same funds would be invalid and rejected by all network participants. While there could be multiple conflicting <em>unconfirmed</em> transactions (e.g. Mallory promising to pay $10 to Bob or Carol, whomever finishes a task first), that tie is broken when a miner chooses to include one of them in a block (Mallory can't actually give one $10 bill away twice). That's what mining does: it defines the canonical order in which the transactions happened on the network. Once one of the conflicting transactions is included in a block, all the competitors are invalid because they're trying to spend funds have been spent already.</p>
<p>The article is confusing here by using the term &quot;confirmation&quot; in two different meanings in parallel. Here is what happens in the lifecycle of a transaction:<br />
A transaction gets submitted by a sender to the network. Every node that sees the unconfirmed transaction validates that it's well-formed and the funds it spends exist, then forwards the transaction to the node's peers. Eventually, the transaction gets &quot;<a href="https://bitcoin.stackexchange.com/q/146/5406">confirmed</a>&quot; when it is included in a block. The block is propagated on the network and every node that hears about the block checks whether the block was valid according to all protocol rules.</p>
<p>Before a transaction is included in a block, it may be valid, but it cannot have any confirmations. After it is included in a block, it has as many confirmations as the number of blocks that have been found since then (including the one that confirmed it). There can never be multiple conflicting transactions that have confirmations.</p>
<p>Full nodes don't trust data just because others may have verified them already. Every single full node validates every single bit of data itself according to all rules of the protocol. So, it doesn't matter how many other nodes have seen a transaction before, if it fails your node's rule checks it's invalid and gets dropped. In fact, every node is required to validate data before forwarding it, so any node passing invalid data is immediately dropped and banned by the receiving peer.</p>
<hr />
<p>¹ Transactions can be marked as replaceable which changes default node policy regarding competing transactions. A replacement with a higher feerate will supersede the original and be relayed, see <a href="/questions/tagged/replace-by-fee" class="post-tag" title="show questions tagged &#39;replace-by-fee&#39;" rel="tag">replace-by-fee</a>.</p>

CC BY-SA 4.0
2021-12-13T04:16:56.767Z
Understood, the other miners are likely to reject the block in this situation
daisy
CC BY-SA 4.0
2021-12-13T05:25:37.700Z
They'll probably never even see it. Every honest node that gets an invalid block will reject the block and then ban the peer for transmitting invalid data. The block wouldn't propagate on the network and the miner would probably be dropped from the network for publishing the block.
Murch
CC BY-SA 4.0
2021-12-12T15:16:53.830Z
2021-12-13T05:28:43.230Z
2021-12-13T05:28:43.230Z
Murch
<p>A transaction is only valid if it spends previously unspent transaction outputs (UTXOs). The validity of each transaction is determined by several checks, and this is one of them. The transaction might even be valid at some earlier time, but it becomes invalid once any of its inputs are spent by another transaction that gets included in the blockchain, because no two transactions in the blockchain can spend the same output.</p>

CC BY-SA 4.0
2021-12-12T14:21:46.227Z
2021-12-12T14:21:46.227Z
Vojtěch Strnad
<p>I'm reading <a href="https://www.investopedia.com/ask/answers/061915/how-does-block-chain-prevent-doublespending-bitcoins.asp" rel="nofollow noreferrer">How does a block chain prevent double-spending of Bitcoins?
</a>, and it says</p>
<blockquote>
<p>The first transaction would be approved via the confirmation mechanism and then verified into the subsequent block. However, the second transaction would be recognized as invalid by the confirmation process and would not be verified</p>
</blockquote>
<p>Why won't the second transaction pass the confirmation process? Does it mean for each BTC address, only one transaction is allowed in each block?</p>

<doublespend>
Why won't the second transaction pass the confirmation process
daisy
# Why won't the second transaction pass the confirmation process

(Asked by: username_0 on 2021-12-12)

I'm reading [How does a block chain prevent double-spending of Bitcoins?](https://www.investopedia.com/ask/answers/061915/how-does-block-chain-prevent-doublespending-bitcoins.asp), and it says

> The first transaction would be approved via the confirmation mechanism and then verified into the subsequent block. However, the second transaction would be recognized as invalid by the confirmation process and would not be verified

Why won't the second transaction pass the confirmation process? Does it mean for each BTC address, only one transaction is allowed in each block?

**Tags:** doublespend


---

## 2 answers

### Answer by username_1 on 2021-12-12. Score: 2 | Accepted answer

I skimmed the article you're quoting from, its description of the basic mechanics of a blockchain system is misleading and the section "Dealing with Double Spending" has some really strange ideas about how Bitcoin works. (The description of mining is alright.) Perhaps a site that is a bit more focused on the topic would be a better source to read.

Let's start from the top:

> The blockchain which undergirds a digital currency like bitcoin is not able to prevent double-spending on its own. Rather, all of the different transactions involving the relevant cryptocurrency are posted to the blockchain, where they are separately verified and protected by a confirmation process.

This makes it sound as if multiple conflicting transactions spending the same funds could be posted into the blockchain in parallel and that conflict would then get sussed out by some "confirmation process". However, the validity of transactions is assessed before they get included in the blockchain. If a block includes any invalid data, it's going to be rejected by the other network participants. All but one out of a set of conflicting transactions are eliminated before they get into the blockchain.

> Details about the identities of the buyer and seller in any transaction are protected by high-level encryption, which also protects the ledger from tampering by outside sources.

There is no encryption used in the Bitcoin protocol anywhere. Bitcoin uses *public-key cryptography* to let users prove that they're authorized to spend funds and prevent tampering with the transactions. The only information about "buyers" and "sellers" is the transaction itself: how much money was transferred, when that occurred, and what exact script mechanics were used. While the addresses involved in the transaction are pseudonyms for the participants, there is no "identity information encrypted" in Bitcoin transactions about senders and receivers. The practice of chain analysis allows observers to make guesses as to what addresses belong together, but no identity information on the owners of addresses is stored anywhere in the Bitcoin network. Most service providers at the edge of the network offering exchange or wallet services do KYC and AML of their customers, though, and do share that data with companies practicing chain surveillance.

> You could attempt to do this by sending the same BTC to two separate bitcoin wallet addresses. Both of these transactions will then go into the pool of unconfirmed transactions.

Yes, but even when there are multiple conflicting transactions submitted to the network, nodes will generally¹ only [forward the first](https://bitcoin.stackexchange.com/q/25236/5406) conflicting transaction they see and drop all subsequent ones.

> The first transaction would be approved via the confirmation mechanism and then verified into the subsequent block. […] If both transactions are pulled from the pool for confirmation simultaneously, the transaction with the highest number of confirmations will be included in the blockchain, while the other one will be discarded.

A blockchain is a data structure consisting of a chain of blocks. It doesn't have an agenda. It's the body of rules that constitute how said blockchain is written and verified that make things interesting. A block that includes multiple transactions spending the same funds would be invalid and rejected by all network participants. While there could be multiple conflicting *unconfirmed* transactions (e.g. Mallory promising to pay $10 to Bob or Carol, whomever finishes a task first), that tie is broken when a miner chooses to include one of them in a block (Mallory can't actually give one $10 bill away twice). That's what mining does: it defines the canonical order in which the transactions happened on the network. Once one of the conflicting transactions is included in a block, all the competitors are invalid because they're trying to spend funds have been spent already.

The article is confusing here by using the term "confirmation" in two different meanings in parallel. Here is what happens in the lifecycle of a transaction:  
A transaction gets submitted by a sender to the network. Every node that sees the unconfirmed transaction validates that it's well-formed and the funds it spends exist, then forwards the transaction to the node's peers. Eventually, the transaction gets "[confirmed](https://bitcoin.stackexchange.com/q/146/5406)" when it is included in a block. The block is propagated on the network and every node that hears about the block checks whether the block was valid according to all protocol rules.

Before a transaction is included in a block, it may be valid, but it cannot have any confirmations. After it is included in a block, it has as many confirmations as the number of blocks that have been found since then (including the one that confirmed it). There can never be multiple conflicting transactions that have confirmations.

Full nodes don't trust data just because others may have verified them already. Every single full node validates every single bit of data itself according to all rules of the protocol. So, it doesn't matter how many other nodes have seen a transaction before, if it fails your node's rule checks it's invalid and gets dropped. In fact, every node is required to validate data before forwarding it, so any node passing invalid data is immediately dropped and banned by the receiving peer.

---

¹ Transactions can be marked as replaceable which changes default node policy regarding competing transactions. A replacement with a higher feerate will supersede the original and be relayed, see [replace-by-fee](/questions/tagged/replace-by-fee "show questions tagged 'replace-by-fee'").

> **Comments:**
> **username_0**: Understood, the other miners are likely to reject the block in this situation  
> **username_1**: They'll probably never even see it. Every honest node that gets an invalid block will reject the block and then ban the peer for transmitting invalid data. The block wouldn't propagate on the network and the miner would probably be dropped from the network for publishing the block.  

---

### Answer by username_2 on 2021-12-12. Score: 1

A transaction is only valid if it spends previously unspent transaction outputs (UTXOs). The validity of each transaction is determined by several checks, and this is one of them. The transaction might even be valid at some earlier time, but it becomes invalid once any of its inputs are spent by another transaction that gets included in the blockchain, because no two transactions in the blockchain can spend the same output.


---

