From 280929ba1e808a32afb6b407afbaa8a51c350b6a Mon Sep 17 00:00:00 2001 From: Slyghtning Date: Wed, 15 Oct 2025 15:57:12 +0200 Subject: [PATCH] rpcserver: return inputs in EstimateFeeResponse --- rpcserver.go | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/rpcserver.go b/rpcserver.go index 29efd150e..21563a82c 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -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",