script: improve isStandard.
This commit is contained in:
parent
c43df089f6
commit
2a12b908a9
@ -1385,10 +1385,10 @@ Script.num = function num(value, flags, size) {
|
|||||||
* account negative zero, minimaldata, etc.
|
* account negative zero, minimaldata, etc.
|
||||||
* @example
|
* @example
|
||||||
* assert.deepEqual(Script.array(0), new Buffer(0));
|
* assert.deepEqual(Script.array(0), new Buffer(0));
|
||||||
* assert.deepEqual(Script.array(0xffee), new Buffer([0xee, 0xff, 0x00]));
|
* assert.deepEqual(Script.array(0xffee), new Buffer('eeff00', 'hex'));
|
||||||
* assert.deepEqual(Script.array(new bn(0xffee)), new Buffer([0xee, 0xff, 0x00]));
|
* assert.deepEqual(Script.array(new bn(0xffee)), new Buffer('eeff00', 'hex'));
|
||||||
* assert.deepEqual(Script.array(new bn(0x1e).ineg()), new Buffer([0x9e]));
|
* assert.deepEqual(Script.array(new bn(0x1e).ineg()), new Buffer('9e', 'hex'));
|
||||||
* @param {Buffer|Number|BN} value
|
* @param {Number|BN} value
|
||||||
* @returns {Buffer}
|
* @returns {Buffer}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -1889,26 +1889,25 @@ Script.prototype.isStandard = function isStandard() {
|
|||||||
var type = this.getType();
|
var type = this.getType();
|
||||||
var m, n;
|
var m, n;
|
||||||
|
|
||||||
if (type === scriptTypes.MULTISIG) {
|
switch (type) {
|
||||||
m = Script.getSmall(this.raw[0]);
|
case scriptTypes.MULTISIG:
|
||||||
n = Script.getSmall(this.raw[this.raw.length - 2]);
|
m = this.getSmall(0);
|
||||||
|
n = this.getSmall(this.code.length - 2);
|
||||||
|
|
||||||
if (n < 1 || n > 3)
|
if (n < 1 || n > 3)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (m < 1 || m > n)
|
if (m < 1 || m > n)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
case scriptTypes.NULLDATA:
|
||||||
|
if (this.raw.length > constants.script.MAX_OP_RETURN_BYTES)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return type !== scriptTypes.NONSTANDARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === scriptTypes.NULLDATA) {
|
|
||||||
if (this.raw.length > constants.script.MAX_OP_RETURN_BYTES)
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return type !== scriptTypes.NONSTANDARD;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user