script: add isDefinedHashType to check hashType
This commit is contained in:
parent
86b2cf75ce
commit
0ff5bd5698
1 changed files with 9 additions and 0 deletions
|
@ -134,10 +134,18 @@ function isCanonicalPubKey (buffer) {
|
||||||
|
|
||||||
function isCanonicalSignature (buffer) {
|
function isCanonicalSignature (buffer) {
|
||||||
if (!Buffer.isBuffer(buffer)) return false
|
if (!Buffer.isBuffer(buffer)) return false
|
||||||
|
if (!isDefinedHashType(buffer[buffer.length - 1])) return false
|
||||||
|
|
||||||
return bip66.check(buffer.slice(0, -1))
|
return bip66.check(buffer.slice(0, -1))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isDefinedHashType (hashType) {
|
||||||
|
var hashTypeMod = hashType & ~0x80
|
||||||
|
|
||||||
|
// return hashTypeMod > SIGHASH_ALL && hashTypeMod < SIGHASH_SINGLE
|
||||||
|
return hashTypeMod > 0x00 && hashTypeMod < 0x04
|
||||||
|
}
|
||||||
|
|
||||||
function isPubKeyHashInput (script) {
|
function isPubKeyHashInput (script) {
|
||||||
var chunks = decompile(script)
|
var chunks = decompile(script)
|
||||||
|
|
||||||
|
@ -369,6 +377,7 @@ module.exports = {
|
||||||
|
|
||||||
isCanonicalPubKey: isCanonicalPubKey,
|
isCanonicalPubKey: isCanonicalPubKey,
|
||||||
isCanonicalSignature: isCanonicalSignature,
|
isCanonicalSignature: isCanonicalSignature,
|
||||||
|
isDefinedHashType: isDefinedHashType,
|
||||||
isPubKeyHashInput: isPubKeyHashInput,
|
isPubKeyHashInput: isPubKeyHashInput,
|
||||||
isPubKeyHashOutput: isPubKeyHashOutput,
|
isPubKeyHashOutput: isPubKeyHashOutput,
|
||||||
isPubKeyInput: isPubKeyInput,
|
isPubKeyInput: isPubKeyInput,
|
||||||
|
|
Loading…
Add table
Reference in a new issue