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; };