Merge pull request #1025 from eordano/tohex
Add shorthand method toHex to Script
This commit is contained in:
commit
688ac4912c
|
@ -206,6 +206,10 @@ Script.prototype.toString = function() {
|
||||||
return str.substr(1);
|
return str.substr(1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Script.prototype.toHex = function() {
|
||||||
|
return this.toBuffer().toString('hex');
|
||||||
|
};
|
||||||
|
|
||||||
Script.prototype.inspect = function() {
|
Script.prototype.inspect = function() {
|
||||||
return '<Script: ' + this.toString() + '>';
|
return '<Script: ' + this.toString() + '>';
|
||||||
};
|
};
|
||||||
|
|
|
@ -193,6 +193,14 @@ describe('Script', function() {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('toHex', function() {
|
||||||
|
it('should return an hexa string "03010203" as expected from [3, 1, 2, 3]', function() {
|
||||||
|
var buf = new Buffer([3, 1, 2, 3]);
|
||||||
|
var script = Script.fromBuffer(buf);
|
||||||
|
script.toHex().should.equal('03010203');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('#isDataOut', function() {
|
describe('#isDataOut', function() {
|
||||||
|
|
||||||
it('should know this is a (blank) OP_RETURN script', function() {
|
it('should know this is a (blank) OP_RETURN script', function() {
|
||||||
|
|
Loading…
Reference in New Issue