electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 7f3542f0801239cfe5e81feac6b54ad90213c289
parent bf4a9d7909ac98332fbec93e256032b1fad8e3c3
Author: ThomasV <thomasv@electrum.org>
Date:   Thu,  5 Mar 2020 10:51:22 +0100

lnworker: set invoice status if htlcs are received from previous session

Diffstat:
Melectrum/lnworker.py | 14++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git 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):