invoices: don't modify .amount_msat directly
This commit is contained in:
@@ -178,6 +178,19 @@ class BaseInvoice(StoredObject):
|
||||
return amount_msat
|
||||
return int(amount_msat // 1000)
|
||||
|
||||
def set_amount_msat(self, amount_msat: Union[int, str]) -> None:
|
||||
"""The GUI uses this to fill the amount for a zero-amount invoice."""
|
||||
if amount_msat == "!":
|
||||
amount_sat = amount_msat
|
||||
else:
|
||||
assert isinstance(amount_msat, int), f"{amount_msat=!r}"
|
||||
assert amount_msat >= 0, amount_msat
|
||||
amount_sat = (amount_msat // 1000) + int(amount_msat % 1000 > 0) # round up
|
||||
if outputs := self.outputs:
|
||||
assert len(self.outputs) == 1, len(self.outputs)
|
||||
self.outputs = [PartialTxOutput(scriptpubkey=outputs[0].scriptpubkey, value=amount_sat)]
|
||||
self.amount_msat = amount_msat
|
||||
|
||||
@amount_msat.validator
|
||||
def _validate_amount(self, attribute, value):
|
||||
if value is None:
|
||||
|
||||
Reference in New Issue
Block a user