electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 40fbf3a929abc040a4db675a69ae18427a647a4d
parent 305ca9064742d6bf6996d2757c1529fde30198e0
Author: ThomasV <thomasv@electrum.org>
Date:   Sun,  6 Dec 2020 12:37:25 +0100

follow-up c66c54a (simplification)

Diffstat:
Melectrum/gui/kivy/main_window.py | 41++++++++++++++---------------------------
1 file changed, 14 insertions(+), 27 deletions(-)

diff --git a/electrum/gui/kivy/main_window.py b/electrum/gui/kivy/main_window.py @@ -192,40 +192,28 @@ class ElectrumWindow(App, Logger): def on_use_unconfirmed(self, instance, x): self.electrum_config.set_key('confirmed_only', not self.use_unconfirmed, True) + def switch_to_send_screen(func): + # try until send_screen is available + def wrapper(self, *args): + f = lambda dt: (bool(func(self, *args) and False) if self.send_screen else bool(self.switch_to('send') or True)) if self.wallet else True + Clock.schedule_interval(f, 0.1) + return wrapper + + @switch_to_send_screen def set_URI(self, uri): - self.switch_to('send') self.send_screen.set_URI(uri) + @switch_to_send_screen def set_ln_invoice(self, invoice): - self.switch_to('send') self.send_screen.set_ln_invoice(invoice) def on_new_intent(self, intent): 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) + scheme = str(intent.getScheme()).lower() + if scheme == 'bitcoin': + self.set_URI(data) + elif scheme == 'lightning': + self.set_ln_invoice(data) def on_language(self, instance, language): self.logger.info('language: {}'.format(language)) @@ -398,7 +386,6 @@ class ElectrumWindow(App, Logger): 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