1
0

submarine swaps: use num_sats_can_receive_no_mpp, to prevent funds being locked

This commit is contained in:
ThomasV
2021-03-26 16:27:32 +01:00
parent bdd9c4823f
commit 41f22df26b
4 changed files with 18 additions and 4 deletions

View File

@@ -726,7 +726,7 @@ 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.lnworker.num_sats_can_receive(),
forward = int(min(self.swap_manager.num_sats_can_receive(),
# maximally supported swap amount by provider
self.swap_manager.get_max_amount(),
max_onchain_spend))

View File

@@ -126,7 +126,7 @@ 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.lnworker.num_sats_can_receive())
max_recv_amt = int(self.swap_manager.num_sats_can_receive())
max_amt = min(max_swap_amt, max_recv_amt)
if amount > max_amt:
amount = max_amt
@@ -149,7 +149,7 @@ class SwapDialog(WindowModalDialog):
if self.is_reverse and send_amount and send_amount > self.lnworker.num_sats_can_send():
# cannot send this much on lightning
recv_amount = None
if (not self.is_reverse) and recv_amount and recv_amount > self.lnworker.num_sats_can_receive():
if (not self.is_reverse) and recv_amount and recv_amount > self.swap_manager.num_sats_can_receive():
# cannot receive this much on lightning
recv_amount = None
self.recv_amount_e.follows = True
@@ -228,7 +228,7 @@ class SwapDialog(WindowModalDialog):
onchain_amount = self.send_amount_e.get_amount()
if lightning_amount is None or onchain_amount is None:
return
if lightning_amount > self.lnworker.num_sats_can_receive():
if lightning_amount > self.swap_manager.num_sats_can_receive():
if not self.window.question(CANNOT_RECEIVE_WARNING):
return
self.window.protect(self.do_normal_swap, (lightning_amount, onchain_amount))