Add wallet_staking_status: read-only query RPC for headless staking - #43
Open
br33zybail wants to merge 1 commit into
Open
Add wallet_staking_status: read-only query RPC for headless staking#43br33zybail wants to merge 1 commit into
br33zybail wants to merge 1 commit into
Conversation
wallet_staking_action lets a headless operator submit staking actions, but there's no headless way to read staking state — which bonds exist, their targets/amounts, staked/withdrawable balances, or sync height. This adds that. wallet_main publishes a clone of its live Arc<Mutex<WalletState>> to a STAKING_STATUS_HANDLE global (same idiom as USER_UFVK_STRING); the new wallet_staking_status RPC serialises a snapshot as a JSON object (bonds with key/target/amount, balances, staked/withdrawable, sync/tip height, own finalizer key). Read-only, mirrors wallet_staking_action's plumbing, fails closed when no wallet is running. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hfv59KmT627YnkA3BhhqgD
br33zybail
force-pushed
the
staking-status-query-rpc
branch
from
July 18, 2026 02:35
b639fbb to
2d00a4e
Compare
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.
Adds
wallet_staking_status, a read-only query RPC that complementswallet_staking_action(
26a6564). Additive - one new method, touches none of the existing staking code.Why
wallet_staking_actionlets a headless operator submit staking actions, but there's noheadless way to read staking state, which bonds exist, their targets and amounts, the
staked/withdrawable balances, or the wallet's sync height. Today that needs the GUI. Driving an
autostaker over
wallet_staking_actionmakes the gap obvious: to size a bond, confirm onelanded, or drive an unbond/claim, you first have to see your bonds. This adds that read side.
What
One method,
wallet_staking_status(no args), returning a JSON object:{ "wallet_is_init": true, "sync_height": 233408, "tip_height": 233410, "user_address": "utest1…", "user_ufvk": "uview1…", "own_finalizer_pubkey": "45833df6…cb91", "user_unshielded_zats": 132998795002, "user_shielded_spendable_zats": 0, "user_shielded_pending_zats": 0, "staked_zats": 521830000000, "withdrawable_zats": 0, "bonded": [ { "bond_key": "744b9031…", "target_finalizer": "45833df6…", "initial_zats": 100000000000 }, … ], "unbonded": [ … ] }How
Read-only, no coupling to the write path. The headless wallet already keeps its live
WalletState(balances,stake_positions_bonded/unbonded, sync height) behind anArc<Mutex<…>>.wallet_mainpublishes a clone of that handle to aSTAKING_STATUS_HANDLEglobal (same idiom as
USER_UFVK_STRING), and the RPC serialises a snapshot. Plumbing mirrorswallet_staking_actionexactly: aTFLServiceRequest/Responsevariant, a one-line servicehandler, a
methods.rsmethod with the same error shape. Fails closed, no wallet(
disable_the_headless_wallet) ⇒ explicit error, never a misleading empty-but-ok response.Four files, additive; with the method uncalled, behaviour is byte-identical to
s1_dev.Addresses the earlier #40 review
wallet_staking_action; changes none of the existing staking code.Testing
s1_dev(cargo build --release -p zebrad).wallet_staking_statusis registered and reachable, and failsclosed with the wallet disabled:
wallet_staking_status failed: headless wallet is not running (is disable_the_headless_wallet set?).by a real headless run: a full up-and-down denomination ladder of self-bonds
(0.01 → 10 → 100 → 1000, then 1000→100 as budget drained), each independently confirmed
consensus-active on canonical blocks.