From 11b5f310340a8ef265d69a85cb7669cb8c45fae0 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 25 Jul 2023 12:44:38 +0930 Subject: [PATCH] lightningd: clean up commando rune_counter from datastore on migration. Pointed out by @ShahanaFarooqui, we leave a single unused entry in the datastore, so we should clean that up too. Signed-off-by: Rusty Russell --- tests/test_runes.py | 4 ++-- wallet/wallet.c | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/test_runes.py b/tests/test_runes.py index 70ce99f6b..e006f9644 100644 --- a/tests/test_runes.py +++ b/tests/test_runes.py @@ -438,7 +438,7 @@ def test_commando_rune_migration(node_factory): l1.daemon.wait_for_logs(['Transferring commando rune to db: '] * 2) # datastore should be empty: - assert l1.rpc.listdatastore(['commando', 'runes']) == {'datastore': []} + assert l1.rpc.listdatastore(['commando']) == {'datastore': []} # Should match commando results! assert l1.rpc.showrunes() == {'runes': [{'rune': @@ -463,7 +463,7 @@ def test_commando_blacklist_migration(node_factory): l1.daemon.wait_for_logs(['Transferring commando blacklist to db: '] * 2) # datastore should be empty: - assert l1.rpc.listdatastore(['commando', 'blacklist']) == {'datastore': []} + assert l1.rpc.listdatastore(['commando']) == {'datastore': []} # Should match commando results! assert l1.rpc.blacklistrune() == {'blacklist': [{'start': 0, 'end': 6}, diff --git a/wallet/wallet.c b/wallet/wallet.c index 5e6f0226b..d73865fe7 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -5722,4 +5722,10 @@ void migrate_datastore_commando_runes(struct lightningd *ld, struct db *db) db_insert_blacklist(db, &b); } db_datastore_remove(db, startkey); + + /* Might as well clean up "rune_counter" while we're here, so + * commando datastore is completely clean. */ + startkey[0] = "commando"; + startkey[1] = "rune_counter"; + db_datastore_remove(db, startkey); }