feat(lite): M5a — wallet persistence after sync/send/shield
Verified against the SDXL Rust source that the backend auto-saves only on new-address / import / rescan; it does NOT save after sync, send, or shield, and litelib_shutdown merely sets a flag. So without intervention a first sync (~30 min) and any sent transaction are lost on restart. The controller now triggers the backend `save` at exactly the right points: - after the detached `sync` completes — and BEFORE syncDone_ is set, so a syncComplete() observer always sees a fully persisted wallet; - after a successful send / shield (the doSend/doShield cores; skipped on failure so a failed broadcast doesn't write); - a guarded best-effort flush in the destructor, only when syncDone_ and no broadcast is in flight, so shutdown never blocks on the wallet lock held by an uninterruptible scan or in-progress proving; - plus a public saveWallet() for explicit/periodic saves. Wallet-file crash recovery (.dat / .dat.bak rotation) is already handled inside the backend. Tests: testLiteWalletControllerM5Persistence proves saves fire after sync/send/shield and explicit saveWallet(), and do NOT fire on a failed send or with no wallet open (fake gains a save counter). Plan doc updated; M5b (packaging/CI/signing/rollout) remains. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -173,6 +173,12 @@ public:
|
||||
LiteExportResult exportPrivateKeys(const std::string& optionalAddress = {});
|
||||
LiteSeedResult exportSeed();
|
||||
|
||||
// Persist the wallet to disk (backend `save`). The backend auto-saves on new-address/import,
|
||||
// but NOT after sync/send/shield — the controller triggers a save at those points so a scan
|
||||
// (~30 min on first run) and sent transactions survive a restart. Also callable explicitly.
|
||||
// Returns false when no wallet is open or the backend save fails.
|
||||
bool saveWallet();
|
||||
|
||||
// Poll sync status + fetch balance/addresses/transactions, and apply the result into the
|
||||
// app's WalletState. Returns true if state was updated. Safe no-op when no wallet is open.
|
||||
// Synchronous (blocks on the backend); used by tests and as the worker's unit of work.
|
||||
|
||||
Reference in New Issue
Block a user