Skip to content

refactor(key-wallet): drop FeeLevel#481

Merged
xdustinface merged 1 commit intov0.42-devfrom
refactor/drop-fee-level
Feb 27, 2026
Merged

refactor(key-wallet): drop FeeLevel#481
xdustinface merged 1 commit intov0.42-devfrom
refactor/drop-fee-level

Conversation

@ZocoLini
Copy link
Collaborator

@ZocoLini ZocoLini commented Feb 27, 2026

This PR drops FeeLEvel, the struct was just a wrapper around FeeRate that, at the same time, is a wrapper around u64 to represent duffs per kb, unnecessary layer imo

Summary by CodeRabbit

Refactor

  • Replaced the predefined fee level system with direct fee rate configuration for transaction building, providing more granular control over transaction fees.
  • Updated transaction builder APIs and method signatures across wallet operations to use the new fee rate model for consistency and simplification.

@ZocoLini ZocoLini requested a review from xdustinface February 27, 2026 16:33
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 27, 2026

Warning

Rate limit exceeded

@ZocoLini has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 21 minutes and 39 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 7f6c198 and d560585.

📒 Files selected for processing (6)
  • key-wallet-ffi/src/transaction.rs
  • key-wallet-manager/src/wallet_manager/transaction_building.rs
  • key-wallet/src/wallet/managed_wallet_info/fee.rs
  • key-wallet/src/wallet/managed_wallet_info/transaction_builder.rs
  • key-wallet/src/wallet/managed_wallet_info/transaction_building.rs
  • key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs
📝 Walkthrough

Walkthrough

This pull request removes the FeeLevel enum abstraction and replaces it with direct FeeRate usage throughout the transaction building and wallet management layers. The change simplifies fee configuration by eliminating the intermediate mapping level and directly using FeeRate values across the FFI, manager, and transaction building components.

Changes

Cohort / File(s) Summary
Fee Model Refactoring
key-wallet/src/wallet/managed_wallet_info/fee.rs
Removed FeeLevel enum and its impl block that provided fee_rate mapping, including associated tests.
Transaction Builder Updates
key-wallet/src/wallet/managed_wallet_info/transaction_builder.rs
Replaced fee_level field (FeeLevel) with fee_rate (FeeRate); renamed set_fee_level() to set_fee_rate(); updated all internal logic to use FeeRate directly instead of deriving from FeeLevel.
Transaction Building Interface
key-wallet/src/wallet/managed_wallet_info/transaction_building.rs, key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs
Updated create_unsigned_payment_transaction signatures to use fee_rate: FeeRate parameter instead of fee_level: FeeLevel across trait and implementations.
Wallet Manager & FFI Integration
key-wallet-manager/src/wallet_manager/transaction_building.rs, key-wallet-ffi/src/transaction.rs
Updated public API signatures in WalletManager and FFI layer to pass FeeRate directly to transaction building calls.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Poem

🐰 A hopping refactor, so clean and so neat,
FeeLevel begone, FeeRate's the beat!
From abstract to direct, the fees now flow straight,
No mapping detours—we simplify fate! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and concisely describes the main change: removing the FeeLevel type from the key-wallet crate.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/drop-fee-level

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
key-wallet/src/wallet/managed_wallet_info/transaction_builder.rs (1)

48-63: LGTM!

Struct field correctly renamed from fee_level: FeeLevel to fee_rate: FeeRate. The doc comment "Fee rate or level" could be simplified to just "Fee rate" since FeeLevel is being removed.

📝 Optional: Update doc comment
     /// Change address
     change_address: Option<Address>,
-    /// Fee rate or level
+    /// Fee rate (satoshis per kilobyte)
     fee_rate: FeeRate,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@key-wallet/src/wallet/managed_wallet_info/transaction_builder.rs` around
lines 48 - 63, Update the doc comment for the TransactionBuilder field fee_rate
to remove the obsolete "or level" phrasing—replace "Fee rate or level" with
simply "Fee rate" in the TransactionBuilder struct definition to reflect that
FeeLevel was removed; ensure you edit the doc comment above the fee_rate:
FeeRate field.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@key-wallet/src/wallet/managed_wallet_info/transaction_builder.rs`:
- Around line 48-63: Update the doc comment for the TransactionBuilder field
fee_rate to remove the obsolete "or level" phrasing—replace "Fee rate or level"
with simply "Fee rate" in the TransactionBuilder struct definition to reflect
that FeeLevel was removed; ensure you edit the doc comment above the fee_rate:
FeeRate field.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2fa3224 and 7f6c198.

📒 Files selected for processing (6)
  • key-wallet-ffi/src/transaction.rs
  • key-wallet-manager/src/wallet_manager/transaction_building.rs
  • key-wallet/src/wallet/managed_wallet_info/fee.rs
  • key-wallet/src/wallet/managed_wallet_info/transaction_builder.rs
  • key-wallet/src/wallet/managed_wallet_info/transaction_building.rs
  • key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs
💤 Files with no reviewable changes (1)
  • key-wallet/src/wallet/managed_wallet_info/fee.rs

@ZocoLini ZocoLini force-pushed the refactor/drop-fee-level branch from 7f6c198 to d560585 Compare February 27, 2026 16:41
change_address: Option<Address>,
/// Fee rate or level
fee_level: FeeLevel,
/// Fee rate (satoshis per kilobyte)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// Fee rate (satoshis per kilobyte)
/// Fee rate (duffs per kilobyte)

In Dash its duffs. We are anyway not consistent with this yet but generally i think better if we don't introduce more of them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I could have fixed that :( I did copy paste a coderabbit suggestion and I didn't notice it used satoshis instead of duffs

@xdustinface xdustinface merged commit b43706f into v0.42-dev Feb 27, 2026
53 checks passed
@xdustinface xdustinface deleted the refactor/drop-fee-level branch February 27, 2026 17:02
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