Browse Source

remove lightning parameter from wallet.create_request

patch-4
ThomasV 3 years ago
parent
commit
9ae0e5bffc
  1. 2
      electrum/commands.py
  2. 2
      electrum/gui/kivy/uix/screens.py
  3. 5
      electrum/gui/qml/qewallet.py
  4. 3
      electrum/gui/qt/receive_tab.py
  5. 3
      electrum/wallet.py

2
electrum/commands.py

@ -957,7 +957,7 @@ class Commands:
return False return False
amount = satoshis(amount) amount = satoshis(amount)
expiration = int(expiration) if expiration else None 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) req = wallet.get_request(key)
return wallet.export_request(req) return wallet.export_request(req)

2
electrum/gui/kivy/uix/screens.py

@ -515,7 +515,7 @@ class ReceiveScreen(CScreen):
return return
self.address = addr self.address = addr
try: 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: except InvoiceError as e:
self.app.show_error(_('Error creating payment request') + ':\n' + str(e)) self.app.show_error(_('Error creating payment request') + ':\n' + str(e))
return return

5
electrum/gui/qml/qewallet.py

@ -469,7 +469,7 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
return return
addr = self.wallet.create_new_address(False) 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: #try:
#self.wallet.add_payment_request(req) #self.wallet.add_payment_request(req)
#except Exception as e: #except Exception as e:
@ -486,6 +486,7 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
@pyqtSlot(QEAmount, str, int, bool) @pyqtSlot(QEAmount, str, int, bool)
@pyqtSlot(QEAmount, str, int, bool, 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): 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: try:
if is_lightning: if is_lightning:
if not self.wallet.lnworker.channels: 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 maybe show a warning if amount exceeds lnworker.num_sats_can_receive (as in kivy)
# TODO fallback address robustness # TODO fallback address robustness
addr = self.wallet.get_unused_address() 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: else:
key, addr = self.create_bitcoin_request(amount.satsInt, message, expiration, ignore_gap) key, addr = self.create_bitcoin_request(amount.satsInt, message, expiration, ignore_gap)
if not key: if not key:

3
electrum/gui/qt/receive_tab.py

@ -325,9 +325,8 @@ class ReceiveTab(QWidget, MessageBoxMixin, Logger):
self.window.address_list.update() self.window.address_list.update()
# generate even if we cannot receive # generate even if we cannot receive
lightning = self.wallet.has_lightning()
try: 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: except InvoiceError as e:
self.show_error(_('Error creating payment request') + ':\n' + str(e)) self.show_error(_('Error creating payment request') + ':\n' + str(e))
return return

3
electrum/wallet.py

@ -2424,12 +2424,13 @@ class Abstract_Wallet(ABC, Logger, EventListener):
status = self.get_request_status(addr) status = self.get_request_status(addr)
util.trigger_callback('request_status', self, addr, status) 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 # for receiving
amount_sat = amount_sat or 0 amount_sat = amount_sat or 0
exp_delay = exp_delay or 0 exp_delay = exp_delay or 0
timestamp = int(time.time()) timestamp = int(time.time())
fallback_address = address if self.config.get('bolt11_fallback', True) else None fallback_address = address if self.config.get('bolt11_fallback', True) else None
lightning = self.has_lightning()
if lightning: if lightning:
lightning_invoice = self.lnworker.add_request( lightning_invoice = self.lnworker.add_request(
amount_sat=amount_sat, amount_sat=amount_sat,

Loading…
Cancel
Save