/** * Parallel Inscription System with Exact Fee Calculation * * This module implements a deterministic parallel inscription system that: * * 1. **Phase 1: Exact Fee Calculation** * - Builds placeholder transactions for each job using createOrdinals() * - Calls tx.getFee() to get EXACT satoshis needed (not estimations) * - Eliminates all change outputs from inscription transactions * * 2. **Phase 2: UTXO Preparation** * - Creates ONE UTXO split transaction for ALL jobs * - Each output is perfectly-sized with exact satoshis from Phase 1 * - Broadcasts the split transaction and waits for acceptance * * 3. **Phase 3: Transaction Building** * - Builds ALL inscription transactions using pre-allocated UTXOs * - Stores raw transaction hex (never rebuilds on retry) * * * 4. **Phase 5: Broadcasting** * - Broadcasts all transactions in parallel batches * - Retry logic ONLY retries broadcast of same raw tx hex * - NEVER rebuilds transactions during retry * * Key Benefits: * - No change outputs (cleaner transactions, lower fees) * - No double-spend errors (verified before broadcasting) * - Deterministic (same inputs = same outputs) * - Parallel processing (fast for large deployments) */ import { PrivateKey, Transaction } from '@bsv/sdk'; import type { Utxo } from 'js-1sat-ord'; import type { IndexerService } from './service-providers/IndexerService.js'; import type { InscribedFile } from './types.js'; /** * Type of inscription */ export type InscriptionType = 'ordinal' | 'bfile'; /** * Progress callback for reporting inscription progress */ export type ProgressCallback = (message: string) => void; /** * Represents a single inscription job (file or chunk) */ export interface InscriptionJob { /** Unique identifier for this job */ id: string; /** Type of inscription (ordinal uses createOrdinals, bfile uses buildBScript) */ type: InscriptionType; /** Absolute file path */ filePath: string; /** Original path for tracking */ originalPath: string; /** Content type */ contentType: string; /** File content buffer */ content: Buffer; /** Destination address */ destinationAddress: string; /** Chunk index if this is a chunk, undefined otherwise */ chunkIndex?: number; /** Total chunks if this is part of a chunked file, undefined otherwise */ totalChunks?: number; } /** * Result of EXACT fee calculation for a single job using getFee() */ export interface JobFeeCalculation { job: InscriptionJob; exactFee: number; requiredSats: number; } /** * A built transaction ready for verification and broadcast */ export interface BuiltTransaction { job: InscriptionJob; tx: Transaction; rawHex: string; utxo: Utxo; } /** * Result of a successful inscription */ export interface InscriptionResult { job: InscriptionJob; inscription: InscribedFile; } /** * Result of parallel inscription including cost information */ export interface ParallelInscriptionResult { results: InscriptionResult[]; totalCost: number; } /** * Calculates EXACT fees for all inscription jobs using getFee() * This builds placeholder transactions for each job to get exact satoshi requirements */ export declare function calculateAllJobFees(jobs: InscriptionJob[], paymentKey: PrivateKey, satsPerKb?: number, batchSize?: number, onProgress?: ProgressCallback): Promise; /** * Splits UTXOs upfront for all inscription jobs * Creates perfectly-sized UTXOs (one per job) in a SINGLE transaction * Each UTXO has EXACT satoshis needed (no change outputs on inscription txs) */ export declare function prepareUtxosForJobs(paymentKey: PrivateKey, indexer: IndexerService, feeCalculations: JobFeeCalculation[], satsPerKb?: number, dryRun?: boolean, seedUtxo?: Utxo, spentUtxos?: Set, onProgress?: ProgressCallback): Promise; /** * Builds ALL inscription transactions upfront (does NOT broadcast) */ export declare function buildAllTransactions(jobs: InscriptionJob[], utxos: Utxo[], paymentKey: PrivateKey, satsPerKb?: number): Promise; /** * Broadcasts ALL transactions in parallel */ export declare function broadcastAllTransactions(builtTxs: BuiltTransaction[], indexer: IndexerService, batchSize?: number): Promise; /** * Main entry point: Inscribe all jobs in parallel with proper verification * * This function implements the complete parallel inscription flow: * 1. Calculate EXACT fees for all jobs using getFee() (builds placeholder transactions) * 2. Split UTXOs upfront with EXACT satoshi amounts (one split transaction, no change on inscriptions) * 3. Build all inscription transactions (does NOT broadcast) * 4. Verify all transactions to detect double-spends BEFORE broadcasting * 5. Broadcast all transactions in parallel batches * * Key features: * - NO change outputs on inscription transactions (perfectly-sized UTXOs) * - NO double-spends (all transactions verified before any broadcasting) * - NO transaction rebuilding on retry (only retries broadcast of same raw tx) */ export declare function parallelInscribe(jobs: InscriptionJob[], paymentKey: PrivateKey, indexer: IndexerService, satsPerKb?: number, dryRun?: boolean, batchSize?: number, seedUtxo?: Utxo, spentUtxos?: Set, onProgress?: ProgressCallback): Promise; //# sourceMappingURL=parallelInscriber.d.ts.map