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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2018-03-07 10:36:47 +10:30 committed by Christian Decker
parent 6c1233de44
commit f8c8d55565

View File

@ -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,
};