keyring: fix serialization.
This commit is contained in:
parent
16ed6d8d87
commit
ac5aa5b04c
@ -34,7 +34,7 @@ function KeyRing(options, network) {
|
|||||||
|
|
||||||
this.network = bcoin.network.get();
|
this.network = bcoin.network.get();
|
||||||
this.witness = false;
|
this.witness = false;
|
||||||
this.publicKey = null;
|
this.publicKey = constants.ZERO_KEY;
|
||||||
this.privateKey = null;
|
this.privateKey = null;
|
||||||
this.script = null;
|
this.script = null;
|
||||||
this.path = null;
|
this.path = null;
|
||||||
@ -830,7 +830,7 @@ KeyRing.prototype.toRaw = function toRaw(writer) {
|
|||||||
|
|
||||||
KeyRing.prototype.fromRaw = function fromRaw(data, network) {
|
KeyRing.prototype.fromRaw = function fromRaw(data, network) {
|
||||||
var p = new BufferReader(data);
|
var p = new BufferReader(data);
|
||||||
var key;
|
var key, script;
|
||||||
|
|
||||||
this.network = bcoin.network.get(network);
|
this.network = bcoin.network.get(network);
|
||||||
this.witness = p.readU8() === 1;
|
this.witness = p.readU8() === 1;
|
||||||
@ -844,10 +844,10 @@ KeyRing.prototype.fromRaw = function fromRaw(data, network) {
|
|||||||
this.publicKey = key;
|
this.publicKey = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.script = p.readVarBytes();
|
script = p.readVarBytes();
|
||||||
|
|
||||||
if (this.script.length === 0)
|
if (script.length > 0)
|
||||||
this.script = null;
|
this.script = bcoin.script.fromRaw(script);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user