<p>The signature signs the spending transaction(*). Modifying it in any way will invalidate the signatures in it.</p>

<p>(*) Not actually, as it's obviously impossible for the signature to sign itself. There are also means for a signature to indicate it explicitly does not sign certain parts of the transaction, permitting those to be modified after the fact.</p>

CC BY-SA 4.0
2019-11-13T06:49:51.903Z
What parts of transaction does signature includes, can you give me a link to it and is values covered under it.
Charan2628
CC BY-SA 4.0
2019-11-13T07:02:31.737Z
For inputs that spend legacy (pre-segwit) outputs, see https://bitcoin.stackexchange.com/q/9300/208. For segwit spends another algorithm is used, described in BIP143.
Pieter Wuille
CC BY-SA 4.0
2019-11-13T07:04:03.483Z
In most cases the signature covers ALL transaction fields. https://en.bitcoin.it/wiki/OP_CHECKSIG
amaclin
CC BY-SA 4.0
2019-11-13T07:06:00.530Z
@amaclin No. In particular, the scriptSig of the input being signed is not included. In segwit inputs, the witnesses are not included.
Pieter Wuille
CC BY-SA 4.0
2019-11-13T06:45:31.080Z
2019-11-13T06:45:31.080Z
Pieter Wuille
<p>I'm learning bitcoin through this book "Mastering Bitcoin, 2nd Edition by Andreas M. Antonopoulos". I'm at Chapter 6 "Transactions".
Here is my doubt:
Example there is node A, received transaction like this below</p>

<pre><code>{
  "version": 1,
  "locktime": 0,
  "vin": [
    {
      "txid": "7957a35fe64f80d234d76d83a2a8f1a0d8149a41d81de548f0a65a8a999f6f18",
      "vout": 0,
      "scriptSig" : "3045022100884d142d86652a3f47ba4746ec719bbfbd040a570b1deccbb6498c75c4ae24cb02204b9f039ff08df09cbe9f6addac960298cad530a863ea8f53982c09db8f6e3813[ALL] 0484ecc0d46f1918b30928fa0e4ed99f16a0fb4fde0735e7ade8416ab9fe423cc5412336376789d172787ec3457eee41c04f4938de5cc17b4a10fa336a8d752adf",
      "sequence": 4294967295
    }
  ],
  "vout": [
    {
      "value": 0.01500000,
      "scriptPubKey": "OP_DUP OP_HASH160 ab68025513c3dbd2f7b92a94e0581f5d50f654e7 OP_EQUALVERIFY OP_CHECKSIG"
    },
    {
      "value": 0.08450000,
      "scriptPubKey": "OP_DUP OP_HASH160 7f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a8 OP_EQUALVERIFY OP_CHECKSIG",
    }
  ]
}
</code></pre>

<p>So here transaction fee is: 0.0005 ( 0.1(input) - 0.015(vout[0]) - 0.0845(vout[1]) ).</p>

<p>So what if node A that received this transaction altered the transaction like this:</p>

<pre><code>{
      "version": 1,
      "locktime": 0,
      "vin": [
        {
          "txid": "7957a35fe64f80d234d76d83a2a8f1a0d8149a41d81de548f0a65a8a999f6f18",
          "vout": 0,
          "scriptSig" : "3045022100884d142d86652a3f47ba4746ec719bbfbd040a570b1deccbb6498c75c4ae24cb02204b9f039ff08df09cbe9f6addac960298cad530a863ea8f53982c09db8f6e3813[ALL] 0484ecc0d46f1918b30928fa0e4ed99f16a0fb4fde0735e7ade8416ab9fe423cc5412336376789d172787ec3457eee41c04f4938de5cc17b4a10fa336a8d752adf",
          "sequence": 4294967295
        }
      ],
      "vout": [
        {
          "value": 0.01500000,
          "scriptPubKey": "OP_DUP OP_HASH160 ab68025513c3dbd2f7b92a94e0581f5d50f654e7 OP_EQUALVERIFY OP_CHECKSIG"
        },
        {
          "value": 0.07450000,
          "scriptPubKey": "OP_DUP OP_HASH160 7f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a8 OP_EQUALVERIFY OP_CHECKSIG",
        }
      ]
}
</code></pre>

<p>Now the transaction fee is: 0.0105 ( 0.1(input) - 0.015(vout[0]) - 0.0745(vout[1]) )</p>

<p>What If node A after altering the transaction, able to find the nonce and submit the block to the other nodes.</p>

<p>Other nodes trying to validate this block will checks the UTXO set and signature by the owner found it's a valid block and accepts it to the chain.</p>

<p>Sender can't deny because that transaction has his signature.</p>

<p>In the book it's mentioned that transactions can happen in unsecured network, what if someone altered the transaction values in the middle going through this unsecured network like I mentioned above, now every node gets this altered transaction. </p>

<p>My Question, is this possible or there any further checks happen to ensure the transaction values are the valid ones sent by owner. So far what I learned (till Chapter 6) there is no hashing of values or whole transaction just owner signature.</p>

