wallet: no-spend (view-only) mode + RPC view-only detection + docs/WALLET.md #41
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/wallet-no-spend-view-only"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
/tipneedsmonero-wallet-rpcmethodtransfer, which a view-only wallet cannot serve. This PR makes that explicit instead of leaving the user with a raw wallet error:ONIONWIRE_WALLET_NO_SPEND=1(1/true/yes/on) —/tipreturnswallet is in view-only/no-spend mode — /tip is disabled; /pay and receipt verification still workand no socket is ever opened (the guard is the first statement in
Wallet::transfer, before the endpoint lookup)./pay(subaddress), receipt verification (get_transfers) and the profile fallback are untouched.docs/WALLET.md(new): view-only setup,--rpc-login/Digest, what breaks, why loopback still needs auth, and the spend-authority warning. Linked fromdocs/THREAT_MODEL.md.Refused before dialing (flag), or mapped to the same sentence after a failed
transfer(RPC signal). Fail closed: if the probe cannot answer, the wallet's own error is surfaced unchanged — no fabricated detection.Which RPC method reveals view-only (acceptance criterion)
query_keywithkey_type=spend_keyis the documented signal:Source of truth (read, not guessed):
on_query_key, view-only branch: https://github.com/monero-project/monero/blob/master/src/wallet/wallet_rpc_server.cpp (lines 2364-2375)#define WALLET_RPC_ERROR_CODE_WATCH_ONLY -29: https://github.com/monero-project/monero/blob/master/src/wallet/wallet_rpc_server_error_codes.hquery_key key_type=mnemonicalso answers-29for a view-only wallet, but on a spend-capable wallet it hands over the whole seed and it answers-43for non-deterministic wallets, so OnionWire asks for the single spend key instead.Trade-off, stated honestly:
query_keyis a key-export method. On a spend-capable wallet it returns the spend key over loopback HTTP, which OnionWire immediately discards; that is exactly why the probe only runs after atransferhas already failed (never on a healthy tip), and why view-only +ONIONWIRE_WALLET_NO_SPEND=1is the recommended default.--restricted-rpcanswers-7 DENIEDto both methods; that is surfaced as the wallet's own error, not as "view-only".Tests (all new in
tests/wallet.rs, TDD — each failed first)no_spend_mode_refuses_transfer_with_no_rpc_requestno_spend_mode_keeps_invoice_and_receipt_paths_workingcreate_address+get_transfers+transfers_matchstill work with the flag on; notransferrequest recordedview_only_wallet_maps_transfer_failure_to_clear_messagetransfer→-18, probequery_key→-29⇒ the same clear sentence; log shows both methodsspend_capable_wallet_keeps_the_original_transfer_erroropen_rpc_without_digest_challenge_is_still_refusedfrom_env_reads_no_spend_flagONIONWIRE_WALLET_NO_SPENDplumbing (1/true/0/no/off/unset)Mutation check on the headline assertion: with the
if self.no_spendguard neutralised,no_spend_mode_refuses_transfer_with_no_rpc_requestfails (called Result::unwrap_err() on an Ok value: "abc123"— i.e. it really did reach the mock wallet); the guard restored, it passes.Evidence (commands actually run, real output)
(3 ignored = the Arti/onion-service tests that need a live Tor network.)
Scope notes
src/node.rsis untouched.tip()reaches the RPC only throughWallet::transfer, so the guard and the mapping live at the single choke point (testable with the existing mock TCP doubles; aNodeneeds Arti bootstrap). TheNodesurface and its error plumbing are unchanged.docs/had no env-var table (only prose indocs/THREAT_MODEL.md);docs/WALLET.mdnow carries one forONIONWIRE_WALLET_RPC,ONIONWIRE_WALLET_RPC_LOGINandONIONWIRE_WALLET_NO_SPEND.docs/README.md(docs index) was not touched — it is outside this card's allowed list. Optional one-line addition for you to apply if you want it: under item 2,Wallet sidecar: [WALLET.md](WALLET.md).README (deferred)
README.mdis owned by open PR #38 — not touched. Exact proposed wording, to apply inside## Monero sidecar(after the existingexportblock and the "Loopback only, HTTP Digest…" paragraph):And the flag list line, if you keep the
/pay/tipbullets:-ONIONWIRE_WALLET_NO_SPEND=1— view-only:/tiprefuses locally;/payand receipts keep working. Recommended.a28a3ceb7501b63c4968Merge order 3 of 7: #38 -> #42 -> #41 -> #44 -> #43 -> #45 -> #46
Goes before #46, which also rewrites
src/wallet.rs— that is the only overlap. Rebase-clean.Note: Forgejo refuses a formal approval from this token ("approve your own pull is not allowed" — the PRs were pushed by account
sirius, which is also the token's user). This review records the sign-off and the merge position; a human approval click is still needed. Rebased onto currentmainbefore this review, diff verified byte-identical.01b63c4968323100b162