electrum

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

commit 0553ab7f3ff31326571a197aa9b2218f4bc97097
parent d2de8de356213585eccb5d4b963429f9a674ed65
Author: SomberNight <somber.night@protonmail.com>
Date:   Wed,  5 Jun 2019 19:05:58 +0200

follow-up prev

PaymentRequest.error is really not intuitive.........

Diffstat:
Melectrum/gui/qt/main_window.py | 9+++------
Melectrum/paymentrequest.py | 11+++++++----
2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py @@ -37,6 +37,7 @@ import base64 from functools import partial import queue import asyncio +from typing import Optional from PyQt5.QtGui import QPixmap, QKeySequence, QIcon, QCursor from PyQt5.QtCore import Qt, QRect, QStringListModel, QSize, pyqtSignal @@ -71,6 +72,7 @@ from electrum.network import Network, TxBroadcastError, BestEffortRequestFailed from electrum.exchange_rate import FxThread from electrum.simple_config import SimpleConfig from electrum.logging import Logger +from electrum.paymentrequest import PR_PAID from .exception_window import Exception_Hook from .amountedit import AmountEdit, BTCAmountEdit, MyLineEdit, FeerateEdit @@ -109,9 +111,6 @@ class StatusBarButton(QPushButton): self.func() -from electrum.paymentrequest import PR_PAID - - class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): payment_request_ok_signal = pyqtSignal() @@ -141,7 +140,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): self.tray = gui_object.tray self.app = gui_object.app self.cleaned_up = False - self.payment_request = None + self.payment_request = None # type: Optional[paymentrequest.PaymentRequest] self.checking_accounts = False self.qr_window = None self.not_enough_funds = False @@ -1604,8 +1603,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): """ pr = self.payment_request if pr: - if pr.error: - return True if pr.has_expired(): self.show_error(_('Payment request has expired')) return True diff --git a/electrum/paymentrequest.py b/electrum/paymentrequest.py @@ -27,6 +27,7 @@ import sys import time import traceback import json +from typing import Optional import certifi import urllib.parse @@ -106,15 +107,15 @@ async def get_payment_request(url: str) -> 'PaymentRequest': else: data = None error = f"Unknown scheme for payment request. URL: {url}" - pr = PaymentRequest(data, error) + pr = PaymentRequest(data, error=error) return pr class PaymentRequest: - def __init__(self, data, error=None): + def __init__(self, data, *, error=None): self.raw = data - self.error = error + self.error = error # FIXME overloaded and also used when 'verify' succeeds self.parse(data) self.requestor = None # known after verify self.tx = None @@ -235,7 +236,9 @@ class PaymentRequest: self.error = "unknown algo" return False - def has_expired(self): + def has_expired(self) -> Optional[bool]: + if not hasattr(self, 'details'): + return None return self.details.expires and self.details.expires < int(time.time()) def get_expiration_date(self):