wallet: smarter path serialization.

This commit is contained in:
Christopher Jeffrey 2017-11-27 13:21:17 -08:00
parent efca42b138
commit 86dc53f9dd
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 23 additions and 10 deletions

View File

@ -120,8 +120,13 @@ class Path {
this.account = br.readU32();
this.keyType = br.readU8();
this.type = br.readU8();
this.version = br.readI8();
const flags = br.readU8();
this.type = flags & 7;
this.version = flags >>> 3;
if (this.version === 0x1f)
this.version = -1;
switch (this.keyType) {
case Path.types.HD:
@ -161,7 +166,7 @@ class Path {
getSize() {
let size = 0;
size += 5;
size += 6;
switch (this.keyType) {
case Path.types.HD:
@ -173,8 +178,6 @@ class Path {
break;
}
size += 2;
return size;
}
@ -190,8 +193,14 @@ class Path {
bw.writeU32(this.account);
bw.writeU8(this.keyType);
bw.writeU8(this.type);
bw.writeI8(this.version);
let version = this.version;
if (version === -1)
version = 0x1f;
const flags = (version << 3) | this.type;
bw.writeU8(flags);
switch (this.keyType) {
case Path.types.HD:

View File

@ -483,7 +483,7 @@ async function updatePaths() {
break;
}
const version = br.readI8();
let version = br.readI8();
let type = br.readU8();
@ -497,8 +497,12 @@ async function updatePaths() {
bw.writeU32(account);
bw.writeU8(keyType);
bw.writeU8(type);
bw.writeI8(version);
if (version === -1)
version = 0x1f;
const flags = (version << 3) | type;
bw.writeU8(flags);
switch (keyType) {
case 0: