tx: refactor hasStandardWitness.

This commit is contained in:
Christopher Jeffrey 2017-08-30 10:14:51 -07:00
parent 063f55f448
commit 57b98b2368
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -1629,14 +1629,14 @@ TX.prototype.hasStandardWitness = function hasStandardWitness(view) {
return false;
}
const redeem = witness.items[witness.items.length - 1];
const raw = witness.items[witness.items.length - 1];
if (redeem.length > policy.MAX_P2WSH_SIZE)
if (raw.length > policy.MAX_P2WSH_SIZE)
return false;
prev = new Script(redeem);
const redeem = Script.fromRaw(raw);
if (prev.isPubkey()) {
if (redeem.isPubkey()) {
if (witness.items.length - 1 !== 1)
return false;
@ -1646,7 +1646,7 @@ TX.prototype.hasStandardWitness = function hasStandardWitness(view) {
continue;
}
if (prev.isPubkeyhash()) {
if (redeem.isPubkeyhash()) {
if (input.witness.items.length - 1 !== 2)
return false;
@ -1659,7 +1659,7 @@ TX.prototype.hasStandardWitness = function hasStandardWitness(view) {
continue;
}
const [m] = prev.getMultisig();
const [m] = redeem.getMultisig();
if (m !== -1) {
if (witness.items.length - 1 !== m + 1)