0

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.

1 Answer 1

1

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.

4
  • What parts of transaction does signature includes, can you give me a link to it and is values covered under it.
    – Charan2628
    Nov 13, 2019 at 6:49
  • For inputs that spend legacy (pre-segwit) outputs, see bitcoin.stackexchange.com/q/9300/208. For segwit spends another algorithm is used, described in BIP143. Nov 13, 2019 at 7:02
  • In most cases the signature covers ALL transaction fields. en.bitcoin.it/wiki/OP_CHECKSIG
    – amaclin
    Nov 13, 2019 at 7:04
  • @amaclin No. In particular, the scriptSig of the input being signed is not included. In segwit inputs, the witnesses are not included. Nov 13, 2019 at 7:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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