Repository navigation
Conversation
Add `ManagedWalletInfo::find_provider_key`, which returns the index and derivation path of the wallet's owner or voting key whose hash160 is given, or `None` when the wallet does not hold it. Wallet libraries no longer need to re-implement this search. The key at a caller's index hint is derived and checked first, never trusted. Then the account's address pool is searched, the same entries the provider-key transaction matching uses. Keys past the pool are derived from the account xpub up to the caller's minimum window, so the lookup needs no seed and works for watch-only and external-signable wallets. Operator (BLS) keys are matched by public key, not hash, and platform-node (Ed25519) keys need the seed; both are out of scope. <sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub> Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WunYYk4eUkHuGstPtj83j4
`find_provider_key` derived a key for every index below the caller's `min_window`, so a large window meant up to 2^31 derivations and then an error at the hardened range. Cap the window at `MAX_GAP_LIMIT`, the ceiling address pools use, and state the remaining error case: a hardened `index_hint` when the wallet has the account. Tests pin the cap and the hardened-hint error. <sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub> Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WunYYk4eUkHuGstPtj83j4
`find_provider_key` returned a pool entry's index without deriving it from `wallet`, so pairing a `ManagedWalletInfo` with another wallet reported a key that wallet does not hold. Derive the key at the pool index from `wallet` before returning it, as the hint and the scan already do. Export `DEFAULT_PROVIDER_KEY_WINDOW` (20), the usual `min_window`, so consumers stop keeping their own scan constant. Also cross-check the voting-key lookup against transaction matching, as the owner test does. <sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub> Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WunYYk4eUkHuGstPtj83j4
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #1465 +/- ##
==========================================
+ Coverage 86.48% 86.55% +0.06%
==========================================
Files 270 271 +1
Lines 70985 71045 +60
==========================================
+ Hits 61393 61491 +98
+ Misses 9592 9554 -38
|
This was referenced Nov 21, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR: key-wallet can now tell which of a wallet's masternode owner or voting keys matches a given key hash, so wallet libraries no longer need to re-implement that search.
User story
As a wallet library developer, I want to ask key-wallet which owner or voting key of a wallet has a given hash160, to achieve masternode key handling without my own derivation and search code.
Scenario
Base flow
A wallet application holds a wallet that controls a masternode and receives the owner or voting key hash from a masternode list entry or a provider transaction.
Actual behavior
key-wallet can derive provider keys and recognise them inside transactions, but it cannot say which of the wallet's keys has a given hash. Each wallet library writes that search itself.
Expected behavior
One call returns the matching key's index and derivation path, or nothing when the wallet does not hold that key.
Detailed discussion
What was done
ManagedWalletInfo::find_provider_keyandProviderKeyRole { Owner, Voting }(key-wallet/src/wallet/managed_wallet_info/provider_keys.rs).MAX_GAP_LIMIT.DEFAULT_PROVIDER_KEY_WINDOW(20) is the usual window.None.Not included: operator (BLS) key lookup by public key is left to a follow-up. Platform-node (Ed25519) keys need the seed and are out of scope.
Testing
New cases in
key-wallet/src/tests/provider_key_derivation_tests.rscover pool hits, scanning past the pool, a pool deeper than the window, the index hint (checked first; a hardened hint is rejected), lookup without the seed, a wallet without the account, the window cap, and a pool from another wallet being ignored.Prior work
feat/masternode-list-freshness) adds a freshness-checked masternode list read to dash-spv; the two share no code.🤖 Generated with Claude Code
https://claude.ai/code/session_01WunYYk4eUkHuGstPtj83j4
🤖 Co-authored by Claudius the Magnificent AI Agent