swaps: (fix) for forward swaps, correctly consider num_sats_can_receive
Previously the min() was passed lightning amounts and on-chain amounts mixed; which is conceptually a type error. It is now only passed on-chain amounts. Due to the bug, we did not allow a swap to fully exhaust out "LN receive" capacity. Now the max amt can be slighly larger.
This commit is contained in:
@@ -726,7 +726,9 @@ class SwapDialog(Factory.Popup):
|
||||
max_onchain_spend = 0
|
||||
reverse = int(min(self.lnworker.num_sats_can_send(),
|
||||
self.swap_manager.get_max_amount()))
|
||||
forward = int(min(self.swap_manager.num_sats_can_receive(),
|
||||
max_recv_amt_ln = int(self.swap_manager.num_sats_can_receive())
|
||||
max_recv_amt_oc = self.swap_manager.get_send_amount(max_recv_amt_ln, is_reverse=False) or float('inf')
|
||||
forward = int(min(max_recv_amt_oc,
|
||||
# maximally supported swap amount by provider
|
||||
self.swap_manager.get_max_amount(),
|
||||
max_onchain_spend))
|
||||
|
||||
@@ -126,8 +126,9 @@ class SwapDialog(WindowModalDialog):
|
||||
if self.tx:
|
||||
amount = self.tx.output_value_for_address(ln_dummy_address())
|
||||
max_swap_amt = self.swap_manager.get_max_amount()
|
||||
max_recv_amt = int(self.swap_manager.num_sats_can_receive())
|
||||
max_amt = min(max_swap_amt, max_recv_amt)
|
||||
max_recv_amt_ln = int(self.swap_manager.num_sats_can_receive())
|
||||
max_recv_amt_oc = self.swap_manager.get_send_amount(max_recv_amt_ln, is_reverse=False) or float('inf')
|
||||
max_amt = int(min(max_swap_amt, max_recv_amt_oc))
|
||||
if amount > max_amt:
|
||||
amount = max_amt
|
||||
self._update_tx(amount)
|
||||
|
||||
Reference in New Issue
Block a user