Skip to content

Commit

Permalink
Remove unused Qi tx multipliers and replace with flat 2x
Browse files Browse the repository at this point in the history
  • Loading branch information
rileystephens28 committed Nov 14, 2024
1 parent 7d65201 commit 9333087
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/wallet/qi-hdwallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,6 @@ export class QiHDWallet extends AbstractHDWallet<QiAddressInfo> {

let attempts = 0;
let finalFee = 0n;
let satisfiedFeeEstimation = false;
const MAX_FEE_ESTIMATION_ATTEMPTS = 5;

while (attempts < MAX_FEE_ESTIMATION_ATTEMPTS) {
Expand All @@ -584,8 +583,8 @@ export class QiHDWallet extends AbstractHDWallet<QiAddressInfo> {

finalFee = await this.provider.estimateFeeForQi(feeEstimationTx);

// Get new selection with updated fee
selection = fewestCoinSelector.performSelection(spendTarget, finalFee);
// Get new selection with updated fee 2x
selection = fewestCoinSelector.performSelection(spendTarget, finalFee * 2n);

// Determine if new addresses are needed for the change outputs
const changeAddressesNeeded = selection.changeOutputs.length - changeAddresses.length;
Expand Down Expand Up @@ -618,19 +617,12 @@ export class QiHDWallet extends AbstractHDWallet<QiAddressInfo> {

// If we need 5 or fewer new outputs, we can break the loop
if ((changeAddressesNeeded <= 0 && spendAddressesNeeded <= 0) || totalNewOutputsNeeded <= 5) {
finalFee *= 3n; // Increase the fee 3x to ensure it's accepted
satisfiedFeeEstimation = true;
break;
}

attempts++;
}

// If we didn't satisfy the fee estimation, increase the fee 10x to ensure it's accepted
if (!satisfiedFeeEstimation) {
finalFee *= 10n;
}

// Proceed with creating and signing the transaction
const chainId = (await this.provider.getNetwork()).chainId;
const tx = await this.prepareTransaction(
Expand Down

0 comments on commit 9333087

Please sign in to comment.