fix(ui): replace f64 round-trip with integer arithmetic in max amount calculations#619
fix(ui): replace f64 round-trip with integer arithmetic in max amount calculations#619thepastaclaw wants to merge 1 commit intodashpay:v1.0-devfrom
Conversation
… calculations Replace floating-point round-trip (u64→f64→u64) with integer saturating_sub for fee reservation in Max button calculations. This eliminates precision loss that could cause incorrect max amounts in transfer and withdraw screens. - transfer_screen: 0.0002 DASH = 20_000_000 credits - withdraw_screen: 0.005 DASH = 500_000_000 credits
7a28435 to
4569b4a
Compare
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughTwo UI screen components replace floating-point arithmetic calculations with saturating integer subtraction to determine maximum transferable and withdrawable amounts after fee deductions. This eliminates float-based operations while preserving external behavior. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~4 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Issue
The "Max" button in transfer and withdraw screens uses a floating-point round-trip (
u64→f64→u64) to subtract fee estimates from the available balance. This can cause precision loss with large credit amounts, potentially resulting in incorrect max values.Changes
Replace the floating-point arithmetic with integer
saturating_sub:saturating_subalso handles the edge case where balance < fee (returns 0 instead of underflowing).Validation
cargo check✅cargo fmt✅Summary by CodeRabbit
Release Notes