UNPKG

chaingate

Version:

Multi-chain cryptocurrency SDK for TypeScript — unified API for Bitcoin, Ethereum, Litecoin, Dogecoin, Bitcoin Cash, Polygon, Arbitrum, and any EVM-compatible chain. Create wallets, query balances, send transactions, and manage tokens and NFTs across UTXO

39 lines (38 loc) 1.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Seed = void 0; const Secret_1 = require("../../../Secret"); const utils_1 = require("../../../../utils"); const errors_1 = require("../../../errors"); /** * A binary seed for HD key derivation. Accepts hex strings, raw bytes, or encrypted state. * * @example * ```ts * const seed = new Seed('abcdef0123456789...'); * const seed = new Seed(seedBytes); * ``` */ class Seed extends Secret_1.Secret { /** * @param source - Hex string, `Uint8Array`, or {@link EncryptedState}. * @throws {@link InvalidSeedError} if invalid. */ constructor(source) { const resolved = Secret_1.Secret.resolveInput(source, (s) => { if ((0, utils_1.isHex)(s)) return (0, utils_1.hexToBytes)(s); throw new errors_1.InvalidSeedError('Invalid seed: must be hex string or Uint8Array'); }); super(resolved); } /** The raw seed bytes. */ get raw() { return this.data; } /** The seed as a hex-encoded string. */ get hex() { return (0, utils_1.bytesToHex)(this.data); } } exports.Seed = Seed;