Skip to content

feat(masternode): use wallet-held node keys and withdraw via platform-wallet - #1109

Open
Claudius-Maginificent wants to merge 47 commits into
v1.0-devfrom
feat/masternode-upstream-keys
Open

Claudius-Maginificent wants to merge 47 commits into
v1.0-devfrom
feat/masternode-upstream-keys

Conversation

@Claudius-Maginificent

@Claudius-Maginificent Claudius-Maginificent commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

TL;DR: If you registered your masternode from a wallet loaded in Dash Evo Tool, you no longer need to paste its owner, voting or payout keys. The app finds them in that wallet and stores only a pointer to them. Withdrawals signed with those keys use the wallet library's own masternode withdrawal, which checks the key and the payout-address rule before sending. Nodes registered from another wallet work as before.

User story

As a masternode operator, I want Dash Evo Tool to recognise the node keys that my own wallet holds, so that I can load my node and withdraw its earnings without copying private keys around.

Scenario

Actual behavior

Loading a masternode or evonode always requires typing the owner, voting and payout private keys, even when the wallet that registered the node is loaded in the app.

Expected behavior

Blank key fields are filled from a loaded wallet that holds the node's keys, and no key is copied into storage. Keys you type still take precedence. Withdrawals signed by such a key go through the wallet library; hand-entered keys keep the existing path. When the node's voting key has been rotated, the node page says so and offers to remove the old voting key after you confirm; the app never removes it on its own.

Detailed discussion

