rpcserver: return inputs in EstimateFeeResponse

This commit is contained in:
Slyghtning committed 2026-01-07 10:25:29 +01:00
1 parent e5456d39f2
commit 280929ba1e
1 file changed
+31 -2
+31 -2
View File
@@ -1275,14 +1275,29 @@ func (r *rpcServer) EstimateFee(ctx context.Context,
return nil, err
}
var selectOutpoints fn.Set[wire.OutPoint]
if len(in.Inputs) != 0 {
wireOutpoints, err := toWireOutpoints(in.Inputs)
if err != nil {
return nil, fmt.Errorf("can't create outpoints %w", err)
}
if fn.HasDuplicates(wireOutpoints) {
return nil, fmt.Errorf("selected outpoints contain " +
"duplicate values")
}
selectOutpoints = fn.NewSet(wireOutpoints...)
}
// We will ask the wallet to create a tx using this fee rate. We set
// dryRun=true to avoid inflating the change addresses in the db.
var tx *txauthor.AuthoredTx
wallet := r.server.cc.Wallet
err = wallet.WithCoinSelectLock(func() error {
tx, err = wallet.CreateSimpleTx(
nil, outputs, feePerKw, minConfs, coinSelectionStrategy,
true,
selectOutpoints, outputs, feePerKw, minConfs,
coinSelectionStrategy, true,
)
return err
})
@@ -1297,12 +1312,26 @@ func (r *rpcServer) EstimateFee(ctx context.Context,
}
totalFee := int64(tx.TotalInput) - totalOutput
// Return the inputs the estimate is for.
outStr := make([]string, 0, len(tx.Tx.TxIn))
for _, txIn := range tx.Tx.TxIn {
outStr = append(
outStr, txIn.PreviousOutPoint.String(),
)
}
inputs, err := UtxosToOutpoints(outStr)
if err != nil {
return nil, fmt.Errorf("can't convert outpoints %w", err)
}
resp := &lnrpc.EstimateFeeResponse{
FeeSat: totalFee,
SatPerVbyte: uint64(feePerKw.FeePerVByte()),
// Deprecated field.
FeerateSatPerByte: int64(feePerKw.FeePerVByte()),
Inputs: inputs,
}
rpcsLog.Debugf("[estimatefee] fee estimate for conf target %d: %v",