checkmultisig fixes. misc.

This commit is contained in:
Christopher Jeffrey 2016-01-11 00:40:16 -08:00
parent cf5a117a3e
commit 9c2b0015d1
2 changed files with 25 additions and 17 deletions

View File

@ -13,7 +13,6 @@ var i;
exports.minVersion = 70001;
exports.version = 70002;
// version - services field
exports.services = {
network: 1
};
@ -45,7 +44,7 @@ exports.opcodes = {
pushdata4: 0x4e,
// negate1: 0x4f,
nop1: 0x61,
nop: 0x61,
if_: 0x63,
notif: 0x64,
else_: 0x67,
@ -124,6 +123,8 @@ exports.opcodes = {
checksigverify: 0xad,
checkmultisig: 0xae,
checkmultisigverify: 0xaf,
eval_: 0xb0,
checklocktimeverify: 0xb1
};
@ -140,7 +141,6 @@ Object.keys(exports.opcodes).forEach(function(name) {
exports.opcodesByVal[exports.opcodes[name]] = name;
});
// Little-endian hash type
exports.hashType = {
all: 1,
none: 2,
@ -206,7 +206,7 @@ exports.hd = {
pathRoots: ['m', 'M', 'm\'', 'M\'']
};
exports.locktimeThreshold = 500000000; // Tue Nov 5 00:53:20 1985 UTC
exports.locktimeThreshold = 500000000; // Tue Nov 5 00:53:20 1985 UTC
exports.oneHash = utils.toArray(
'0000000000000000000000000000000000000000000000000000000000000001',

View File

@ -330,7 +330,7 @@ script.execute = function execute(s, stack, tx, index, flags, recurse) {
}
switch (o) {
case 'nop1':
case 'nop':
case 'nop3':
case 'nop4':
case 'nop5':
@ -743,12 +743,12 @@ script.execute = function execute(s, stack, tx, index, flags, recurse) {
if (!script.isKey(key))
return false;
if (!script.isSig(sig))
return false;
if (flags.strictder !== false) {
if (!script.isValidSig(sig))
return false;
} else {
if (!script.isSig(sig))
return false;
}
type = sig[sig.length - 1];
@ -775,9 +775,14 @@ script.execute = function execute(s, stack, tx, index, flags, recurse) {
return false;
n = stack.pop();
if (n.length !== 1 || !(1 <= n[0] && n[0] <= 15))
if (!Array.isArray(n))
return false;
n = n[0] || 0;
if (n.length !== 1 || !(n[0] >= 1 && n[0] <= 15))
return false;
n = n[0];
if (stack.length < n + 1)
return false;
@ -792,26 +797,30 @@ script.execute = function execute(s, stack, tx, index, flags, recurse) {
}
m = stack.pop();
if (m.length !== 1 || !(1 <= m[0] && m[0] <= n))
if (!Array.isArray(m))
return false;
m = m[0] || 0;
if (m.length !== 1 || !(m[0] >= 1 && m[0] <= n))
return false;
m = m[0];
if (stack.length < m + 1)
return false;
subscript = script.subscript(s, lastSep);
// Get signatures
succ = 0;
for (i = 0, j = 0; i < m && j < n; i++) {
sig = stack.pop();
if (!script.isSig(sig))
return false;
if (flags.strictder !== false) {
if (!script.isValidSig(sig))
return false;
} else {
if (!script.isSig(sig))
return false;
}
type = sig[sig.length - 1];
@ -829,7 +838,6 @@ script.execute = function execute(s, stack, tx, index, flags, recurse) {
succ++;
}
// Extra value
if (stack.length < 1)
return false;