From f8c8d5556522b92911c1f68661d20d4876f8ec7e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 7 Mar 2018 10:36:47 +1030 Subject: [PATCH] db: migrate old shutdown_keyidx_local -1 values onto key 0. It would be better to give them unique values, but we don't fully support db migrate anyway and this is simple (though they will end up using the same key for multiple channel closes if created before this commit). Note that even if bip32_max_index is currently unset, it defaults to 0 so it will be found. Signed-off-by: Rusty Russell --- wallet/db.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wallet/db.c b/wallet/db.c index 9ccc2d029..9e86226fe 100644 --- a/wallet/db.c +++ b/wallet/db.c @@ -230,6 +230,9 @@ char *dbmigrations[] = { /* Necessary index for long rollbacks of the blockchain, otherwise we're * doing table scans for every block removed. */ "CREATE INDEX utxoset_spend ON utxoset (spendheight)", + /* Assign key 0 to unassigned shutdown_keyidx_local. */ + "UPDATE channels SET shutdown_keyidx_local=0 WHERE shutdown_keyidx_local = -1;", + /* FIXME: We should rename shutdown_keyidx_local to final_key_index */ NULL, };