Repository navigation
refactor(key-wallet): move extended_public_key out of Signer into ExtendedPubKeySigner subtrait - #839
Conversation
…endedPubKeySigner Signer::extended_public_key (added in #817) forced every signer to implement xpub export, but exporting a chain code is a key-export capability, not a signing one: pure signing backends (HSMs, remote signing services whose policy forbids chain-code export) could not implement Signer without stubbing the method with an error. Move the method unchanged into a new ExtendedPubKeySigner: Signer subtrait. Callers that need offline descendant derivation (e.g. DashPay contact xpubs) bound on the subtrait; everything else keeps the minimal Signer. Reusing the Signer supertrait keeps a single associated Error type. No production code called the method, so only the two InMemorySigner test signers move their impl to the new trait, and the unreachable NoDigestSigner stubs are deleted outright — evidence the requirement never belonged on the base trait. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Warning Review limit reached
Next review available in: 54 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR splits extended public key export into a dedicated ChangesExtendedPubKeySigner Trait Split
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 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
key-wallet/src/wallet/managed_wallet_info/asset_lock_builder.rs (1)
474-488: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider adding a correctness test for
extended_public_keyhere too.
transaction_building.rsaddedin_memory_signer_extended_public_key_matches_wallet_derivationto verify the newExtendedPubKeySignerimpl derives the same xpub as the wallet. This test module defines the identicalInMemorySigner::extended_public_keyimpl but has no equivalent check.🤖 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/asset_lock_builder.rs` around lines 474 - 488, Add a correctness test for InMemorySigner::extended_public_key in the asset_lock_builder test module, since it defines the same ExtendedPubKeySigner implementation as transaction_building.rs but currently lacks an equivalent assertion. Mirror the existing wallet-derivation check by deriving an xpub through InMemorySigner and comparing it against the wallet-derived extended public key for the same derivation path, so this implementation stays verified against the wallet behavior.
🤖 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.
Nitpick comments:
In `@key-wallet/src/wallet/managed_wallet_info/asset_lock_builder.rs`:
- Around line 474-488: Add a correctness test for
InMemorySigner::extended_public_key in the asset_lock_builder test module, since
it defines the same ExtendedPubKeySigner implementation as
transaction_building.rs but currently lacks an equivalent assertion. Mirror the
existing wallet-derivation check by deriving an xpub through InMemorySigner and
comparing it against the wallet-derived extended public key for the same
derivation path, so this implementation stays verified against the wallet
behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: bc80078a-2e3d-4e8b-bb2b-72dcdac7223f
📒 Files selected for processing (4)
key-wallet/src/lib.rskey-wallet/src/signer.rskey-wallet/src/wallet/managed_wallet_info/asset_lock_builder.rskey-wallet/src/wallet/managed_wallet_info/transaction_building.rs
…allet derivation The asset_lock_builder test module duplicates the InMemorySigner ExtendedPubKeySigner impl but had no correctness check, unlike its twin in transaction_building.rs. Mirror the hardened-path assertion so both copies stay verified against Wallet::derive_extended_public_key. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Addressed the CodeRabbit nitpick in 39f20ed: added 🤖 Addressed by Claude Code |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #839 +/- ##
==========================================
+ Coverage 73.13% 73.46% +0.33%
==========================================
Files 324 324
Lines 72562 72577 +15
==========================================
+ Hits 53066 53318 +252
+ Misses 19496 19259 -237
|
What changed
Removes
extended_public_keyas a required method on theSignertrait (added in #817) and moves it, unchanged, into a newExtendedPubKeySigner: Signersubtrait.Signeris back to its minimal signing surface:supported_methods,sign_ecdsa,public_key.Why
Exporting a BIP-32 extended public key is a key-export capability, not a signing one. Requiring it on
Signerforced every backend to implement xpub export — including pure signing backends (HSMs, remote signing services) whose policy deliberately forbids exporting chain codes, since an xpub plus any non-hardened descendant private key compromises the whole subtree. Those backends had no honest implementation available other than stubbing an error.The split keeps both use cases first-class:
Signeralone.m/9'/coin'/15'/account'/sender/recipient— the motivation for feat(key-wallet): add Signer::extended_public_key #817) bound onExtendedPubKeySignerand keep the exact same method.Making it a subtrait (rather than an independent trait) reuses the single associated
Errortype, so implementors and callers don't juggle two error types for one device.Notes for reviewers
Signer::extended_public_key— only a test. The two in-repoInMemorySignertest signers move their impl to the new trait, and theunreachable!()stubs on theNoDigestSignertest signers are deleted outright (they no longer need the method at all, which is the concrete evidence the requirement never belonged on the base trait).key_walletroot alongsideSigner.cargo check --all-targets, all 536 key-wallet tests pass, clippy (--all-features --all-targets -D warnings) andcargo fmt --checkclean.🤖 Generated with Claude Code
Summary by CodeRabbit