Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused Qi tx multipliers and replace with flat 2x #355

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading