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 . import ElectrumGui
|
||||||
from electrum.simple_config import SimpleConfig
|
from electrum.simple_config import SimpleConfig
|
||||||
from electrum.plugin import Plugins
|
from electrum.plugin import Plugins
|
||||||
|
from electrum.paymentrequest import PaymentRequest
|
||||||
|
|
||||||
|
|
||||||
class ElectrumWindow(App):
|
class ElectrumWindow(App):
|
||||||
|
@ -364,13 +365,13 @@ class ElectrumWindow(App):
|
||||||
self.fee_status = self.electrum_config.get_fee_status()
|
self.fee_status = self.electrum_config.get_fee_status()
|
||||||
self.request_popup = None
|
self.request_popup = None
|
||||||
|
|
||||||
def on_pr(self, pr):
|
def on_pr(self, pr: 'PaymentRequest'):
|
||||||
if not self.wallet:
|
if not self.wallet:
|
||||||
self.show_error(_('No wallet loaded.'))
|
self.show_error(_('No wallet loaded.'))
|
||||||
return
|
return
|
||||||
if pr.verify(self.wallet.contacts):
|
if pr.verify(self.wallet.contacts):
|
||||||
key = pr.get_id()
|
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:
|
if invoice and invoice['status'] == PR_PAID:
|
||||||
self.show_error("invoice already paid")
|
self.show_error("invoice already paid")
|
||||||
self.send_screen.do_clear()
|
self.send_screen.do_clear()
|
||||||
|
|
|
@ -4,7 +4,7 @@ from decimal import Decimal
|
||||||
import re
|
import re
|
||||||
import threading
|
import threading
|
||||||
import traceback, sys
|
import traceback, sys
|
||||||
from typing import TYPE_CHECKING, List
|
from typing import TYPE_CHECKING, List, Optional
|
||||||
|
|
||||||
from kivy.app import App
|
from kivy.app import App
|
||||||
from kivy.cache import Cache
|
from kivy.cache import Cache
|
||||||
|
@ -43,6 +43,7 @@ from electrum.gui.kivy.i18n import _
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from electrum.gui.kivy.main_window import ElectrumWindow
|
from electrum.gui.kivy.main_window import ElectrumWindow
|
||||||
|
from electrum.paymentrequest import PaymentRequest
|
||||||
|
|
||||||
|
|
||||||
class HistoryRecycleView(RecycleView):
|
class HistoryRecycleView(RecycleView):
|
||||||
|
@ -183,11 +184,11 @@ class HistoryScreen(CScreen):
|
||||||
class SendScreen(CScreen):
|
class SendScreen(CScreen):
|
||||||
|
|
||||||
kvname = 'send'
|
kvname = 'send'
|
||||||
payment_request = None
|
payment_request = None # type: Optional[PaymentRequest]
|
||||||
payment_request_queued = None
|
payment_request_queued = None # type: Optional[str]
|
||||||
parsed_URI = None
|
parsed_URI = None
|
||||||
|
|
||||||
def set_URI(self, text):
|
def set_URI(self, text: str):
|
||||||
if not self.app.wallet:
|
if not self.app.wallet:
|
||||||
self.payment_request_queued = text
|
self.payment_request_queued = text
|
||||||
return
|
return
|
||||||
|
@ -263,7 +264,7 @@ class SendScreen(CScreen):
|
||||||
self.screen.locked = False
|
self.screen.locked = False
|
||||||
self.parsed_URI = None
|
self.parsed_URI = None
|
||||||
|
|
||||||
def set_request(self, pr):
|
def set_request(self, pr: 'PaymentRequest'):
|
||||||
self.screen.address = pr.get_requestor()
|
self.screen.address = pr.get_requestor()
|
||||||
amount = pr.get_amount()
|
amount = pr.get_amount()
|
||||||
self.screen.amount = self.app.format_amount_and_units(amount) if amount else ''
|
self.screen.amount = self.app.format_amount_and_units(amount) if amount else ''
|
||||||
|
@ -308,11 +309,14 @@ class SendScreen(CScreen):
|
||||||
message = self.screen.message
|
message = self.screen.message
|
||||||
if self.screen.is_lightning:
|
if self.screen.is_lightning:
|
||||||
return self.app.wallet.lnworker.parse_bech32_invoice(address)
|
return self.app.wallet.lnworker.parse_bech32_invoice(address)
|
||||||
else:
|
else: # on-chain
|
||||||
if not bitcoin.is_address(address):
|
if self.payment_request:
|
||||||
self.app.show_error(_('Invalid Bitcoin Address') + ':\n' + address)
|
outputs = self.payment_request.get_outputs()
|
||||||
return
|
else:
|
||||||
outputs = [PartialTxOutput.from_address_and_value(address, amount)]
|
if not bitcoin.is_address(address):
|
||||||
|
self.app.show_error(_('Invalid Bitcoin Address') + ':\n' + address)
|
||||||
|
return
|
||||||
|
outputs = [PartialTxOutput.from_address_and_value(address, amount)]
|
||||||
return self.app.wallet.create_invoice(outputs, message, self.payment_request, self.parsed_URI)
|
return self.app.wallet.create_invoice(outputs, message, self.payment_request, self.parsed_URI)
|
||||||
|
|
||||||
def do_save(self):
|
def do_save(self):
|
||||||
|
|
Loading…
Add table
Reference in a new issue