paulmillr / scure-btc-signer

Audited & minimal library for creating, signing & decoding Bitcoin transactions.
https://paulmillr.com/noble/#scure
MIT License
151 stars 39 forks source link

fix: looser type for allowedSighash #54

Closed kyranjamie closed 1 year ago

kyranjamie commented 1 year ago

SignatureHash is the three sig hash values, a default, and the ANYONECANPAY modifier.

As far as I understand, the sighash can be any of the possible 6 resulting combinations [0x01, 0x02, 0x03, 0x80, 0x81, 0x82, 0x83], meaning this type on signIdx is too strict, as say it doesn't except, say 0x82.

In this PR I've just loosened the type, but maybe library should check for these possible 6 values, either as a type or runtime check?

Or, might it make sense to update the enum?

export enum SigHash {
  ALL = 0x01,
  NONE = 0x02,
  SINGLE = 0x03,
  ALL_ANYONECANPAY = 0x81,
  NONE_ANYONECANPAY = 0x82,
  SINGLE_ANYONECANPAY = 0x83,
}

cc/ @fbwoolf

paulmillr commented 1 year ago

Thanks, incorporated in 07581a7