ClawRouter icon indicating copy to clipboard operation
ClawRouter copied to clipboard

Core wallet outranks a funded legacy wallet.key, moving which wallet pays

Open VickyXAI opened this issue 2 months ago • 1 comments

Follow-up from the #313 review. Not a regression in that PR alone — it is the wallet-unification design meeting existing installs, and the right answer is a call worth making explicitly.

What happens

resolveExistingWalletKey() (src/auth.ts) resolves in this order:

  1. BLOCKRUN_WALLET_KEY
  2. BlockRun Core — ~/.blockrun/.session
  3. Legacy — ~/.openclaw/blockrun/wallet.key

migrateLegacyWalletToCore() runs first and copies legacy into Core only when Core is absent, so the two hold the same key in the common case and the order does not matter.

They diverge in one case: Core already exists, written independently by another BlockRun product, while ClawRouter has its own funded wallet.key. On upgrade, payment silently moves to the Core wallet. Requests then fail on an empty balance while the funded wallet sits idle. Funds are not lost — the legacy file is preserved — but nothing explicit asked for the switch and nothing announces it.

loadPaymentChain() has the same shape: ~/.blockrun/.chain outranks the legacy payment-chain file, so an install can move between Base and Solana — a different signer and a different gateway — on the strength of a file another product wrote.

Why it is not simply "prefer legacy"

Flipping the order trades one failure for another. apps/desktop/electron/core/manager.ts reads ~/.blockrun/.session directly, so if the proxy preferred legacy, Desktop would display and fund one address while the proxy spent from another — the fund-vs-spend mismatch that blocked #291.

So the options are roughly:

  • Core wins (today): unified across products, silent flip for existing installs.
  • Legacy wins: existing installs untouched, Desktop shows the wrong wallet.
  • Refuse when they disagree: no silent flip either way, names both addresses and asks the operator to pick. Costs a hard failure for anyone currently holding two different wallets.
  • Core wins, loudly: keep today's behavior, log both addresses at startup when they differ.

Whichever way it goes, Desktop and the proxy should resolve through the same function rather than each reading their own file.

Tests pinning current behavior: src/auth.payment-chain-default.test.ts ("reuses the canonical BlockRun Core wallets before a legacy saved wallet", "refuses to replace an invalid Core wallet with a legacy wallet").

cc @KillerQueen-Z — your design, so your call on which of these you intended.

🤖 Generated with Claude Code

https://claude.ai/code/session_017wMqBG57KZjH7TKybHN8BS

VickyXAI avatar Sep 02 '26 23:09 VickyXAI

Fixed in v0.12.274 (1d9d51f). Went with "Core wins, loudly".

Core still outranks the legacy wallet — preferring legacy reintroduces the fund-vs-spend mismatch that blocked #291, and refusing outright turns a working install into a hard failure for anyone legitimately holding two. The silence was the actual defect: startup now names both addresses and the one line that keeps paying from the funded one. ~/.blockrun/.chain overriding this install's saved chain is reported the same way.

Resolving through one function across Desktop and the proxy is the right follow-up but lives in the Desktop tree; not part of this.

VickyXAI avatar Sep 05 '26 22:09 VickyXAI