keyring json.
This commit is contained in:
parent
59cdc96c9f
commit
cfdbe2e970
@ -620,9 +620,9 @@ KeyRing.prototype.toJSON = function toJSON() {
|
||||
index: this.index,
|
||||
key: utils.toBase58(this.key),
|
||||
keys: this.keys.map(utils.toBase58),
|
||||
keyAddress: this.getKeyAddress(),
|
||||
scriptAddress: this.getScriptAddress(),
|
||||
programAddress: this.getProgramAddress()
|
||||
keyAddress: this.getKeyAddress('base58'),
|
||||
scriptAddress: this.getScriptAddress('base58'),
|
||||
programAddress: this.getProgramAddress('base58')
|
||||
};
|
||||
};
|
||||
|
||||
@ -635,6 +635,20 @@ KeyRing.prototype.toJSON = function toJSON() {
|
||||
KeyRing.prototype.fromJSON = function fromJSON(json) {
|
||||
var i;
|
||||
|
||||
assert(json);
|
||||
assert(typeof json.network === 'string');
|
||||
assert(typeof json.type === 'string');
|
||||
assert(utils.isNumber(json.m));
|
||||
assert(utils.isNumber(json.n));
|
||||
assert(typeof json.witness === 'boolean');
|
||||
assert(!json.id || typeof json.id === 'string');
|
||||
assert(!json.name || typeof json.name === 'string');
|
||||
assert(utils.isNumber(json.account));
|
||||
assert(utils.isNumber(json.change));
|
||||
assert(utils.isNumber(json.index));
|
||||
assert(typeof json.key === 'string');
|
||||
assert(Array.isArray(json.keys));
|
||||
|
||||
this.nework = bcoin.network.get(json.network);
|
||||
this.type = json.type;
|
||||
this.m = json.m;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user