sweep+itest: change MaxFeeRate to use SatPerVbyte

This commit is contained in:
yyforyongyu 2023-07-26 11:04:04 +02:00 committed by Olaoluwa Osuntokun
parent bea0ffdf81
commit 258fe7999b
4 changed files with 12 additions and 12 deletions

View file

@ -231,9 +231,7 @@ func runCPFP(ht *lntest.HarnessTest, alice, bob *node.HarnessNode) {
// CPFP from Alice's point of view. // CPFP from Alice's point of view.
bumpFeeReq := &walletrpc.BumpFeeRequest{ bumpFeeReq := &walletrpc.BumpFeeRequest{
Outpoint: op, Outpoint: op,
SatPerVbyte: uint64( SatPerVbyte: uint64(sweep.DefaultMaxFeeRate),
sweep.DefaultMaxFeeRate.FeePerKVByte() / 2000,
),
} }
bob.RPC.BumpFee(bumpFeeReq) bob.RPC.BumpFee(bumpFeeReq)

View file

@ -2,6 +2,8 @@ package sweep
import ( import (
"time" "time"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
) )
var ( var (
@ -9,4 +11,9 @@ var (
// window. The sweep is held back during the batch window to allow more // window. The sweep is held back during the batch window to allow more
// inputs to be added and thereby lower the fee per input. // inputs to be added and thereby lower the fee per input.
DefaultBatchWindowDuration = 30 * time.Second 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
) )

View file

@ -21,11 +21,6 @@ import (
) )
const ( 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 // DefaultFeeRateBucketSize is the default size of fee rate buckets
// we'll use when clustering inputs into buckets with similar fee rates // we'll use when clustering inputs into buckets with similar fee rates
// within the UtxoSweeper. // within the UtxoSweeper.
@ -288,7 +283,7 @@ type UtxoSweeperConfig struct {
// MaxFeeRate is the the maximum fee rate allowed within the // MaxFeeRate is the the maximum fee rate allowed within the
// UtxoSweeper. // UtxoSweeper.
MaxFeeRate chainfee.SatPerKWeight MaxFeeRate chainfee.SatPerVByte
// FeeRateBucketSize is the default size of fee rate buckets we'll use // FeeRateBucketSize is the default size of fee rate buckets we'll use
// when clustering inputs into buckets with similar fee rates within the // 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 "+ return 0, fmt.Errorf("fee preference resulted in invalid fee "+
"rate %v, minimum is %v", feeRate, s.relayFeeRate) "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 "+ return 0, fmt.Errorf("fee preference resulted in invalid fee "+
"rate %v, maximum is %v", feeRate, s.cfg.MaxFeeRate) "rate %v, maximum is %v", feeRate, s.cfg.MaxFeeRate)
} }

View file

@ -1186,7 +1186,7 @@ func TestBumpFeeRBF(t *testing.T) {
// We'll then attempt to bump its fee rate. // We'll then attempt to bump its fee rate.
highFeePref := FeePreference{ConfTarget: 6} highFeePref := FeePreference{ConfTarget: 6}
highFeeRate := DefaultMaxFeeRate highFeeRate := DefaultMaxFeeRate.FeePerKWeight()
ctx.estimator.blocksToFee[highFeePref.ConfTarget] = highFeeRate ctx.estimator.blocksToFee[highFeePref.ConfTarget] = highFeeRate
// We should expect to see an error if a fee preference isn't provided. // We should expect to see an error if a fee preference isn't provided.