UNPKG

@node-dlc/core

Version:
45 lines (44 loc) 1.89 kB
import { Tx } from '@node-dlc/bitcoin'; import { DlcAcceptWithoutSigs, DlcOffer, FundingInput } from '@node-dlc/messaging'; export declare const DUST_LIMIT: bigint; export declare class DlcTxBuilder { readonly dlcOffer: DlcOffer; readonly dlcAccept: DlcAcceptWithoutSigs; constructor(dlcOffer: DlcOffer, dlcAccept: DlcAcceptWithoutSigs); buildFundingTransaction(): Tx; } export declare class BatchDlcTxBuilder { readonly dlcOffers: DlcOffer[]; readonly dlcAccepts: DlcAcceptWithoutSigs[]; constructor(dlcOffers: DlcOffer[], dlcAccepts: DlcAcceptWithoutSigs[]); /** * Calculates the maximum collateral that can be used given a set of funding inputs * for exact-amount DLC scenarios (no change outputs). * * @param fundingInputs The inputs to be used for funding * @param feeRatePerVb Fee rate in satoshis per virtual byte * @param numContracts Number of DLC contracts being created (default: 1) * @returns Maximum collateral amount in satoshis * * @example * ```typescript * // Calculate max collateral for DLC splicing scenario * const dlcFundingInput = getDlcFundingInput(); // 970,332 sats * const additionalInput = getAdditionalInput(); // 100,000 sats * const inputs = [dlcFundingInput, additionalInput]; * * const maxCollateral = BatchDlcTxBuilder.calculateMaxCollateral( * inputs, * BigInt(1), // 1 sat/vB fee rate * 1 // Single DLC contract * ); * * // Use maxCollateral in DLC offer to ensure exact amount with no change * const dlcOffer = createDlcOffer(contractInfo, maxCollateral, ...); * ``` */ static calculateMaxCollateral(fundingInputs: FundingInput[], feeRatePerVb: bigint, numContracts?: number): bigint; buildFundingTransaction(): Tx; private ensureSameFundingInputs; private arraysEqual; }