<p>Transaction signing process involves signing the hash of the entire transaction data as a message in the ECDSA signature. So, if you modify the transaction outputs or any other data then it will render the signature invalid. If you include this transaction in the block, mine it and then relay that block, the other full nodes will see that a transaction included in the block is invalid (since it has invalid signature) and reject the block. So you will lose the block reward even after spending huge amount of electricity and compute costs to mine it.</p>

<p>However, having said that there can be transactions that can be signed with <code>SINGLE</code> or <code>NONE</code> sighash flags. The <code>SINGLE</code> flag commits to only one output, while the <code>NONE</code> flag commits to none of the outputs. If those flags are set while signing the transaction, then the miner can modify other outputs. </p>

CC BY-SA 4.0
2019-08-27T16:42:12.967Z
Thanks for the hint you provided. Looking into https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch06.asciidoc#P2PubKHash1 right now. Need to study this is detail. Cheers!
JDAWG287
CC BY-SA 4.0
2019-08-27T14:53:18.670Z
2019-08-27T14:53:18.670Z
Ugam Kamat
<p>I have been trying to wrap my head around some core concepts of how a blockchain works and something has been bothering me for a while.</p>

<p>Let's consider a case where I am running a full node of a blockchain (either PoW or PoS chain). Now I am aware that a transaction relayed to my node is verified before it gets added to my node's mempool and again when it has to be added to a block. Now, let's assume that I am going to be the next block winner (I know that it is highly unpredictable), my question is as simple as, what is stopping me from taking out a transaction from the mempool (preferably one with a high amount), modifying it's vout (for e.g. replacing it with my scriptPubKey and keeping the vin intact), and accepting it in my block?</p>

<transactions><proof-of-work><proof-of-stake><mempool>
What is stopping me from modifying the mempool of my node (may it be PoS or PoW)?
JDAWG287
# What is stopping me from modifying the mempool of my node (may it be PoS or PoW)?

(Asked by: username_0 on 2019-08-27)

I have been trying to wrap my head around some core concepts of how a blockchain works and something has been bothering me for a while.

Let's consider a case where I am running a full node of a blockchain (either PoW or PoS chain). Now I am aware that a transaction relayed to my node is verified before it gets added to my node's mempool and again when it has to be added to a block. Now, let's assume that I am going to be the next block winner (I know that it is highly unpredictable), my question is as simple as, what is stopping me from taking out a transaction from the mempool (preferably one with a high amount), modifying it's vout (for e.g. replacing it with my scriptPubKey and keeping the vin intact), and accepting it in my block?

**Tags:** transactions, proof-of-work, proof-of-stake, mempool


---

## 1 answers

### Answer by username_1 on 2019-08-27. Score: 2 | Accepted answer

Transaction signing process involves signing the hash of the entire transaction data as a message in the ECDSA signature. So, if you modify the transaction outputs or any other data then it will render the signature invalid. If you include this transaction in the block, mine it and then relay that block, the other full nodes will see that a transaction included in the block is invalid (since it has invalid signature) and reject the block. So you will lose the block reward even after spending huge amount of electricity and compute costs to mine it.

However, having said that there can be transactions that can be signed with `SINGLE` or `NONE` sighash flags. The `SINGLE` flag commits to only one output, while the `NONE` flag commits to none of the outputs. If those flags are set while signing the transaction, then the miner can modify other outputs.

> **Comments:**
> **username_0**: Thanks for the hint you provided. Looking into https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch06.asciidoc#P2PubKHash1 right now. Need to study this is detail. Cheers!  

---

