qt swaps: fix _spend_max_reverse_swap: round down msats
Clicking "max" btn for a reverse swap was setting the text field to a too high value.
```
>>> wallet.lnworker.num_sats_can_send()
Decimal('1242647.947')
>>> util.format_satoshis_plain(Decimal('1242647.947'))
'0.01242648'
```
This commit is contained in:
@@ -193,6 +193,7 @@ class SwapDialog(WindowModalDialog, QtEventListener):
|
||||
|
||||
def _spend_max_reverse_swap(self) -> None:
|
||||
amount = min(self.lnworker.num_sats_can_send(), self.swap_manager.get_max_amount())
|
||||
amount = int(amount) # round down msats
|
||||
self.send_amount_e.setAmount(amount)
|
||||
|
||||
def on_send_edited(self):
|
||||
|
||||
@@ -967,14 +967,16 @@ class SwapManager(Logger):
|
||||
self._max_amount = pairs.max_amount
|
||||
self.is_initialized.set()
|
||||
|
||||
def get_max_amount(self):
|
||||
def get_max_amount(self) -> int:
|
||||
"""in satoshis"""
|
||||
return self._max_amount
|
||||
|
||||
def get_min_amount(self):
|
||||
def get_min_amount(self) -> int:
|
||||
"""in satoshis"""
|
||||
return self._min_amount
|
||||
|
||||
def check_invoice_amount(self, x):
|
||||
return x >= self.get_min_amount() and x <= self.get_max_amount()
|
||||
def check_invoice_amount(self, x) -> bool:
|
||||
return self.get_min_amount() <= x <= self.get_max_amount()
|
||||
|
||||
def _get_recv_amount(self, send_amount: Optional[int], *, is_reverse: bool) -> Optional[int]:
|
||||
"""For a given swap direction and amount we send, returns how much we will receive.
|
||||
|
||||
Reference in New Issue
Block a user