mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
fix paying bip70 payment request with Kivy GUI
This commit is contained in:
parent
1d0aa4042a
commit
96fa03c11b
2 changed files with 17 additions and 12 deletions
|
@ -82,6 +82,7 @@ if TYPE_CHECKING:
|
|||
from . import ElectrumGui
|
||||
from electrum.simple_config import SimpleConfig
|
||||
from electrum.plugin import Plugins
|
||||
from electrum.paymentrequest import PaymentRequest
|
||||
|
||||
|
||||
class ElectrumWindow(App):
|
||||
|
@ -364,13 +365,13 @@ class ElectrumWindow(App):
|
|||
self.fee_status = self.electrum_config.get_fee_status()
|
||||
self.request_popup = None
|
||||
|
||||
def on_pr(self, pr):
|
||||
def on_pr(self, pr: 'PaymentRequest'):
|
||||
if not self.wallet:
|
||||
self.show_error(_('No wallet loaded.'))
|
||||
return
|
||||
if pr.verify(self.wallet.contacts):
|
||||
key = pr.get_id()
|
||||
invoice = self.wallet.get_invoice(key)
|
||||
invoice = self.wallet.get_invoice(key) # FIXME wrong key...
|
||||
if invoice and invoice['status'] == PR_PAID:
|
||||
self.show_error("invoice already paid")
|
||||
self.send_screen.do_clear()
|
||||
|
|
|
@ -4,7 +4,7 @@ from decimal import Decimal
|
|||
import re
|
||||
import threading
|
||||
import traceback, sys
|
||||
from typing import TYPE_CHECKING, List
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
|
||||
from kivy.app import App
|
||||
from kivy.cache import Cache
|
||||
|
@ -43,6 +43,7 @@ from electrum.gui.kivy.i18n import _
|
|||
|
||||
if TYPE_CHECKING:
|
||||
from electrum.gui.kivy.main_window import ElectrumWindow
|
||||
from electrum.paymentrequest import PaymentRequest
|
||||
|
||||
|
||||
class HistoryRecycleView(RecycleView):
|
||||
|
@ -183,11 +184,11 @@ class HistoryScreen(CScreen):
|
|||
class SendScreen(CScreen):
|
||||
|
||||
kvname = 'send'
|
||||
payment_request = None
|
||||
payment_request_queued = None
|
||||
payment_request = None # type: Optional[PaymentRequest]
|
||||
payment_request_queued = None # type: Optional[str]
|
||||
parsed_URI = None
|
||||
|
||||
def set_URI(self, text):
|
||||
def set_URI(self, text: str):
|
||||
if not self.app.wallet:
|
||||
self.payment_request_queued = text
|
||||
return
|
||||
|
@ -263,7 +264,7 @@ class SendScreen(CScreen):
|
|||
self.screen.locked = False
|
||||
self.parsed_URI = None
|
||||
|
||||
def set_request(self, pr):
|
||||
def set_request(self, pr: 'PaymentRequest'):
|
||||
self.screen.address = pr.get_requestor()
|
||||
amount = pr.get_amount()
|
||||
self.screen.amount = self.app.format_amount_and_units(amount) if amount else ''
|
||||
|
@ -308,6 +309,9 @@ class SendScreen(CScreen):
|
|||
message = self.screen.message
|
||||
if self.screen.is_lightning:
|
||||
return self.app.wallet.lnworker.parse_bech32_invoice(address)
|
||||
else: # on-chain
|
||||
if self.payment_request:
|
||||
outputs = self.payment_request.get_outputs()
|
||||
else:
|
||||
if not bitcoin.is_address(address):
|
||||
self.app.show_error(_('Invalid Bitcoin Address') + ':\n' + address)
|
||||
|
|
Loading…
Add table
Reference in a new issue