wallet: Actually save the correct min_index when creating shachains

If we kill the daemon without performing any commits we ended up with
a 0 instead of UINT48_MAX which was expected.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker
2017-08-22 13:18:20 +02:00
committed by Rusty Russell
parent 1b3eeec8f1
commit 05aaaa1f49

View File

@@ -243,8 +243,10 @@ bool wallet_shachain_init(struct wallet *wallet, struct wallet_shachain *chain)
{ {
/* Create shachain */ /* Create shachain */
shachain_init(&chain->chain); shachain_init(&chain->chain);
if (!db_exec(__func__, wallet->db, if (!db_exec(
"INSERT INTO shachains (min_index, num_valid) VALUES (0,0);")) { __func__, wallet->db,
"INSERT INTO shachains (min_index, num_valid) VALUES (%"PRIu64",0);",
chain->chain.min_index)) {
return false; return false;
} }
chain->id = sqlite3_last_insert_rowid(wallet->db->sql); chain->id = sqlite3_last_insert_rowid(wallet->db->sql);