add script.isStandard()
This commit is contained in:
parent
883a7cae54
commit
ef8f1eabd2
@ -329,6 +329,15 @@ Script.prototype.classify = function() {
|
|||||||
return Script.types.UNKNOWN;
|
return Script.types.UNKNOWN;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns true if script is one of the known types
|
||||||
|
*/
|
||||||
|
Script.prototype.isStandard = function() {
|
||||||
|
return this.classify() !== Script.types.UNKNOWN;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Script construction methods
|
// Script construction methods
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -166,6 +166,11 @@ describe('Script', function() {
|
|||||||
|
|
||||||
describe('#toString', function() {
|
describe('#toString', function() {
|
||||||
|
|
||||||
|
it('should work with an empty script', function() {
|
||||||
|
var script = new Script();
|
||||||
|
script.toString().should.equal('');
|
||||||
|
});
|
||||||
|
|
||||||
it('should output this buffer an OP code, data, and another OP code', function() {
|
it('should output this buffer an OP code, data, and another OP code', function() {
|
||||||
var buf = new Buffer([0, 0, 0, 0, 0, 0, 1, 2, 3, 0]);
|
var buf = new Buffer([0, 0, 0, 0, 0, 0, 1, 2, 3, 0]);
|
||||||
buf[0] = Opcode('OP_0').toNumber();
|
buf[0] = Opcode('OP_0').toNumber();
|
||||||
@ -361,4 +366,13 @@ describe('Script', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#isStandard', function() {
|
||||||
|
it('should classify correctly standard script', function() {
|
||||||
|
Script('OP_RETURN 1 0x00').isStandard().should.equal(true);
|
||||||
|
});
|
||||||
|
it('should classify correctly non standard script', function() {
|
||||||
|
Script('OP_TRUE OP_FALSE').isStandard().should.equal(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user