electrum

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

commit 0878fe08f77ce15d47a3b597a50a2b7e7e8f897f
parent 8cb36cb9692a6e9e42035e8d1c883a96f1b1344f
Author: ThomasV <thomasv@electrum.org>
Date:   Mon,  1 Jun 2020 22:18:08 +0200

do not display 'Expires in 100 years' for LN invoices

Diffstat:
Melectrum/invoices.py | 8+++++++-
Melectrum/lnworker.py | 8++------
2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/electrum/invoices.py b/electrum/invoices.py @@ -56,6 +56,12 @@ assert PR_DEFAULT_EXPIRATION_WHEN_CREATING in pr_expiration_values outputs_decoder = lambda _list: [PartialTxOutput.from_legacy_tuple(*x) for x in _list] +# hack: BOLT-11 is not really clear on what an expiry of 0 means. +# It probably interprets it as 0 seconds, so already expired... +# Our higher level invoices code however uses 0 for "never". +# Hence set some high expiration here +LN_EXPIRY_NEVER = 100 * 365 * 24 * 60 * 60 # 100 years + @attr.s class Invoice(StoredObject): type = attr.ib(type=int) @@ -70,7 +76,7 @@ class Invoice(StoredObject): def get_status_str(self, status): status_str = pr_tooltips[status] if status == PR_UNPAID: - if self.exp > 0: + if self.exp > 0 and self.exp != LN_EXPIRY_NEVER: expiration = self.exp + self.time status_str = _('Expires') + ' ' + age(expiration, include_seconds=True) else: diff --git a/electrum/lnworker.py b/electrum/lnworker.py @@ -24,7 +24,7 @@ from aiorpcx import run_in_thread from . import constants, util from . import keystore from .util import profiler -from .invoices import PR_TYPE_LN, PR_UNPAID, PR_EXPIRED, PR_PAID, PR_INFLIGHT, PR_FAILED, PR_ROUTING, LNInvoice +from .invoices import PR_TYPE_LN, PR_UNPAID, PR_EXPIRED, PR_PAID, PR_INFLIGHT, PR_FAILED, PR_ROUTING, LNInvoice, LN_EXPIRY_NEVER from .util import NetworkRetryManager from .lnutil import LN_MAX_FUNDING_SAT from .keystore import BIP32_KeyStore @@ -1086,11 +1086,7 @@ class LNWallet(LNWorker): info = PaymentInfo(payment_hash, amount_sat, RECEIVED, PR_UNPAID) amount_btc = amount_sat/Decimal(COIN) if amount_sat else None if expiry == 0: - # hack: BOLT-11 is not really clear on what an expiry of 0 means. - # It probably interprets it as 0 seconds, so already expired... - # Our higher level invoices code however uses 0 for "never". - # Hence set some high expiration here - expiry = 100 * 365 * 24 * 60 * 60 # 100 years + expiry = LN_EXPIRY_NEVER lnaddr = LnAddr(paymenthash=payment_hash, amount=amount_btc, tags=[('d', message),