From 3b517390d8db4ce4dd0f989b1b300bdf4e9f27a1 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Wed, 11 Mar 2020 08:52:20 +0100 Subject: [PATCH] cnct+sweeper: give contract court access to relay fee Relay fee is needed later to sweep anchors at the minimum fee rate. --- contractcourt/commit_sweep_resolver_test.go | 5 +++++ contractcourt/interfaces.go | 5 +++++ sweep/sweeper.go | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/contractcourt/commit_sweep_resolver_test.go b/contractcourt/commit_sweep_resolver_test.go index c142167e..e5c7df05 100644 --- a/contractcourt/commit_sweep_resolver_test.go +++ b/contractcourt/commit_sweep_resolver_test.go @@ -10,6 +10,7 @@ import ( "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/lnwallet" + "github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/sweep" ) @@ -120,6 +121,10 @@ func (s *mockSweeper) CreateSweepTx(inputs []input.Input, feePref sweep.FeePrefe return nil, nil } +func (s *mockSweeper) RelayFeePerKW() chainfee.SatPerKWeight { + return 253 +} + var _ UtxoSweeper = &mockSweeper{} // TestCommitSweepResolverNoDelay tests resolution of a direct commitment output diff --git a/contractcourt/interfaces.go b/contractcourt/interfaces.go index 18dfbc0e..5497dad8 100644 --- a/contractcourt/interfaces.go +++ b/contractcourt/interfaces.go @@ -9,6 +9,7 @@ import ( "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/invoices" "github.com/lightningnetwork/lnd/lntypes" + "github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/sweep" ) @@ -51,4 +52,8 @@ type UtxoSweeper interface { // estimate before generating the required witnesses. CreateSweepTx(inputs []input.Input, feePref sweep.FeePreference, currentBlockHeight uint32) (*wire.MsgTx, error) + + // RelayFeePerKW returns the minimum fee rate required for transactions + // to be relayed. + RelayFeePerKW() chainfee.SatPerKWeight } diff --git a/sweep/sweeper.go b/sweep/sweeper.go index f176f703..3b9acebe 100644 --- a/sweep/sweeper.go +++ b/sweep/sweeper.go @@ -384,6 +384,12 @@ func (s *UtxoSweeper) Start() error { return nil } +// RelayFeePerKW returns the minimum fee rate required for transactions to be +// relayed. +func (s *UtxoSweeper) RelayFeePerKW() chainfee.SatPerKWeight { + return s.relayFeeRate +} + // Stop stops sweeper from listening to block epochs and constructing sweep // txes. func (s *UtxoSweeper) Stop() error {