diff --git a/daemon/db.c b/daemon/db.c index 552ba1cd3..71e38ffc4 100644 --- a/daemon/db.c +++ b/daemon/db.c @@ -1172,9 +1172,17 @@ static void db_check_version(struct lightningd_state *dstate) fatal("db_check_version:step gave %s:%s", sqlite3_errstr(err), sqlite3_errmsg(sql)); ver = sqlite3_column_str(stmt, 0); - if (!streq(ver, VERSION)) - fatal("DATABASE NEEDS UPDATE. Version %s does not match %s", - ver, VERSION); + if (!streq(ver, VERSION)) { + if (dstate->config.db_version_ignore) + log_unusual(dstate->base_log, + "DATABASE NEEDS UPDATE." + " Version %s does not match %s", + ver, VERSION); + else + fatal("DATABASE NEEDS UPDATE." + " Version %s does not match %s", + ver, VERSION); + } } tal_free(ctx); } diff --git a/daemon/lightningd.c b/daemon/lightningd.c index 17390b9d6..3d3938ead 100644 --- a/daemon/lightningd.c +++ b/daemon/lightningd.c @@ -161,6 +161,10 @@ static void config_register_opts(struct lightningd_state *dstate) opt_register_noarg("--disable-irc", opt_set_invbool, &dstate->config.use_irc, "Disable IRC peer discovery for routing"); + + opt_register_noarg("--ignore-dbversion", opt_set_bool, + &dstate->config.db_version_ignore, + "Continue despite invalid database version (DANGEROUS!)"); } static void dev_register_opts(struct lightningd_state *dstate) @@ -228,6 +232,9 @@ static const struct config testnet_config = { /* Discover new peers using IRC */ .use_irc = true, + + /* Don't ignore database version */ + .db_version_ignore = false, }; /* aka. "Dude, where's my coins?" */ @@ -289,6 +296,9 @@ static const struct config mainnet_config = { /* Discover new peers using IRC */ .use_irc = true, + + /* Don't ignore database version */ + .db_version_ignore = false, }; static void check_config(struct lightningd_state *dstate) diff --git a/daemon/lightningd.h b/daemon/lightningd.h index b81cfbd1f..520fc6c9a 100644 --- a/daemon/lightningd.h +++ b/daemon/lightningd.h @@ -62,6 +62,9 @@ struct config { /* Whether to enable IRC peer discovery. */ bool use_irc; + + /* Whether to ignore database version. */ + bool db_version_ignore; }; /* Here's where the global variables hide! */