Monday, December 23, 2024

transactions – hashTypeCode/sighash flag instance byte arrays for every sort

To create the signature pre-image for spending txprev.output0 in txnew.input1, we have to assemble the byte array that features the mandatory knowledge fields and hashTypeCode for every sighashflag. This is the byte array for every sighashflag (0x01, 0x02, 0x03, 0x81, 0x82, 0x83):

  1. sighashflag 0x01 (SIGHASH_ALL):
<model><prev_txid><prev_vout><prev_output_scriptPubKey><input_sequence><txnew.txid><txnew.vout><txnew.output_scriptPubKey><txnew.quantity><sequence><sighashflag>
0100000064891cd6a9771adf75b343367850198633d2865df516533f523ce33fdf8c55c2000000001976a91471ba0c0827171ef16859048b5157ef1f5b7d516288acffffffffc2558cdf3fe33c523f5316f55d86d233861950783643b375df1a77a9d61c8964000000001976a91406f723b0acdefec3b50e7e318951c69dff77bd5688ac00000000ffffffff00000001
  1. sighashflag 0x02 (SIGHASH_NONE):
<model><prev_txid><prev_vout><prev_output_scriptPubKey><input_sequence><txnew.txid><txnew.vout><txnew.output_scriptPubKey><txnew.quantity><sequence><sighashflag>
0100000064891cd6a9771adf75b343367850198633d2865df516533f523ce33fdf8c55c2000000001976a91471ba0c0827171ef16859048b5157ef1f5b7d516288acffffffffc2558cdf3fe33c523f5316f55d86d233861950783643b375df1a77a9d61c89640100000000ffffffff00000002
  1. sighashflag 0x03 (SIGHASH_SINGLE):
<model><prev_txid><prev_vout><prev_output_scriptPubKey><input_sequence><txnew.txid><txnew.vout><txnew.output_scriptPubKey><txnew.quantity><sequence><sighashflag>
0100000064891cd6a9771adf75b343367850198633d2865df516533f523ce33fdf8c55c2000000001976a91471ba0c0827171ef16859048b5157ef1f5b7d516288acffffffffc2558cdf3fe33c523f5316f55d86d233861950783643b375df1a77a9d61c896400000000ffffffff00000003
  1. sighashflag 0x81 (SIGHASH_ALL | SIGHASH_ANYONECANPAY):
<model><prev_txid><prev_vout><prev_output_scriptPubKey><input_sequence><txnew.txid><txnew.vout><txnew.output_scriptPubKey><txnew.quantity><sequence><sighashflag>
0100000064891cd6a9771adf75b343367850198633d2865df516533f523ce33fdf8c55c2000000001976a91471ba0c0827171ef16859048b5157ef1f5b7d516288acffffffffc2558cdf3fe33c523f5316f55d86d233861950783643b375df1a77a9d61c8964000000001976a91406f723b0acdefec3b50e7e318951c69dff77bd5688ac00000000ffffffff00000081
  1. sighashflag 0x82 (SIGHASH_NONE | SIGHASH_ANYONECANPAY):
<model><prev_txid><prev_vout><prev_output_scriptPubKey><input_sequence><txnew.txid><txnew.vout><txnew.output_scriptPubKey><txnew.quantity><sequence><sighashflag>
0100000064891cd6a9771adf75b343367850198633d2865df516533f523ce33fdf8c55c2000000001976a91471ba0c0827171ef16859048b5157ef1f5b7d516288acffffffffc2558cdf3fe33c523f5316f55d86d233861950783643b375df1a77a9d61c89640100000000ffffffff00000082
  1. sighashflag 0x83 (SIGHASH_SINGLE | SIGHASH_ANYONECANPAY):
<model><prev_txid><prev_vout><prev_output_scriptPubKey><input_sequence><txnew.txid><txnew.vout><txnew.output_scriptPubKey><txnew.quantity><sequence><sighashflag>
0100000064891cd6a9771adf75b343367850198633d2865df516533f523ce33fdf8c55c2000000001976a91471ba0c0827171ef16859048b5157ef1f5b7d516288acffffffffc2558cdf3fe33c523f5316f55d86d233861950783643b375df1a77a9d61c896400000000ffffffff00000083

In every case, the variations within the byte array are primarily as a result of inclusion of the particular sighashflag and the serialization of the transaction knowledge.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles