<p>The mining algorithm does nothing to prevent this.  However, the mining algorithm is just a part of the larger consensus algorithm.  This is the algorithm that is not just implemented by a single participant, but by the network as a whole.</p>

<p>If a block includes a transaction that says "Alice sent me 100 bitcoins", it would need to contain a valid signature from Alice.  If it doesn't, then the transaction is invalid as well as the block that contains it.  Every full node on the network checks this transaction when the block is propagated, and will ignore the block as spam if it doesn't validate.  If a miner were to put in the computing power to generate this block, knowing full well that it will be ignored, then they are wasting a considerable amount of their own money.  This is how Bitcoin incentivizes good participants.</p>

CC BY-SA 3.0
2018-03-23T16:52:04.260Z
2018-03-23T16:52:04.260Z
Jestin
<p>A miner isn't able to add anything they want to the block. Each transaction they include still has to be valid. For all but the most esoteric transactions, part of the requirements of being valid is that the transaction contains a signature proving that the creator of the transaction knows the private key of the transaction inputs.</p>

<p>In other words, nothing about mining gives you any power over creating valid transactions. To create a valid transaction you still need to be the actual owner of the bitcoins going into that transaction. Mining gives you control over what transactions are included in the block you are mining but gives you no special abilities or control over transaction validity.</p>

<p>In the same way that a miner can't just create bitcoins out of nowhere (aside from their mining reward), they also can't arbitrarily create transactions out of nowhere.</p>

CC BY-SA 3.0
2018-03-23T14:10:24.080Z
2018-03-23T14:10:24.080Z
David Ogren
<p>The transaction "Alice sends me 100 BTC" is not valid unless existing unspent transaction outputs are referenced in the transaction inputs and the transaction is signed correctly.</p>

<p>If either the referenced transaction inputs are no longer available for spending, or the signature is invalid, the transaction is invalid. If an invalid transaction is included in a block, the block is invalid. Invalid blocks are rejected by all full nodes since every full node enforces all consensus rules independently.</p>

<p>Hence, the mining algorithm doesn't prevent creation of invalid blocks, but the remaining network will reject the block and the mining work invested by the invalid block's author is wasted.</p>

CC BY-SA 3.0
2018-03-23T17:16:29.043Z
2018-03-23T17:16:29.043Z
Murch
<p>This isn't possible because every node in the network enforces the consensus rules. </p>

<p>A miner is only allowed to include 1 transaction that moves coins with no previous inputs, which is the coinbase transaction. The output value of the coinbase transaction <em>must</em> not exceed the block reward plus any transaction fees from transactions in that block. If the value exceeds this amount, the block will be rejected by the network, and the miner loses the work they did to create it.</p>

<p>If the miner includes the "Alice sent me 100 bitcoin" tx by using previous outputs from Alice as inputs, they <em>must</em> be part of a valid transaction. That is to say, Alice must have signed those inputs to prove that she wants the BTC to be spent. If the miner includes them as unsigned inputs, the transaction is invalid, and any block they create including it is also invalid.</p>

CC BY-SA 3.0
2018-03-23T11:14:04.560Z
2018-03-23T13:58:07.850Z
2018-03-23T13:58:07.850Z
Raghav Sood
<p>Suppose there is a miner who consistently cheats. That is, she will include "Alice sent me 100 bitcoins" in every block she creates. If she became the first miner to find a passable hash, then she would get 100 coins. This scenario is not impossible. How does the mining algorithm prevent this?</p>

<mining-theory><block-validity>
What stops a miner from including arbitrary transactions in their block?
Zirui Wang
# What stops a miner from including arbitrary transactions in their block?

(Asked by: username_0 on 2018-03-23)

Suppose there is a miner who consistently cheats. That is, she will include "Alice sent me 100 bitcoins" in every block she creates. If she became the first miner to find a passable hash, then she would get 100 coins. This scenario is not impossible. How does the mining algorithm prevent this?

**Tags:** mining-theory, block-validity


---

## 4 answers

### Answer by username_4 on 2018-03-23. Score: 4 | Accepted answer

This isn't possible because every node in the network enforces the consensus rules.

A miner is only allowed to include 1 transaction that moves coins with no previous inputs, which is the coinbase transaction. The output value of the coinbase transaction *must* not exceed the block reward plus any transaction fees from transactions in that block. If the value exceeds this amount, the block will be rejected by the network, and the miner loses the work they did to create it.

If the miner includes the "Alice sent me 100 bitcoin" tx by using previous outputs from Alice as inputs, they *must* be part of a valid transaction. That is to say, Alice must have signed those inputs to prove that she wants the BTC to be spent. If the miner includes them as unsigned inputs, the transaction is invalid, and any block they create including it is also invalid.


---

### Answer by username_1 on 2018-03-23. Score: 2

The mining algorithm does nothing to prevent this. However, the mining algorithm is just a part of the larger consensus algorithm. This is the algorithm that is not just implemented by a single participant, but by the network as a whole.

If a block includes a transaction that says "Alice sent me 100 bitcoins", it would need to contain a valid signature from Alice. If it doesn't, then the transaction is invalid as well as the block that contains it. Every full node on the network checks this transaction when the block is propagated, and will ignore the block as spam if it doesn't validate. If a miner were to put in the computing power to generate this block, knowing full well that it will be ignored, then they are wasting a considerable amount of their own money. This is how Bitcoin incentivizes good participants.


---

### Answer by username_2 on 2018-03-23. Score: 1

A miner isn't able to add anything they want to the block. Each transaction they include still has to be valid. For all but the most esoteric transactions, part of the requirements of being valid is that the transaction contains a signature proving that the creator of the transaction knows the private key of the transaction inputs.

In other words, nothing about mining gives you any power over creating valid transactions. To create a valid transaction you still need to be the actual owner of the bitcoins going into that transaction. Mining gives you control over what transactions are included in the block you are mining but gives you no special abilities or control over transaction validity.

In the same way that a miner can't just create bitcoins out of nowhere (aside from their mining reward), they also can't arbitrarily create transactions out of nowhere.


---

### Answer by username_3 on 2018-03-23. Score: 1

The transaction "Alice sends me 100 BTC" is not valid unless existing unspent transaction outputs are referenced in the transaction inputs and the transaction is signed correctly.

If either the referenced transaction inputs are no longer available for spending, or the signature is invalid, the transaction is invalid. If an invalid transaction is included in a block, the block is invalid. Invalid blocks are rejected by all full nodes since every full node enforces all consensus rules independently.

Hence, the mining algorithm doesn't prevent creation of invalid blocks, but the remaining network will reject the block and the mining work invested by the invalid block's author is wasted.


---

