<p>Every valid bitcoin transaction can only be created if you have the sender's private key, public key, and the receiver's public key. You can check that the transaction is valid without having the private key, but to modify it you would need to recreate the transaction from scratch, which would only be possible if you had the sender's private key.</p>

<p>So no, it is not possible.</p>

<p>Edit: For a good explanation, see <a href="https://youtu.be/Lx9zgZCMqXE?t=193" rel="noreferrer">https://youtu.be/Lx9zgZCMqXE?t=193</a></p>

CC BY-SA 3.0
2018-03-13T16:00:40.710Z
2018-03-13T19:09:22.550Z
2018-03-13T19:09:22.550Z
Eliyahu
<p>Normally everything in a transaction except <em>scriptSig</em> is cryptographically signed. So nobody can alter your transaction outputs. This is the default case.</p>
<p><strong>But it's indeed possible to craft valid transactions where the outputs can be altered.</strong></p>
<p>Have a look at the configurable <a href="https://developer.bitcoin.org/devguide/transactions.html#signature-hash-types" rel="nofollow noreferrer">signature hash types</a>. Using DER signatures with the <code>SIGHASH_NONE</code> flag (<code>0x00000002</code>) appended in <a href="https://en.bitcoin.it/wiki/OP_CHECKSIG" rel="nofollow noreferrer"><code>OP_CHECKSIG</code></a> will produce a valid transaction of which the unlocked funds can be redistributed to any output.</p>

CC BY-SA 4.0
2021-01-18T21:54:56.280Z
2021-01-19T09:18:05.847Z
2021-01-19T09:18:05.847Z
schmijos
<p>It is possible, but not for regular transactions</p>

CC BY-SA 4.0
2021-01-18T20:31:52.450Z
A bit of a short answer to say that it's possible to craft transactions which can be altered (without signatures).
schmijos
CC BY-SA 3.0
2018-03-13T17:41:24.787Z
2018-03-13T17:41:24.787Z
amaclin
<blockquote>
  <p>Is is possible that a miner modified a unconfirmed transaction (like changing the output of transaction to the miner himself) and put it into the local block, and after 10 mins the miner luckily solved the PoW, putting the block on the chain and broadcast it to others?</p>
</blockquote>

<p>No, because the transaction would be invalid. The vast majority of transactions contain digital signatures which signs the entire transaction. If the transaction is changed, the signatures will become invalid and thus the transaction will be invalid. And if a transaction is invalid, the block containing it is also invalid.</p>

<blockquote>
  <p>If a transaction was modified and finally linked onto the chain, how others check whether the tx was valid or not? (others only check if PoW answer was right or wrong, not checking tx, am I right?)</p>
</blockquote>

<p>No, this is completely incorrect. ALL full nodes verify all transactions in all blocks that they receive (as well as transactions received outside of blocks). Just because a block has a valid proof of work does not mean that the block is valid. It must still build upon a valid block and must only contain valid transactions. Full nodes still verify that transactions contained within a block are valid.</p>

<p>Contrary to popular belief, miners do not say what transactions are valid. Their job is to determine the order of transactions, within certain constraints. It is the job of full nodes to verify transactions, and all miners (or the mining pools) should be running full nodes.</p>

CC BY-SA 3.0
2018-03-14T03:49:16.533Z
Thank a lot, it's really helpful. So, it is that full node would verify every transactions in the block which was newly created by miner? For my scenario as example, if someone modified a tx and successfully mined the block containing it, and as the block was sent to a full node, the full node would verify it and find out the invalid tx, and then what would this full node do? broadcasts to other nodes and informs them that this block is invalid? is it so? and then every node just discards the block that is just mined, which causing no new blocks found in last 10 mins?  Thanks
Ren
CC BY-SA 3.0
2018-03-14T03:50:46.407Z
Every full node that receives that block would reject it as invalid. They just discard the block; there is no notifying other nodes that the block is invalid. All full nodes will figure out it is invalid. It will be just as if no block had been found. Most nodes will also ban the node that relayed them the invalid block. Such bans are local to the node, not network-wide. Note that the block being discarded does not mean that work was wasted. Mining is stateless and every block tried has the same probability of having a valid PoW as every other attempt for a block at a given height.
Ava Chow
CC BY-SA 4.0
2021-01-20T08:57:21.617Z
"If a transaction was modified and finally linked onto the chain, how others check whether the tx was valid or not? (others only check if PoW answer was right or wrong, not checking tx, am I right?)" You can't check anything about a block until you *understand* the block. If the transaction doesn't comply with the rules, then you don't understand the transaction and thus don't understand the block. That makes it indistinguishable from random garbage. A node doesn't try to figure out what particular invalidities mean since there is no such specification that says what they mean.
David Schwartz
CC BY-SA 3.0
2018-03-13T17:34:42.827Z
2018-03-13T17:34:42.827Z
Ava Chow
<p>Is is possible that a miner modified a unconfirmed transaction (like changing the output of transaction to the miner himself) and put it into the local block, and after 10 mins the miner luckily solved the PoW, putting the block on the chain and broadcast it to others?</p>

<p>If a transaction was modified and finally linked onto the chain, how others check whether the tx was valid or not? (others only check if PoW answer was right or wrong, not checking tx, am I right?)</p>

