Registry Mirror
Skip to content

Conversation

@Claudius-Maginificent

@Claudius-Maginificent Claudius-Maginificent commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

TL;DR: platform-wallet can now find a wallet's masternode owner or voting key from the key's hash, using rust-dashcore's lookup instead of its own search, and masternode withdrawals use the same lookup.

User story

As a wallet app developer, I want to ask platform-wallet which of a wallet's owner or voting keys has a given hash, to achieve masternode key matching without the seed and without my own derivation code.

Scenario

Base flow

A wallet app knows the owner or voting key hash of a masternode (for example from the masternode list) and needs the wallet's matching key index and path, for display or to withdraw the node's credits.

Actual behavior

platform-wallet offers no such lookup. Masternode withdrawals use their own private owner-key scan with a separate window constant.

Expected behavior

PlatformWallet::find_provider_key returns the key's index and derivation path, or None when the wallet does not hold it. Withdrawals find the owner key the same way.

Detailed discussion

Issue being fixed or feature implemented

Stacked atop #6030 (chore/mn-dashcore-k1-s1), which pins rust-dashcore with key-wallet's provider-key lookup (dashpay/rust-dashcore#1465).

What was done?

  • New PlatformWallet::find_provider_key(&self, role: ProviderKeyRole, key_hash160: &[u8; 20], index_hint: Option<u32>) -> Result<Option<(u32, DerivationPath)>, PlatformWalletError> (wallet/provider_key_at_index.rs).
    • It delegates to key-wallet's ManagedWalletInfo::find_provider_key under the wallet-manager read lock. It is seedless and blocking (blocking_read), like derive_provider_key_at_index.
    • It checks the key at index_hint first, then the provider pool's entries, then every index below DEFAULT_PROVIDER_KEY_WINDOW. A key at or past that index and outside the pool is found only through its hint, which is verified, never trusted.
    • Errors: WalletNotFound if the wallet was removed; new PlatformWalletError::ProviderKeyLookup { role, source: key_wallet::Error } if key-wallet refuses the lookup, for example for an index hint in the hardened range.
  • ProviderKeyRole (Owner, Voting) is re-exported from the crate root.
  • masternode_withdrawal_keys finds the owner key through find_provider_key. The private find_owner_key, owner_key_matches_at and PROVIDER_KEY_WINDOW are removed.
  • FFI (rs-platform-wallet-ffi/src/error.rs): a refused lookup maps by its cause. A hardened index hint (key_wallet::Error::Bip32(InvalidChildNumber)) is caller input and maps to ErrorInvalidParameter; any other refused lookup maps to ErrorWalletOperation.

Not included: operator (BLS) keys, which key-wallet's lookup does not cover; the operator windows from #5889 stay as they are.

How Has This Been Tested?

  • provider_key_at_index.rs: owner and voting keys found by their hash; a key past the window found only through a matching hint; an owner key not found among the voting keys; a hardened hint refused with ProviderKeyLookup.
  • masternode_withdrawal.rs: should_resolve_the_owner_key_from_its_hash.
  • FFI: should_map_a_refused_provider_key_lookup_by_its_cause.
  • Clippy and nextest green on this tree (3707 passed). An independent review approved it; its two LOW findings (FFI mapping, window doc) are fixed here.

Breaking Changes

Public Rust API (not consensus), additive: PlatformWallet::find_provider_key, PlatformWalletError::ProviderKeyLookup, the ProviderKeyRole re-export. The removed items were private. FFI: no signature change; a refused lookup maps to ErrorInvalidParameter or ErrorWalletOperation as described above.

Checklist:

  • I have performed a self-review of my own code
  • My Rust, FFI, WASM, Swift or Kotlin changes follow the coding conventions
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed
  • If I added or changed GroveDB structure, I described it in the area's structure.rs, regenerated grovedb-structure.json, and checked the structure viewer link posted on this pull request
  • If I added or changed a system contract's document schemas, I checked the contract viewer link posted on this pull request

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

https://claude.ai/code/session_01WunYYk4eUkHuGstPtj83j4

🤖 Co-authored by Claudius the Magnificent AI Agent

lklimek and others added 2 commits November 21, 2026 07:08
`PlatformWallet::find_provider_key` delegates to key-wallet's
`ManagedWalletInfo::find_provider_key` under the wallet-manager read lock:
seedless and blocking, like `derive_provider_key_at_index`. It checks a
verified index hint, then the provider pool, then the default window past it.

`masternode_withdrawal_keys` finds the owner key through it, replacing its own
derive-and-compare scan and window constant. `ProviderKeyRole` is re-exported,
and a refused lookup is the typed `PlatformWalletError::ProviderKeyLookup`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A hardened index hint is caller input and maps to ErrorInvalidParameter; any
other refused lookup maps to ErrorWalletOperation instead of ErrorUnknown.
`find_provider_key`'s doc states the lookup window as the index it covers
below, not a count past the pool.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@thepastaclaw

thepastaclaw commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

🕓 Review not started yet because this PR is a draft.

  • Request normal review — click when the PR is ready for review.
  • Request priority review — click to move this review to the front of the queue.

Commit 3fc37c4. Normal review starts when eligible; priority review starts as soon as a slot is available.

…c link

The merge of the split rust-dashcore update removed the platform-node pool
writer, the last code user of `ManagedWalletInfo` in this module; the
`find_provider_key` doc link now names it by its full path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lklimek and others added 2 commits November 24, 2026 11:05
…r replay

Co-Authored-By: Codex <noreply@openai.com>
… replay

Co-Authored-By: Codex <noreply@openai.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants