From 7b49832a3f4f187e4718cc9d3e649c4453b7548f Mon Sep 17 00:00:00 2001 From: SomberNight Date: Mon, 16 Dec 2019 21:03:34 +0100 Subject: [PATCH] payment requests: fix explicit "None" expiration Traceback (most recent call last): File "...\electrum\electrum\gui\qt\main_window.py", line 994, in self.create_invoice_button.clicked.connect(lambda: self.create_invoice(False)) File "...\electrum\electrum\gui\qt\main_window.py", line 1123, in create_invoice key = self.create_bitcoin_request(amount, message, expiry) File "...\electrum\electrum\gui\qt\main_window.py", line 1132, in create_bitcoin_request addr = self.wallet.get_unused_address() File "...\electrum\electrum\wallet.py", line 1452, in wrapper addr = func(self, *args, **kwargs) File "...\electrum\electrum\wallet.py", line 1465, in get_unused_address addrs = self.get_unused_addresses() File "...\electrum\electrum\wallet.py", line 1459, in get_unused_addresses in_use_by_request = [k for k in self.receive_requests.keys() if self.get_request_status(k)[0] != PR_EXPIRED] File "...\electrum\electrum\wallet.py", line 1459, in in_use_by_request = [k for k in self.receive_requests.keys() if self.get_request_status(k)[0] != PR_EXPIRED] File "...\electrum\electrum\wallet.py", line 1535, in get_request_status if exp > 0 and time.time() > timestamp + exp: TypeError: '>' not supported between instances of 'NoneType' and 'int' --- electrum/gui/qt/request_list.py | 1 - electrum/util.py | 2 +- electrum/wallet.py | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/electrum/gui/qt/request_list.py b/electrum/gui/qt/request_list.py index b2e09339a..cb9212a9b 100644 --- a/electrum/gui/qt/request_list.py +++ b/electrum/gui/qt/request_list.py @@ -117,7 +117,6 @@ class RequestList(MyTreeView): continue request_type = req['type'] timestamp = req.get('time', 0) - expiration = req.get('exp', 0) amount = req.get('amount') message = req.get('message') or req.get('memo') date = format_time(timestamp) diff --git a/electrum/util.py b/electrum/util.py index 81e84c71c..f839d0fac 100644 --- a/electrum/util.py +++ b/electrum/util.py @@ -113,7 +113,7 @@ pr_expiration_values = { def get_request_status(req): status = req['status'] - exp = req.get('exp', 0) + exp = req.get('exp', 0) or 0 if req['status'] == PR_UNPAID and exp > 0 and req['time'] + req['exp'] < time.time(): status = PR_EXPIRED status_str = pr_tooltips[status] diff --git a/electrum/wallet.py b/electrum/wallet.py index 4d7e84ee4..2ac690837 100644 --- a/electrum/wallet.py +++ b/electrum/wallet.py @@ -1529,7 +1529,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC): timestamp = r.get('time', 0) if timestamp and type(timestamp) != int: timestamp = 0 - exp = r.get('exp', 0) + exp = r.get('exp', 0) or 0 paid, conf = self.get_payment_status(address, amount) if not paid: if exp > 0 and time.time() > timestamp + exp: