wallet: derive readiness from the wallet's get_height, not a nonexistent get_info
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.
This commit is contained in:
parent
dddf74f274
commit
3aafaefae8
6 changed files with 476 additions and 159 deletions
|
|
@ -208,18 +208,42 @@ C++ binary, so it reaches Tor through a SOCKS proxy the app provides:
|
|||
**Tor hides the transport, not the host.** The daemon operator still sees the
|
||||
wallet's addresses during sync.
|
||||
|
||||
### Readiness — receipt verification needs a synced daemon
|
||||
### Readiness — receipt verification needs a synced wallet
|
||||
|
||||
`chain_ready()` asks the wallet RPC `get_info` and requires
|
||||
**`synchronized == true`** with `height > 0` and `height >= target_height`. A
|
||||
missing field is *not ready* — fail closed.
|
||||
`chain_ready()` compares the wallet's **own scanned height** with the **chain
|
||||
tip**. Both halves must answer:
|
||||
|
||||
1. the wallet RPC's `get_height` reports `height > 0`. That is
|
||||
`monero-wallet-rpc`'s own method; `get_info` does **not** exist there — it
|
||||
answers `-32601 Method not found`, so readiness never asks for it.
|
||||
2. the chain daemon reports a tip, and the wallet is at it or within **2
|
||||
blocks**. The tip moves every ~2 minutes and the two numbers are two reads,
|
||||
not one snapshot, so a strict equality flaps; two blocks of slack does not
|
||||
hide a real lag.
|
||||
|
||||
The tip comes from `daemon_get_height` (`GET /get_height` — one spelling that
|
||||
works on monerod and Cuprate) against `ChildConfig::daemon_probe_addr()`:
|
||||
|
||||
- local `monerod` / in-process Cuprate → `127.0.0.1:18081`;
|
||||
- a **clearnet** remote daemon the user typed → that host. The wallet child
|
||||
already dials it, so one `get_height` is the same exposure, not a new path;
|
||||
- a **`.onion`** daemon → **not dialled** without the SOCKS child: a direct dial
|
||||
would resolve the name on clearnet DNS and leak. Readiness stays false
|
||||
(height-only); the status row reads syncing. A documented limit, not a bug;
|
||||
- receive-only, or an externally run wallet RPC with no chain source → nothing
|
||||
to ask, so not ready.
|
||||
|
||||
Unknown is **not caught up**. A daemon that does not answer, a wallet with no
|
||||
file open (`-13 No wallet file`), and a missing height all read *not ready*,
|
||||
never a silent pass. "No wallet open" is a state, not an error banner.
|
||||
|
||||
Until then, **receipt verification stays `verified=0`**. An unsynced wallet
|
||||
cannot see the chain. That is an honest limit, not a UI bug.
|
||||
|
||||
Loopback management calls (`get_address`, `query_key`, create/import) get 5s.
|
||||
Calls that wait on the chain (`get_info`, `get_transfers`, `transfer`) get 60s
|
||||
(`CHAIN_RPC_TIMEOUT`).
|
||||
Calls that wait on the chain (`get_transfers`, `transfer`) get 60s
|
||||
(`CHAIN_RPC_TIMEOUT`). Readiness is not a chain wait: it is one local
|
||||
`get_height` plus one bounded daemon probe.
|
||||
|
||||
## Env vars (migration path)
|
||||
|
||||
|
|
@ -256,8 +280,9 @@ re-points the wallet without a restart; a rejected form writes nothing.
|
|||
UniFFI: `set_chain_source(ChainConfig)` / `chain_source()`,
|
||||
`start_wallet_child()`, `stop_wallet_child()`, `wallet_status()` (cached read:
|
||||
no dial, for first paint) and `wallet_child_refresh()` (a live probe of the
|
||||
same record — it dials the loopback wallet RPC, and the local daemon's
|
||||
`get_info` when that RPC does not answer, so poll it on the order of seconds).
|
||||
same record — it dials the loopback wallet RPC and asks the configured daemon
|
||||
for its tip (the wallet's `get_height` is the other half), so poll it on the
|
||||
order of seconds).
|
||||
Pass absolute paths for `wallet_rpc_bin` / `arti_bin` (`nativeLibraryDir`); the
|
||||
core never resolves a binary the caller named explicitly.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue