diff --git a/plugins/bkpr/recorder.c b/plugins/bkpr/recorder.c index 82c3498c4a70..4b5170f61d99 100644 --- a/plugins/bkpr/recorder.c +++ b/plugins/bkpr/recorder.c @@ -175,7 +175,14 @@ bool find_txo_chain(const tal_t *ctx, bool is_complete = true; const char *start_acct_name; - assert(acct->open_event_db_id); + /* If we have lost our database and used recovery, this can be + * NULL. That's the least of our problems though! */ + if (!acct->open_event_db_id) { + plugin_log(cmd->plugin, LOG_BROKEN, + "Cannot find the open_event for %s: did we lose our db?", + acct->name); + return false; + } open_ev = find_chain_event_by_id(ctx, bkpr, cmd, *acct->open_event_db_id); diff --git a/tests/test_misc.py b/tests/test_misc.py index 5baebbcdce42..9e5416fd78fa 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -3141,7 +3141,7 @@ def test_emergencyrecover(node_factory, bitcoind): Test emergencyrecover """ l1, l2 = node_factory.get_nodes(2, opts=[{'may_reconnect': True, - 'broken_log': 'ERROR: Unknown commitment #.*, recovering our funds'}, + 'broken_log': 'ERROR: Unknown commitment #.*, recovering our funds|plugin-bookkeeper: Cannot find the open_event for '}, {'may_reconnect': True}]) l1.rpc.connect(l2.info['id'], 'localhost', l2.port) @@ -3177,6 +3177,9 @@ def test_emergencyrecover(node_factory, bitcoind): wait_for(lambda: l1.rpc.listfunds()["channels"][0]["state"] == "ONCHAIN") wait_for(lambda: l2.rpc.listfunds()["channels"][0]["state"] == "ONCHAIN") + # Does bookkeeper get upset? + l1.rpc.bkpr_listbalances() + withdraw = l1.rpc.withdraw(l2.rpc.newaddr('bech32')['bech32'], 'all') # Should have two inputs assert len(bitcoind.rpc.decoderawtransaction(withdraw['tx'])['vin']) == 2