1
0

invoices: don't modify .amount_msat directly

This commit is contained in:
SomberNight
2023-08-22 18:12:15 +00:00
parent 4e6e6f76ca
commit ffa3acc013
6 changed files with 21 additions and 7 deletions

View File

@@ -351,7 +351,7 @@ class SendScreen(CScreen, Logger):
assert type(amount_sat) is int
invoice = Invoice.from_bech32(address)
if invoice.amount_msat is None:
invoice.amount_msat = int(amount_sat * 1000)
invoice.set_amount_msat(int(amount_sat * 1000))
return invoice
else:
# on-chain

View File

@@ -379,8 +379,7 @@ class QEInvoice(QObject, QtEventListener):
if self.amount.isEmpty:
if self.amountOverride.isEmpty:
raise Exception('can not pay 0 amount')
# TODO: is update amount_msat for overrideAmount sufficient?
self._effectiveInvoice.amount_msat = self.amountOverride.satsInt * 1000
self._effectiveInvoice.set_amount_msat(self.amountOverride.satsInt * 1000)
self._wallet.pay_lightning_invoice(self._effectiveInvoice)
@@ -627,9 +626,9 @@ class QEInvoiceParser(QEInvoice):
if not self._effectiveInvoice.amount_msat and not self.amountOverride.isEmpty:
if self.invoiceType == QEInvoice.Type.OnchainInvoice and self.amountOverride.isMax:
self._effectiveInvoice.amount_msat = '!'
self._effectiveInvoice.set_amount_msat('!')
else:
self._effectiveInvoice.amount_msat = self.amountOverride.satsInt * 1000
self._effectiveInvoice.set_amount_msat(self.amountOverride.satsInt * 1000)
self.canSave = False

View File

@@ -606,7 +606,7 @@ class ElectrumGui(BaseElectrumGui, EventListener):
if invoice.amount_msat is None:
amount_sat = self.parse_amount(self.str_amount)
if amount_sat:
invoice.amount_msat = int(amount_sat * 1000)
invoice.set_amount_msat(int(amount_sat * 1000))
else:
self.show_error(_('No amount'))
return