UNPKG

@lifi/sdk

Version:

LI.FI Any-to-Any Cross-Chain-Swap SDK

30 lines 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.generateRedeemScript = exports.toBigmiChainId = exports.toXOnly = void 0; exports.isPsbtFinalized = isPsbtFinalized; const core_1 = require("@bigmi/core"); const types_1 = require("@lifi/types"); const bitcoinjs_lib_1 = require("bitcoinjs-lib"); function isPsbtFinalized(psbt) { try { psbt.extractTransaction(); return true; } catch (_) { return false; } } const toXOnly = (pubKey) => pubKey.length === 32 ? pubKey : pubKey.subarray(1, 33); exports.toXOnly = toXOnly; const toBigmiChainId = (chainId) => { switch (chainId) { case types_1.ChainId.BTC: return core_1.ChainId.BITCOIN_MAINNET; default: throw new Error(`Unsupported chainId mapping: ${chainId}`); } }; exports.toBigmiChainId = toBigmiChainId; const generateRedeemScript = (publicKey) => bitcoinjs_lib_1.payments.p2wpkh({ pubkey: publicKey }).output; exports.generateRedeemScript = generateRedeemScript; //# sourceMappingURL=utils.js.map