0

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?

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.