keyring: fix serialization.

This commit is contained in:
Christopher Jeffrey 2016-08-24 00:09:10 -07:00
parent 16ed6d8d87
commit ac5aa5b04c
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

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