Skip to content

fix(satoshi-wallet): recover from runtime Core wallet unloads - #1294

Merged
macterra merged 2 commits into
mainfrom
fix/1288-runtime-wallet-recovery
Sep 25, 2026
Merged

macterra merged 2 commits into
mainfrom
fix/1288-runtime-wallet-recovery

Conversation

@macterra

Copy link
Copy Markdown
Collaborator

After Bitcoin Core unloaded the configured watch-only wallet, Satoshi wallet requests could fail indefinitely because successful startup permanently disabled setup retries. Core RPC error -18 now clears wallet readiness and schedules the existing 30-second setup retry. Requests return 503 for that condition; the existing 60-second metrics collector also detects idle unloads.

Startup, manual setup, and runtime recovery share one in-flight setup attempt. Recovery reuses descriptor validation, stops on descriptor mismatch or missing SQLite support, and clears the retry timer on success. Failed sends, anchors, and fee bumps are returned to the caller without automatic replay. Runtime unload detection applies only to the Bitcoin Core backend.

Updated #1288 and the service documentation to reflect this scope. Added fast coordinator tests and a separate built-service integration command that uses the actual Bitcoin RPC client against isolated HTTP fixtures with real 30/60-second timers.

Validation:

  • Wallet service build and root typecheck passed.
  • Root lint passed with two pre-existing warnings; changed-file lint clean.
  • 129 tests passed across 16 wallet/mediator suites.
  • npm run test:recovery --prefix services/mediators/satoshi-wallet passed: successful startup, concurrent request failures with HTTP 500 / RPC -18 envelopes, HTTP 503 responses, automatic reload, idle metrics recovery, unrelated RPC errors retaining 500, descriptor refusal, and explicit manual repair. Uses no live wallet or node.

Closes #1288.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The wallet-info route suppresses RPC -18, preventing recovery and the documented 503 response.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds runtime recovery when Bitcoin Core unloads the Satoshi watch-only wallet.

Changes:

  • Introduces shared setup/retry coordination and -18 detection.
  • Returns 503 during recovery and monitors idle unloads via metrics.
  • Adds unit/integration coverage and documentation.
File Description
wallet-recovery.ts Coordinates readiness, retries, and fatal failures.
wallet-api.ts Integrates runtime recovery into API and metrics.
runtime-recovery.test.ts Tests coordinator behavior.
runtime-recovery.integration.mjs Tests built-service recovery with RPC fixtures.
package.json Adds the recovery integration command.
README.md Documents recovery behavior and testing.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread services/mediators/satoshi-wallet/src/wallet-api.ts
@macterra
macterra enabled auto-merge (squash) September 25, 2026 18:31
@macterra
macterra merged commit a99cf57 into main Sep 25, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(satoshi-wallet): recover when Bitcoin Core unloads the wallet at runtime

2 participants