diff --git a/packages/blaze-tx/src/tx.ts b/packages/blaze-tx/src/tx.ts index e6fb8e7e..6c8478c8 100644 --- a/packages/blaze-tx/src/tx.ts +++ b/packages/blaze-tx/src/tx.ts @@ -1263,7 +1263,9 @@ export class TxBuilder { // Gather all inputs from the transaction body. const inputs = [...this.body.inputs().values()]; // Perform initial checks and preparations for coin selection. - let excessValue = this.getPitch(5_000_000n); + const preliminaryDraftTx = new Transaction(this.body, new TransactionWitnessSet()); + const preliminaryFee = this.params.minFeeConstant + fromHex(preliminaryDraftTx.toCbor()).length * this.params.minFeeCoefficient; + let excessValue = this.getPitch(bigintMax(BigInt(Math.ceil(preliminaryFee)), this.minimumFee)); let spareInputs: TransactionUnspentOutput[] = []; for (const [utxo] of this.utxos.entries()) { if (!inputs.includes(utxo.input())) {