Browse Source

swaps: limit forward amount to receivable amount on lightning

patch-4
bitromortac 4 years ago
parent
commit
c377694347
No known key found for this signature in database GPG Key ID: 1965063FC13BEBE2
  1. 5
      electrum/gui/qt/swap_dialog.py

5
electrum/gui/qt/swap_dialog.py

@ -126,14 +126,15 @@ class SwapDialog(WindowModalDialog):
self._update_tx('!') self._update_tx('!')
if self.tx: if self.tx:
amount = self.tx.output_value_for_address(ln_dummy_address()) 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: if amount > max_amt:
amount = max_amt amount = max_amt
self._update_tx(amount) self._update_tx(amount)
if self.tx: if self.tx:
amount = self.tx.output_value_for_address(ln_dummy_address()) amount = self.tx.output_value_for_address(ln_dummy_address())
assert amount <= max_amt assert amount <= max_amt
# TODO: limit onchain amount if lightning cannot receive this much
self.send_amount_e.setAmount(amount) self.send_amount_e.setAmount(amount)
def _spend_max_reverse_swap(self): def _spend_max_reverse_swap(self):

Loading…
Cancel
Save