match scriptHash types 1 for 1, ignore classify order
This commit is contained in:
parent
deb8b0f7d8
commit
8f01e4273c
2 changed files with 25 additions and 7 deletions
|
@ -20,12 +20,23 @@ function check (script, allowIncomplete) {
|
||||||
// is redeemScriptSig push only?
|
// is redeemScriptSig push only?
|
||||||
if (!bscript.isPushOnly(scriptSigChunks)) return false
|
if (!bscript.isPushOnly(scriptSigChunks)) return false
|
||||||
|
|
||||||
var inputType = bscript.classifyInput(scriptSigChunks, allowIncomplete)
|
// is witness?
|
||||||
var outputType = bscript.classifyOutput(redeemScriptChunks)
|
|
||||||
if (chunks.length === 1) {
|
if (chunks.length === 1) {
|
||||||
return outputType === bscript.types.P2WSH || outputType === bscript.types.P2WPKH
|
return bscript.witnessScriptHash.output.check(redeemScriptChunks) ||
|
||||||
|
bscript.witnessPubKeyHash.output.check(redeemScriptChunks)
|
||||||
}
|
}
|
||||||
return inputType === outputType
|
|
||||||
|
// match types
|
||||||
|
if (bscript.pubKeyHash.input.check(scriptSigChunks) &&
|
||||||
|
bscript.pubKeyHash.output.check(redeemScriptChunks)) return true
|
||||||
|
|
||||||
|
if (bscript.multisig.input.check(scriptSigChunks, allowIncomplete) &&
|
||||||
|
bscript.multisig.output.check(redeemScriptChunks)) return true
|
||||||
|
|
||||||
|
if (bscript.pubKey.input.check(scriptSigChunks) &&
|
||||||
|
bscript.pubKey.output.check(redeemScriptChunks)) return true
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
check.toJSON = function () { return 'scriptHash input' }
|
check.toJSON = function () { return 'scriptHash input' }
|
||||||
|
|
||||||
|
|
13
test/fixtures/templates.json
vendored
13
test/fixtures/templates.json
vendored
|
@ -153,6 +153,15 @@
|
||||||
""
|
""
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "scripthash",
|
||||||
|
"redeemScript": "OP_2 0327e023a353d111808f61d554c2e1934721eaf87f33b7a771e807006908a49372 03251670bb6a179a0d43b75476c7e580c0ba274378a18077e8de0832c870e5381f 02cca7f9a64425a0466d26d5c7e9eb3ad6b64cd48ea89edb38bc08f58a792dde47 OP_3 OP_CHECKMULTISIG",
|
||||||
|
"redeemScriptSig": "OP_0 304502210093efc26facedc5f51e304aa270a7b4f1a911b2d912c3674e5c6e2ad4ac7a410402201cf0b62c240461902f9f16d8a0bc3a210b7bfcd2c06523dd4b4b63be22e8525201",
|
||||||
|
"input": "OP_0 304502210093efc26facedc5f51e304aa270a7b4f1a911b2d912c3674e5c6e2ad4ac7a410402201cf0b62c240461902f9f16d8a0bc3a210b7bfcd2c06523dd4b4b63be22e8525201 52210327e023a353d111808f61d554c2e1934721eaf87f33b7a771e807006908a493722103251670bb6a179a0d43b75476c7e580c0ba274378a18077e8de0832c870e5381f2102cca7f9a64425a0466d26d5c7e9eb3ad6b64cd48ea89edb38bc08f58a792dde4753ae",
|
||||||
|
"inputHex": "0048304502210093efc26facedc5f51e304aa270a7b4f1a911b2d912c3674e5c6e2ad4ac7a410402201cf0b62c240461902f9f16d8a0bc3a210b7bfcd2c06523dd4b4b63be22e85252014c6952210327e023a353d111808f61d554c2e1934721eaf87f33b7a771e807006908a493722103251670bb6a179a0d43b75476c7e580c0ba274378a18077e8de0832c870e5381f2102cca7f9a64425a0466d26d5c7e9eb3ad6b64cd48ea89edb38bc08f58a792dde4753ae",
|
||||||
|
"output": "OP_HASH160 fcc42dd4aa770d75cb6796bbd7853a325e746659 OP_EQUAL",
|
||||||
|
"outputHex": "a914fcc42dd4aa770d75cb6796bbd7853a325e746659"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "nonstandard",
|
"type": "nonstandard",
|
||||||
"typeIncomplete": "scripthash",
|
"typeIncomplete": "scripthash",
|
||||||
|
@ -191,9 +200,7 @@
|
||||||
"outputHex": "00"
|
"outputHex": "00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "scripthash",
|
"type": "nonstandard",
|
||||||
"redeemScript": "OP_0",
|
|
||||||
"redeemScriptSig": "OP_0",
|
|
||||||
"input": "OP_0 00",
|
"input": "OP_0 00",
|
||||||
"inputHex": "000100",
|
"inputHex": "000100",
|
||||||
"inputStack": [
|
"inputStack": [
|
||||||
|
|
Loading…
Add table
Reference in a new issue