diff --git a/lightningd/pay.c b/lightningd/pay.c index cb7921230..6a2669771 100644 --- a/lightningd/pay.c +++ b/lightningd/pay.c @@ -431,6 +431,17 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout, &hout->payment_hash); #ifdef COMPAT_V052 + /* Prior to "pay: delete HTLC when we delete payment." we would + * delete a payment on retry, but leave the HTLC. */ + if (!payment) { + log_unusual(hout->key.channel->log, + "No payment for %s:" + " was this an old database?", + type_to_string(tmpctx, struct sha256, + &hout->payment_hash)); + return; + } + /* FIXME: Prior to 299b280f7, we didn't put route_nodes and * route_channels in db. If this happens, it's an old payment, * so we can simply mark it failed in db and return. */