Skip to content

Conversation

@OttoAllmendinger
Copy link
Contributor

This PR focuses on fixing fee calculation issues in the backup key recovery
functionality and refactoring related code for better maintainability. The
changes include:

  • Extract hard-coded fee rates into named constants
  • Fix dimension calculation for backup key recovery to include recovery
    destination output
  • Ensure KRS fee output is only added to dimensions when fee > 0
  • Refactor PSBT creation logic into separate functions
  • Add and update tests to verify fee rate calculations
  • Set consistent fee rates for all backup key recovery tests

These changes ensure proper fee calculation for backup key recovery
transactions, preventing potential issues with insufficient fees and
improving overall code quality.

BTC-2891

OttoAllmendinger and others added 6 commits December 18, 2025 12:14
Extract hard-coded fee rates into named constants for better maintainability
and clarity. Use these constants in the recovery functions to ensure
consistent fee calculation.

Issue: BTC-2891

Co-authored-by: llm-git <llm-git@ttll.de>
Add test case to verify the actual fee rate used in backup key recovery
transactions. This ensures that the fee calculation logic is working
as expected.

Note that basically all tests fail because fee calculation is utterly broken.

Issue: BTC-2891

Co-authored-by: llm-git <llm-git@ttll.de>
Fix dimension calculation for backup key recovery to include the recovery
destination output. Without this, the approximated transaction fee would
be incorrect, potentially creating transactions with insufficient fees.

Issue: BTC-2891

Co-authored-by: llm-git <llm-git@ttll.de>
Set a consistent fee rate for all backup key recovery tests. Remove
test that used a different fee rate since it's no longer needed.

Issue: BTC-2891

Co-authored-by: llm-git <llm-git@ttll.de>
Only add KRS fee output to dimensions if KRS fee is greater than zero.

Issue: BTC-2891

Co-authored-by: llm-git <llm-git@ttll.de>
Extract PSBT creation logic to separate functions for better maintainability
and testability. Improves error handling for insufficient funds and adds
proper type annotations for fee parameters.

Issue: BTC-2891

Co-authored-by: llm-git <llm-git@ttll.de>
@OttoAllmendinger OttoAllmendinger marked this pull request as ready for review December 18, 2025 12:17
@OttoAllmendinger OttoAllmendinger requested a review from a team as a code owner December 18, 2025 12:17
@OttoAllmendinger OttoAllmendinger merged commit faaa29a into master Dec 18, 2025
14 checks passed
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.

3 participants