diff --git a/plugins/bkpr/blockheights.c b/plugins/bkpr/blockheights.c index 094c8489666c..e483a0662dd8 100644 --- a/plugins/bkpr/blockheights.c +++ b/plugins/bkpr/blockheights.c @@ -140,7 +140,7 @@ struct blockheights *init_blockheights(const tal_t *ctx, if (keytok->size != 3) goto weird; - if (!json_to_txid(buf, keytok + 2, &txid)) + if (!json_to_txid(buf, keytok + 3, &txid)) goto weird; if (!json_hex_to_be32(buf, hextok, &be_blockheight)) goto weird; diff --git a/tests/test_bookkeeper.py b/tests/test_bookkeeper.py index 2beceb8462f6..4186d917f990 100644 --- a/tests/test_bookkeeper.py +++ b/tests/test_bookkeeper.py @@ -1193,3 +1193,10 @@ def test_listincome_timebox(node_factory, bitcoind): incomes = l1.rpc.bkpr_listincome(end_time=first_one)['income_events'] assert [i for i in incomes if i['timestamp'] > first_one] == [] + + # We save blockheights in storage, so make sure we restore them on restart! + acctevents_before = l1.rpc.bkpr_listaccountevents() + l1.restart() + + acctevents_after = l1.rpc.bkpr_listaccountevents() + assert acctevents_after == acctevents_before