1
0

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.
This commit is contained in:
f321x
2026-01-13 14:51:38 +01:00
parent 40811abe45
commit 7b828a8317

View File

@@ -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()