sweep: allow specifying starting fee rate for fee func

This commit is contained in:
yyforyongyu committed 2024-04-19 21:33:37 +08:00
1 parent db3aad31aa
commit b6a2984167
8 files changed
+140 -20

No files matched your search

+12 -3
View File
@@ -65,6 +65,10 @@ type Params struct {
// without waiting for blocks to come to trigger the sweeping of
// inputs.
Immediate bool
// StartingFeeRate is an optional parameter that can be used to specify
// the initial fee rate to use for the fee function.
StartingFeeRate fn.Option[chainfee.SatPerKWeight]
}
// ParamsUpdate contains a new set of parameters to update a pending sweep with.
@@ -77,6 +81,10 @@ type ParamsUpdate struct {
// Immediate indicates that the input should be swept immediately
// without waiting for blocks to come.
Immediate bool
// StartingFeeRate is an optional parameter that can be used to specify
// the initial fee rate to use for the fee function.
StartingFeeRate fn.Option[chainfee.SatPerKWeight]
}
// String returns a human readable interpretation of the sweep parameters.
@@ -91,9 +99,9 @@ func (p Params) String() string {
exclusiveGroup = fmt.Sprintf("%d", *p.ExclusiveGroup)
}
return fmt.Sprintf("fee=%v, immediate=%v, exclusive_group=%v, budget=%v, "+
"deadline=%v", p.Fee, p.Immediate, exclusiveGroup, p.Budget,
deadline)
return fmt.Sprintf("startingFeeRate=%v, immediate=%v, "+
"exclusive_group=%v, budget=%v, deadline=%v", p.StartingFeeRate,
p.Immediate, exclusiveGroup, p.Budget, deadline)
}
// SweepState represents the current state of a pending input.
@@ -830,6 +838,7 @@ func (s *UtxoSweeper) sweep(set InputSet) error {
DeadlineHeight: set.DeadlineHeight(),
DeliveryAddress: s.currentOutputScript,
MaxFeeRate: s.cfg.MaxFeeRate.FeePerKWeight(),
StartingFeeRate: set.StartingFeeRate(),
// TODO(yy): pass the strategy here.
}