lightningd: fix crash on startup expirations.

The wait code assumes ld->wallet is populated, but it's not.  Start the
expiration cycle later.

```
0x7f271a18d08f ??? /build/glibc-SzIz7B/glibc-2.31/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0x5581a27dc082 wait_index_increment lightningd/wait.c:112
0x5581a27e331a invoice_index_inc wallet/invoices.c:738
0x5581a27e3dfe invoice_index_update_status wallet/invoices.c:775
0x5581a27e3ea3 trigger_expiration wallet/invoices.c:185
0x5581a27e3f47 invoices_new wallet/invoices.c:134
0x5581a27e8a2c wallet_new wallet/wallet.c:121
0x5581a27b08b5 main lightningd/lightningd.c:1082
```

Fixes: #6457
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2023-07-31 18:34:42 +09:30
parent 4b173eec3b
commit 2c2592fe36
5 changed files with 20 additions and 4 deletions

View File

@@ -77,6 +77,7 @@
#include <lightningd/runes.h>
#include <lightningd/subd.h>
#include <sys/resource.h>
#include <wallet/invoices.h>
#include <wallet/txfilter.h>
#include <wally_bip32.h>
@@ -1192,6 +1193,9 @@ int main(int argc, char *argv[])
/*~ Finish our runes initialization (includes reading from db) */
runes_finish_init(ld->runes);
/*~ Start expiring old invoices now ld->wallet is set.*/
invoices_start_expiration(ld);
/*~ That's all of the wallet db operations for now. */
db_commit_transaction(ld->wallet->db);