fix(key-wallet): skip already used accounts when funding a transaction - #930
fix(key-wallet): skip already used accounts when funding a transaction#930ZocoLini wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughFunding now deduplicates repeated ChangesFunding preference deduplication
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@key-wallet/src/wallet/managed_wallet_info/transaction_building.rs`:
- Around line 915-922: Update the assertion around result to avoid consuming the
non-Copy Result before constructing its diagnostic: borrow result in matches!,
or compute the input count before the assertion and reuse it in the message.
Preserve the existing insufficient-funds/coin-selection validation and
diagnostic output.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 3e61a20e-f653-41df-9843-d0bd0a2d69d0
📒 Files selected for processing (1)
key-wallet/src/wallet/managed_wallet_info/transaction_building.rs
| assert!( | ||
| matches!( | ||
| result, | ||
| Err(BuilderError::InsufficientFunds { .. }) | Err(BuilderError::CoinSelection(_)) | ||
| ), | ||
| "300k must not cover a 400k target, got: {:?}", | ||
| result.map(|(tx, _)| tx.input.len()) | ||
| ); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
Avoid moving result before building the diagnostic.
matches!(result, ...) consumes the non-Copy Result. The later result.map(...) use then causes a compile error. Compute the input count before the assertion, or borrow result in the match.
Proposed fix
+ let input_count = result.as_ref().map(|(tx, _)| tx.input.len());
assert!(
matches!(
result,
Err(BuilderError::InsufficientFunds { .. }) | Err(BuilderError::CoinSelection(_))
),
"300k must not cover a 400k target, got: {:?}",
- result.map(|(tx, _)| tx.input.len())
+ input_count
);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| assert!( | |
| matches!( | |
| result, | |
| Err(BuilderError::InsufficientFunds { .. }) | Err(BuilderError::CoinSelection(_)) | |
| ), | |
| "300k must not cover a 400k target, got: {:?}", | |
| result.map(|(tx, _)| tx.input.len()) | |
| ); | |
| let input_count = result.as_ref().map(|(tx, _)| tx.input.len()); | |
| assert!( | |
| matches!( | |
| result, | |
| Err(BuilderError::InsufficientFunds { .. }) | Err(BuilderError::CoinSelection(_)) | |
| ), | |
| "300k must not cover a 400k target, got: {:?}", | |
| input_count | |
| ); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@key-wallet/src/wallet/managed_wallet_info/transaction_building.rs` around
lines 915 - 922, Update the assertion around result to avoid consuming the
non-Copy Result before constructing its diagnostic: borrow result in matches!,
or compute the input count before the assertion and reuse it in the message.
Preserve the existing insufficient-funds/coin-selection validation and
diagnostic output.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #930 +/- ##
==========================================
- Coverage 75.23% 75.22% -0.01%
==========================================
Files 328 328
Lines 77767 77793 +26
==========================================
+ Hits 58507 58522 +15
- Misses 19260 19271 +11
|
|
already included in #929 |
Summary by CodeRabbit
Bug Fixes
Tests