Skip to content

feat: centralize fee logic and add Bitcoin deposit forwarding#3258

Draft
bernd2022 wants to merge 1 commit intodevelopfrom
feat/centralize-fee-logic-and-btc-forwarding
Draft

feat: centralize fee logic and add Bitcoin deposit forwarding#3258
bernd2022 wants to merge 1 commit intodevelopfrom
feat/centralize-fee-logic-and-btc-forwarding

Conversation

@bernd2022
Copy link
Collaborator

@bernd2022 bernd2022 commented Feb 24, 2026

Summary

  • Move getSendFeeRate() into BitcoinBasedFeeService using template method pattern, eliminating duplicate fee multiplier logic across Bitcoin and Firo services
  • Add dedicated Bitcoin deposit forwarding with explicit UTXO selection and subtract_fee_from_outputs for accurate fee handling
  • Add getUtxoForAddresses() to NodeClient for address-filtered UTXO queries
  • Remove dead code: unused DexFiroService.getFeeRate() wrapper, unused Config import in PayoutBitcoinService

Test plan

  • Verify TypeScript compilation passes (npm run build)
  • Verify all existing tests pass (npm test)
  • Verify Bitcoin deposit forwarding creates correct transactions with fee subtracted from output
  • Verify fee multiplier is applied consistently across all services (DexBitcoin, DexFiro, PayInBitcoin, PayInFiro, PayoutBitcoin)

Move getSendFeeRate() into BitcoinBasedFeeService using template method
pattern, eliminating duplicate fee multiplier logic across Bitcoin and
Firo services. Add dedicated Bitcoin deposit forwarding with explicit
UTXO selection and subtract_fee_from_outputs for accurate fee handling.
@bernd2022 bernd2022 marked this pull request as draft February 24, 2026 16:56
Comment on lines +195 to +203
// only use UTXOs from the payment address (not deposit UTXOs on the same wallet)
const utxos = await client.getUtxoForAddresses([paymentAddress], true);
if (!utxos.length) return '';

const inputs = utxos.map((u) => ({ txid: u.txid, vout: u.vout }));
const utxoBalance = utxos.reduce((sum, u) => sum + u.amount, 0);

// sweep all UTXOs: send full balance and let Bitcoin Core subtract the fee from the output
return client.sendMany([{ addressTo: outputAddress, amount: utxoBalance }], feeRate, inputs, [0]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is already in FiroClient.sendMany. Maybe we should add a method sendManyFromAddress to BitcoinBasedClient and reuse it in both places? Is this possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants