electrum

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

commit 730bfda33a0d5c29fc9f7c53b17a0e408a8c0829
parent 782bfd06e5ff1c6f5eb0ab70ea1ed966cf0d0f63
Author: ThomasV <thomasv@electrum.org>
Date:   Fri, 26 Jun 2020 11:14:23 +0200

OnchainInvoice: make get_amount_sat return 0 instead of None. fixes #6203

Diffstat:
Melectrum/invoices.py | 4++--
Melectrum/wallet.py | 7+++----
2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/electrum/invoices.py b/electrum/invoices.py @@ -125,8 +125,8 @@ class OnchainInvoice(Invoice): assert len(self.outputs) == 1 return self.outputs[0].address - def get_amount_sat(self) -> Union[int, str, None]: - return self.amount_sat + def get_amount_sat(self) -> Union[int, str]: + return self.amount_sat or 0 @classmethod def from_bip70_payreq(cls, pr: 'PaymentRequest') -> 'OnchainInvoice': diff --git a/electrum/wallet.py b/electrum/wallet.py @@ -1671,7 +1671,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC): status = self.lnworker.get_payment_status(bfh(r.rhash)) if self.lnworker else PR_UNKNOWN else: assert isinstance(r, OnchainInvoice) - paid, conf = self.get_payment_status(r.get_address(), r.amount_sat) + paid, conf = self.get_payment_status(r.get_address(), r.get_amount_sat()) status = PR_PAID if paid else PR_UNPAID return self.check_expired_status(r, status) @@ -1712,10 +1712,9 @@ class Abstract_Wallet(AddressSynchronizer, ABC): else: assert isinstance(x, OnchainInvoice) amount_sat = x.get_amount_sat() - assert isinstance(amount_sat, (int, str, type(None))) - d['amount_sat'] = amount_sat addr = x.get_address() - paid, conf = self.get_payment_status(addr, x.amount_sat) + paid, conf = self.get_payment_status(addr, amount_sat) + d['amount_sat'] = amount_sat d['address'] = addr d['URI'] = self.get_request_URI(x) if conf is not None: