From 8354dd006bae178d197b5e524cde038eaaa35065 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Sat, 23 Apr 2022 12:06:24 +0200 Subject: [PATCH] fix receiving lightning requests without amount --- electrum/lnworker.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/electrum/lnworker.py b/electrum/lnworker.py index b782dc4cf..3d042b48c 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -1789,6 +1789,7 @@ class LNWallet(LNWorker): write_to_disk: bool = True, ) -> Tuple[LnAddr, str]: + assert amount_msat is None or amount_msat > 0 timestamp = int(time.time()) routing_hints = self.calc_routing_hints_for_invoice(amount_msat) if not routing_hints: @@ -1831,7 +1832,7 @@ class LNWallet(LNWorker): def add_request(self, amount_sat: Optional[int], message:str, expiry: int, fallback_address:str) -> str: # passed expiry is relative, it is absolute in the lightning invoice - amount_msat = amount_sat * 1000 if amount_sat is not None else None + amount_msat = amount_sat * 1000 if amount_sat else None timestamp = int(time.time()) lnaddr, invoice = self.create_invoice( amount_msat=amount_msat, @@ -1932,7 +1933,8 @@ class LNWallet(LNWorker): return if info is None and status == PR_SCHEDULED: # we should add a htlc to our ctx, so that the funds are 'reserved' - info = PaymentInfo(payment_hash, 0, SENT, PR_SCHEDULED) + # Note: info.amount will be added by pay_invoice + info = PaymentInfo(payment_hash, None, SENT, PR_SCHEDULED) info = info._replace(status=status) self.save_payment_info(info)