From d11f4deef13727abedba9fc8cd5298b1d76053f7 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 27 Jun 2016 16:34:39 -0700 Subject: [PATCH] add id to keyring. --- lib/bcoin/keyring.js | 6 ++++++ lib/bcoin/wallet.js | 1 + 2 files changed, 7 insertions(+) diff --git a/lib/bcoin/keyring.js b/lib/bcoin/keyring.js index 419befc9..abbf2584 100644 --- a/lib/bcoin/keyring.js +++ b/lib/bcoin/keyring.js @@ -39,6 +39,7 @@ function KeyRing(options) { this.m = 1; this.n = 1; this.witness = false; + this.id = null; this.name = null; this.account = 0; this.change = 0; @@ -75,6 +76,7 @@ KeyRing.prototype.fromOptions = function fromOptions(options) { this.m = options.m || 1; this.n = options.n || 1; this.witness = options.witness || false; + this.id = options.id; this.name = options.name; this.account = options.account; this.change = options.change; @@ -578,6 +580,7 @@ KeyRing.prototype.toJSON = function toJSON() { m: this.m, n: this.n, witness: this.witness, + id: this.id, name: this.name, account: this.account, change: this.change, @@ -604,6 +607,7 @@ KeyRing.prototype.fromJSON = function fromJSON(json) { this.m = json.m; this.n = json.n; this.witness = json.witness; + this.id = json.id; this.name = json.name; this.account = json.account; this.change = json.change; @@ -640,6 +644,7 @@ KeyRing.prototype.toRaw = function toRaw(writer) { p.writeU8(this.m); p.writeU8(this.n); p.writeU8(this.witness ? 1 : 0); + p.writeVarString(this.id, 'utf8'); p.writeVarString(this.name, 'utf8'); p.writeU32(this.account); p.writeU32(this.change); @@ -671,6 +676,7 @@ KeyRing.prototype.fromRaw = function fromRaw(data) { this.m = p.readU8(); this.n = p.readU8(); this.witness = p.readU8() === 1; + this.id = p.readVarString('utf8'); this.name = p.readVarString('utf8'); this.account = p.readU32(); this.change = p.readU32(); diff --git a/lib/bcoin/wallet.js b/lib/bcoin/wallet.js index 90875e83..7a8d142d 100644 --- a/lib/bcoin/wallet.js +++ b/lib/bcoin/wallet.js @@ -1967,6 +1967,7 @@ Account.prototype.deriveAddress = function deriveAddress(change, index) { return new bcoin.keyring({ network: this.network, key: key.publicKey, + id: this.id, name: this.name, account: this.accountIndex, change: change,