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
1 changed files with 4 additions and 2 deletions

View File

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