From 0f191f5d4f133411faf0f88322ce09aa6d6b68e1 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Wed, 18 Apr 2018 15:23:15 +0200 Subject: [PATCH] opts: Add the --rescan option This is intended to recover from an inconsistent state, involving `onchaind`. Should we for some reason not restore the `onchaind` process correctly we can instruct `lightningd` to go back in time and just replay everything. Signed-off-by: Christian Decker --- lightningd/lightningd.h | 4 ++++ lightningd/options.c | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h index 087f6f093..0287a612a 100644 --- a/lightningd/lightningd.h +++ b/lightningd/lightningd.h @@ -72,6 +72,10 @@ struct config { /* Do we let the funder set any fee rate they want */ bool ignore_fee_limits; + + /* Number of blocks to rescan from the current head, or absolute + * blockheight if rescan >= 500'000 */ + s32 rescan; }; struct lightningd { diff --git a/lightningd/options.c b/lightningd/options.c index ec13b20dc..b35cb8ee3 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -309,6 +309,10 @@ static void config_register_opts(struct lightningd *ld) opt_register_arg("--fee-base", opt_set_u32, opt_show_u32, &ld->config.fee_base, "Millisatoshi minimum to charge for HTLC"); + opt_register_arg("--rescan", opt_set_s32, opt_show_s32, + &ld->config.rescan, + "Number of blocks to rescan from the current head, or " + "absolute blockheight if negative"); opt_register_arg("--fee-per-satoshi", opt_set_s32, opt_show_s32, &ld->config.fee_per_satoshi, "Microsatoshi fee for every satoshi in HTLC"); @@ -420,6 +424,9 @@ static const struct config testnet_config = { /* Testnet sucks */ .ignore_fee_limits = true, + + /* Rescan 5 hours of blocks on testnet, it's reorg happy */ + .rescan = 30, }; /* aka. "Dude, where's my coins?" */ @@ -481,6 +488,9 @@ static const struct config mainnet_config = { /* Mainnet should have more stable fees */ .ignore_fee_limits = false, + + /* Rescan 2.5 hours of blocks on startup, it's not so reorg happy */ + .rescan = 15, }; static void check_config(struct lightningd *ld)