|
|
@ -1,5 +1,6 @@ |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
var $ = require('./util/preconditions'); |
|
|
|
var base58check = require('./encoding/base58check'); |
|
|
|
var Networks = require('./networks'); |
|
|
|
var Hash = require('./crypto/hash'); |
|
|
@ -316,6 +317,10 @@ Address.fromJSON = function fromJSON(json) { |
|
|
|
if (JSUtil.isValidJSON(json)) { |
|
|
|
json = JSON.parse(json); |
|
|
|
} |
|
|
|
$.checkState( |
|
|
|
JSUtil.isHexa(json.hash), |
|
|
|
'Unexpected hash property, "' + json.hash + '", expected to be hex.' |
|
|
|
); |
|
|
|
var hashBuffer = new Buffer(json.hash, 'hex'); |
|
|
|
return new Address(hashBuffer, json.network, json.type); |
|
|
|
}; |
|
|
@ -390,7 +395,7 @@ Address.prototype.toBuffer = function() { |
|
|
|
/** |
|
|
|
* @returns {Object} An object of the address |
|
|
|
*/ |
|
|
|
Address.prototype.toJSON = function toJSON() { |
|
|
|
Address.prototype.toObject = function toObject() { |
|
|
|
return { |
|
|
|
hash: this.hashBuffer.toString('hex'), |
|
|
|
type: this.type, |
|
|
@ -398,6 +403,13 @@ Address.prototype.toJSON = function toJSON() { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* @returns {Object} An object of the address |
|
|
|
*/ |
|
|
|
Address.prototype.toJSON = function toJSON() { |
|
|
|
return JSON.stringify(this.toObject()); |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* Will return a the string representation of the address |
|
|
|
* |
|
|
|