Repository navigation
fix(repl): persist wallet after each command - #376
Open
emma31-dev wants to merge 2 commits into
Open
emma31-dev wants to merge 2 commits into
emma31-dev wants to merge 2 commits 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.
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: