0

As per hashtype value in https://en.bitcoin.it/wiki/OP_CHECKSIG or https://developer.bitcoin.org/devguide/transactions.html#signature-hash-types, hashtype could either be 0x01, 0x02, 0x03, 0x80, 0x81, 0x82, 0x83.

However, looking at bitcoin testing data in https://github.com/bitcoin/bitcoin/blob/452bb90c718da18a79bfad50ff9b7d1c8f1b4aa3/src/test/data/sighash.json, the hashtype could be in many other value such 1190874345 or -886562767 or other numerical value

Thanks for in advance!

1

Yes, the sighash type can be other than 0x01, 0x02, 0x03, 0x80, 0x81, 0x82, and 0x83, but it can't be values like 1190874345 or -886562767. You will see these in the tests because of the specific functions being tested, but those sighash types will not work in actual transactions.

In actual transactions, the sighash type is the last byte of the signature item. Because it is one byte, there are only 256 possible sighash type values. However, in creating the sighash (and the functions that create that) take a signed int which is 4 bytes. So the unit tests for that function use valid values for the function but those are not valid in transactions.

So in actual transactions, you can use other sighash types. How they behave is a little hard to describe. Confusingly, sometimes the sighash type is treated as a bit set, and other times, as an int.

If the eigth bit (most significant bit) is set, then the SIGHASH_ANYONECANPAY behavior will apply. If taking just the first 5 bits is equal to 2, then SIGHASH_NONE behavior applies. And if taking just the first 5 bits is equal to 3, then SIGHASH_SINGLE behavior applies. All values that do not meet these requirements (which includes the default SIGHASH_ALL 0x01) all mean to use the SIGHASH_ALL rules.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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