Browse Source

Allow requests that never expire

hard-fail-on-bad-server-string
ThomasV 5 years ago
parent
commit
f08796fe68
  1. 2
      electrum/gui/qt/request_list.py
  2. 8
      electrum/util.py
  3. 6
      electrum/wallet.py

2
electrum/gui/qt/request_list.py

@ -117,7 +117,7 @@ class RequestList(MyTreeView):
continue continue
request_type = req['type'] request_type = req['type']
timestamp = req.get('time', 0) timestamp = req.get('time', 0)
expiration = req.get('exp', None) expiration = req.get('exp', 0)
amount = req.get('amount') amount = req.get('amount')
message = req.get('message') or req.get('memo') message = req.get('message') or req.get('memo')
date = format_time(timestamp) date = format_time(timestamp)

8
electrum/util.py

@ -104,6 +104,7 @@ pr_tooltips = {
} }
pr_expiration_values = { pr_expiration_values = {
0: _('Never'),
10*60: _('10 minutes'), 10*60: _('10 minutes'),
60*60: _('1 hour'), 60*60: _('1 hour'),
24*60*60: _('1 day'), 24*60*60: _('1 day'),
@ -112,12 +113,13 @@ pr_expiration_values = {
def get_request_status(req): def get_request_status(req):
status = req['status'] status = req['status']
if req['status'] == PR_UNPAID and 'exp' in req and req['time'] + req['exp'] < time.time(): exp = req.get('exp', 0)
if req['status'] == PR_UNPAID and exp > 0 and req['time'] + req['exp'] < time.time():
status = PR_EXPIRED status = PR_EXPIRED
status_str = pr_tooltips[status] status_str = pr_tooltips[status]
if status == PR_UNPAID: if status == PR_UNPAID:
if req.get('exp'): if exp > 0:
expiration = req['exp'] + req['time'] expiration = exp + req['time']
status_str = _('Expires') + ' ' + age(expiration, include_seconds=True) status_str = _('Expires') + ' ' + age(expiration, include_seconds=True)
else: else:
status_str = _('Pending') status_str = _('Pending')

6
electrum/wallet.py

@ -1527,12 +1527,10 @@ class Abstract_Wallet(AddressSynchronizer):
timestamp = r.get('time', 0) timestamp = r.get('time', 0)
if timestamp and type(timestamp) != int: if timestamp and type(timestamp) != int:
timestamp = 0 timestamp = 0
expiration = r.get('exp') exp = r.get('exp', 0)
if expiration and type(expiration) != int:
expiration = 0
paid, conf = self.get_payment_status(address, amount) paid, conf = self.get_payment_status(address, amount)
if not paid: if not paid:
if expiration is not None and time.time() > timestamp + expiration: if exp > 0 and time.time() > timestamp + exp:
status = PR_EXPIRED status = PR_EXPIRED
else: else:
status = PR_UNPAID status = PR_UNPAID

Loading…
Cancel
Save