mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 01:11:35 +00:00
parent
f1d54d3cd8
commit
c66c54a254
3 changed files with 28 additions and 12 deletions
|
@ -201,11 +201,31 @@ class ElectrumWindow(App):
|
|||
self.send_screen.set_ln_invoice(invoice)
|
||||
|
||||
def on_new_intent(self, intent):
|
||||
data = intent.getDataString()
|
||||
if intent.getScheme() == 'bitcoin':
|
||||
self.set_URI(data)
|
||||
elif intent.getScheme() == 'lightning':
|
||||
self.set_ln_invoice(data)
|
||||
data = str(intent.getDataString())
|
||||
if str(intent.getScheme()).lower() in ('bitcoin', 'lightning'):
|
||||
self._process_invoice_str(data)
|
||||
|
||||
_invoice_intent_queued = None # type: Optional[str]
|
||||
def _process_invoice_str(self, invoice: str) -> None:
|
||||
if not self.wallet:
|
||||
self._invoice_intent_queued = invoice
|
||||
return
|
||||
if not self.send_screen:
|
||||
self.switch_to('send')
|
||||
self._invoice_intent_queued = invoice
|
||||
return
|
||||
if invoice.lower().startswith('bitcoin:'):
|
||||
self.set_URI(invoice)
|
||||
elif invoice.lower().startswith('lightning:'):
|
||||
self.set_ln_invoice(invoice)
|
||||
|
||||
def _maybe_process_queued_invoice(self, *dt):
|
||||
if not self.wallet:
|
||||
return
|
||||
invoice_queued = self._invoice_intent_queued
|
||||
if invoice_queued:
|
||||
self._invoice_intent_queued = None
|
||||
self._process_invoice_str(invoice_queued)
|
||||
|
||||
def on_language(self, instance, language):
|
||||
Logger.info('language: {}'.format(language))
|
||||
|
@ -377,6 +397,7 @@ class ElectrumWindow(App):
|
|||
self._trigger_update_interfaces = Clock.create_trigger(self.update_interfaces, .5)
|
||||
|
||||
self._periodic_update_status_during_sync = Clock.schedule_interval(self.update_wallet_synchronizing_progress, .5)
|
||||
self._periodic_process_queued_invoice = Clock.schedule_interval(self._maybe_process_queued_invoice, .5)
|
||||
|
||||
# cached dialogs
|
||||
self._settings_dialog = None
|
||||
|
|
|
@ -177,12 +177,10 @@ class SendScreen(CScreen):
|
|||
|
||||
kvname = 'send'
|
||||
payment_request = None # type: Optional[PaymentRequest]
|
||||
payment_request_queued = None # type: Optional[str]
|
||||
parsed_URI = None
|
||||
|
||||
def set_URI(self, text: str):
|
||||
if not self.app.wallet:
|
||||
self.payment_request_queued = text
|
||||
return
|
||||
try:
|
||||
uri = parse_URI(text, self.app.on_pr, loop=self.app.asyncio_loop)
|
||||
|
@ -197,7 +195,7 @@ class SendScreen(CScreen):
|
|||
self.payment_request = None
|
||||
self.is_lightning = False
|
||||
|
||||
def set_ln_invoice(self, invoice):
|
||||
def set_ln_invoice(self, invoice: str):
|
||||
try:
|
||||
invoice = str(invoice).lower()
|
||||
lnaddr = lndecode(invoice, expected_hrp=constants.net.SEGWIT_HRP)
|
||||
|
@ -213,9 +211,6 @@ class SendScreen(CScreen):
|
|||
def update(self):
|
||||
if self.app.wallet is None:
|
||||
return
|
||||
if self.payment_request_queued:
|
||||
self.set_URI(self.payment_request_queued)
|
||||
self.payment_request_queued = None
|
||||
_list = self.app.wallet.get_invoices()
|
||||
_list.reverse()
|
||||
payments_container = self.ids.payments_container
|
||||
|
|
|
@ -96,7 +96,7 @@ class RequestList(MyTreeView):
|
|||
self.update()
|
||||
return
|
||||
if req.is_lightning():
|
||||
self.parent.receive_payreq_e.setText(req.invoice)
|
||||
self.parent.receive_payreq_e.setText(req.invoice) # TODO maybe prepend "lightning:" ??
|
||||
self.parent.receive_address_e.setText(req.invoice)
|
||||
else:
|
||||
self.parent.receive_payreq_e.setText(self.parent.wallet.get_request_URI(req))
|
||||
|
|
Loading…
Add table
Reference in a new issue