Repository navigation
fix: require explicit wallet selection after account errors - #158
Merged
Merged
Conversation
VickyXAI
added a commit
that referenced
this pull request
Sep 5, 2026
main went red on `the mode is read at call time, not captured at import`. The code is right; the test was wrong. #163 landed before #158, when invalidateKey() demoted a session to wallet mode after a 401, so the test used it to prove the billing copy re-reads the mode. #158 changed that on purpose: a rejected key now only refreshes the credential, because an account failure is never permission to spend from a wallet. The property still holds — useWalletMode() (`--wallet`) is the lever that actually flips the mode. The test now uses it, and additionally asserts that invalidateKey() does NOT move billing to the wallet, so it cannot drift back. Both directions are mutation-tested: freezing the mode at import fails it, and restoring invalidateKey()'s old demotion fails it too. Claude-Session: https://claude.ai/code/session_01Rm7cRGtC7wCofhYuHRo21h Co-authored-by: 1bcMax <195689928+1bcMax@users.noreply.github.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An API 401 or unsupported-endpoint 404 silently replayed the request against a wallet gateway; a 401 also switched the rest of the process to wallet billing. This follow-up to #157 returns account errors without changing payment methods. Users can explicitly retry with --wallet.
Invalid, empty or unreadable configured keys now stop with an actionable error instead of selecting a wallet or another saved account. Key saving, rotation and logout refresh the active credential. README and agent instructions describe API registration/top-ups and explicit switching. The wallet reservation boundary test now uses a fixed clock instead of relying on a 1 ms scheduling window.
Validation: build and all 724 local tests pass. New tests cover 401/402/404/429/500 without wallet replay, invalid env/file configuration, explicit --wallet and key rotation/logout across Solana and Base. The fallback tests failed before this patch. Production paid Anthropic Messages SSE and Surf calls now pass against api.blockrun.ai, with account credit snapshots and matching portal receipts. Follow-up coverage found the separate Messages 402 path still invoked wallet signing; preserve the gateway credit error and never sign a key-authenticated request. Its regression test failed before the fix. No real wallet transfers were executed.
Based on current main, rather than the older open #156. Automatic account-to-wallet fallback is deliberately removed because it changes who pays.