chanfunding: fee estimation based on change output in CoinSelect

Add a dust-limit to `CoinSelect` and let the fee estimation consider if a change output is needed or not, assuring that if the change is below the dust-limit it will go towards the fee instead.
This commit is contained in:
Bjarne Magnussen committed 2021-04-13 11:37:12 +02:00
1 parent 235e73205d
commit 59c40ec8b4
3 files changed
+72 -33

No files matched your search

+2 -1
View File
@@ -289,9 +289,10 @@ func (w *WalletAssembler) ProvisionChannel(r *Request) (Intent, error) {
// Otherwise do a normal coin selection where we target a given
// funding amount.
default:
dustLimit := w.cfg.DustLimit
localContributionAmt = r.LocalAmt
selectedCoins, changeAmt, err = CoinSelect(
r.FeeRate, r.LocalAmt, coins,
r.FeeRate, r.LocalAmt, dustLimit, coins,
)
if err != nil {
return err