Saturday, September 28, 2024
HomeBitcoinWhich is the hash-preimage of a 2-input transaction?

Which is the hash-preimage of a 2-input transaction?


When verifying a transaction, the Bitcoin node rebuilds the hash-preimage of it from the transaction that has acquired.

With one-input transaction, it’s straightforward to construct the hash-preimage of it:

  1. Change the scriptSig to the scriptPubKey the place the funds are being spent from.
  2. Change the sigHash placement.

The results of the steps above is double hashed, then is verified with the general public key and the “r” and “s” worth of the signature.

However with a two-inputs transaction, which is the whole course of?
To confirm every enter, does the hash-preimage embrace the opposite enter?

Thanks prematurely, it will be useful if an instance is supplied.

[Context]

I wrote the next code that verifies utilizing ECDSA math a one-input and one-output transaction, each P2PKH: https://github.com/SalvaZaraes/bitcoin-digital-signatures-article/blob/essential/verify-p2pkh-tx.py

Now I having issues with constructing the hash-preimage of a two-input transaction, that is the explanation behind asking the higher questions.


So, for instance, a transaction like this one:
https://mempool.area/es/tx/592ea2010ec259252959b6047e227ceac6ffd0dbbe20bad71248960c18a5d890

That has two P2PKH inputs and one P2PKH output.

The corresponding Hash-preimage for the primary enter could be like this?:

010000000219f4d40cb4204ad8429ec3d98d240661593edcfcfb8efcb3b684141ceb0df2e4000000001976a914d52c9ce97c8dea0b71df687659a847a62c37732c88acffffffff22d07db06b68e4c15154db0ce0dd9c9dcd683a60a5117490451e0b52743492ca000000001976a91497ccdcca4f494b1bd652ad8f9d816b4bbb1108ac88acffffffff01c047bfe54d0000001976a91492512166101806dd6a695cbe56f883c3bea2a7e488ac0000000001000000

Breakdown:

01000000 – Model

02 – Variety of Inputs

19f4d40cb4204ad8429ec3d98d240661593edcfcfb8efcb3b684141ceb0df2e4 – Earlier Tx-id

00000000 – Enter to be spent, on this case the Enter at place 0 of the earlier tx (First enter on this tx)

1976a914d52c9ce97c8dea0b71df687659a847a62c37732c88ac – First Enter Locking Script (scriptPubKey)

ffffffff – Sequence

22d07db06b68e4c15154db0ce0dd9c9dcd683a60a5117490451e0b52743492ca – Earlier Tx-id

00000000 – Enter to be spent, on this case the Enter at place 0 of the earlier tx (Second enter on this tx)

1976a91497ccdcca4f494b1bd652ad8f9d816b4bbb1108ac88ac – Second Enter Locking Script (scriptPubKey)

ffffffff – Sequence

01 – Variety of Outputs

c047bfe54d000000 – Quantity of Satoshis being locked within the new scriptPubKey
1976a91492512166101806dd6a695cbe56f883c3bea2a7e488ac – new scriptPubKey

00000000 – Locktime

01000000 – SigHash ALL

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments