rpcserver: return inputs in EstimateFeeResponse
This commit is contained in:
1 file changed
+31
-2
+31
-2
@@ -1275,14 +1275,29 @@ func (r *rpcServer) EstimateFee(ctx context.Context,
|
|||||||
return nil, err
|
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
|
// 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.
|
// dryRun=true to avoid inflating the change addresses in the db.
|
||||||
var tx *txauthor.AuthoredTx
|
var tx *txauthor.AuthoredTx
|
||||||
wallet := r.server.cc.Wallet
|
wallet := r.server.cc.Wallet
|
||||||
err = wallet.WithCoinSelectLock(func() error {
|
err = wallet.WithCoinSelectLock(func() error {
|
||||||
tx, err = wallet.CreateSimpleTx(
|
tx, err = wallet.CreateSimpleTx(
|
||||||
nil, outputs, feePerKw, minConfs, coinSelectionStrategy,
|
selectOutpoints, outputs, feePerKw, minConfs,
|
||||||
true,
|
coinSelectionStrategy, true,
|
||||||
)
|
)
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
@@ -1297,12 +1312,26 @@ func (r *rpcServer) EstimateFee(ctx context.Context,
|
|||||||
}
|
}
|
||||||
totalFee := int64(tx.TotalInput) - totalOutput
|
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{
|
resp := &lnrpc.EstimateFeeResponse{
|
||||||
FeeSat: totalFee,
|
FeeSat: totalFee,
|
||||||
SatPerVbyte: uint64(feePerKw.FeePerVByte()),
|
SatPerVbyte: uint64(feePerKw.FeePerVByte()),
|
||||||
|
|
||||||
// Deprecated field.
|
// Deprecated field.
|
||||||
FeerateSatPerByte: int64(feePerKw.FeePerVByte()),
|
FeerateSatPerByte: int64(feePerKw.FeePerVByte()),
|
||||||
|
Inputs: inputs,
|
||||||
}
|
}
|
||||||
|
|
||||||
rpcsLog.Debugf("[estimatefee] fee estimate for conf target %d: %v",
|
rpcsLog.Debugf("[estimatefee] fee estimate for conf target %d: %v",
|
||||||
|
|||||||
Reference in new issue
Block a user