@hazae41/ledger
Version:
Private and supply-chain hardened Ledger controller for TypeScript
31 lines (28 loc) • 749 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;
}
}
exports.Paths = Paths;
//# sourceMappingURL=paths.cjs.map