Skip to content

Commit

Permalink
sweep+itest: change MaxFeeRate to use SatPerVbyte
Browse files Browse the repository at this point in the history
  • Loading branch information
yyforyongyu authored and backend-engineer1 committed Oct 6, 2023
1 parent 84ae949 commit 852bce2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 2 additions & 4 deletions itest/lnd_onchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 7 additions & 0 deletions sweep/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@ package sweep

import (
"time"

"github.com/lightningnetwork/lnd/lnwallet/chainfee"
)

var (
// DefaultBatchWindowDuration specifies duration of the sweep batch
// 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
)
9 changes: 2 additions & 7 deletions sweep/sweeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion sweep/sweeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 852bce2

Please sign in to comment.