@hazae41/ledger
Version:
Private and supply-chain hardened Ledger controller for TypeScript
29 lines (27 loc) • 729 B
JavaScript
class Paths {
paths;
constructor(paths) {
this.paths = paths;
}
static from(path) {
const paths = new Array();
for (const subpath of path.split("/")) {
const value = subpath.endsWith("'")
? parseInt(subpath, 10) + 0x80_00_00_00
: parseInt(subpath, 10);
paths.push(value);
}
return new Paths(paths);
}
sizeOrThrow() {
return 1 + (this.paths.length * 4);
}
writeOrThrow(cursor) {
cursor.writeUint8OrThrow(this.paths.length);
for (const path of this.paths)
cursor.writeUint32OrThrow(path);
return;
}
}
export { Paths };
//# sourceMappingURL=paths.mjs.map