update isStandardProgram.
This commit is contained in:
parent
6dd5b936ef
commit
fcf5af802e
@ -2379,34 +2379,30 @@ Script.prototype.isStandard = function isStandard() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Script.prototype.isStandardProgram = function isStandardProgram(witness, flags) {
|
Script.prototype.isStandardProgram = function isStandardProgram(witness, flags) {
|
||||||
var program, witnessScript, i;
|
var program = this.getWitnessProgram();
|
||||||
|
var i;
|
||||||
|
|
||||||
|
assert(program);
|
||||||
assert((flags & constants.flags.VERIFY_WITNESS) !== 0);
|
assert((flags & constants.flags.VERIFY_WITNESS) !== 0);
|
||||||
assert(this.isWitnessProgram());
|
|
||||||
|
|
||||||
program = this.getWitnessProgram();
|
if (program.version === 0) {
|
||||||
|
if (program.data.length === 32) {
|
||||||
if (!program.type)
|
if (witness.items.length === 0)
|
||||||
return false;
|
return false;
|
||||||
|
} else if (program.data.length === 20) {
|
||||||
if (program.version > 0) {
|
if (witness.items.length !== 2)
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (flags & constants.flags.VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM)
|
if (flags & constants.flags.VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (program.type === 'witnesspubkeyhash') {
|
|
||||||
if (witness.items.length !== 2)
|
|
||||||
return false;
|
|
||||||
} else if (program.type === 'witnessscripthash') {
|
|
||||||
if (witness.items.length === 0)
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < witness.items.length; i++) {
|
for (i = 0; i < witness.items.length; i++) {
|
||||||
if (witness.items[i].length > constants.script.MAX_SIZE)
|
if (witness.items[i].length > constants.script.MAX_PUSH)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user