script json.
This commit is contained in:
parent
d158918a14
commit
a110ddab27
@ -117,7 +117,7 @@ Coin.prototype.toJSON = function toJSON() {
|
||||
version: this.version,
|
||||
height: this.height,
|
||||
value: utils.btc(this.value),
|
||||
script: utils.toHex(bcoin.protocol.framer.script(this.script)),
|
||||
script: utils.toHex(this.script.encode()),
|
||||
coinbase: this.coinbase,
|
||||
hash: this.hash ? utils.revHex(this.hash) : null,
|
||||
index: this.index
|
||||
@ -129,7 +129,7 @@ Coin._fromJSON = function _fromJSON(json) {
|
||||
version: json.version,
|
||||
height: json.height,
|
||||
value: utils.satoshi(json.value),
|
||||
script: new bcoin.script(new Buffer(json.script, 'hex')),
|
||||
script: bcoin.script.parseScript(new Buffer(json.script, 'hex')),
|
||||
coinbase: json.coinbase,
|
||||
hash: json.hash ? utils.revHex(json.hash) : null,
|
||||
index: json.index
|
||||
|
||||
@ -202,7 +202,7 @@ Input.prototype.toJSON = function toJSON() {
|
||||
index: this.prevout.index
|
||||
},
|
||||
coin: this.coin ? this.coin.toJSON() : null,
|
||||
script: utils.toHex(bcoin.protocol.framer.script(this.script)),
|
||||
script: utils.toHex(this.script.encode()),
|
||||
witness: utils.toHex(bcoin.protocol.framer.witness(this.witness)),
|
||||
sequence: this.sequence
|
||||
};
|
||||
@ -215,7 +215,7 @@ Input._fromJSON = function _fromJSON(json) {
|
||||
index: json.prevout.index
|
||||
},
|
||||
coin: json.coin ? bcoin.coin._fromJSON(json.coin) : null,
|
||||
script: bcoin.protocol.parser.parseScript(new Buffer(json.script, 'hex')),
|
||||
script: bcoin.script.parseScript(new Buffer(json.script, 'hex')),
|
||||
witness: bcoin.protocol.parser.parseWitness(new Buffer(json.witness, 'hex')),
|
||||
sequence: json.sequence
|
||||
};
|
||||
|
||||
@ -110,14 +110,14 @@ Output.prototype.inspect = function inspect() {
|
||||
Output.prototype.toJSON = function toJSON() {
|
||||
return {
|
||||
value: utils.btc(this.value),
|
||||
script: utils.toHex(bcoin.protocol.framer.script(this.script))
|
||||
script: utils.toHex(this.script.encode())
|
||||
};
|
||||
};
|
||||
|
||||
Output._fromJSON = function _fromJSON(json) {
|
||||
return {
|
||||
value: utils.satoshi(json.value),
|
||||
script: new bcoin.script(new Buffer(json.script, 'hex'))
|
||||
script: bcoin.script.parseScript(new Buffer(json.script, 'hex'))
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@ -2708,6 +2708,13 @@ Script.sign = function sign(msg, key, type) {
|
||||
return sig;
|
||||
};
|
||||
|
||||
Script.parseScript = function parseScript(buf) {
|
||||
return {
|
||||
code: Script.decode(buf),
|
||||
raw: buf
|
||||
};
|
||||
};
|
||||
|
||||
Script.decode = function decode(buf) {
|
||||
var code = [];
|
||||
var off = 0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user