/tip needs monero-wallet-rpc `transfer`, which a view-only wallet cannot do. With ONIONWIRE_WALLET_NO_SPEND=1 (`1`/`true`/`yes`/`on`) `Wallet::transfer` refuses locally, before any RPC dial, and /pay + receipt verification are unchanged. When a transfer does fail, ask the documented signal before surfacing the raw wallet error: `query_key` key_type=spend_key answers WALLET_RPC_ERROR_CODE_WATCH_ONLY (-29) on a view-only wallet (wallet_rpc_server.cpp on_query_key). Both paths return one sentence — "wallet is in view-only/no-spend mode — /tip is disabled; /pay and receipt verification still work". Fail closed: if the probe cannot answer, the wallet's own error stands; no fabricated detection. New docs/WALLET.md: --generate-from-view-key / generate_from_keys watch-only setup, --rpc-login Digest, why loopback still needs auth, the local spend-authority warning, and the detection trade-off (a spend-capable wallet answers the probe with its spend key, which is discarded). Linked from docs/THREAT_MODEL.md.
8.5 KiB
OnionWire + monero-wallet-rpc
OnionWire is not a wallet. It never holds a seed, a spend key, or a view key.
It talks optional JSON-RPC to a monero-wallet-rpc that you run, on
loopback, only to:
- hand out a receive subaddress for
/payinvoices (create_address), - read incoming transfers to verify a peer's receipt (
get_transfers), - and — only if you let it — spend for
/tip(transfer).
Run it view-only, and switch /tip off explicitly. Everything else in this
document explains why, and what breaks when you do.
Env vars
| Variable | Meaning |
|---|---|
ONIONWIRE_WALLET_RPC |
http://[user:pass@]host[:port][/path]. Unset → no wallet; chat still works and /pay falls back to the profile xmr_addr. |
ONIONWIRE_WALLET_RPC_LOGIN |
user:pass when you do not want the password in the URL. Ignored if the URL carries userinfo. |
ONIONWIRE_WALLET_NO_SPEND |
1 / true / yes / on → view-only deployment: /tip is refused locally, before any RPC dial. /pay and receipt verification keep working. |
README.md carries the operator summary; this file is the long form.
Recommended topology
wallet host (this machine)
┌──────────────────────────────────────────────────────────────┐
│ monero-wallet-rpc --rpc-bind-ip 127.0.0.1 --rpc-login u:p │
│ ▲ HTTP Digest, loopback only │
│ │ │
│ OnionWire (ONIONWIRE_WALLET_NO_SPEND=1) ── /pay, receipts │
│ └── /tip refused locally │
└──────────────────────────────────────────────────────────────┘
Loopback is the only address OnionWire will dial. .onion RPC URLs are
rejected: there is no Arti dial for the wallet, and a remote wallet would move
your key material off the box.
Create a view-only wallet
Either path produces a wallet file with the view key only. Keep the seed / spend key on a machine that is not running OnionWire.
With monero-wallet-cli (--generate-from-view-key prompts for the standard
address the view key belongs to, then the secret view key):
monero-wallet-cli --generate-from-view-key "$HOME/.onionwire-viewonly" \
--daemon-address "$YOUR_MONEROD:18089" --restore-height "$BIRTH_HEIGHT"
# Standard address: 4...
# Secret view key: <hex>
Or through a running RPC that was started with --wallet-dir (generate_from_keys
without spendkey writes a watch-only wallet):
curl -u onionwire:secret http://127.0.0.1:18083/json_rpc \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":"0","method":"generate_from_keys","params":{
"filename":"viewonly","password":"walletpass",
"address":"4...","viewkey":"<hex>","restore_height":<height>}}'
# → "Watch-only wallet has been generated successfully."
Then serve it:
monero-wallet-rpc --wallet-file "$HOME/.onionwire-viewonly" \
--rpc-bind-ip 127.0.0.1 --rpc-bind-port 18083 --rpc-login onionwire:secret \
--daemon-address "$YOUR_MONEROD:18089"
export ONIONWIRE_WALLET_RPC=http://127.0.0.1:18083
export ONIONWIRE_WALLET_RPC_LOGIN=onionwire:secret
export ONIONWIRE_WALLET_NO_SPEND=1
Restore the wallet from a height at or before its first incoming transaction — a view-only wallet cannot rescan cheaply from height 0.
What works, what does not
| Feature | View-only | Spend-capable |
|---|---|---|
/pay <xmr> invoice subaddress (create_address) |
works | works |
Receipt verification (get_transfers) |
works | works |
Profile xmr_addr fallback when RPC is down |
works | works |
/tip <xmr> (transfer) |
cannot work | works |
| OnionWire learns your spend key | never | never (it stays in the wallet) |
With ONIONWIRE_WALLET_NO_SPEND=1 a /tip is refused before the RPC is
contacted, with:
wallet is in view-only/no-spend mode — /tip is disabled; /pay and receipt verification still work
Without the flag, /tip against a view-only wallet fails at the wallet and
OnionWire then asks the wallet directly whether it can spend (see below), so you
get the same sentence instead of a raw RPC error.
How OnionWire detects view-only over RPC
The signal people usually reach for is query_key with key_type=mnemonic. It
works, but it is the wrong key to ask for: on a spend-capable wallet it hands
over the whole seed (full spend ability) over loopback HTTP, and it answers
-43 for wallets that have no mnemonic at all. The spend key is narrower and
just as unambiguous:
query_key {"key_type":"spend_key"}
spend-capable → result.key = <hex secret spend key>
view-only → error code -29, "The wallet is watch-only. Cannot retrieve spend key."
(query_key key_type=mnemonic returns -29 for a view-only wallet too, so the
two agree — OnionWire asks for the spend key because it is the smaller secret.)
- Method:
query_key -29isWALLET_RPC_ERROR_CODE_WATCH_ONLYinwallet_rpc_server_error_codes.h- The view-only branch is
on_query_keyinwallet_rpc_server.cpp
OnionWire only calls this after a transfer has already failed — it never
probes a healthy wallet — and it discards result.key immediately. There is no
RPC method that reports "view-only" as a plain field; query_key is the
documented signal and this is its only cost: a spend-capable wallet answers with
its spend key over loopback HTTP, which is one more reason to run view-only.
Fail-closed details: if the probe cannot answer (wallet down, --restricted-rpc
answers -7 DENIED instead), OnionWire surfaces the wallet's own error
unchanged. It never guesses "view-only" from an unrelated failure.
Why loopback still needs authentication
--rpc-bind-ip 127.0.0.1 keeps the port off the network; it does not keep it
away from other users or processes on the same machine. Any local process can
connect(127.0.0.1:18083).
- OnionWire refuses an RPC that answers HTTP 200 without a Digest challenge, and refuses URLs without credentials. Unset the credentials and the wallet is open to every local process — with a spend-capable wallet file, that is a one-curl drain of your balance.
--rpc-loginis HTTP Digest (MD5), so the password is not sent in cleartext, but Digest gives no confidentiality: a local attacker who can sniff loopback can replay it. Treat loopback as trusted-ish, not safe.- Do not log the password, and do not put it in a shell history you share.
Prefer
ONIONWIRE_WALLET_RPC_LOGINover userinfo in the URL.
The spend-authority warning
An OnionWire instance pointed at a spend-capable monero-wallet-rpc is a
local spend authority: any process that can read the RPC credentials (env var,
/proc/<pid>/environ, shell history, a stored URL) can spend the wallet's
balance, and /tip gives a chat peer a supported path to ask for a transfer.
That is why view-only plus ONIONWIRE_WALLET_NO_SPEND=1 is the recommended
default:
- the wallet file holds no spend key, so a stolen wallet file cannot be used to move funds;
- the RPC credentials grant only receive-address and history reads;
/tipfails locally with a plain message, so nothing in the UI pretends the spend path exists.
If you want tips to work, understand that you are deliberately making the OnionWire process able to spend. Give it a separate hot wallet with a small balance, not your savings wallet.
References
- Monero Wallet RPC reference: https://www.getmonero.org/resources/developer-guides/wallet-rpc.html
on_query_key(view-only →-29): https://github.com/monero-project/monero/blob/master/src/wallet/wallet_rpc_server.cppWALLET_RPC_ERROR_CODE_WATCH_ONLY = -29: https://github.com/monero-project/monero/blob/master/src/wallet/wallet_rpc_server_error_codes.h--generate-from-view-key(incoming-only wallet): https://github.com/monero-project/monero/blob/master/src/simplewallet/simplewallet.cppgenerate_from_keys(watch-only whenspendkeyis omitted): https://www.getmonero.org/resources/developer-guides/wallet-rpc.html#generate_from_keys