sweep: increase delta fee rate precision in fee function

This commit adds a private type `mSatPerKWeight` that expresses a given
fee rate in millisatoshi per kw. This is needed to increase the
precision of the fee function. When sweeping anchor inputs, if using a
deadline delta of over 1000, it's likely the delta will be 0 sat/kw due
to precision.
This commit is contained in:
yyforyongyu
2024-03-18 11:35:55 +08:00
parent 23feef7e6c
commit 7fb18bc0d5
2 changed files with 32 additions and 9 deletions

View File

@@ -54,8 +54,8 @@ func TestLinearFeeFunctionNew(t *testing.T) {
//
// Mock the fee estimator to return the fee rate.
estimator.On("EstimateFeePerKW", confTarget).Return(
// The starting fee rate is 1 sat/kw less than the max fee rate.
maxFeeRate-1, nil).Once()
// The starting fee rate is the max fee rate.
maxFeeRate, nil).Once()
estimator.On("RelayFeePerKW").Return(estimatedFeeRate).Once()
f, err = NewLinearFeeFunction(maxFeeRate, confTarget, estimator)
@@ -96,7 +96,7 @@ func TestLinearFeeFunctionFeeRateAtPosition(t *testing.T) {
startingFeeRate: 1000,
endingFeeRate: 3000,
position: 0,
deltaFeeRate: 1000,
deltaFeeRate: 1_000_000,
width: 3,
}