Repository navigation
fix(repl): persist wallet after each command - #376
Open
emma31-dev wants to merge 1 commit into
Open
emma31-dev wants to merge 1 commit into
emma31-dev wants to merge 1 commit into
Conversation
The REPL loaded a persisted wallet but never called `wallet.persist()`, so every change made in a session was lost on exit: the address index rewound (reusing already handed-out addresses), and created or broadcast transactions, UTXO locks and scan results disappeared. Persist after each successful command, matching the non-REPL path, so the state also survives a crash or Ctrl-C instead of only being flushed on exit. Add a regression test that runs `wallet new_address` in two consecutive REPL processes and asserts the address index advances.
emma31-dev
force-pushed
the
fix/repl-wallet-persist
branch
from
November 14, 2026 19:55
11a6cb8 to
977a703
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #376 +/- ##
=======================================
Coverage 59.33% 59.34%
=======================================
Files 25 25
Lines 4562 4563 +1
=======================================
+ Hits 2707 2708 +1
Misses 1855 1855
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
tACK 977a703 The new test fails on master’s I also tested it manually. On master, I ran |
This branch has not been deployed
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.
Fixes #375
Description
REPL mode loaded a persisted wallet, but the REPL loop never called
wallet.persist(). The non-REPL path persists after every wallet command, so changes made inside the REPL were lost on exit.This adds
wallet.persist()?after every successful REPL command. Consequences of the bug this fixes:wallet new_addressrewound the address index each session, handing out already-used addressescreate_tx/bump_feeresults disappeared from the tx graphbroadcasttransactions were not recordedlock_utxo/unlock_utxostate was lostfull_scan/syncresults were discarded, so funds appeared missing until re-syncingNotes to the reviewers
exit, so a crash or Ctrl-C doesn't discard the session either. Persisting an empty changeset is a no-op in BDK, so the extra calls are cheap.cmd.execute(...)?skips the persist on error). Happy to change this if reviewers prefer persisting regardless.repl+sqlite(notrepl+electrumlike the existingrepl_tests) so it runs under the default feature set. It spawns two separate REPL processes against the same datadir and asserts the address index advances0 -> 1.master(0vs1) and passes with the fix.Checklists
All Submissions:
cargo fmtandcargo clippybefore committingBugfixes: