From 258fe7999b202f10b722c5cdb1946e600e118bae Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Wed, 26 Jul 2023 11:04:04 +0200 Subject: [PATCH] sweep+itest: change `MaxFeeRate` to use `SatPerVbyte` --- itest/lnd_onchain_test.go | 6 ++---- sweep/defaults.go | 7 +++++++ sweep/sweeper.go | 9 ++------- sweep/sweeper_test.go | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/itest/lnd_onchain_test.go b/itest/lnd_onchain_test.go index 7ea7d106e..e7a9b2a91 100644 --- a/itest/lnd_onchain_test.go +++ b/itest/lnd_onchain_test.go @@ -230,10 +230,8 @@ func runCPFP(ht *lntest.HarnessTest, alice, bob *node.HarnessNode) { // We'll attempt to bump the fee of this transaction by performing a // CPFP from Alice's point of view. bumpFeeReq := &walletrpc.BumpFeeRequest{ - Outpoint: op, - SatPerVbyte: uint64( - sweep.DefaultMaxFeeRate.FeePerKVByte() / 2000, - ), + Outpoint: op, + SatPerVbyte: uint64(sweep.DefaultMaxFeeRate), } bob.RPC.BumpFee(bumpFeeReq) diff --git a/sweep/defaults.go b/sweep/defaults.go index 2f53cdb0a..3ea492190 100644 --- a/sweep/defaults.go +++ b/sweep/defaults.go @@ -2,6 +2,8 @@ package sweep import ( "time" + + "github.com/lightningnetwork/lnd/lnwallet/chainfee" ) var ( @@ -9,4 +11,9 @@ var ( // window. The sweep is held back during the batch window to allow more // inputs to be added and thereby lower the fee per input. DefaultBatchWindowDuration = 30 * time.Second + + // DefaultMaxFeeRate is the default maximum fee rate allowed within the + // UtxoSweeper. The current value is equivalent to a fee rate of 1,000 + // sat/vbyte. + DefaultMaxFeeRate chainfee.SatPerVByte = 1e3 ) diff --git a/sweep/sweeper.go b/sweep/sweeper.go index 2d4502a82..cd31e8620 100644 --- a/sweep/sweeper.go +++ b/sweep/sweeper.go @@ -21,11 +21,6 @@ import ( ) const ( - // DefaultMaxFeeRate is the default maximum fee rate allowed within the - // UtxoSweeper. The current value is equivalent to a fee rate of 1,000 - // sat/vbyte. - DefaultMaxFeeRate = chainfee.AbsoluteFeePerKwFloor * 1e3 - // DefaultFeeRateBucketSize is the default size of fee rate buckets // we'll use when clustering inputs into buckets with similar fee rates // within the UtxoSweeper. @@ -288,7 +283,7 @@ type UtxoSweeperConfig struct { // MaxFeeRate is the the maximum fee rate allowed within the // UtxoSweeper. - MaxFeeRate chainfee.SatPerKWeight + MaxFeeRate chainfee.SatPerVByte // FeeRateBucketSize is the default size of fee rate buckets we'll use // when clustering inputs into buckets with similar fee rates within the @@ -483,7 +478,7 @@ func (s *UtxoSweeper) feeRateForPreference( return 0, fmt.Errorf("fee preference resulted in invalid fee "+ "rate %v, minimum is %v", feeRate, s.relayFeeRate) } - if feeRate > s.cfg.MaxFeeRate { + if feeRate > s.cfg.MaxFeeRate.FeePerKWeight() { return 0, fmt.Errorf("fee preference resulted in invalid fee "+ "rate %v, maximum is %v", feeRate, s.cfg.MaxFeeRate) } diff --git a/sweep/sweeper_test.go b/sweep/sweeper_test.go index 13f891857..b0ddbee2e 100644 --- a/sweep/sweeper_test.go +++ b/sweep/sweeper_test.go @@ -1186,7 +1186,7 @@ func TestBumpFeeRBF(t *testing.T) { // We'll then attempt to bump its fee rate. highFeePref := FeePreference{ConfTarget: 6} - highFeeRate := DefaultMaxFeeRate + highFeeRate := DefaultMaxFeeRate.FeePerKWeight() ctx.estimator.blocksToFee[highFeePref.ConfTarget] = highFeeRate // We should expect to see an error if a fee preference isn't provided.