From c3776943477343d7bf943afee6e76969d8fdda3f Mon Sep 17 00:00:00 2001 From: bitromortac Date: Thu, 17 Dec 2020 06:44:27 +0100 Subject: [PATCH] swaps: limit forward amount to receivable amount on lightning --- electrum/gui/qt/swap_dialog.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/electrum/gui/qt/swap_dialog.py b/electrum/gui/qt/swap_dialog.py index 828e7c984..d2aaf7089 100644 --- a/electrum/gui/qt/swap_dialog.py +++ b/electrum/gui/qt/swap_dialog.py @@ -126,14 +126,15 @@ class SwapDialog(WindowModalDialog): self._update_tx('!') if self.tx: amount = self.tx.output_value_for_address(ln_dummy_address()) - max_amt = self.swap_manager.get_max_amount() + max_swap_amt = self.swap_manager.get_max_amount() + max_recv_amt = int(self.lnworker.num_sats_can_receive()) + max_amt = min(max_swap_amt, max_recv_amt) if amount > max_amt: amount = max_amt self._update_tx(amount) if self.tx: amount = self.tx.output_value_for_address(ln_dummy_address()) assert amount <= max_amt - # TODO: limit onchain amount if lightning cannot receive this much self.send_amount_e.setAmount(amount) def _spend_max_reverse_swap(self):