From 7b828a831751bfeb34f4f8265244b62f71ec2340 Mon Sep 17 00:00:00 2001 From: f321x Date: Tue, 13 Jan 2026 14:51:38 +0100 Subject: [PATCH] wallet: check swap provider liquidity for send change to ln Check the swap providers liquidity as well if we try to send change to lightning in `make_unsigned_transaction`. It is now expected that the swap_manager is already initialized when calling `make_unsigned_transaction`, otherwise no dummy output will get added. --- electrum/wallet.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/electrum/wallet.py b/electrum/wallet.py index c852603af..0c608c9b7 100644 --- a/electrum/wallet.py +++ b/electrum/wallet.py @@ -2058,11 +2058,14 @@ class Abstract_Wallet(ABC, Logger, EventListener): fee_estimator_vb=fee_estimator, dust_threshold=self.dust_threshold(), BIP69_sort=BIP69_sort) - if self.lnworker and send_change_to_lightning: + if send_change_to_lightning and self.lnworker and self.lnworker.swap_manager.is_initialized.is_set(): + sm = self.lnworker.swap_manager change = tx.get_change_outputs() if len(change) == 1: amount = change[0].value - if amount <= self.lnworker.num_sats_can_receive(): + min_swap_amount = sm.get_min_amount() + max_swap_amount = sm.client_max_amount_forward_swap() or 0 + if min_swap_amount <= amount <= max_swap_amount: tx.replace_output_address(change[0].address, DummyAddress.SWAP) if self.should_keep_reserve_utxo(tx.inputs(), tx.outputs(), is_anchor_channel_opening): raise NotEnoughFunds()