sweep: pass default deadline height when clustering inputs

This commit changes the method `ClusterInputs` to also take a default
deadline height. Previously, when calculating the default deadline
height for a non-time sensitive input, we would first cluster it with
other non-time sensitive inputs, then give it a deadline before we are
about to `sweep`. This is now moved to the step where we decide to
cluster inputs, allowing time-sensitive and non-sensitive inputs to be
grouped together, if they happen to share the same deadline heights.
This commit is contained in:
yyforyongyu committed 2024-04-19 21:33:32 +08:00
1 parent 15588355b3
commit 4c13ea1747
7 files changed
+80 -69

No files matched your search

+6 -5
View File
@@ -8,7 +8,6 @@ import (
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
@@ -342,8 +341,10 @@ type mockUtxoAggregator struct {
var _ UtxoAggregator = (*mockUtxoAggregator)(nil)
// ClusterInputs takes a list of inputs and groups them into clusters.
func (m *mockUtxoAggregator) ClusterInputs(inputs InputsMap) []InputSet {
args := m.Called(inputs)
func (m *mockUtxoAggregator) ClusterInputs(inputs InputsMap,
defaultDeadline int32) []InputSet {
args := m.Called(inputs, defaultDeadline)
return args.Get(0).([]InputSet)
}
@@ -484,10 +485,10 @@ func (m *MockInputSet) NeedWalletInput() bool {
}
// DeadlineHeight returns the deadline height for the set.
func (m *MockInputSet) DeadlineHeight() fn.Option[int32] {
func (m *MockInputSet) DeadlineHeight() int32 {
args := m.Called()
return args.Get(0).(fn.Option[int32])
return args.Get(0).(int32)
}
// Budget givens the total amount that can be used as fees by this input set.