Browse Source

fix #5761

hard-fail-on-bad-server-string
ThomasV 5 years ago
parent
commit
aa37979100
  1. 5
      electrum/gui/qt/main_window.py
  2. 5
      electrum/lnworker.py

5
electrum/gui/qt/main_window.py

@ -1390,8 +1390,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
return False # no errors return False # no errors
def pay_lightning_invoice(self, invoice): def pay_lightning_invoice(self, invoice, amount_sat=None):
amount_sat = self.amount_e.get_amount()
attempts = LN_NUM_PAYMENT_ATTEMPTS attempts = LN_NUM_PAYMENT_ATTEMPTS
def task(): def task():
self.wallet.lnworker.pay(invoice, amount_sat, attempts) self.wallet.lnworker.pay(invoice, amount_sat, attempts)
@ -1469,7 +1468,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
def do_pay_invoice(self, invoice): def do_pay_invoice(self, invoice):
if invoice['type'] == PR_TYPE_LN: if invoice['type'] == PR_TYPE_LN:
self.pay_lightning_invoice(invoice['invoice']) self.pay_lightning_invoice(invoice['invoice'], amount_sat=invoice['amount'])
elif invoice['type'] == PR_TYPE_ONCHAIN: elif invoice['type'] == PR_TYPE_ONCHAIN:
outputs = invoice['outputs'] outputs = invoice['outputs']
self.pay_onchain_dialog(self.get_coins(), outputs, invoice=invoice) self.pay_onchain_dialog(self.get_coins(), outputs, invoice=invoice)

5
electrum/lnworker.py

@ -845,10 +845,10 @@ class LNWallet(LNWorker):
@log_exceptions @log_exceptions
async def _pay(self, invoice, amount_sat=None, attempts=1): async def _pay(self, invoice, amount_sat=None, attempts=1):
lnaddr = lndecode(invoice, expected_hrp=constants.net.SEGWIT_HRP) lnaddr = self._check_invoice(invoice, amount_sat)
payment_hash = lnaddr.paymenthash payment_hash = lnaddr.paymenthash
key = payment_hash.hex() key = payment_hash.hex()
amount = int(lnaddr.amount * COIN) if lnaddr.amount else None amount = int(lnaddr.amount * COIN)
status = self.get_payment_status(payment_hash) status = self.get_payment_status(payment_hash)
if status == PR_PAID: if status == PR_PAID:
raise PaymentFailure(_("This invoice has been paid already")) raise PaymentFailure(_("This invoice has been paid already"))
@ -856,7 +856,6 @@ class LNWallet(LNWorker):
raise PaymentFailure(_("A payment was already initiated for this invoice")) raise PaymentFailure(_("A payment was already initiated for this invoice"))
info = PaymentInfo(lnaddr.paymenthash, amount, SENT, PR_UNPAID) info = PaymentInfo(lnaddr.paymenthash, amount, SENT, PR_UNPAID)
self.save_payment_info(info) self.save_payment_info(info)
self._check_invoice(invoice, amount_sat)
self.wallet.set_label(key, lnaddr.get_description()) self.wallet.set_label(key, lnaddr.get_description())
log = self.logs[key] log = self.logs[key]
for i in range(attempts): for i in range(attempts):

Loading…
Cancel
Save