diff --git a/lib/bcoin/input.js b/lib/bcoin/input.js index 5e715dc1..065e335d 100644 --- a/lib/bcoin/input.js +++ b/lib/bcoin/input.js @@ -68,7 +68,7 @@ Input.prototype.__defineGetter__('hash', function() { }); Input.prototype.__defineGetter__('address', function() { - return this.data.scriptaddress || this.addresses[0] || this._id; + return this.data.scriptaddress || this.addresses[0] || this.getID(); }); Input.prototype.__defineGetter__('signatures', function() { @@ -109,6 +109,10 @@ Input.prototype.__defineGetter__('lock', function() { return this.output.lock; }); +Input.prototype.__defineGetter__('flags', function() { + return this.data.flags; +}); + Input.prototype.__defineGetter__('text', function() { return this.data.text; }); @@ -129,17 +133,6 @@ Input.prototype.__defineGetter__('tx', function() { return this.out.tx; }); -Input.prototype.__defineGetter__('_id', function() { - var data = [].concat( - this.out.hash, - this.out.index, - bcoin.script.encode(this.script), - this.seq - ); - var hash = utils.toHex(utils.dsha256(data)); - return '[' + this.type + ':' + hash.slice(0, 7) + ']'; -}); - Input.prototype.__defineGetter__('addr', function() { return this.address; }); @@ -232,6 +225,12 @@ Input.getData = function getData(input) { return utils.merge(def, bcoin.script.getInputData(input.script)); }; +Input.prototype.getID = function getID() { + var data = bcoin.script.encode(this.script); + var hash = utils.toHex(utils.ripesha(data)); + return '[' + this.type + ':' + hash.slice(0, 7) + ']'; +}; + Input.prototype.inspect = function inspect() { var output = this.output ? this.output.inspect() @@ -245,9 +244,11 @@ Input.prototype.inspect = function inspect() { type: this.type, subtype: this.subtype, address: this.address, - addresses: this.addresses, - signatures: this.signatures.map(utils.toHex), keys: this.keys.map(utils.toHex), + hashes: this.hashes.map(utils.toHex), + addresses: this.addresses, + scriptaddress: this.scriptaddress, + signatures: this.signatures.map(utils.toHex), text: this.text, lock: this.lock, value: utils.btc(output.value), diff --git a/lib/bcoin/output.js b/lib/bcoin/output.js index 7a5d9846..353d66ea 100644 --- a/lib/bcoin/output.js +++ b/lib/bcoin/output.js @@ -70,7 +70,7 @@ Output.prototype.__defineGetter__('hash', function() { }); Output.prototype.__defineGetter__('address', function() { - return this.data.scriptaddress || this.addresses[0] || this._id; + return this.data.scriptaddress || this.addresses[0] || this.getID(); }); Output.prototype.__defineGetter__('signatures', function() { @@ -105,17 +105,12 @@ Output.prototype.__defineGetter__('lock', function() { return bcoin.script.lockTime(this.script); }); -Output.prototype.__defineGetter__('text', function() { - return this.data.text; +Output.prototype.__defineGetter__('flags', function() { + return this.data.flags; }); -Output.prototype.__defineGetter__('_id', function() { - var data = [].concat( - this.value.toArray(), - bcoin.script.encode(this.script) - ); - var hash = utils.toHex(utils.dsha256(data)); - return '[' + this.type + ':' + hash.slice(0, 7) + ']'; +Output.prototype.__defineGetter__('text', function() { + return this.data.text; }); Output.prototype.__defineGetter__('addr', function() { @@ -187,6 +182,12 @@ Output.getData = function getData(output) { return utils.merge(def, bcoin.script.getOutputData(output.script)); }; +Output.prototype.getID = function getID() { + var data = bcoin.script.encode(this.script); + var hash = utils.toHex(utils.ripesha(data)); + return '[' + this.type + ':' + hash.slice(0, 7) + ']'; +}; + Output.prototype.inspect = function inspect() { return { type: this.type, @@ -194,6 +195,7 @@ Output.prototype.inspect = function inspect() { keys: this.keys.map(utils.toHex), hashes: this.hashes.map(utils.toHex), addresses: this.addresses, + scriptaddress: this.scriptaddress, m: this.m, n: this.n, text: this.text, diff --git a/lib/bcoin/script.js b/lib/bcoin/script.js index d6deda5e..95fbd849 100644 --- a/lib/bcoin/script.js +++ b/lib/bcoin/script.js @@ -1416,6 +1416,15 @@ script.getOutputData = function getOutputData(s) { }; } + if (script.isNulldata(s)) { + return { + type: 'nulldata', + side: 'output', + nulldata: s[1], + text: utils.array2utf8(s[1]) + }; + } + return script.getUnknownData(s); };