keyring json.
This commit is contained in:
parent
59cdc96c9f
commit
cfdbe2e970
@ -620,9 +620,9 @@ KeyRing.prototype.toJSON = function toJSON() {
|
|||||||
index: this.index,
|
index: this.index,
|
||||||
key: utils.toBase58(this.key),
|
key: utils.toBase58(this.key),
|
||||||
keys: this.keys.map(utils.toBase58),
|
keys: this.keys.map(utils.toBase58),
|
||||||
keyAddress: this.getKeyAddress(),
|
keyAddress: this.getKeyAddress('base58'),
|
||||||
scriptAddress: this.getScriptAddress(),
|
scriptAddress: this.getScriptAddress('base58'),
|
||||||
programAddress: this.getProgramAddress()
|
programAddress: this.getProgramAddress('base58')
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -635,6 +635,20 @@ KeyRing.prototype.toJSON = function toJSON() {
|
|||||||
KeyRing.prototype.fromJSON = function fromJSON(json) {
|
KeyRing.prototype.fromJSON = function fromJSON(json) {
|
||||||
var i;
|
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.nework = bcoin.network.get(json.network);
|
||||||
this.type = json.type;
|
this.type = json.type;
|
||||||
this.m = json.m;
|
this.m = json.m;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user