Skip to content

feat(platform-wallet): fetch the key references of any masternode - #6026

Draft
Claudius-Maginificent wants to merge 5 commits into
v5.2-devfrom
feat/mn-key-reference
Draft

Claudius-Maginificent wants to merge 5 commits into
v5.2-devfrom
feat/mn-key-reference

Conversation

@Claudius-Maginificent

Copy link
Copy Markdown
Collaborator

TL;DR: A wallet can now look up the registered keys of any masternode, tracked or not, from the current masternode list and the node's Platform identities, and tracked nodes no longer show a payout key that the node has since disabled.

User story

As a wallet app developer, I want to fetch the owner, voting, payout and operator payout key references of any masternode without tracking it first, to achieve key checks and withdrawals for nodes the user has just added or that have retired.

Scenario

Base flow

The user adds a masternode to the wallet, or changes the node's payout address, and the app shows or checks the node's keys.

Actual behavior

  • Key references are available only for tracked nodes.
  • After a payout address change, a tracked node can keep a disabled payout key, depending on key-id order, or bring it back from the registration data.
  • A tracked refresh can overwrite the cached entry with a stale list while the client is still catching up.

Expected behavior

  • One call returns the key references of any node; nothing is persisted.
  • Once the owner identity has been read, only its enabled keys count; a disabled payout key is dropped.
  • The tracked refresh reads the list only while it follows the chain and keeps the cached entry otherwise.

Detailed discussion

Issue being fixed or feature implemented

Stacked atop #6025 (feat/mn-current-list), part of the stack over #5889.

What was done?

  • New PlatformWalletManager::fetch_masternode_key_reference (masternode/key_reference.rs): the current list's fields joined with the owner and payout key hashes of the node's owner identity and the operator payout key hash of its operator identity. It fails with MasternodeListUnavailable while the list does not follow the chain. A node absent from the list but with an owner identity (retired, credits still claimable) gets its list fields None. Ok(None) when neither the list nor Platform knows the node.
  • One helper picks the enabled ECDSA_HASH160 key of a purpose; the tracked refresh (masternode/tracked.rs) uses it too.
  • Tracked refresh reads the gated current list (CurrentMasternodeList::entry); a stale list no longer overwrites the cached entry.
  • A freshly fetched owner or operator identity sets the payout key hashes to its enabled keys, so a key Drive disabled is forgotten; a failed or empty fetch leaves the snapshot as it was.
  • TrackedMasternode::key_reference and record no longer fall back to the registered payout script or owner key once the owner identity has been read.

FFI / mobile behaviour changes

  • Tracked refresh reads the list only while it follows the chain: during catch-up it reports the list as unavailable and keeps the cached entry. Tracked list/track reads are still ungated (follow-up).
  • Tracked records and key references: after the owner identity is read, owner and payout keys come only from its enabled keys. With no enabled TRANSFER key, the payout script and payout key reference are None, so verifying a replaced payout key gives Unverifiable instead of Matches. There is no registration fallback once the identity has been read.
  • The operator payout key is cleared once the operator identity disables it.

How Has This Been Tested?

Unit tests in key_reference.rs and tracked.rs, including reproduction tests that a tracked node forgets its payout key once its fetched identity disables it (they failed before the fix). The gated read inside the tracked refresh and the live-SDK manager path were verified by code trace.

Breaking Changes

No Rust signature changes (additive API); the FFI behaviour changes above apply to mobile hosts.

Deferred

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

@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 3df63fc. Normal review starts when eligible; priority review starts as soon as a slot is available.

lklimek and others added 5 commits December 3, 2026 19:34
…m the list and its Platform identities

Add PlatformWalletManager::fetch_masternode_key_reference: the current
masternode list's fields joined with the owner and payout key hashes of
the node's owner identity and the operator payout key hash of its
operator identity, for any node, tracked or not. Nothing is persisted.
It fails with MasternodeListUnavailable while the list does not follow
the chain; a node absent from the list but with an owner identity
(retired, credits still claimable) gets its list fields None; Ok(None)
when neither the list nor Platform knows the node.

Fix the tracked-node refresh with the same rule: it took any key of the
purpose, so after a payout address change it could keep a disabled
TRANSFER key depending on key-id order. One helper now picks the enabled
ECDSA_HASH160 key. The refresh also reads the list only while it follows
the chain, so a stale list no longer overwrites the cached entry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WunYYhpfoE88XJoyRt4hcR
…entity disables it

Reproduction tests: they fail until learn_owner_identity and
learn_operator_identity stop keeping a previously learned key when the
fetched identity has no enabled key of that purpose.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ched identity disables it

The tracked-node refresh kept the last known owner and operator payout
key hashes when the freshly fetched identity had no enabled key for them.
Drive disables every owner TRANSFER key when the payout is no sole P2PKH
output, and the operator TRANSFER key when the operator payout is
removed, so the kept key was stale. A fetched identity now sets the key
hashes to its enabled keys; a failed or empty fetch still leaves the
snapshot as it was.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WunYYhpfoE88XJoyRt4hcR
…ut of tracked reads

Once the owner identity has been read, its keys are the current ones:
TrackedMasternode::key_reference and record no longer fall back to the
registered payout script (or owner key) when the identity holds no
enabled key for it, so a retired payout key no longer comes back. Before
that read, the registration is still used.

Add CurrentMasternodeList::entry and use it for the per-node lookups in
key_reference and the tracked refresh. Fold the learn tests that
re-asserted the enabled-key ordering into the learn regression tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WunYYhpfoE88XJoyRt4hcR
@lklimek
lklimek force-pushed the feat/mn-key-reference branch from b6f72c8 to 3df63fc Compare December 3, 2026 18:34
@github-actions github-actions Bot added this to the v5.2.0 milestone Dec 3, 2026

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