script: minor.
This commit is contained in:
parent
ec475d6d1c
commit
50c75aeea8
@ -2891,7 +2891,7 @@ Script.verify = function verify(input, witness, output, tx, i, value, flags) {
|
|||||||
Script.verifyProgram = function verifyProgram(witness, output, flags, tx, i, value) {
|
Script.verifyProgram = function verifyProgram(witness, output, flags, tx, i, value) {
|
||||||
let program = output.toProgram();
|
let program = output.toProgram();
|
||||||
let stack = witness.toStack();
|
let stack = witness.toStack();
|
||||||
let j, witnessScript, redeem;
|
let witnessScript, redeem;
|
||||||
|
|
||||||
assert(program, 'verifyProgram called on non-witness-program.');
|
assert(program, 'verifyProgram called on non-witness-program.');
|
||||||
assert((flags & Script.flags.VERIFY_WITNESS) !== 0);
|
assert((flags & Script.flags.VERIFY_WITNESS) !== 0);
|
||||||
@ -2932,7 +2932,7 @@ Script.verifyProgram = function verifyProgram(witness, output, flags, tx, i, val
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Witnesses still have push limits.
|
// Witnesses still have push limits.
|
||||||
for (j = 0; j < stack.length; j++) {
|
for (let j = 0; j < stack.length; j++) {
|
||||||
if (stack.get(j).length > consensus.MAX_SCRIPT_PUSH)
|
if (stack.get(j).length > consensus.MAX_SCRIPT_PUSH)
|
||||||
throw new ScriptError('PUSH_SIZE');
|
throw new ScriptError('PUSH_SIZE');
|
||||||
}
|
}
|
||||||
@ -2967,7 +2967,6 @@ Script.verifyMast = function verifyMast(program, stack, output, flags, tx, i, va
|
|||||||
let version = 0;
|
let version = 0;
|
||||||
let pathdata, depth, path, posdata, pos;
|
let pathdata, depth, path, posdata, pos;
|
||||||
let metadata, subscripts, ops, script;
|
let metadata, subscripts, ops, script;
|
||||||
let j;
|
|
||||||
|
|
||||||
assert(program.version === 1);
|
assert(program.version === 1);
|
||||||
assert((flags & Script.flags.VERIFY_MAST) !== 0);
|
assert((flags & Script.flags.VERIFY_MAST) !== 0);
|
||||||
@ -2989,7 +2988,7 @@ Script.verifyMast = function verifyMast(program, stack, output, flags, tx, i, va
|
|||||||
if (metadata[metadata.length - 1] === 0x00)
|
if (metadata[metadata.length - 1] === 0x00)
|
||||||
throw new ScriptError('INVALID_MAST_STACK');
|
throw new ScriptError('INVALID_MAST_STACK');
|
||||||
|
|
||||||
for (j = 1; j < metadata.length; j++)
|
for (let j = 1; j < metadata.length; j++)
|
||||||
version |= metadata[i] << 8 * (j - 1);
|
version |= metadata[i] << 8 * (j - 1);
|
||||||
|
|
||||||
if (version < 0)
|
if (version < 0)
|
||||||
@ -3020,7 +3019,7 @@ Script.verifyMast = function verifyMast(program, stack, output, flags, tx, i, va
|
|||||||
|
|
||||||
path = [];
|
path = [];
|
||||||
|
|
||||||
for (j = 0; j < depth; j++)
|
for (let j = 0; j < depth; j++)
|
||||||
path.push(pathdata.slice(j * 32, j * 32 + 32));
|
path.push(pathdata.slice(j * 32, j * 32 + 32));
|
||||||
|
|
||||||
posdata = stack.top(-3);
|
posdata = stack.top(-3);
|
||||||
@ -3033,7 +3032,7 @@ Script.verifyMast = function verifyMast(program, stack, output, flags, tx, i, va
|
|||||||
if (posdata[posdata.length - 1] === 0x00)
|
if (posdata[posdata.length - 1] === 0x00)
|
||||||
throw new ScriptError('INVALID_MAST_STACK');
|
throw new ScriptError('INVALID_MAST_STACK');
|
||||||
|
|
||||||
for (j = 0; j < posdata.length; j++)
|
for (let j = 0; j < posdata.length; j++)
|
||||||
pos |= posdata[i] << 8 * j;
|
pos |= posdata[i] << 8 * j;
|
||||||
|
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
@ -3047,7 +3046,7 @@ Script.verifyMast = function verifyMast(program, stack, output, flags, tx, i, va
|
|||||||
|
|
||||||
scripts.writeBytes(output.raw);
|
scripts.writeBytes(output.raw);
|
||||||
|
|
||||||
for (j = 0; j < subscripts; j++) {
|
for (let j = 0; j < subscripts; j++) {
|
||||||
script = stack.top(-(4 + j));
|
script = stack.top(-(4 + j));
|
||||||
if (version === 0) {
|
if (version === 0) {
|
||||||
if ((scripts.written + script.length) > consensus.MAX_SCRIPT_SIZE)
|
if ((scripts.written + script.length) > consensus.MAX_SCRIPT_SIZE)
|
||||||
@ -3069,7 +3068,7 @@ Script.verifyMast = function verifyMast(program, stack, output, flags, tx, i, va
|
|||||||
if (version === 0) {
|
if (version === 0) {
|
||||||
stack.length -= 3 + subscripts;
|
stack.length -= 3 + subscripts;
|
||||||
|
|
||||||
for (j = 0; j < stack.length; j++) {
|
for (let j = 0; j < stack.length; j++) {
|
||||||
if (stack.get(j).length > consensus.MAX_SCRIPT_PUSH)
|
if (stack.get(j).length > consensus.MAX_SCRIPT_PUSH)
|
||||||
throw new ScriptError('PUSH_SIZE');
|
throw new ScriptError('PUSH_SIZE');
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user