mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 17:31:36 +00:00
follow-up prev
PaymentRequest.error is really not intuitive.........
This commit is contained in:
parent
d2de8de356
commit
0553ab7f3f
2 changed files with 10 additions and 10 deletions
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Add table
Reference in a new issue