sweep: update sweeper to use AuxSweeper to add extra change addr

In this commit, we start to use the AuxSweeper (if present) to obtain a
new extra change addr we should add to the sweeping transaction. With
this, we'll take the set of inputs and our change addr, and then maybe
gain a new change addr to add to the sweep transaction.

The extra change addr will be treated as an extra required tx out,
shared across all the relevant inputs. This'll also be used in
NeedWalletInput to make sure that we add an extra input if needed to be
able to pay for the change addr.
This commit is contained in:
Olaoluwa Osuntokun
2024-06-03 23:08:37 -07:00
parent cb93f8c01a
commit eaea11e48f
11 changed files with 310 additions and 96 deletions

View File

@@ -150,7 +150,7 @@ func TestBudgetAggregatorFilterInputs(t *testing.T) {
// Init the budget aggregator with the mocked estimator and zero max
// num of inputs.
b := NewBudgetAggregator(estimator, 0)
b := NewBudgetAggregator(estimator, 0, fn.None[AuxSweeper]())
// Call the method under test.
result := b.filterInputs(inputs)
@@ -214,7 +214,7 @@ func TestBudgetAggregatorSortInputs(t *testing.T) {
}
// Init the budget aggregator with zero max num of inputs.
b := NewBudgetAggregator(nil, 0)
b := NewBudgetAggregator(nil, 0, fn.None[AuxSweeper]())
// Call the method under test.
result := b.sortInputs(inputs)
@@ -279,7 +279,7 @@ func TestBudgetAggregatorCreateInputSets(t *testing.T) {
}
// Create a budget aggregator with max number of inputs set to 2.
b := NewBudgetAggregator(nil, 2)
b := NewBudgetAggregator(nil, 2, fn.None[AuxSweeper]())
// Create test cases.
testCases := []struct {
@@ -540,7 +540,9 @@ func TestBudgetInputSetClusterInputs(t *testing.T) {
}
// Create a budget aggregator with a max number of inputs set to 100.
b := NewBudgetAggregator(estimator, DefaultMaxInputsPerTx)
b := NewBudgetAggregator(
estimator, DefaultMaxInputsPerTx, fn.None[AuxSweeper](),
)
// Call the method under test.
result := b.ClusterInputs(inputs)