From 7f3542f0801239cfe5e81feac6b54ad90213c289 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Thu, 5 Mar 2020 10:51:22 +0100 Subject: [PATCH] lnworker: set invoice status if htlcs are received from previous session --- electrum/lnworker.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/electrum/lnworker.py b/electrum/lnworker.py index e3d1524b7..2aaf106de 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -1201,16 +1201,22 @@ class LNWallet(LNWorker): def payment_failed(self, chan, payment_hash: bytes, reason): self.set_payment_status(payment_hash, PR_UNPAID) - f = self.pending_payments[payment_hash] - if not f.cancelled(): + f = self.pending_payments.get(payment_hash) + if f and not f.cancelled(): f.set_result((False, None, reason)) + else: + self.logger.info('received unexpected payment_failed, probably from previous session') + self.network.trigger_callback('invoice_status', payment_hash.hex()) def payment_sent(self, chan, payment_hash: bytes): self.set_payment_status(payment_hash, PR_PAID) preimage = self.get_preimage(payment_hash) - f = self.pending_payments[payment_hash] - if not f.cancelled(): + f = self.pending_payments.get(payment_hash) + if f and not f.cancelled(): f.set_result((True, preimage, None)) + else: + self.logger.info('received unexpected payment_sent, probably from previous session') + self.network.trigger_callback('invoice_status', payment_hash.hex()) self.network.trigger_callback('ln_payment_completed', payment_hash, chan.channel_id) def payment_received(self, chan, payment_hash: bytes):