This commit is contained in:
Christopher Jeffrey 2016-06-28 22:28:48 -07:00
parent b6ce94cec3
commit 634290687b
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
3 changed files with 19 additions and 28 deletions

View File

@ -438,25 +438,6 @@ Input.prototype.test = function test(addressMap) {
*/
Input.prototype.inspect = function inspect() {
var coin;
if (this.coin) {
coin = this.coin;
} else {
coin = {
type: 'unknown',
version: 1,
height: -1,
value: '0.0',
script: '',
coinbase: false,
hash: this.prevout.hash,
index: this.prevout.index,
age: 0,
address: null
};
}
return {
type: this.getType(),
subtype: this.getSubtype(),
@ -467,7 +448,7 @@ Input.prototype.inspect = function inspect() {
redeem: this.getRedeem(),
sequence: this.sequence,
prevout: this.prevout,
coin: coin
coin: this.coin
};
};

View File

@ -50,7 +50,10 @@ Output.prototype.fromOptions = function fromOptions(options, mutable) {
assert(!mutable || options.value >= 0);
this.mutable = !!mutable;
this.value = options.value || 0;
if (options.value)
this.value = options.value;
if (options.script)
this.script.fromOptions(options.script);
@ -232,6 +235,7 @@ Output.prototype.isDust = function isDust(rate) {
*/
Output.prototype.fromJSON = function fromJSON(json) {
assert(typeof json.value === 'string');
this.value = utils.satoshi(json.value);
this.script.fromJSON(json.script);
return this;

View File

@ -874,18 +874,24 @@ NetworkAddress.uid = 0;
NetworkAddress.prototype.fromOptions = function fromOptions(options) {
var host = options.host;
assert(typeof options.host === 'string');
assert(typeof options.port === 'number');
if (IP.version(host) !== -1)
host = IP.normalize(host);
assert(typeof options.host === 'string');
assert(typeof options.port === 'number');
assert(typeof options.services === 'number');
assert(typeof options.ts === 'number');
this.host = host;
this.port = options.port;
this.services = options.services;
this.ts = options.ts;
if (options.services) {
assert(typeof options.services === 'number');
this.services = options.services;
}
if (options.ts) {
assert(typeof options.ts === 'number');
this.ts = options.ts;
}
return this;
};