<p>And If modified tx was on chain, how do affected people recover their assets from the loss in modified tx (in which output was modified to the miner himself)?
Could they ask to revoke the block or how could they do?</p>

<p>Thanks</p>

CC BY-SA 3.0
2018-03-13T21:36:24.867Z
If a miner could modify your unconfirmed transaction, *I* could also modify your unconfirmed transaction even without mining.
Criticize SE actions means ban
<blockchain><security><attack>
Miner modifies unconfirmed transactions and put it into the block
Ren
# Miner modifies unconfirmed transactions and put it into the block

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

Is is possible that a miner modified a unconfirmed transaction (like changing the output of transaction to the miner himself) and put it into the local block, and after 10 mins the miner luckily solved the PoW, putting the block on the chain and broadcast it to others?

If a transaction was modified and finally linked onto the chain, how others check whether the tx was valid or not? (others only check if PoW answer was right or wrong, not checking tx, am I right?)

And If modified tx was on chain, how do affected people recover their assets from the loss in modified tx (in which output was modified to the miner himself)?
Could they ask to revoke the block or how could they do?

Thanks

**Tags:** blockchain, security, attack

> **Comments:**
> **username_1**: If a miner could modify your unconfirmed transaction, *I* could also modify your unconfirmed transaction even without mining.  

---

## 4 answers

### Answer by username_5 on 2018-03-13. Score: 13 | Accepted answer

> Is is possible that a miner modified a unconfirmed transaction (like changing the output of transaction to the miner himself) and put it into the local block, and after 10 mins the miner luckily solved the PoW, putting the block on the chain and broadcast it to others?

No, because the transaction would be invalid. The vast majority of transactions contain digital signatures which signs the entire transaction. If the transaction is changed, the signatures will become invalid and thus the transaction will be invalid. And if a transaction is invalid, the block containing it is also invalid.

> If a transaction was modified and finally linked onto the chain, how others check whether the tx was valid or not? (others only check if PoW answer was right or wrong, not checking tx, am I right?)

No, this is completely incorrect. ALL full nodes verify all transactions in all blocks that they receive (as well as transactions received outside of blocks). Just because a block has a valid proof of work does not mean that the block is valid. It must still build upon a valid block and must only contain valid transactions. Full nodes still verify that transactions contained within a block are valid.

Contrary to popular belief, miners do not say what transactions are valid. Their job is to determine the order of transactions, within certain constraints. It is the job of full nodes to verify transactions, and all miners (or the mining pools) should be running full nodes.

> **Comments:**
> **username_0**: Thank a lot, it's really helpful. So, it is that full node would verify every transactions in the block which was newly created by miner? For my scenario as example, if someone modified a tx and successfully mined the block containing it, and as the block was sent to a full node, the full node would verify it and find out the invalid tx, and then what would this full node do? broadcasts to other nodes and informs them that this block is invalid? is it so? and then every node just discards the block that is just mined, which causing no new blocks found in last 10 mins?  Thanks  
> **username_5**: Every full node that receives that block would reject it as invalid. They just discard the block; there is no notifying other nodes that the block is invalid. All full nodes will figure out it is invalid. It will be just as if no block had been found. Most nodes will also ban the node that relayed them the invalid block. Such bans are local to the node, not network-wide. Note that the block being discarded does not mean that work was wasted. Mining is stateless and every block tried has the same probability of having a valid PoW as every other attempt for a block at a given height.  
> **username_6**: "If a transaction was modified and finally linked onto the chain, how others check whether the tx was valid or not? (others only check if PoW answer was right or wrong, not checking tx, am I right?)" You can't check anything about a block until you *understand* the block. If the transaction doesn't comply with the rules, then you don't understand the transaction and thus don't understand the block. That makes it indistinguishable from random garbage. A node doesn't try to figure out what particular invalidities mean since there is no such specification that says what they mean.  

---

### Answer by username_2 on 2018-03-13. Score: 6

Every valid bitcoin transaction can only be created if you have the sender's private key, public key, and the receiver's public key. You can check that the transaction is valid without having the private key, but to modify it you would need to recreate the transaction from scratch, which would only be possible if you had the sender's private key.

So no, it is not possible.

Edit: For a good explanation, see <https://youtu.be/Lx9zgZCMqXE?t=193>


---

### Answer by username_3 on 2021-01-18. Score: 1

Normally everything in a transaction except *scriptSig* is cryptographically signed. So nobody can alter your transaction outputs. This is the default case.

**But it's indeed possible to craft valid transactions where the outputs can be altered.**

Have a look at the configurable [signature hash types](https://developer.bitcoin.org/devguide/transactions.html#signature-hash-types). Using DER signatures with the `SIGHASH_NONE` flag (`0x00000002`) appended in [`OP_CHECKSIG`](https://en.bitcoin.it/wiki/OP_CHECKSIG) will produce a valid transaction of which the unlocked funds can be redistributed to any output.


---

### Answer by username_4 on 2018-03-13. Score: -1

It is possible, but not for regular transactions

> **Comments:**
> **username_3**: A bit of a short answer to say that it's possible to craft transactions which can be altered (without signatures).  

---

