From ac5aa5b04cb4081795d3a771a38792ec4f75cfcc Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 24 Aug 2016 00:09:10 -0700 Subject: [PATCH] keyring: fix serialization. --- lib/bcoin/primitives/keyring.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/bcoin/primitives/keyring.js b/lib/bcoin/primitives/keyring.js index 36c27794..a773f786 100644 --- a/lib/bcoin/primitives/keyring.js +++ b/lib/bcoin/primitives/keyring.js @@ -34,7 +34,7 @@ function KeyRing(options, network) { this.network = bcoin.network.get(); this.witness = false; - this.publicKey = null; + this.publicKey = constants.ZERO_KEY; this.privateKey = null; this.script = null; this.path = null; @@ -830,7 +830,7 @@ KeyRing.prototype.toRaw = function toRaw(writer) { KeyRing.prototype.fromRaw = function fromRaw(data, network) { var p = new BufferReader(data); - var key; + var key, script; this.network = bcoin.network.get(network); this.witness = p.readU8() === 1; @@ -844,10 +844,10 @@ KeyRing.prototype.fromRaw = function fromRaw(data, network) { this.publicKey = key; } - this.script = p.readVarBytes(); + script = p.readVarBytes(); - if (this.script.length === 0) - this.script = null; + if (script.length > 0) + this.script = bcoin.script.fromRaw(script); return this; };