Example #1
0
 def _lnurl_get_invoice(self) -> None:
     assert self.lnurl_data
     try:
         amount = self.app.get_amount(self.amount)
     except:
         self.app.show_error(_('Invalid amount') + ':\n' + self.amount)
         return
     if not (self.lnurl_data.min_sendable_sat <= amount <=
             self.lnurl_data.max_sendable_sat):
         self.app.show_error(
             f'Amount must be between {self.lnurl_data.min_sendable_sat} and {self.lnurl_data.max_sendable_sat} sat.'
         )
         return
     try:
         # FIXME network request blocking GUI thread:
         invoice_data = Network.run_from_another_thread(
             callback_lnurl(
                 self.lnurl_data.callback_url,
                 params={'amount': amount * 1000},
             ))
     except LNURLError as e:
         self.app.show_error(f"LNURL request encountered error: {e}")
         self.do_clear()
         return
     invoice = invoice_data.get('pr')
     self.set_bolt11(invoice)
     self.lnurl_data = None
     self.is_lnurl = False
Example #2
0
 def set_lnurl6(self, lnurl: str):
     url = decode_lnurl(lnurl)
     domain = urlparse(url).netloc
     # FIXME network request blocking GUI thread:
     lnurl_data = Network.run_from_another_thread(request_lnurl(url))
     if not lnurl_data:
         return
     self.lnurl_data = lnurl_data
     self.address = "invoice from lnurl"
     self.message = f"lnurl: {domain}: {lnurl_data.metadata_plaintext}"
     self.amount = self.app.format_amount_and_units(
         lnurl_data.min_sendable_sat)
     self.is_lightning = True
     self.is_lnurl = True  # `bool(self.lnurl_data)` should be equivalent, this is only here as it is a kivy Property