UNPKG

@ledgerhq/hw-app-aptos

Version:
35 lines 1.41 kB
"use strict"; /** * @file bip32.ts * @description BIP32 Path Handling for Aptos Wallets * * This file provides utility functions to handle BIP32 paths, * which are commonly used in hierarchical deterministic (HD) wallets. * It includes functions to convert BIP32 paths to and from different formats, * extract components from extended public keys (xpubs), and manipulate path elements. */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.pathStringToArray = exports.bip32asBuffer = exports.pathElementsToBuffer = void 0; const bip32_path_1 = __importDefault(require("bip32-path")); function pathElementsToBuffer(paths) { const buffer = Buffer.alloc(1 + paths.length * 4); buffer[0] = paths.length; paths.forEach((element, index) => { buffer.writeUInt32BE(element, 1 + 4 * index); }); return buffer; } exports.pathElementsToBuffer = pathElementsToBuffer; function bip32asBuffer(path) { const pathElements = !path ? [] : pathStringToArray(path); return pathElementsToBuffer(pathElements); } exports.bip32asBuffer = bip32asBuffer; function pathStringToArray(path) { return bip32_path_1.default.fromString(path).toPathArray(); } exports.pathStringToArray = pathStringToArray; //# sourceMappingURL=bip32.js.map