-
Notifications
You must be signed in to change notification settings - Fork 7
bug fixes #75
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
bug fixes #75
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -723,7 +723,12 @@ export async function CoinswapComponent(container, swapConfig) { | |
| 'fundingTxidsByHop', | ||
| [] | ||
| ); | ||
| const totalFee = getValue('total_fee', 'totalFee', 0); | ||
| const feePaidOrEarned = getValue( | ||
| 'fee_paid_or_earned', | ||
| 'feePaidOrEarned', | ||
| NaN | ||
| ); | ||
| const totalFee = getValue('total_fee', 'totalFee', NaN); | ||
| const miningFee = getValue('mining_fee', 'miningFee', 0); | ||
| const inputUtxos = getArrayValue('input_utxos', 'inputUtxos', []); | ||
| const outputRegularUtxos = getArrayValue( | ||
|
|
@@ -769,9 +774,17 @@ export async function CoinswapComponent(container, swapConfig) { | |
| }; | ||
| }); | ||
|
|
||
| const calculatedMiningFee = miningFee || totalFee - totalMakerFees; | ||
| const derivedTotalFee = Number.isFinite(feePaidOrEarned) | ||
| ? Math.abs(feePaidOrEarned) | ||
| : totalMakerFees + miningFee; | ||
| const normalizedTotalFee = | ||
| Number.isFinite(totalFee) && (totalFee > 0 || derivedTotalFee <= 0) | ||
| ? totalFee | ||
| : derivedTotalFee; | ||
| const calculatedMiningFee = | ||
| miningFee || normalizedTotalFee - totalMakerFees; | ||
| const feePercentage = | ||
| targetAmount > 0 ? (totalFee / targetAmount) * 100 : 0; | ||
| targetAmount > 0 ? (normalizedTotalFee / targetAmount) * 100 : 0; | ||
|
Comment on lines
+777
to
+787
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Consider adding a brief comment explaining the fee derivation priority. The fee derivation logic correctly implements a fallback chain, but the conditions are non-obvious. A brief comment would help future maintainers understand the priority: // Fee derivation priority:
// 1. Use fee_paid_or_earned (absolute value) if available
// 2. Fall back to totalMakerFees + miningFee
// 3. Prefer backend total_fee when positive, else use derived valueAs per coding guidelines: "Comment complex Bitcoin/swap logic". 🤖 Prompt for AI Agents |
||
|
|
||
| return { | ||
| swapId, | ||
|
|
@@ -783,7 +796,7 @@ export async function CoinswapComponent(container, swapConfig) { | |
| makerAddresses, | ||
| totalFundingTxs, | ||
| fundingTxidsByHop, | ||
| totalFee, | ||
| totalFee: normalizedTotalFee, | ||
| totalMakerFees, | ||
| miningFee: calculatedMiningFee, | ||
| feePercentage, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.