Script: add toHex, fromHex
Script.fromHex previously existed, but was not under any kind of test. This commit adds tests (despite being a little circular in nature) to check that the output is as expected.
This commit is contained in:
parent
57b8afbdab
commit
d0f684844c
2 changed files with 30 additions and 4 deletions
src
|
@ -13,6 +13,7 @@ function Script(data) {
|
|||
this.parse()
|
||||
}
|
||||
|
||||
// Import operations
|
||||
Script.fromBuffer = function(buffer) {
|
||||
assert(Buffer.isBuffer(buffer)) // FIXME: transitionary
|
||||
|
||||
|
@ -23,6 +24,15 @@ Script.fromHex = function(hex) {
|
|||
return Script.fromBuffer(new Buffer(hex, 'hex'))
|
||||
}
|
||||
|
||||
// Export operations
|
||||
Script.prototype.toBuffer = function() {
|
||||
return new Buffer(this.buffer)
|
||||
}
|
||||
|
||||
Script.prototype.toHex = function() {
|
||||
return this.toBuffer().toString('hex')
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the parsed script representation.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue