mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
lnwallet+docs: minrelayfee always above fee floor
The minimum relay fee is always ensured to be above our fee floor except in the very first min relay fee query to bitcoind. This commit ensures that the fee floor is respected in this first query.
This commit is contained in:
parent
485ec0f697
commit
2449e66d29
@ -35,6 +35,9 @@
|
|||||||
|
|
||||||
* [Fix memory corruption in Mission Control
|
* [Fix memory corruption in Mission Control
|
||||||
Store](https://github.com/lightningnetwork/lnd/pull/6068)
|
Store](https://github.com/lightningnetwork/lnd/pull/6068)
|
||||||
|
|
||||||
|
* [Ensure that the min relay fee is always clamped by our fee
|
||||||
|
floor](https://github.com/lightningnetwork/lnd/pull/6076)
|
||||||
|
|
||||||
## RPC Server
|
## RPC Server
|
||||||
|
|
||||||
@ -49,6 +52,7 @@
|
|||||||
|
|
||||||
* Andras Banki-Horvath
|
* Andras Banki-Horvath
|
||||||
* Bjarne Magnussen
|
* Bjarne Magnussen
|
||||||
|
* Elle Mouton
|
||||||
* Harsha Goli
|
* Harsha Goli
|
||||||
* Martin Habovštiak
|
* Martin Habovštiak
|
||||||
* Naveen Srinivasan
|
* Naveen Srinivasan
|
||||||
|
@ -32,6 +32,12 @@ func newMinFeeManager(minUpdateInterval time.Duration,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure that the minimum fee we use is always clamped by our fee
|
||||||
|
// floor.
|
||||||
|
if minFee < FeePerKwFloor {
|
||||||
|
minFee = FeePerKwFloor
|
||||||
|
}
|
||||||
|
|
||||||
return &minFeeManager{
|
return &minFeeManager{
|
||||||
minFeePerKW: minFee,
|
minFeePerKW: minFee,
|
||||||
lastUpdatedTime: time.Now(),
|
lastUpdatedTime: time.Now(),
|
||||||
|
@ -23,8 +23,10 @@ func (m *mockChainBackend) fetchFee() (SatPerKWeight, error) {
|
|||||||
func TestMinFeeManager(t *testing.T) {
|
func TestMinFeeManager(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
// Initialize the mock backend and let it have a minimum fee rate
|
||||||
|
// below our fee floor.
|
||||||
chainBackend := &mockChainBackend{
|
chainBackend := &mockChainBackend{
|
||||||
minFee: SatPerKWeight(1000),
|
minFee: FeePerKwFloor - 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialise the min fee manager. This should call the chain backend
|
// Initialise the min fee manager. This should call the chain backend
|
||||||
@ -36,11 +38,14 @@ func TestMinFeeManager(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, 1, chainBackend.callCount)
|
require.Equal(t, 1, chainBackend.callCount)
|
||||||
|
|
||||||
|
// Check that the minimum fee rate is clamped by our fee floor.
|
||||||
|
require.Equal(t, feeManager.minFeePerKW, FeePerKwFloor)
|
||||||
|
|
||||||
// If the fee is requested again, the stored fee should be returned
|
// If the fee is requested again, the stored fee should be returned
|
||||||
// and the chain backend should not be queried.
|
// and the chain backend should not be queried.
|
||||||
chainBackend.minFee = SatPerKWeight(2000)
|
chainBackend.minFee = SatPerKWeight(2000)
|
||||||
minFee := feeManager.fetchMinFee()
|
minFee := feeManager.fetchMinFee()
|
||||||
require.Equal(t, minFee, SatPerKWeight(1000))
|
require.Equal(t, minFee, FeePerKwFloor)
|
||||||
require.Equal(t, 1, chainBackend.callCount)
|
require.Equal(t, 1, chainBackend.callCount)
|
||||||
|
|
||||||
// Fake the passing of time.
|
// Fake the passing of time.
|
||||||
|
Loading…
Reference in New Issue
Block a user