Skip to content

Commit

Permalink
feat: add ceiling to getFeeRate return
Browse files Browse the repository at this point in the history
  • Loading branch information
Polybius93 committed Dec 16, 2024
1 parent b31390f commit bd0237e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/functions/bitcoin/bitcoin-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,19 @@ export async function getFeeRate(
getEstimatedFeeRate(bitcoinBlockchainAPIFeeURL),
]);

const currentBlockFeeRateMultiplied = Math.ceil(currentBlockFeeRate) * multiplier;
const currentBlockFeeRateMultiplied = currentBlockFeeRate * multiplier;

const lastTwoBlocksfeeRateAverageMultiplied =
(lastTwoBlocksFeeRate.reduce((a, b) => a + b) / lastTwoBlocksFeeRate.length) * multiplier;

const estimatedFeeRateMultiplied = estimatedFeeRate * multiplier;

return Math.max(
lastTwoBlocksfeeRateAverageMultiplied,
currentBlockFeeRateMultiplied,
estimatedFeeRateMultiplied
return Math.ceil(
Math.max(
lastTwoBlocksfeeRateAverageMultiplied,
currentBlockFeeRateMultiplied,
estimatedFeeRateMultiplied
)
);
}

Expand Down
1 change: 0 additions & 1 deletion tests/unit/bitcoin-functions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
ecdsaPublicKeyToSchnorr,
finalizeUserInputs,
getFeeAmount,
getFeeRate,
getFeeRecipientAddress,
getInputIndicesByScript,
getScriptMatchingOutputFromTransaction,
Expand Down

0 comments on commit bd0237e

Please sign in to comment.