diff --git a/htlcswitch/mock.go b/htlcswitch/mock.go index 58ccc8b18..bb260156a 100644 --- a/htlcswitch/mock.go +++ b/htlcswitch/mock.go @@ -75,6 +75,10 @@ func (m *mockFeeEstimator) EstimateFeePerKW( } } +func (m *mockFeeEstimator) RelayFeePerKW() lnwallet.SatPerKWeight { + return 1e3 +} + func (m *mockFeeEstimator) Start() error { return nil } diff --git a/lnwallet/fee_estimator.go b/lnwallet/fee_estimator.go index 1f63a19ff..6ac6a38a2 100644 --- a/lnwallet/fee_estimator.go +++ b/lnwallet/fee_estimator.go @@ -59,6 +59,11 @@ type FeeEstimator interface { // Stop stops any spawned goroutines and cleans up the resources used // by the fee estimator. Stop() error + + // RelayFeePerKW returns the minimum fee rate required for transactions + // to be relayed. This is also the basis for calculation of the dust + // limit. + RelayFeePerKW() SatPerKWeight } // StaticFeeEstimator will return a static value for all fee calculation @@ -68,6 +73,10 @@ type StaticFeeEstimator struct { // FeePerKW is the static fee rate in satoshis-per-vbyte that will be // returned by this fee estimator. FeePerKW SatPerKWeight + + // RelayFee is the minimum fee rate required for transactions to be + // relayed. + RelayFee SatPerKWeight } // EstimateFeePerKW will return a static value for fee calculations. @@ -77,6 +86,14 @@ func (e StaticFeeEstimator) EstimateFeePerKW(numBlocks uint32) (SatPerKWeight, e return e.FeePerKW, nil } +// RelayFeePerKW returns the minimum fee rate required for transactions to be +// relayed. +// +// NOTE: This method is part of the FeeEstimator interface. +func (e StaticFeeEstimator) RelayFeePerKW() SatPerKWeight { + return e.RelayFee +} + // Start signals the FeeEstimator to start any processes or goroutines // it needs to perform its duty. // @@ -206,6 +223,14 @@ func (b *BtcdFeeEstimator) EstimateFeePerKW(numBlocks uint32) (SatPerKWeight, er return feeEstimate, nil } +// RelayFeePerKW returns the minimum fee rate required for transactions to be +// relayed. +// +// NOTE: This method is part of the FeeEstimator interface. +func (b *BtcdFeeEstimator) RelayFeePerKW() SatPerKWeight { + return b.minFeePerKW +} + // fetchEstimate returns a fee estimate for a transaction to be confirmed in // confTarget blocks. The estimate is returned in sat/kw. func (b *BtcdFeeEstimator) fetchEstimate(confTarget uint32) (SatPerKWeight, error) { @@ -359,6 +384,14 @@ func (b *BitcoindFeeEstimator) EstimateFeePerKW(numBlocks uint32) (SatPerKWeight return feeEstimate, nil } +// RelayFeePerKW returns the minimum fee rate required for transactions to be +// relayed. +// +// NOTE: This method is part of the FeeEstimator interface. +func (b *BitcoindFeeEstimator) RelayFeePerKW() SatPerKWeight { + return b.minFeePerKW +} + // fetchEstimate returns a fee estimate for a transaction to be confirmed in // confTarget blocks. The estimate is returned in sat/kw. func (b *BitcoindFeeEstimator) fetchEstimate(confTarget uint32) (SatPerKWeight, error) {