<bitcoin-core><transactions><transaction-fees><transaction-verification>
What stopping miner from altering value in transaction to increase transaction fee?
Charan2628
# What stopping miner from altering value in transaction to increase transaction fee?

(Asked by: username_0 on 2019-11-13)

I'm learning bitcoin through this book "Mastering Bitcoin, 2nd Edition by Andreas M. Antonopoulos". I'm at Chapter 6 "Transactions".
Here is my doubt:
Example there is node A, received transaction like this below

```
{
  "version": 1,
  "locktime": 0,
  "vin": [
    {
      "txid": "7957a35fe64f80d234d76d83a2a8f1a0d8149a41d81de548f0a65a8a999f6f18",
      "vout": 0,
      "scriptSig" : "3045022100884d142d86652a3f47ba4746ec719bbfbd040a570b1deccbb6498c75c4ae24cb02204b9f039ff08df09cbe9f6addac960298cad530a863ea8f53982c09db8f6e3813[ALL] 0484ecc0d46f1918b30928fa0e4ed99f16a0fb4fde0735e7ade8416ab9fe423cc5412336376789d172787ec3457eee41c04f4938de5cc17b4a10fa336a8d752adf",
      "sequence": 4294967295
    }
  ],
  "vout": [
    {
      "value": 0.01500000,
      "scriptPubKey": "OP_DUP OP_HASH160 ab68025513c3dbd2f7b92a94e0581f5d50f654e7 OP_EQUALVERIFY OP_CHECKSIG"
    },
    {
      "value": 0.08450000,
      "scriptPubKey": "OP_DUP OP_HASH160 7f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a8 OP_EQUALVERIFY OP_CHECKSIG",
    }
  ]
}

```

So here transaction fee is: 0.0005 ( 0.1(input) - 0.015(vout[0]) - 0.0845(vout[1]) ).

So what if node A that received this transaction altered the transaction like this:

```
{
      "version": 1,
      "locktime": 0,
      "vin": [
        {
          "txid": "7957a35fe64f80d234d76d83a2a8f1a0d8149a41d81de548f0a65a8a999f6f18",
          "vout": 0,
          "scriptSig" : "3045022100884d142d86652a3f47ba4746ec719bbfbd040a570b1deccbb6498c75c4ae24cb02204b9f039ff08df09cbe9f6addac960298cad530a863ea8f53982c09db8f6e3813[ALL] 0484ecc0d46f1918b30928fa0e4ed99f16a0fb4fde0735e7ade8416ab9fe423cc5412336376789d172787ec3457eee41c04f4938de5cc17b4a10fa336a8d752adf",
          "sequence": 4294967295
        }
      ],
      "vout": [
        {
          "value": 0.01500000,
          "scriptPubKey": "OP_DUP OP_HASH160 ab68025513c3dbd2f7b92a94e0581f5d50f654e7 OP_EQUALVERIFY OP_CHECKSIG"
        },
        {
          "value": 0.07450000,
          "scriptPubKey": "OP_DUP OP_HASH160 7f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a8 OP_EQUALVERIFY OP_CHECKSIG",
        }
      ]
}

```

Now the transaction fee is: 0.0105 ( 0.1(input) - 0.015(vout[0]) - 0.0745(vout[1]) )

What If node A after altering the transaction, able to find the nonce and submit the block to the other nodes.

Other nodes trying to validate this block will checks the UTXO set and signature by the owner found it's a valid block and accepts it to the chain.

Sender can't deny because that transaction has his signature.

In the book it's mentioned that transactions can happen in unsecured network, what if someone altered the transaction values in the middle going through this unsecured network like I mentioned above, now every node gets this altered transaction.

My Question, is this possible or there any further checks happen to ensure the transaction values are the valid ones sent by owner. So far what I learned (till Chapter 6) there is no hashing of values or whole transaction just owner signature.

**Tags:** bitcoin-core, transactions, transaction-fees, transaction-verification


---

## 1 answers

### Answer by username_1 on 2019-11-13. Score: 1 | Accepted answer

The signature signs the spending transaction(\*). Modifying it in any way will invalidate the signatures in it.

(\*) Not actually, as it's obviously impossible for the signature to sign itself. There are also means for a signature to indicate it explicitly does not sign certain parts of the transaction, permitting those to be modified after the fact.

> **Comments:**
> **username_0**: What parts of transaction does signature includes, can you give me a link to it and is values covered under it.  
> **username_1**: For inputs that spend legacy (pre-segwit) outputs, see https://bitcoin.stackexchange.com/q/9300/208. For segwit spends another algorithm is used, described in BIP143.  
> **username_2**: In most cases the signature covers ALL transaction fields. https://en.bitcoin.it/wiki/OP_CHECKSIG  
> **username_1**: @username_2 No. In particular, the scriptSig of the input being signed is not included. In segwit inputs, the witnesses are not included.  

---

