<p>The rule is that the longest* <strong>valid</strong> chain is considered the active one. If you build a forking branch with invalid transactions in it, the network (in particular, all full nodes - including miners) will simply ignore it. If it's invalid, it does not exist. Blocks are not relayed to peers before validating them entirely.</p>

<p>You may be able to temporarily fool lightweight clients that don't do full validation, but to build a chain with sufficient length to "confirm" these invalid transactions requires sustained high hashrate, assumed to be impossible without significant (close to or above 50%) mining power.</p>

<p>longest* = it's actually the branch with the highest estimated total number of hashes that is considered the active one (as a tie breaker), not the longest one. This only very occasionally makes a difference (in particular, when the fork crosses a retarget).</p>

CC BY-SA 3.0
2014-07-22T23:08:57.710Z
Ok thanks for your answer. When you say "the total number of hashes", you mean in the last found block or in the whole blockchain?
heyo
CC BY-SA 3.0
2014-07-22T23:11:14.283Z
In the whole blockchain. Fun fact: that number recently surpassed 1 yottahash (a 1 with 24 zeroes).
Pieter Wuille
CC BY-SA 3.0
2014-07-22T23:11:55.070Z
another question: when are the transactions checked? When the block is found, when the emitter of the transaction sends it to other nodes or the both?
heyo
CC BY-SA 3.0
2014-07-22T23:12:37.773Z
Every node validates it before sending it to other nodes.
Pieter Wuille
CC BY-SA 3.0
2014-07-22T23:18:13.153Z
Ok but if I create a custom-fake block with fake transactions, successfully mine it and say to the network I have the answer, they're gonna compare the merkle root, no? My question is : how are they gonna find out if it's a fake and ignore it.
heyo
CC BY-SA 3.0
2014-07-22T23:53:16.423Z
Because they validate it.
Pieter Wuille
CC BY-SA 3.0
2014-07-23T17:59:36.810Z
@heyo When you say "fake transactions", what do you mean? In what sense are they fake? How are they different from valid transactions?
David Schwartz
CC BY-SA 3.0
2014-08-14T17:44:57.127Z
Fake because they're present twice (double spending). If I understand well, miners can validate blockchain in a fraction of second, Proof Of Work is only there to slow down and regulate the distribution of Bitcoins that need to be created.
heyo
CC BY-SA 3.0
2014-08-14T17:50:45.027Z
Adding the same transaction again in a block within a block chain that already has that transaction is a classic double spend attempt, and simply makes the block invalid. No node or wallet in the network will accept it.
Pieter Wuille
CC BY-SA 3.0
2014-07-22T22:40:24.357Z
2014-07-22T23:12:00.063Z
2014-07-22T23:12:00.063Z
Pieter Wuille
<p>I'm not sure I understood everything but all the clients always keep the longest chain, ok. 
So, what happens if an evil person injects bad transactions in a block and successfully mine it (given the difficulty, the probability is extremely low, but let's imagine), how is the network gonna answer?</p>

<mining-theory><blockchain-fork><transaction-verification><best-chain><block-validity>
Is it possible that someone forks the chain?
heyo
# Is it possible that someone forks the chain?

(Asked by: username_0 on 2014-07-22)

I'm not sure I understood everything but all the clients always keep the longest chain, ok.
So, what happens if an evil person injects bad transactions in a block and successfully mine it (given the difficulty, the probability is extremely low, but let's imagine), how is the network gonna answer?

**Tags:** mining-theory, blockchain-fork, transaction-verification, best-chain, block-validity


---

## 1 answers

### Answer by username_1 on 2014-07-22. Score: 3

The rule is that the longest\* **valid** chain is considered the active one. If you build a forking branch with invalid transactions in it, the network (in particular, all full nodes - including miners) will simply ignore it. If it's invalid, it does not exist. Blocks are not relayed to peers before validating them entirely.

You may be able to temporarily fool lightweight clients that don't do full validation, but to build a chain with sufficient length to "confirm" these invalid transactions requires sustained high hashrate, assumed to be impossible without significant (close to or above 50%) mining power.

longest\* = it's actually the branch with the highest estimated total number of hashes that is considered the active one (as a tie breaker), not the longest one. This only very occasionally makes a difference (in particular, when the fork crosses a retarget).

> **Comments:**
> **username_0**: Ok thanks for your answer. When you say "the total number of hashes", you mean in the last found block or in the whole blockchain?  
> **username_1**: In the whole blockchain. Fun fact: that number recently surpassed 1 yottahash (a 1 with 24 zeroes).  
> **username_0**: another question: when are the transactions checked? When the block is found, when the emitter of the transaction sends it to other nodes or the both?  
> **username_1**: Every node validates it before sending it to other nodes.  
> **username_0**: Ok but if I create a custom-fake block with fake transactions, successfully mine it and say to the network I have the answer, they're gonna compare the merkle root, no? My question is : how are they gonna find out if it's a fake and ignore it.  
> **username_1**: Because they validate it.  
> **username_2**: @username_0 When you say "fake transactions", what do you mean? In what sense are they fake? How are they different from valid transactions?  
> **username_0**: Fake because they're present twice (double spending). If I understand well, miners can validate blockchain in a fraction of second, Proof Of Work is only there to slow down and regulate the distribution of Bitcoins that need to be created.  
> **username_1**: Adding the same transaction again in a block within a block chain that already has that transaction is a classic double spend attempt, and simply makes the block invalid. No node or wallet in the network will accept it.  

---

