/** * Fee Quote Types * * Types for gas-free fee quotes from the backend service * * @module features/gas-free/types/FeeQuote */ /** * Mining UTXO provided by backend for paying fees */ export interface MiningUTXO { /** Transaction ID */ txid: string; /** Output index */ vout: number; /** Amount in satoshis */ value: number; /** Script pubkey (hex) */ script_pubkey: string; } /** * Mining change UTXO details */ export interface MiningChangeUTXO { /** Bitcoin address for change */ address: string; /** Change amount in satoshis */ value: number; } /** * Fee quote from the gas-free service */ export interface FeeQuote { /** Unique quote identifier (UUID) */ quoteId: string; /** User ID from request */ userId: string; /** Asset ID from request */ assetId?: string; /** Mining fee in satoshis */ miningFeeSats: number; /** Fee rate in sat/vByte */ feeRateSatPerVByte: number; /** Service fee percentage */ serviceFeePercentage: number; /** Service fee amount */ serviceFeeAmount: number; /** Asset type for service fee */ assetType?: string; /** Satoshi amount needed to fund witness UTXO (0 for blinded invoices, typically 1000 for witness invoices) */ witnessUtxoFundingSats: number; /** Mining UTXO provided by backend */ miningUTXO: MiningUTXO; /** Mining change UTXO details (undefined if entire mining UTXO is consumed) */ miningChangeUTXO?: MiningChangeUTXO; /** RGB invoice for service fee payment */ serviceFeeInvoice: string; /** Service fee recipient ID (utxob) */ serviceFeeRecipientId: string; /** Quote status */ status: 'pending' | 'accepted' | 'expired' | 'completed' | 'failed'; /** Quote expiration timestamp (ISO 8601) */ expiresAt: string; /** Quote creation timestamp (ISO 8601) */ createdAt: string; } /** * Request parameters for generating a fee quote */ export interface FeeQuoteRequest { /** Unique identifier for the user */ userId: string; /** RGB asset ID for the transfer */ assetId: string; /** Number of USER's transaction inputs (excludes service's mining UTXO) */ numInputs: number; /** Number of USER's transaction outputs (INCLUDES OP_RETURN, must be >= 2) */ numOutputs: number; /** RGB invoice for the recipient (mandatory) */ recipientInvoice: string; /** Amount being transferred in base units with precision included (e.g., 100250000 for 100.25 TUSDT with precision 6) */ transferAmount: number; } /** * Check if a fee quote is expired * * @param quote - Fee quote to check * @returns True if expired, false otherwise */ export function isQuoteExpired(quote: FeeQuote): boolean { return new Date() >= new Date(quote.expiresAt); } /** * Get time remaining for a quote (in milliseconds) * * @param quote - Fee quote to check * @returns Milliseconds until expiration (negative if expired) */ export function getQuoteTimeRemaining(quote: FeeQuote): number { return new Date(quote.expiresAt).getTime() - Date.now(); } /** * Calculate total mining UTXO value * * @param quote - Fee quote * @returns Total satoshis available from mining UTXO */ export function getTotalMiningValue(quote: FeeQuote): number { return quote.miningUTXO.value; }