refactor: change DerivedAddress::public_key to PublicKey#765
Conversation
Replace the raw `[u8; 33]` field with `dashcore::PublicKey` so the event payload carries a validated curve point instead of opaque bytes. The projection in `DerivedAddress::from_info` now parses via `PublicKey::from_slice` and logs a warn on failure, matching the existing skip-on-bad-input pattern. The FFI surface in `dash-spv-ffi` keeps its `[u8; 33]` field for ABI stability and serializes the parsed key back to compressed bytes at the boundary.
📝 WalkthroughWalkthroughThe pull request updates ChangesDerivedAddress Public Key Type Upgrade
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
key-wallet-manager/src/events.rs (1)
127-133:⚠️ Potential issue | 🟠 Major | ⚡ Quick winInsert dedup keys only after successful projection.
With parse failures now possible in
DerivedAddress::from_info, marking a key as seen before projection can drop a later valid duplicate for the same(account_type, pool_type, derivation_index). That can suppress a validDerivedAddressemission.Suggested fix
for info in infos { let key = (info.account_type, info.pool_type, info.info.index); - if !seen.insert(key) { + if seen.contains(&key) { continue; } if let Some(d) = DerivedAddress::from_info(info) { + seen.insert(key); out.push(d); } }🤖 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-manager/src/events.rs` around lines 127 - 133, In the loop over infos in events.rs, don't mark the dedup key as seen before attempting projection: change the logic so you first call DerivedAddress::from_info(info) and only if it returns Some(d) check/insert the key into seen (e.g., check seen.contains(&key) then insert(&key) after successful projection) before pushing d into out; this ensures parse failures in DerivedAddress::from_info won't cause a key to be prematurely consumed and drop later valid DerivedAddress instances.
🤖 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.
Outside diff comments:
In `@key-wallet-manager/src/events.rs`:
- Around line 127-133: In the loop over infos in events.rs, don't mark the dedup
key as seen before attempting projection: change the logic so you first call
DerivedAddress::from_info(info) and only if it returns Some(d) check/insert the
key into seen (e.g., check seen.contains(&key) then insert(&key) after
successful projection) before pushing d into out; this ensures parse failures in
DerivedAddress::from_info won't cause a key to be prematurely consumed and drop
later valid DerivedAddress instances.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 24a52284-98ad-4c15-90a2-9bad74743995
📒 Files selected for processing (3)
dash-spv-ffi/src/callbacks.rskey-wallet-manager/src/event_tests.rskey-wallet-manager/src/events.rs
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v0.42-dev #765 +/- ##
=============================================
+ Coverage 72.26% 72.28% +0.01%
=============================================
Files 320 320
Lines 70275 70271 -4
=============================================
+ Hits 50785 50793 +8
+ Misses 19490 19478 -12
|
Replace the raw
[u8; 33]field withdashcore::PublicKeyso the event payload carries a validated curve point instead of opaque bytes. The projection inDerivedAddress::from_infonow parses viaPublicKey::from_sliceand logs a warn on failure, matching the existing skip-on-bad-input pattern.The FFI surface in
dash-spv-ffikeeps its[u8; 33]field for ABI stability and serializes the parsed key back to compressed bytes at the boundary.Summary by CodeRabbit
Bug Fixes
Refactor