From 9ae0e5bffc8c6563bd43850db69293b03618306a Mon Sep 17 00:00:00 2001 From: ThomasV Date: Mon, 11 Jul 2022 13:52:13 +0200 Subject: [PATCH] remove lightning parameter from wallet.create_request --- electrum/commands.py | 2 +- electrum/gui/kivy/uix/screens.py | 2 +- electrum/gui/qml/qewallet.py | 5 +++-- electrum/gui/qt/receive_tab.py | 3 +-- electrum/wallet.py | 3 ++- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/electrum/commands.py b/electrum/commands.py index c952b0221..329fbebae 100644 --- a/electrum/commands.py +++ b/electrum/commands.py @@ -957,7 +957,7 @@ class Commands: return False amount = satoshis(amount) expiration = int(expiration) if expiration else None - key = wallet.create_request(amount, memo, expiration, addr, True) + key = wallet.create_request(amount, memo, expiration, addr) req = wallet.get_request(key) return wallet.export_request(req) diff --git a/electrum/gui/kivy/uix/screens.py b/electrum/gui/kivy/uix/screens.py index 0aec77690..fabf86896 100644 --- a/electrum/gui/kivy/uix/screens.py +++ b/electrum/gui/kivy/uix/screens.py @@ -515,7 +515,7 @@ class ReceiveScreen(CScreen): return self.address = addr try: - key = self.app.wallet.create_request(amount_sat, message, expiry, self.address, lightning=self.app.wallet.has_lightning()) + key = self.app.wallet.create_request(amount_sat, message, expiry, self.address) except InvoiceError as e: self.app.show_error(_('Error creating payment request') + ':\n' + str(e)) return diff --git a/electrum/gui/qml/qewallet.py b/electrum/gui/qml/qewallet.py index fbb35b7ac..039205279 100644 --- a/electrum/gui/qml/qewallet.py +++ b/electrum/gui/qml/qewallet.py @@ -469,7 +469,7 @@ class QEWallet(AuthMixin, QObject, QtEventListener): return addr = self.wallet.create_new_address(False) - req_key = self.wallet.create_request(amount, message, expiration, addr, False) + req_key = self.wallet.create_request(amount, message, expiration, addr) #try: #self.wallet.add_payment_request(req) #except Exception as e: @@ -486,6 +486,7 @@ class QEWallet(AuthMixin, QObject, QtEventListener): @pyqtSlot(QEAmount, str, int, bool) @pyqtSlot(QEAmount, str, int, bool, bool) def create_request(self, amount: QEAmount, message: str, expiration: int, is_lightning: bool = False, ignore_gap: bool = False): + # TODO: unify this method and create_bitcoin_request try: if is_lightning: if not self.wallet.lnworker.channels: @@ -494,7 +495,7 @@ class QEWallet(AuthMixin, QObject, QtEventListener): # TODO maybe show a warning if amount exceeds lnworker.num_sats_can_receive (as in kivy) # TODO fallback address robustness addr = self.wallet.get_unused_address() - key = self.wallet.create_request(amount.satsInt, message, expiration, addr, True) + key = self.wallet.create_request(amount.satsInt, message, expiration, addr) else: key, addr = self.create_bitcoin_request(amount.satsInt, message, expiration, ignore_gap) if not key: diff --git a/electrum/gui/qt/receive_tab.py b/electrum/gui/qt/receive_tab.py index 28e6a963d..56b5802d7 100644 --- a/electrum/gui/qt/receive_tab.py +++ b/electrum/gui/qt/receive_tab.py @@ -325,9 +325,8 @@ class ReceiveTab(QWidget, MessageBoxMixin, Logger): self.window.address_list.update() # generate even if we cannot receive - lightning = self.wallet.has_lightning() try: - key = self.wallet.create_request(amount_sat, message, expiry, address, lightning=lightning) + key = self.wallet.create_request(amount_sat, message, expiry, address) except InvoiceError as e: self.show_error(_('Error creating payment request') + ':\n' + str(e)) return diff --git a/electrum/wallet.py b/electrum/wallet.py index f1d33718f..4ae7419eb 100644 --- a/electrum/wallet.py +++ b/electrum/wallet.py @@ -2424,12 +2424,13 @@ class Abstract_Wallet(ABC, Logger, EventListener): status = self.get_request_status(addr) util.trigger_callback('request_status', self, addr, status) - def create_request(self, amount_sat: int, message: str, exp_delay: int, address: str, lightning: bool): + def create_request(self, amount_sat: int, message: str, exp_delay: int, address: str): # for receiving amount_sat = amount_sat or 0 exp_delay = exp_delay or 0 timestamp = int(time.time()) fallback_address = address if self.config.get('bolt11_fallback', True) else None + lightning = self.has_lightning() if lightning: lightning_invoice = self.lnworker.add_request( amount_sat=amount_sat,