Based on v1.0-dev (Platform v5.1-dev 575d961f). This replaces #1109, whose branch carried the #1015 remainder; this branch holds only that PR's two commits, cherry-picked with -x.

  • Wallet seam (src/wallet_backend/masternode.rs):
    • find_masternode_wallet_keys asks each registered wallet for the node's keys, without the seed and inside spawn_blocking. Owner and payout keys come from upstream masternode_withdrawal_keys. Voting keys come from derive_provider_key_at_index, over the wallet's whole voting pool (at least 20 indices, like upstream's owner scan). The results are wallet derivation paths only.
    • A wallet that cannot be inspected is skipped with a warning, and the other wallets are still searched.
    • masternode_withdraw re-resolves the keys and calls PlatformWallet::masternode_withdraw with DET's signer, inside a secret session.
  • Model (src/model/masternode_keys.rs): the owner and payout hashes come from the node identity's active OWNER and TRANSFER keys. The withdrawal role comes from the key's purpose.
  • Loading: for masternode and evonode identities, empty key fields become PrivateKeyData::AtWalletDerivationPath.
    • No vault copies are made.
    • Typed and already-stored keys are never replaced. A stored key that the network has since disabled or replaced does not count, so a merge after a key rotation finds the new key.
    • A voting key found in a wallet never displaces a stored one.
    • A repeat headless load (det-cli or MCP) merges into the stored node instead of replacing its keys. Typed keys still replace the one they match, and a password-protected node fails closed.
    • Discovery failures are logged, and loading continues. This includes a failed fetch of the voter identity for a voting key found in a wallet.
    • Voting-key discovery needs the SPV masternode list to be synced. masternode_voting_key_hash reads sync progress, then the list, then progress again, and returns a hash only when the list is at the tip by both readings. TODO(upstream): an atomic, height-tagged list snapshot.
  • Retired voting key (backend_task/identity/retired_voting_key.rs, ui/state/retired_voting_key.rs, the masternode detail view):
    • A reload never deletes a voting key or voter identity, because the masternode list can lag the chain and make the current key look retired.
    • The detail view checks each time it opens (computed, not stored). When the synced list names a different voting key, it shows a notice with "Remove old voting key…" (confirmed first) or "Keep it".
    • Removal is a backend task. It re-reads the list hash (TaskError::VotingKeyCheckUnavailable while the list is updating). A reload that changed the stored voting keys since before that read refuses the removal (TaskError::VotingKeyChangedDuringRemoval) and nothing is removed. Otherwise, under the identity's record lock, recomputes the retired keys on the fresh record. A key that is current again is kept (RetiredVotingKeyKept). Otherwise it deletes the old key's vault secret through the secret seam, then the key and its voter identity.
    • After a removal, the node is merged again with nothing typed, so a wallet holding the current key takes its place. This search is best effort, because the old key is already gone, and it skips a node that stores a voting key.
    • Scheduled DPNS votes belong to the node (keyed by its ProTxHash), so they stay scheduled but cannot be cast until the node's current voting key is added. Only a target filed under an old separate voter record's own id, which could never be cast, is cancelled with that record.
  • Owner-key index: a withdrawal signed by a wallet-held owner key passes the stored derivation index to upstream as a hint, so owner keys above upstream's scan window are found.
  • Withdrawal routing:
    • A wallet-held OWNER or TRANSFER key on a node identity routes to upstream masternode_withdraw.
    • Hand-entered keys and user identities keep the SDK path.
    • DET's existing owner→payout-only check runs first on both paths.
    • New TaskError::MasternodeWithdrawalFailed and MasternodeWithdrawalUnconfirmed. The second tells the user not to retry blindly.
  • Wallet linking:
    • Node key references live only in the private-key data, not in the public key's wallet path. So determine_wallet_info cannot file a node into the wallet's identity list at a bogus index.
    • The key info screen still finds the wallet through a fallback that leaves user identities unchanged.
  • Docs:
    • The masternode UX spec (§4c) and the requirements no longer say derivation is impossible.
    • User story MN-013 is now marked implemented, MN-014 (unban) is added as a gap, and MN-015 (retired voting key) is added.

Known limitations

  • After a withdrawal signed with a wallet-held masternode key, a balance refresh fetched before the withdrawal but saved after it can show the pre-withdrawal balance until the next refresh: platform-wallet's masternode_withdraw returns no proof height to pin it with (TODO(platform-wallet) at withdraw_from_identity.rs). Platform rejects any withdrawal above the real balance, so no funds are at risk.
  • No DET test drives a wallet-backed masternode withdrawal through signing and submission; that path is upstream's and needs a manual testnet check.
  • The shared signing-key chooser (ui/helpers.rs, used by every transaction type) still lists a key whose wallet is no longer loaded. Choosing it shows a clear "no usable key" message and nothing is sent; the withdrawal screen's default key and gate use only keys this app can sign with.
  • DET's own wallet bootstrap derives provider voting and owner addresses at hardened indices (m/9'/c'/3'/{1',2'}/i'). DIP-9 and platform-wallet use non-hardened indices. These addresses exist in memory only and never receive funds, but they show in the address and account views. Fixing the bootstrap is a follow-up.
  • Unban (ProUpServTx) is a separate follow-up.
  • Hand-entered-key withdrawals stay on the SDK path. Moving them upstream needs upstream's tracked-masternode registry.
  • Upstream reports definitive consensus rejections as strings, so they map to the generic MasternodeWithdrawalFailed, which asks the user to wait and retry.
  • Upstream masternode_withdraw returns the credits without a block height. A refresh in flight during such a withdrawal can restore the balance from before it until the next refresh. A top-up has the same limit.
  • Wallet key lookup applies to loading in the app. Loading through det-cli or MCP still needs a typed owner or payout key.

Testing

  • New tests:
    • DIP-3 key discovery against an independently derived vector: non-hardened keys are found, hardened keys are not;
    • load filling and precedence, including a merge after an owner key rotation;
    • the voting scan bound;
    • withdrawal routing;
    • the misfiling guard;
    • error mapping;
    • the owner-key index hint (an owner key at index 150 resolves only with it) and withdrawal refusal before broadcast;
    • the list-freshness gate, including a tip that moves between the two progress reads;
    • the retired voting key check, removal, kept-when-current and unavailable cases, and the detail-view notice.
    • The behaviour tests were shown failing first.
  • On the replayed branch:
    • cargo clippy --all-features --all-targets -- -D warnings is clean;
    • library tests for masternode, identity loading, withdrawal and qualified identity pass (306), and the masternode and key-info kittests pass (42).
  • Not run: backend-e2e identity_masternode_withdraw (needs live funds). No live withdrawal was made.

🤖 Co-authored by Claudius the Magnificent AI Agent

🤖 Generated with Claude Code

https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q

PR Hygiene · 79980b9

  • Bots — coderabbitai skipped after its own rate limit · thepastaclaw skipped after the window
  • Self-review — not asked of a bot author
  • Build failed — review was already requested; it still has to pass to merge
  • Approvals
    • files with no dedicated owner (docs/CLI.md, docs/MCP.md, docs/ai-design/2026-07-09-masternode-page-design/01-requirements.md and 29 more) — lklimek

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

Summary by CodeRabbit

  • New Features
    • Masternode and evonode identities can use matching keys held in device wallets, including for withdrawals.
    • The detail screen can notify you when a stored voting key is outdated and lets you review and confirm its removal. If the key is current again, it is kept.
    • CLI and MCP identity loading can omit owner and payout keys, including when no local withdrawal key is available. Results indicate whether withdrawals are available and explain when they are not.
  • Bug Fixes
    • Reloading an identity preserves keys and associations for blank fields, while updating keys that you explicitly provide.
    • Identity refreshes preserve local changes made while a refresh is in progress.
  • Documentation
    • Updated CLI and MCP guidance to explain wallet-provided keys and withdrawal availability.

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 51 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 993abec and 79980b9.

Files selected for processing: 32
  • docs/CLI.md
  • docs/MCP.md
  • docs/ai-design/2026-07-09-masternode-page-design/01-requirements.md
  • docs/ai-design/2026-07-09-masternode-page-design/02-ux-spec.md
  • docs/user-stories.md
  • src/backend_task/error.rs
  • src/backend_task/identity/load_identity.rs
  • src/backend_task/identity/mod.rs
  • src/backend_task/identity/refresh_identity.rs
  • src/backend_task/identity/retired_voting_key.rs
  • src/backend_task/identity/top_up_identity.rs
  • src/backend_task/identity/transfer.rs
  • src/backend_task/identity/withdraw_from_identity.rs
  • src/backend_task/mod.rs
  • src/context/identity_db.rs
  • src/context/identity_db/balance_watermark.rs
  • src/context/lock_probe.rs
  • src/mcp/tools/masternode.rs
  • src/model/masternode_input.rs
  • src/model/masternode_keys.rs
  • src/model/mod.rs
  • src/model/qualified_identity/encrypted_key_storage.rs
  • src/model/qualified_identity/mod.rs
  • src/ui/masternodes/detail_screen.rs
  • src/ui/masternodes/list_screen.rs
  • src/ui/masternodes/load_form.rs
  • src/ui/state/mod.rs
  • src/ui/state/retired_voting_key.rs
  • src/wallet_backend/masternode.rs
  • src/wallet_backend/mod.rs
  • tests/backend-e2e/identity_masternode_withdraw.rs
  • tests/kittest/masternode_tab.rs
Walkthrough

Masternode loads can discover wallet-held keys and preserve stored keys during repeat loads. Wallet-held owner or payout keys can sign withdrawals. The masternode detail view can check and remove retired voting-key material. Identity refresh applies fetched data to the current stored record.

Changes: Wallet-backed masternode keys

Layer / File(s) Summary
Key matching and derivation metadata
src/model/masternode_input.rs, src/model/masternode_keys.rs, src/model/qualified_identity/*, src/model/mod.rs, docs/user-stories.md
Blank owner and payout keys are permitted. Helpers identify active owner, payout, and voting hashes. Key storage exposes wallet derivation paths and builds wallet withdrawal routes.
Wallet discovery and identity loading
src/backend_task/identity/load_identity.rs, src/backend_task/identity/mod.rs, src/wallet_backend/*, src/mcp/tools/masternode.rs, src/ui/masternodes/load_form.rs, docs/CLI.md, docs/MCP.md, docs/ai-design/2026-07-09-masternode-page-design/*, docs/user-stories.md, tests/backend-e2e/identity_masternode_withdraw.rs
Repeat loads merge stored identity data. Blank fields can use matching wallet keys, stored keys remain when fields are blank, and typed keys take precedence. MCP output reports withdrawal availability and a note when no withdrawal key is available.
Wallet-backed withdrawals
src/backend_task/error.rs, src/backend_task/identity/withdraw_from_identity.rs, src/wallet_backend/masternode.rs, src/wallet_backend/mod.rs
Withdrawals use a wallet route when the selected masternode key is wallet-held; otherwise, the existing identity signer is used. Wallet and SDK withdrawal paths record different balance provenance. Withdrawal errors distinguish failed and unconfirmed results.

Retired voting-key handling

Layer / File(s) Summary
Retirement checks and removal
src/backend_task/error.rs, src/backend_task/identity/*, src/backend_task/mod.rs, src/model/masternode_keys.rs, src/context/identity_db.rs
Identity tasks check and remove retired voting-key material. Removal rechecks the list and stored voting state, retains a key that is current again, and removes retired voter data when confirmed.
Retired-key notice and confirmation
src/ui/state/retired_voting_key.rs, src/ui/masternodes/detail_screen.rs, src/ui/masternodes/list_screen.rs, src/ui/state/mod.rs, tests/kittest/masternode_tab.rs, docs/user-stories.md
The detail view displays retired-key status and requires confirmation before removal. The list screen routes results and displays removal outcomes. Tests cover state, UI, and offline behavior.

Identity refresh consistency

Layer / File(s) Summary
Refresh and storage update handling
src/backend_task/identity/refresh_identity.rs, src/backend_task/identity/top_up_identity.rs, src/backend_task/identity/transfer.rs, src/context/identity_db.rs, src/context/lock_probe.rs
Refresh applies fetched state to the currently stored identity record. A concurrency test checks that a local change made during refresh is preserved. Supporting changes add lock-probe tests and document whole-snapshot writes and locked deletion.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant MCP
  participant LoadIdentity
  participant WalletBackend
  participant QualifiedIdentity
  MCP->>LoadIdentity: Submit load with blank key fields
  LoadIdentity->>WalletBackend: Find matching masternode wallet keys
  WalletBackend-->>LoadIdentity: Return matching derivation paths
  LoadIdentity->>QualifiedIdentity: Store wallet derivation references
  LoadIdentity-->>MCP: Return withdrawal availability and note
Loading
sequenceDiagram
  participant DetailView
  participant IdentityTaskRunner
  participant WalletBackend
  participant IdentityStorage
  DetailView->>IdentityTaskRunner: Request retired-key check
  IdentityTaskRunner->>WalletBackend: Read current voting-key hash
  WalletBackend-->>IdentityTaskRunner: Return current hash or unavailable status
  DetailView->>IdentityTaskRunner: Submit confirmed removal
  IdentityTaskRunner->>IdentityStorage: Recheck and remove retired key material
  IdentityTaskRunner-->>DetailView: Return removed or kept result
Loading

Possibly related PRs

  • dashpay/dash-evo-tool#1110: Changes identity loading, refresh, and storage writes, which overlap paths touched here.
  • dashpay/dash-evo-tool#1107: Changes the identity withdrawal flow and balance persistence, which overlaps this PR’s wallet-backed withdrawal route.
  • dashpay/dash-evo-tool#1157: Changes backend-result delivery through the Masternodes screen, which overlaps retired-key result routing.
Merge Risk: Low · previous review 993ab

If a wallet-backed masternode withdrawal fails while looking up the key, before anything is sent, the user sees a warning that the withdrawal may already have gone through. This is a minor error-message accuracy problem and can be fixed by mapping that step's errors to a definite failure variant.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 78.69% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "feat(masternode): use wallet-held node keys and withdraw via platform-wallet" matches the main change. The changeset adds wallet-based discovery of masternode owner, voting, and payout keys…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat(masternode): use wallet-held node keys and withdraw via platform-wallet" matches the main change. The changeset adds wallet-based discovery of masternode owner, voting, and payout keys, stores derivation-path references, and routes withdrawals through the platform wallet for wallet-held keys. The title is concise, specific, and follows a conventional commit style. It omits the retired-voting-key feature and the MergeOrInsert load behavior, but that is expected for a short title.

Full details: Docstring Coverage

Explanation

Docstring coverage is 78.69% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 61 functions across 26 files. (3 skipped: 3 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • 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
Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 4c5c22f and 993abec.

Files selected for processing: 19
  • docs/CLI.md
  • docs/MCP.md
  • docs/user-stories.md
  • src/backend_task/error.rs
  • src/backend_task/identity/load_identity.rs
  • src/backend_task/identity/mod.rs
  • src/backend_task/identity/refresh_identity.rs
  • src/backend_task/identity/retired_voting_key.rs
  • src/backend_task/identity/top_up_identity.rs
  • src/backend_task/identity/transfer.rs
  • src/backend_task/identity/withdraw_from_identity.rs
  • src/backend_task/mod.rs
  • src/context/identity_db.rs
  • src/mcp/tools/masternode.rs
  • src/model/mod.rs
  • src/ui/masternodes/list_screen.rs
  • src/wallet_backend/masternode.rs
  • src/wallet_backend/mod.rs
  • tests/backend-e2e/identity_masternode_withdraw.rs
Files skipped from review as they are similar to previous changes: 2
  • src/backend_task/identity/top_up_identity.rs
  • src/backend_task/identity/transfer.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@thepastaclaw

thepastaclaw commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

⛔ Final review complete — 2 blocking finding(s) (commit 79980b9)

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final validation — Phase 2 only (no Phase 1 for this repository)

The wallet-held masternode key discovery is generally well integrated, but merge loading can preserve a rotated disabled key and suppress discovery of its replacement. Three additional non-blocking gaps affect discovery completeness and entry-point consistency. CI checks are skipped because the PR is draft.

🔴 1 blocking | 🟡 3 suggestion(s)

1 finding(s) not shown inline (the lines are not part of this PR's diff)

🟡 Suggestion: Allow wallet-only masternode loads through the MCP entry point
src/mcp/tools/masternode.rs:147-152

The backend discovery path supports blank owner and payout fields when a loaded wallet holds the node keys, but this MCP preflight rejects that request before dispatching the backend. A wallet-only load through standalone MCP or det-cli therefore still requires a pasted owner or payout key, creating different behavior from the GUI path. Relax this preflight and update the parameter documentation so wallet-held keys are a supported MCP load mode, or explicitly document and enforce that this feature is GUI-only.

source: gpt-6.1-sol (phase2-reviewer: general)

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The diff is large and intricate and changes funds movement plus private-key discovery, storage references, signing, and withdrawal routing in src/wallet_backend/masternode.rs and src/backend_task/identity/withdraw_from_identity.rs.
  • Phase 1 reviewers: not run (disabled for this repository)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `src/backend_task/identity/load_identity.rs`:
- [BLOCKING] src/backend_task/identity/load_identity.rs:226-236: Do not let a disabled stored key suppress discovery of the current node key
  During a merge, this guard treats any stored key with the same target and purpose as authoritative without checking whether that key still corresponds to an active key in the freshly fetched identity. After a masternode payout or owner key rotation, the old key can remain in local storage while Platform marks it disabled and exposes a new active key with a different ID. Discovery is then skipped, the merge preserves the unusable old entry, and withdrawal resolution rejects it. Check the stored key ID against the refreshed identity and only suppress discovery when the corresponding current key has the same purpose and is active.

In `src/wallet_backend/masternode.rs`:
- [SUGGESTION] src/wallet_backend/masternode.rs:40-43: Do not cap voting-key discovery at index 19
  The fixed `0..20` scan excludes a valid provider voting key at index 20 and every later index. `derive_provider_key_at_index` accepts arbitrary indices, and the wallet can retain provider-key pool depth beyond this floor when it operates multiple nodes. As a result, a wallet-held voting key outside the first 20 indices is silently reported as absent. Reuse a durable voting-account pool bound or expose an upstream seedless provider-account depth lookup instead of imposing a separate fixed limit here.
- [SUGGESTION] src/wallet_backend/masternode.rs:115-126: Continue wallet-key discovery after an individual wallet inspection error
  Discovery is intended to be best effort, but an error from `wallet_held_keys` is immediately propagated. The caller then discards all accumulated results and proceeds without wallet references, so one stale, partially restored, or malformed wallet can prevent later healthy wallets from being inspected. Treat an individual wallet inspection error as a per-wallet skip with a warning, while still returning infrastructure failures such as a `spawn_blocking` join error.

In `src/mcp/tools/masternode.rs`:
- [SUGGESTION] src/mcp/tools/masternode.rs:147-152: Allow wallet-only masternode loads through the MCP entry point
  The backend discovery path supports blank owner and payout fields when a loaded wallet holds the node keys, but this MCP preflight rejects that request before dispatching the backend. A wallet-only load through standalone MCP or `det-cli` therefore still requires a pasted owner or payout key, creating different behavior from the GUI path. Relax this preflight and update the parameter documentation so wallet-held keys are a supported MCP load mode, or explicitly document and enforce that this feature is GUI-only.

Comment thread src/wallet_backend/masternode.rs Resolved
Comment thread src/wallet_backend/masternode.rs Resolved
lklimek and others added 7 commits October 26, 2026 21:08
…h platform-wallet

A wallet that registered a masternode holds its owner and voting keys in
its DIP-3 provider accounts and its payout key in its funding accounts.
Loading such a node no longer needs those keys pasted:

- new wallet_backend::masternode seam finds the keys seedlessly through
  upstream platform-wallet (masternode_withdrawal_keys for owner/payout,
  derive_provider_key_at_index for voting), on the blocking pool, and
  returns derivation references only
- load_identity fills blank owner/payout/voting fields with those
  references (PrivateKeyData::AtWalletDerivationPath, no vault copy);
  typed keys win and a merge never replaces a stored key
- withdrawals signed with a wallet-held OWNER/TRANSFER key go through
  PlatformWallet::masternode_withdraw with DetSigner in a JIT seed
  session; hand-entered keys keep the existing SDK path
- typed MasternodeWithdrawalFailed / MasternodeWithdrawalUnconfirmed
  errors (the latter tells the user not to retry blindly)
- node key references are kept out of the public-key wallet path that
  determine_wallet_info reads, so a node is never filed as one of the
  wallet's own identities at a bogus index
- design doc 02-ux-spec §4c and US-6 corrected; user stories MN-013
  (implemented) and MN-014 unban (gap, follow-up PR)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit cff5863)
…rence fallback

The KeyStorage wallet-info fallback only fills a missing wallet path;
a key whose public key records one keeps it, and a user identity's
wallet and identity index are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit fd4780f)
A merge skipped wallet discovery for any role the node already stored a key
for, even when the network had since disabled or replaced that key. After
an owner or payout key rotation the new key was then never found, and a
withdrawal had no usable key. A stored main-identity key now counts only
while the freshly fetched identity still holds it, active, for that purpose.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
… the fetch fails

A voting key found in a wallet is optional, but a network error or timeout
while fetching its voter identity failed the whole load. The node now loads
without that key, with a warning in the log. A typed voting key still fails
the load as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
One wallet that could not be inspected ended discovery for every wallet and
dropped what earlier wallets had found; it is now skipped with a warning. A
voting key past index 19 was never found; the scan now covers the wallet's
whole voting pool, with 20 indices as the floor, like upstream's owner scan.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The failure covers network, nonce and signing problems as well as bad input,
and an owner-key withdrawal has no destination to check. Ask the user to
wait and retry, and to check the amount if it keeps failing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The load form comment said node keys are never wallet-derived, and MN-013
did not say that det-cli and MCP loads still need a typed owner or payout
key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
@lklimek
lklimek force-pushed the feat/masternode-upstream-keys branch from fd4780f to 84c38ac Compare October 26, 2026 23:31
@Claudius-Maginificent
Claudius-Maginificent changed the base branch from chore/bump-platform-v4.3 to v1.0-dev October 26, 2026 23:31
@Claudius-Maginificent
Claudius-Maginificent marked this pull request as ready for review October 28, 2026 10:25
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai skipped after its own rate limit · thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. labels Oct 28, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)

The wallet-held key discovery and withdrawal integration is generally sound, and the supplied CI checks are green. However, owner/payout rotation can leave stale retained key metadata ahead of the newly discovered key, causing the withdrawal screen to select a key that the refreshed identity rejects; voting-key rotation and the MCP wallet-only entry point also remain incomplete.

🔴 1 blocking | 🟡 2 suggestion(s)

1 finding(s) not shown inline (the lines are not part of this PR's diff)

🟡 Suggestion: Allow wallet-only masternode loads through the MCP entry point
src/mcp/tools/masternode.rs:147-152

The MCP load tool still calls require_at_least_one_signing_key before dispatching the backend task. Consequently, a masternode whose owner and payout keys are held by a wallet loaded in Dash Evo Tool cannot be loaded through masternode_identity_load or the CLI, even though the shared backend task now supports wallet discovery when key fields are blank. Remove this preflight restriction and enforce success after discovery by validating that the backend found at least one usable signing key, or provide equivalent wallet-only discovery in this entry point.

source: gpt-6.1-sol (phase2-reviewer: general, rust-quality)

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — This is a large, intricate change that modifies wallet-held private-key discovery, signing, key storage references, and masternode withdrawals in src/wallet_backend/masternode.rs and src/backend_task/identity/withdraw_from_identity.rs, directly affecting key handling and funds movement.
  • Phase 1 reviewers: not run (disabled for this repository)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `src/backend_task/identity/load_identity.rs`:
- [BLOCKING] src/backend_task/identity/load_identity.rs:227-255: Refresh retained node-key metadata after a key rotation before choosing a withdrawal key
  The rotation guard now allows wallet discovery when a stored main-identity key is no longer active, but the subsequent merge still preserves the old `QualifiedIdentityPublicKey` unchanged through `merge_existing_keys_into`. The retained copy therefore still appears active because its local `disabled_at` metadata is stale, while the newly discovered replacement is added alongside it. `available_withdrawal_keys` and `default_withdrawal_key` inspect the stored public-key metadata, so the withdrawal screen can preselect the stale key. The withdrawal task then refreshes the identity and rejects that explicitly selected old key in `resolve_withdrawal_signing_key`, causing the normal owner-only or payout-key withdrawal flow to fail after rotation. Retain the old private material if needed, but make active-key selection use the refreshed identity metadata or refresh retained key metadata during the merge.
- [SUGGESTION] src/backend_task/identity/load_identity.rs:238-243: Do not suppress wallet discovery for a stale stored voting key
  The rotation check only consults the freshly fetched main identity. For `PrivateKeyOnVoterIdentity`, the `target != PrivateKeyOnMainIdentity` branch makes the predicate true for any stored voting key without comparing it to the current voter identity or current masternode-list voting hash. During a merge after voting-key rotation, `want_voting` is therefore false, so the loader never searches wallets for the replacement and preserves the old voter identity and key. A wallet-held replacement voting key remains undiscovered until the user enters it manually. Stored voter keys should not suppress fresh voting-key discovery, or the check must validate them against the current voter identity.

In `src/mcp/tools/masternode.rs`:
- [SUGGESTION] src/mcp/tools/masternode.rs:147-152: Allow wallet-only masternode loads through the MCP entry point
  The MCP load tool still calls `require_at_least_one_signing_key` before dispatching the backend task. Consequently, a masternode whose owner and payout keys are held by a wallet loaded in Dash Evo Tool cannot be loaded through `masternode_identity_load` or the CLI, even though the shared backend task now supports wallet discovery when key fields are blank. Remove this preflight restriction and enforce success after discovery by validating that the backend found at least one usable signing key, or provide equivalent wallet-only discovery in this entry point.

lklimek and others added 5 commits October 28, 2026 19:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… state on merge

After an owner or payout key rotation, a merge carried the replaced key over
with its stored (still active) state, so the withdrawal screen could preselect
a key the refreshed identity rejects. A carried-over main-identity key now
takes the fetched identity's state; its private material is kept.

A stored voting key also suppressed wallet discovery even after the voting
key rotated. It now counts only while it hashes to the voting key the
masternode list records.

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

The tool rejected a load with neither an owner nor a payout key before the
backend could look them up in this device's wallets. Blank keys now go to
the backend; the tool fails after the load only when the node ends up with
no owner or payout key to withdraw with.

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

A load that stored the node and then returned an error misled the caller.
The tool now returns the loaded node with `withdrawals_available` and, when
neither an owner nor a payout key is on this device, a note saying how to
enable withdrawals, matching the GUI. `NoSigningKey` is no longer used and
is removed.

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

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot removed the bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. label Oct 28, 2026
@Claudius-Maginificent

Copy link
Copy Markdown
Collaborator Author

mcp/tools/masternode.rs:147: Fixed in bedec80. Blank keys now reach the backend's wallet lookup. When the loaded node has neither an owner key nor a payout key on this device, the tool still returns it, with withdrawals_available set and a note, matching the GUI. It no longer saves the node and then reports an error.

🤖 Co-authored by Claudius the Magnificent AI Agent

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)

The PR correctly adds seedless wallet-key discovery, rotation-aware main-identity key handling, and wallet-backed withdrawal routing. Four non-blocking issues remain: stale voter state can be restored after a detected voting-key rotation, restored high-index owner keys may not re-resolve because their derivation index is discarded, unavailable registered wallets are silent, and the new fund-moving withdrawal seam lacks deterministic execution coverage. Test Suite and Clippy are still queued for this head.

🟡 4 suggestion(s)

1 finding(s) not shown inline (the lines are not part of this PR's diff)

🟡 Suggestion: Do not restore a stale voter identity after a detected voting-key rotation
src/backend_task/identity/load_identity.rs:72-73

When the masternode list reports a voting hash different from the stored voting key, the loader correctly performs wallet discovery. However, if no replacement is found, or if fetching the replacement voter identity fails, the freshly built identity has no voter state and no new voter key. merge_existing_keys_into then unconditionally restores existing.associated_voter_identity and the retained PrivateKeyOnVoterIdentity entry. The loaded node can therefore still appear voting-ready and attempt to vote with the old voter identity even though the masternode list says that key is no longer current. Clear the retained voter state and voter key when a rotation is confirmed and no replacement was loaded, or make the merge conditional on the stored voter key matching the current voting hash.

source: gpt-6.1-sol (phase2-reviewer: rust-quality)

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — This large, intricate diff changes wallet-held private-key discovery, signing, key storage references, and masternode withdrawal behavior in src/wallet_backend/masternode.rs and related identity-loading and withdrawal code, directly affecting key handling and funds movement.
  • Phase 1 reviewers: not run (disabled for this repository)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `src/backend_task/identity/load_identity.rs`:
- [SUGGESTION] src/backend_task/identity/load_identity.rs:72-73: Do not restore a stale voter identity after a detected voting-key rotation
  When the masternode list reports a voting hash different from the stored voting key, the loader correctly performs wallet discovery. However, if no replacement is found, or if fetching the replacement voter identity fails, the freshly built identity has no voter state and no new voter key. `merge_existing_keys_into` then unconditionally restores `existing.associated_voter_identity` and the retained `PrivateKeyOnVoterIdentity` entry. The loaded node can therefore still appear voting-ready and attempt to vote with the old voter identity even though the masternode list says that key is no longer current. Clear the retained voter state and voter key when a rotation is confirmed and no replacement was loaded, or make the merge conditional on the stored voter key matching the current voting hash.

In `src/wallet_backend/masternode.rs`:
- [SUGGESTION] src/wallet_backend/masternode.rs:214-217: Preserve the stored owner-key index for upstream re-resolution
  The discovery path stores the complete `WalletDerivationPath`, but `wallet_masternode_withdrawal` retains only the wallet seed hash and `MasternodeWithdrawal` retains only key hashes. The withdrawal lookup therefore always passes `None` for `owner_key_index_hint`. The pinned platform-wallet API documents this hint specifically for restored wallets whose provider-owner pool has no watermark or whose key is above the default scan window. A previously discovered high-index owner key can consequently fail to resolve after wallet restoration even though its local derivation reference is still correct. Propagate the stored owner derivation index through the withdrawal route and pass it to `masternode_withdrawal_keys`; the upstream implementation verifies the hinted key before using it.
- [SUGGESTION] src/wallet_backend/masternode.rs:119-121: Log registered wallets that disappear before key inspection
  The registered-wallet map is snapshotted before asynchronous inspection, so a wallet can be removed or fail to finish loading before `get_wallet` runs. This branch silently skips it, unlike the subsequent `wallet_held_keys` error branch, making a missing wallet indistinguishable from a wallet that simply does not hold the node key. Add a warning containing the seed and wallet identifiers before continuing so best-effort discovery remains diagnosable.
- [SUGGESTION] src/wallet_backend/masternode.rs:157-187: Add regression coverage for wallet-backed withdrawal request marshalling
  The tests exercise seedless key discovery, model-level routing, wire-hash reversal, and error classification, but no test executes `WalletBackend::masternode_withdraw`. That method is the fund-moving boundary combining wallet re-resolution, payout-script construction, owner-versus-transfer request mapping, destination handling, secret-session scope, and the upstream invocation. Add deterministic mocked-SDK/backend coverage for owner and transfer requests, including the owner destination restriction and the unconfirmed-error mapping, so regressions in this boundary cannot pass while only the pure helpers remain covered.

Comment thread src/wallet_backend/masternode.rs Resolved
Comment thread src/wallet_backend/masternode.rs Resolved
Comment thread src/wallet_backend/masternode.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Ready for review — files with no dedicated owner: lklimek.
Full checklist in the description.

@github-actions github-actions Bot added ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human. and removed waiting-bots Waiting for the review bots to report on this head labels Oct 28, 2026
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · thepastaclaw requested changes — dismiss the review or push a fix. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 4, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)

Most earlier findings are fixed or superseded, but two correctness issues remain: an in-flight top-up can undo retired-key removal, and GUI withdrawal selection still offers unavailable wallet references. The key-absence E2E fixtures also remain dependent on the operator's wallet contents. Static verification only; current Clippy passed, while Test Suite remains pending.

🔴 2 blocking | 🟡 1 suggestion(s)

2 finding(s) not shown inline (the lines are not part of this PR's diff)

🔴 Blocking: Do not let in-flight whole-record writes restore removed voting keys
src/backend_task/identity/mod.rs:1115-1120

The withdrawal edit fixes that caller, but the new retirement operation can still be undone by this top-up completion. identity_credits_topup_from_platform accepts a locally stored node without requiring identity-wallet ownership and dispatches TopUpIdentityFromPlatformAddresses. This task retains its original QualifiedIdentity across the network call, then writes that entire snapshot here. If retirement completes during the call, the write restores the removed voter association and key placement; it can also overwrite the replacement voting key discovered after removal. update_local_qualified_identity_observed reconciles the balance but does not merge the key inventory, and already-vaulted entries are serialized without checking whether their deleted secrets still exist. Although the writer predates this PR, durable removal and replacement are new feature behavior that depends on it. Apply balance-only changes through edit_local_qualified_identity_observed and add a top-up-completion-after-retirement regression. Deferring the remaining race requires a linked tracking issue covering it; the landed #1110 balance-watermark changes do not resolve this writer.

source: gpt-6.1-sol (phase2-reviewer: general)

🔴 Blocking: Apply the obtainable-key predicate to GUI withdrawal selection
src/model/qualified_identity/mod.rs:1239-1246

signable_withdrawal_keys correctly excludes references to absent wallets, but default_withdrawal_key and can_attempt_withdrawal still use available_withdrawal_keys. Load a node with a hand-entered owner key and a wallet-referenced payout key, remove the payout wallet, and reopen the node. The stored node and reference survive, but the GUI still prefers the unavailable payout key over the usable owner key. WithdrawalScreen submits that selection as Some(selected_key.id()), so backend resolution rejects it rather than falling back to the owner. With only an unavailable reference, the withdrawal form also remains enabled. The key chooser in ui/helpers.rs likewise checks stored entries rather than obtainable secrets. Use the shared obtainable-key predicate for GUI defaults, gating, and withdrawal choices, while preserving references for a later wallet reload. Cover both the owner fallback and the no-obtainable-key case.

source: gpt-6.1-sol (phase2-reviewer: general)

1 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The large, intricate diff changes key discovery and wallet derivation references in src/wallet_backend/masternode.rs and signature-authorized funds movement in src/backend_task/identity/withdraw_from_identity.rs, directly affecting key handling and withdrawals.
  • Phase 1 reviewers: not run (disabled for this repository)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `src/backend_task/identity/mod.rs`:
- [BLOCKING] src/backend_task/identity/mod.rs:1115-1120: Do not let in-flight whole-record writes restore removed voting keys
  The withdrawal edit fixes that caller, but the new retirement operation can still be undone by this top-up completion. `identity_credits_topup_from_platform` accepts a locally stored node without requiring identity-wallet ownership and dispatches `TopUpIdentityFromPlatformAddresses`. This task retains its original `QualifiedIdentity` across the network call, then writes that entire snapshot here. If retirement completes during the call, the write restores the removed voter association and key placement; it can also overwrite the replacement voting key discovered after removal. `update_local_qualified_identity_observed` reconciles the balance but does not merge the key inventory, and already-vaulted entries are serialized without checking whether their deleted secrets still exist. Although the writer predates this PR, durable removal and replacement are new feature behavior that depends on it. Apply balance-only changes through `edit_local_qualified_identity_observed` and add a top-up-completion-after-retirement regression. Deferring the remaining race requires a linked tracking issue covering it; the landed #1110 balance-watermark changes do not resolve this writer.

In `src/model/qualified_identity/mod.rs`:
- [BLOCKING] src/model/qualified_identity/mod.rs:1239-1246: Apply the obtainable-key predicate to GUI withdrawal selection
  `signable_withdrawal_keys` correctly excludes references to absent wallets, but `default_withdrawal_key` and `can_attempt_withdrawal` still use `available_withdrawal_keys`. Load a node with a hand-entered owner key and a wallet-referenced payout key, remove the payout wallet, and reopen the node. The stored node and reference survive, but the GUI still prefers the unavailable payout key over the usable owner key. `WithdrawalScreen` submits that selection as `Some(selected_key.id())`, so backend resolution rejects it rather than falling back to the owner. With only an unavailable reference, the withdrawal form also remains enabled. The key chooser in `ui/helpers.rs` likewise checks stored entries rather than obtainable secrets. Use the shared obtainable-key predicate for GUI defaults, gating, and withdrawal choices, while preserving references for a later wallet reload. Cover both the owner fallback and the no-obtainable-key case.

In `tests/backend-e2e/identity_masternode_withdraw.rs`:
- [SUGGESTION] tests/backend-e2e/identity_masternode_withdraw.rs:150-157: Isolate key-absence E2E scenarios after switching loads to merge semantics
  (existing thread: https://github.com/dashpay/dash-evo-tool/pull/1109#discussion_r4457765099)
  `Overwrite` removes contamination from earlier loads, but it does not establish the key-absence precondition. For node identities, `load_identity` searches registered wallets for blank owner fields regardless of load mode; `derive_keys_from_wallets: false` disables only user-identity matching. The shared harness registers the operator-provided framework wallet, and the documented setup does not require that wallet to be unrelated to `E2E_MN_PROTX_HASH`. If it holds the node's owner key—the scenario introduced by this feature—mn016, mn019, and mn054 still discover it and fail their owner-key-absence assertions despite correct application behavior. Isolate wallet-discovery state for these cases or explicitly verify a nonmatching wallet fixture independently of record-overwrite mode.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. and removed waiting-bots Waiting for the review bots to report on this head labels Nov 4, 2026
lklimek and others added 3 commits November 4, 2026 12:38
Top-ups and credit transfers wrote their whole pre-network snapshot back,
so a retired voting key removed while they ran came back. They now set
only the balance on the current record, and a failed save after the
paid task is logged instead of reported as a failed task. The unused
whole-snapshot balance writer is removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The withdrawal screen's default key and the withdraw button's gate now
skip a key held by a wallet that is no longer loaded, so an owner key
typed by hand is pre-selected instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Key-absence cases now fail with setup guidance when a harness wallet
holds the node's owner key, since a load fills a blank owner field from
any loaded wallet.

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

Copy link
Copy Markdown
Collaborator Author

Re latest review-body findings:

Do not let in-flight whole-record writes restore removed voting keys (top-up) (FIXED): Agreed, and fixed for every paid-balance writer, not just this one. Top-up from Platform addresses (identity/mod.rs:1116), transfer to addresses (:1192), top-up from a wallet (top_up_identity.rs:208) and identity-to-identity transfer (transfer.rs:85, :90) now go through store_paid_balance (identity/mod.rs:1204). It sets only the balance on the record as stored now. A voting key removed or replaced while the task ran stays that way. If the save fails after a finished task, we log it and still report the task as done. The unused whole-snapshot update_local_qualified_identity_observed is removed. Test: a_paid_balance_keeps_a_change_made_while_the_task_ran. Fixed in ea9d11d.

Apply the obtainable-key predicate to GUI withdrawal selection (FIXED): Agreed for the default and the gate. default_withdrawal_key (model/qualified_identity/mod.rs:1239) and can_attempt_withdrawal (:1227) now use signable_withdrawal_keys. With the payout key held only by an absent wallet, the screen pre-selects the hand-entered owner key. With no key the app can sign with, withdrawal is not offered. Stored references are kept for when the wallet is loaded again. Test: withdrawal_defaults_and_gate_skip_a_key_whose_wallet_is_absent, covering both the owner fallback and the no-signable-key case. Fixed in 35146bf.
Known limitation: the generic key chooser in ui/helpers.rs (render_key_combo) is shared by every transaction type, so it still lists a stored reference to an absent wallet. Picking it gets a clear NoUsableWithdrawalKey message and nothing is sent. Filtering that shared chooser is out of scope for this PR.

🤖 Co-authored by Claudius the Magnificent AI Agent

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · thepastaclaw requested changes — dismiss the review or push a fix, 1 thread unresolved — resolve it. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. labels Nov 4, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)

Static verification of e90c2e2 found one blocking balance-ordering regression and two non-blocking issues concerning cache notifications and wallet-backed withdrawal coverage. All 22 prior findings were revalidated: 17 are fixed, three remain withdrawn, one is outdated, and the withdrawal integration-coverage finding remains valid. Current-head Clippy passed; Test Suite was still pending when checked, and no local builds or tests were run.

🔴 1 blocking | 🟡 2 suggestion(s)

1 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The large, intricate diff directly changes key discovery and storage references in src/backend_task/identity/load_identity.rs and withdrawal signing and funds movement in src/wallet_backend/masternode.rs::masternode_withdraw.
  • Phase 1 reviewers: not run (disabled for this repository)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `src/backend_task/identity/withdraw_from_identity.rs`:
- [BLOCKING] src/backend_task/identity/withdraw_from_identity.rs:120-123: Preserve the withdrawal proof height on the wallet-backed path
  The wallet-backed route regresses the balance ordering preserved by the existing SDK route. With a stored watermark at height 100, a refresh can fetch the pre-withdrawal balance at height 101, then save after a withdrawal confirmed at height 102. ConfirmedUnordered stores the withdrawn balance at the old watermark height, so reconcile_balance subsequently accepts the delayed height-101 refresh and restores credits already withdrawn. That incorrect balance is then available to the withdrawal screen's maximum calculation. The documented top-up limitation does not make this equivalent to the base withdrawal behavior, which stores metadata.height. Fix the owning platform-wallet boundary to expose the withdrawal proof metadata, then propagate its height here as ObservedAt. Both the pinned and default upstream implementations currently discard that metadata, although the SDK provides wait_for_affected_state_with_metadata. Add a regression that saves a pre-withdrawal refresh after a successful wallet-backed withdrawal.

In `src/backend_task/identity/mod.rs`:
- [SUGGESTION] src/backend_task/identity/mod.rs:1023-1024: Publish an identity-cache change after retired-key cleanup
  RemoveRetiredVotingKey deletes voting-key placements and potentially a separate voter record, then can install a replacement through its internal reload, but neither this dispatch arm nor the called operations publishes CacheDomain::Identities. The originating Masternodes screen reloads on completion; other open screens do not receive that result. For example, opening Key Info while the post-removal wallet lookup awaits network work gives that screen the detail view's old identity clone, which continues reporting the retired key as held after cleanup completes. KeyInfoScreen already handles identity-cache notifications by reloading its identity and key placement. Follow the project's cache-update contract by calling notify_cache_changed after successful removal and reconciliation, and cover completion while a non-origin Key Info screen is open.

In `src/wallet_backend/masternode.rs`:
- [SUGGESTION] src/wallet_backend/masternode.rs:201-208: Add regression coverage for wallet-backed withdrawal request marshalling
  (existing thread: https://github.com/dashpay/dash-evo-tool/pull/1109#discussion_r4405934716)
  The extracted request tests now cover owner/payout mapping, and the wired-backend test executes this adapter, but its owner-with-destination request is rejected upstream before identity fetching or DetSigner invocation. The backend E2E tests do not supply the remaining integration coverage: test_mn050_owner_withdraw_to_payout and test_mn051_transfer_withdraw_to_address explicitly load their signing private keys, so typed-key precedence routes both through the legacy SDK branch. Consequently, no test exercises the new composition of wallet re-resolution, the held HD-secret session, actual signing, and confirmed or unconfirmed completion. Add deterministic mocked-SDK coverage that executes owner and payout withdrawals through this adapter past signing, verifies the submitted transition's signing key and destination, and checks successful and unconfirmed outcomes.

Comment thread src/backend_task/identity/mod.rs Resolved
…d voting key

Other open screens, such as Key Info, now reload the node once its old
voting key is removed, instead of still showing the key as held.

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

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai skipped after its own rate limit · thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@Claudius-Maginificent

Copy link
Copy Markdown
Collaborator Author

Re thepastaclaw review at e90c2e2 — Add regression coverage for wallet-backed withdrawal request marshalling:

Unit tests cover the request mapping, and the wired adapter test covers the refusal before broadcast. Mocking signing and submission end to end would need a mocked SDK behind upstream PlatformWallet::masternode_withdraw, which DET doesn't own. That signing path is upstream's to test.
Known limitation: no DET test drives a wallet-backed masternode withdrawal through signing and submission. That needs a manual check on testnet with a node registered from a wallet loaded in the app.

🤖 Co-authored by Claudius the Magnificent AI Agent

@lklimek
lklimek dismissed thepastaclaw’s stale review November 4, 2026 13:14

Dismissed by maintainer decision: the remaining blocker (withdrawal proof height on the wallet-backed path) needs platform-wallet's masternode_withdraw to return the proof height; accepted as a documented known limitation (no funds at risk). See discussion_r on PRRT_kwDOM8GK3c6zmjoF.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)

Verified the Phase-2 findings and all 24 prior findings against head 79980b9 and the relevant upstream sources. The identity-cache notification is fixed, but two blockers remain: wallet-backed withdrawals lose balance-proof ordering, and retired-key removal can delete a current key using a list observation retained across a record-lock wait. This was static verification only; current Clippy and Platform pin guard checks pass, while Test Suite remains pending.

🔴 2 blocking | 🟡 1 suggestion(s)

3 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — This large, intricate change directly modifies key discovery and storage references in src/backend_task/identity/load_identity.rs and withdrawal signing and funds movement in src/wallet_backend/masternode.rs and src/backend_task/identity/withdraw_from_identity.rs.
  • Phase 1 reviewers: not run (disabled for this repository)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `src/backend_task/identity/withdraw_from_identity.rs`:
- [BLOCKING] src/backend_task/identity/withdraw_from_identity.rs:120-123: Preserve the withdrawal proof height on the wallet-backed path
  (existing thread: https://github.com/dashpay/dash-evo-tool/pull/1109#discussion_r4467833337)
  The wallet-backed route replaces the existing withdrawal's height-tagged balance with `ConfirmedUnordered`, which breaks the balance watermark's ordering guarantee. With a stored watermark at height 100, a refresh can fetch the pre-withdrawal balance at 101, the withdrawal can confirm at 102 and save first, and the delayed refresh can then restore the already-withdrawn credits because the watermark remains at 100. The reverse completion order is also unsafe: a delayed withdrawal result can overwrite a newer balance already observed at 104 while retaining the height-104 watermark, preventing another observation at that height from repairing it. The fresh-record edit preserves concurrent key changes but does not address either balance race. Both pinned and default `dashpay/platform` implementations return only `u64` from `PlatformWallet::masternode_withdraw`; expose the withdrawal proof height at that owning upstream boundary, propagate it here as `ObservedAt`, and cover both completion orderings. The documented top-up limitation does not justify removing ordering that the base withdrawal path already provided.

In `src/backend_task/identity/retired_voting_key.rs`:
- [BLOCKING] src/backend_task/identity/retired_voting_key.rs:177-180: Revalidate the voting-list hash after acquiring the identity record
  (existing thread: https://github.com/dashpay/dash-evo-tool/pull/1109#discussion_r4416358938)
  The fingerprint check prevents a changed stored key from being judged by the earlier list, but it does not detect a changed list when the stored key stays the same. This window can include a substantial lock wait: `finish_identity_load_storage` holds the same record mutex through protected-key verification and vault writes, and a preserving reload need not change `StoredVotingKeys`. If the record stores B, the list read still names A, and the list catches up to B while removal waits, the fingerprint comparison succeeds and `retired_voting_keys(&node, A)` deletes B's vault secret even though the available list now names B as current. Removal accepts hand-entered `InVault` keys too, so derivation-based recovery is not guaranteed. Do not await an asynchronous list query under the synchronous guard; instead invalidate or revalidate the observation across contention, for example by refusing a contended acquisition and restarting validation, or by using an upstream generation-tagged snapshot checked at the destructive decision. Add a regression where the list changes during the wait without changing the stored voting fingerprint.

In `src/wallet_backend/masternode.rs`:
- [SUGGESTION] src/wallet_backend/masternode.rs:201-208: Add regression coverage for wallet-backed withdrawal request marshalling
  (existing thread: https://github.com/dashpay/dash-evo-tool/pull/1109#discussion_r4405934716)
  The extracted request tests verify owner/payout field mapping, and the wired owner-destination test reaches the upstream refusal, but that refusal occurs before the derived signer is used. The unconfirmed-outcome test also fabricates an upstream error and calls the mapper directly rather than obtaining it from the wallet future inside this secret session. Consequently, the tests do not cover the adapter's signed-completion boundary: an incorrectly constructed `DetSigner`, or broken propagation of a post-broadcast result-wait failure, can pass the existing checks. Add deterministic mocked-SDK tests that execute owner and payout withdrawals through signing and successful completion, plus a result-wait failure that returns `MasternodeWithdrawalUnconfirmed` through `WalletBackend::masternode_withdraw`. These checks do not require a live funded withdrawal.

@lklimek
lklimek dismissed thepastaclaw’s stale review November 4, 2026 13:33

Dismissed by maintainer decision: both blockers are carried-forward findings already decided — withdrawal proof height (accepted as a documented known limitation, #1109 (comment)) and voting-list hash revalidation (rejected by the maintainer, #1109 (comment)). No new findings on 79980b9.

@github-actions github-actions Bot added the bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. label Nov 4, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@thepastaclaw review

No review for 79980b99 yet, so PR Hygiene is asking once. If nothing arrives, the requirement is dropped for this commit and the pull request is labelled bot-review-skipped.

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Ready for review — files with no dedicated owner: lklimek.
Full checklist in the description.

@github-actions github-actions Bot added ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human. and removed waiting-bots Waiting for the review bots to report on this head labels Nov 5, 2026
@Claudius-Maginificent Claudius-Maginificent added priority: high High priority — address soon priority: medium Medium priority and removed priority: high High priority — address soon labels Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. priority: medium Medium priority ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants