Merge pull request #10087 from starius/estimate-feerate-allow-1

walletrpc: allow conf_target=1 in EstimateFee and FundPsbt
This commit is contained in:
Yong authored and GitHub committed 2025-08-04 14:08:42 +08:00
commit 149a81911a
5 files changed
+62 -9

No files matched your search

@@ -45,6 +45,10 @@
## Functional Enhancements
* RPCs `walletrpc.EstimateFee` and `walletrpc.FundPsbt` now
[allow](https://github.com/lightningnetwork/lnd/pull/10087)
`conf_target=1`. Previously they required `conf_target >= 2`.
## RPC Additions
* When querying [`ForwardingEvents`](https://github.com/lightningnetwork/lnd/pull/9813)
logs, the response now include the incoming and outgoing htlc indices of the payment
+4
View File
@@ -731,6 +731,10 @@ var allTestCases = []*lntest.TestCase{
Name: "delete canceled invoice",
TestFunc: testDeleteCanceledInvoice,
},
{
Name: "estimate fee",
TestFunc: testEstimateFee,
},
}
// appendPrefixed is used to add a prefix to each test name in the subtests
+47
View File
@@ -5,6 +5,7 @@ import (
"encoding/hex"
"fmt"
"os"
"testing"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash"
@@ -1593,3 +1594,49 @@ func testReorgNotifications(ht *lntest.HarnessTest) {
require.NotNil(ht, spendDetails)
require.Equal(ht, txid2a[:], spendDetails.SpendingTxHash)
}
// testEstimateFee tests walletrpc.EstimateFee API.
func testEstimateFee(ht *lntest.HarnessTest) {
alice := ht.NewNode("Alice", nil)
ctx := context.Background()
testCases := []struct {
name string
confTarget int32
errContains string
}{
{
name: "conf target 1",
confTarget: 1,
},
{
name: "conf target 0",
confTarget: 0,
errContains: "must be greater than 0",
},
{
name: "conf target -1",
confTarget: -1,
errContains: "must be greater than 0",
},
}
for _, tc := range testCases {
ht.Run(tc.name, func(t *testing.T) {
req := &walletrpc.EstimateFeeRequest{
ConfTarget: tc.confTarget,
}
resp, err := alice.RPC.WalletKit.EstimateFee(ctx, req)
if tc.errContains != "" {
require.ErrorContains(t, err, tc.errContains)
return
}
require.NoError(t, err)
require.NotZero(t, resp.SatPerKw)
require.NotZero(t, resp.MinRelayFeeSatPerKw)
})
}
}
+2 -2
View File
@@ -1253,8 +1253,8 @@ func fundPsbtCoinSelect(t testing.TB, node *node.HarnessNode,
Template: &walletrpc.FundPsbtRequest_CoinSelect{
CoinSelect: cs,
},
Fees: &walletrpc.FundPsbtRequest_SatPerVbyte{
SatPerVbyte: 50,
Fees: &walletrpc.FundPsbtRequest_TargetConf{
TargetConf: 1,
},
})
+5 -7
View File
@@ -843,12 +843,10 @@ func (w *WalletKit) SendOutputs(ctx context.Context,
func (w *WalletKit) EstimateFee(ctx context.Context,
req *EstimateFeeRequest) (*EstimateFeeResponse, error) {
switch {
// A confirmation target of zero doesn't make any sense. Similarly, we
// reject confirmation targets of 1 as they're unreasonable.
case req.ConfTarget == 0 || req.ConfTarget == 1:
// A confirmation target of zero or lower doesn't make any sense.
if req.ConfTarget <= 0 {
return nil, fmt.Errorf("confirmation target must be greater " +
"than 1")
"than 0")
}
satPerKw, err := w.cfg.FeeEstimator.EstimateFeePerKW(
@@ -1557,9 +1555,9 @@ func (w *WalletKit) FundPsbt(_ context.Context,
// Estimate the fee by the target number of blocks to confirmation.
case req.GetTargetConf() != 0:
targetConf := req.GetTargetConf()
if targetConf < 2 {
if targetConf < 1 {
return nil, fmt.Errorf("confirmation target must be " +
"greater than 1")
"greater than 0")
}
feeSatPerKW, err = w.cfg.FeeEstimator.EstimateFeePerKW(