wallet: derive readiness from the wallet's get_height, not a nonexistent get_info #204

Merged
sirius merged 2 commits from wt/t_e4e55a04 into main 2026-10-31 05:49:07 +00:00
Owner

What was broken

monero-wallet-rpc has no get_info — it answers -32601 Method not found. The readiness probe asked it anyway, so every wallet read as unsynced forever: no balance, spends refused with NOT_SYNCED_MSG, receipts never verified.

Verified live on this host (monero-wallet-rpc v0.18.5.1):

$ curl --digest ... -d '{"jsonrpc":"2.0","id":"0","method":"get_info"}'  http://127.0.0.1:18099/json_rpc
{"error":{"code":-32601,"message":"Method not found"},"id":"0","jsonrpc":"2.0"}
$ curl --digest ... -d '{"jsonrpc":"2.0","id":"0","method":"get_height"}' http://127.0.0.1:18099/json_rpc
{"id":"0","jsonrpc":"2.0","result":{"height":3707001}}

The fix

  • Wallet::chain_info() asks the wallet RPC for get_height (its own scanned height) and the daemon client (daemon_get_height, GET /get_height) for the tip. get_info is never asked of the wallet RPC.
  • Readiness stated once: height > 0 && (tip == 0 || height + 2 >= tip). Two blocks of deliberate slack — the tip moves every ~2 min and the two reads are not a snapshot — so a wallet at the tip does not flap.
  • Unknown is not caught up: a daemon that does not answer, a missing height, and -13 No wallet file all read not-ready. "No wallet open" is a state, not an error banner (chain_ready → Ok(false)).
  • ChildConfig::daemon_probe_addr() now resolves a tip source for a clearnet remote daemon the user typed (the wallet child already dials it). A .onion daemon is still not dialled without the SOCKS child: fail-closed (height-only), documented.
  • Node::wallet_child_refresh, Node::tip and receipt ingest attach the probe from the child config; the status row shows wallet_height/daemon_tip.
  • docs/WALLET.md readiness section now documents the real rule (spec matches main).

Verification

  • cargo test green; new tests: readiness_never_asks_the_wallet_rpc_for_get_info, a_wallet_within_the_slack_of_the_daemon_tip_is_ready, an_unreachable_daemon_is_not_ready, an_rpc_with_no_wallet_open_is_not_ready_and_not_an_error, a_missing_or_zero_wallet_height_is_not_ready.
  • cargo clippy --all-targets -- -D warnings clean.
  • Live: real monero-wallet-rpc at height 3707001 + daemon stub — tip 3707001 → Ok(true); tip 3790000 → Ok(false); no daemon → Ok(false). The ready flip is proven against a stub daemon, not a live chain (no monerod on this host).

Rebased on main @ dddf74f (includes #202). Do not merge — Lance merges.

## What was broken `monero-wallet-rpc` has no `get_info` — it answers `-32601 Method not found`. The readiness probe asked it anyway, so every wallet read as unsynced forever: no balance, spends refused with `NOT_SYNCED_MSG`, receipts never verified. Verified live on this host (monero-wallet-rpc v0.18.5.1): ``` $ curl --digest ... -d '{"jsonrpc":"2.0","id":"0","method":"get_info"}' http://127.0.0.1:18099/json_rpc {"error":{"code":-32601,"message":"Method not found"},"id":"0","jsonrpc":"2.0"} $ curl --digest ... -d '{"jsonrpc":"2.0","id":"0","method":"get_height"}' http://127.0.0.1:18099/json_rpc {"id":"0","jsonrpc":"2.0","result":{"height":3707001}} ``` ## The fix - `Wallet::chain_info()` asks the wallet RPC for `get_height` (its own scanned height) and the daemon client (`daemon_get_height`, `GET /get_height`) for the tip. `get_info` is never asked of the wallet RPC. - Readiness stated once: `height > 0 && (tip == 0 || height + 2 >= tip)`. Two blocks of deliberate slack — the tip moves every ~2 min and the two reads are not a snapshot — so a wallet at the tip does not flap. - Unknown is not caught up: a daemon that does not answer, a missing height, and `-13 No wallet file` all read not-ready. "No wallet open" is a state, not an error banner (`chain_ready` → `Ok(false)`). - `ChildConfig::daemon_probe_addr()` now resolves a tip source for a **clearnet** remote daemon the user typed (the wallet child already dials it). A **.onion** daemon is still not dialled without the SOCKS child: fail-closed (height-only), documented. - `Node::wallet_child_refresh`, `Node::tip` and receipt ingest attach the probe from the child config; the status row shows `wallet_height/daemon_tip`. - `docs/WALLET.md` readiness section now documents the real rule (spec matches main). ## Verification - `cargo test` green; new tests: `readiness_never_asks_the_wallet_rpc_for_get_info`, `a_wallet_within_the_slack_of_the_daemon_tip_is_ready`, `an_unreachable_daemon_is_not_ready`, `an_rpc_with_no_wallet_open_is_not_ready_and_not_an_error`, `a_missing_or_zero_wallet_height_is_not_ready`. - `cargo clippy --all-targets -- -D warnings` clean. - Live: real monero-wallet-rpc at height 3707001 + daemon stub — tip 3707001 → `Ok(true)`; tip 3790000 → `Ok(false)`; no daemon → `Ok(false)`. The ready flip is proven against a stub daemon, not a live chain (no monerod on this host). Rebased on main @ dddf74f (includes #202). Do not merge — Lance merges.
wallet: derive readiness from the wallet's get_height, not a nonexistent get_info
Some checks failed
ci / test (pull_request) Has been cancelled
ci / sdk (pull_request) Has been cancelled
3aafaefae8
monero-wallet-rpc does not implement get_info (-32601 Method not found); it
exists on the daemon only. Every wallet therefore sat in syncing forever:
no balance, spends refused, receipts never verified.

Readiness is now the pair:
- the wallet RPC's own get_height (its scanned height), and
- the chain tip from the existing daemon client (GET /get_height).

ready = height > 0 && (tip == 0 || height + 2 >= tip). The 2-block slack is
deliberate: the tip moves every ~2 min and the two reads are not a snapshot.
A daemon that does not answer, a missing height and -13 No wallet file are
all not-ready, never an error banner.

ChildConfig::daemon_probe_addr resolves a tip source for clearnet remotes
(the wallet child already dials them); a .onion daemon is not dialled without
the SOCKS child and stays fail-closed. docs/WALLET.md now documents the real
rule. Tests cover -32601 get_info, equal tip, slack boundary, dead daemon and
the no-wallet-file answer.
Merge branch 'main' into wt/t_e4e55a04
Some checks failed
ci / test (pull_request) Has been cancelled
ci / sdk (pull_request) Has been cancelled
717a33b4c2
sirius merged commit 488eb94e28 into main 2026-10-31 05:49:07 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/onionwire!204
No description provided.