-
Notifications
You must be signed in to change notification settings - Fork 2.2k
UTXO consolidation #10295
-
I have a question regarding coin selection and fee estimation in LND.
suppose a merchant, receive payments in sats, which results in many small UTXOs spread across multiple addresses for example, several 100ドル UTXOs or similar-sized ones.
- By default, LND seems to prefer picking larger UTXOs for efficient transactions, which makes sense.
- However, when I explicitly set the coin selection strategy to RANDOM, LND often selects many smaller UTXOs to complete a payment.
- This increases the overall transaction size and, therefore, the total fee.
Here’s the issue I’m facing:
-
When I call EstimateFee with CoinSelectionStrategy = RANDOM, the node picks one random combination of UTXOs to estimate the fee.
-
A few seconds later, when I call SendCoins (also with CoinSelectionStrategy = RANDOM), it picks a different random set of UTXOs.
-
Because of this, the actual transaction size — and therefore the actual fee — can differ a lot from the estimated value.
So the fee estimation becomes unpredictable.
My question:
-
Would it be possible for the EstimateFee API response to include which UTXOs were used for the estimation (their outpoints), so that we can pass those exact UTXOs in the SendCoins request?
-
That way, we could eliminate this randomness and achieve predictable behavior between estimation and execution.
Additionally :
-
Do you have any suggestions or recommended practices for UTXO management in this scenario?
For example, does LND provide a built-in mechanism to consolidate UTXOs automatically when network fees are low or when the number of small UTXOs crosses a threshold? -
Or How should we handle consolidation manually (e.g., using SendCoins to self-addresses during low-fee periods) or any other aproch which is best for us?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments 1 reply
-
Hi @pranav-punjabi,
I added a draft PR that adds the feature you are requesting, see #10296.
Let me know what you think.
Beta Was this translation helpful? Give feedback.
All reactions
-
🎉 1
-
Additionally :
- Do you have any suggestions or recommended practices for UTXO management in this scenario?
For example, does LND provide a built-in mechanism to consolidate UTXOs automatically when network fees are low or when the number of small UTXOs crosses a threshold?- Or How should we handle consolidation manually (e.g., using SendCoins to self-addresses during low-fee periods) or any other aproch which is best for us?
Afaik lnd
does not provide an built-in mechanism.
As suggested on Slack you could either create your own script that consolidates periodically according to your needs.
Alternatively, you could check out https://docs.lightning.engineering/lightning-network-tools/loop/static-loop-in-addresses
If you get your users to send funds to a static loop address you could from time-to-time swap all the received on-chain outputs
with a lightning payment to your lightning node.
Beta Was this translation helpful? Give feedback.
All reactions
-
thank you @hieblmi , it is very helpful
Beta Was this translation helpful? Give feedback.