Repository navigation
feat(platform-wallet): return the proved block height with a withdrawal's remaining balance - #6027
Draft
Claudius-Maginificent wants to merge 11 commits into
Draft
Claudius-Maginificent wants to merge 11 commits into
Claudius-Maginificent wants to merge 11 commits into
Conversation
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. |
9 tasks
Collaborator
|
🕓 Review not started yet because this PR is a draft.
Commit 7cf6be2. Normal review starts when eligible; priority review starts as soon as a slot is available. |
lklimek
force-pushed
the
feat/mn-withdrawal-height
branch
from
November 24, 2026 11:15
1dd2661 to
3612e42
Compare
…its height Add SpvRuntime::current_masternode_list, returning a CurrentMasternodeList (the list's known height and its summaries from one snapshot) only while the list follows the chain, through the existing while_following_the_chain gate. CurrentMasternodeList::key_reference gives the list-known keys of a node, or None when the node is not on the list. The crate-private current_masternode_list_summaries is now a projection of it; its callers see the same results. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WunYYhpfoE88XJoyRt4hcR
…ternodeListUnavailable SpvRuntime::current_masternode_list returns Err(PlatformWalletError::MasternodeListUnavailable) instead of None while the list does not follow the chain or SPV restarted during the read, the error #5889's callers already map that case to. The crate-private current_masternode_list_summaries keeps returning None in that case. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WunYYhpfoE88XJoyRt4hcR
…order proTxHash only Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e and describe its dash-spv follow-up in words CurrentMasternodeList is exported from `masternode` only, like MasternodeListSummary and MasternodeKeyReference. The TODO on current_masternode_list names the dependency in words, as no upstream issue exists yet. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WunYYhpfoE88XJoyRt4hcR
…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
…record Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WunYYhpfoE88XJoyRt4hcR
…al's remaining balance
Add WithdrawalOutcome { remaining_credits, proved_at: BlockTime }, built
from the result proof's response metadata, so a host can tell a
withdrawal's proved balance from an older balance read.
PlatformWallet::masternode_withdraw, TrackedMasternodes::withdraw and
IdentityWallet::withdraw_credits_with_signer return it instead of the bare
balance; the masternode path waits with
wait_for_affected_state_with_metadata, the identity path uses
withdraw_with_metadata. When an outcome is unconfirmed is unchanged.
These public Rust signatures change (not consensus). The FFI keeps its
balance out-parameter and reads remaining_credits.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WunYYhpfoE88XJoyRt4hcR
…or identity withdrawals Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WunYYhpfoE88XJoyRt4hcR
lklimek
force-pushed
the
feat/mn-withdrawal-height
branch
from
December 3, 2026 07:11
3612e42 to
7cf6be2
Compare
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: After a masternode or identity credit withdrawal, the wallet now also gets the block height at which the remaining balance was proved, so it can tell that balance apart from an older balance read.
User story
As a wallet app developer, I want a withdrawal to return the proved block height together with the remaining balance, to achieve correct ordering against balances read elsewhere (a refresh that answered from an older block must not overwrite it).
Scenario
Base flow
The user withdraws credits from a masternode or an identity while the app also refreshes balances in the background.
Actual behavior
The withdrawal returns only the remaining balance. The app cannot tell whether it is newer than a balance a concurrent refresh read.
Expected behavior
The withdrawal returns
WithdrawalOutcome { remaining_credits, proved_at }, withproved_attaken from the result proof's metadata.Detailed discussion
Issue being fixed or feature implemented
Stacked atop #6026 (
feat/mn-key-reference), part of the stack over #5889.What was done?
WithdrawalOutcome { remaining_credits, proved_at: BlockTime }(wallet/identity/types/withdrawal_outcome.rs), built from the result proof's response metadata. There is no height without a proved balance.PlatformWallet::masternode_withdraw,TrackedMasternodes::withdrawandIdentityWallet::withdraw_credits_with_signerreturn it. The masternode path waits withwait_for_affected_state_with_metadata; the identity path useswithdraw_with_metadata. When an outcome counts as unconfirmed is unchanged.remaining_credits; C signatures are unchanged.How Has This Been Tested?
Existing withdrawal tests updated; workspace callers swept; clippy also run on
rs-unified-sdk-ffiandrs-unified-sdk-jni(host target). Not executed: a live testnet withdrawal, the Android cross-build.Breaking Changes
Public Rust API (not consensus):
PlatformWallet::masternode_withdraw,TrackedMasternodes::withdrawandIdentityWallet::withdraw_credits_with_signerreturnWithdrawalOutcomeinstead of the bare balance. No FFI change.Deferred
withdraw_credits_with_signerpropagatesproved_atneeds an rs-sdk mock hook for state-transition result proofs (markedTODOin code).WithdrawalOutcomename serves a crate-wide need (a proved balance with its height) under a withdrawal-only name; renaming or generalising it is a follow-up.Checklist:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull requestFor repository code-owners and collaborators only
🤖 Generated with Claude Code
https://claude.ai/code/session_01WunYYk4eUkHuGstPtj83j4
🤖 Co-authored by Claudius the Magnificent AI Agent