sweep: introduce BudgetInputSet to manage budget-based inputs

This commit adds `BudgetInputSet` which implements `InputSet`. It
handles the pending inputs based on the supplied budgets and will be
used in the following commit.
This commit is contained in:
yyforyongyu
2024-02-27 17:52:47 +08:00
parent bd5eec8e1f
commit e7400f6a94
3 changed files with 723 additions and 0 deletions

View File

@@ -52,11 +52,22 @@ type Params struct {
// Force indicates whether the input should be swept regardless of
// whether it is economical to do so.
//
// TODO(yy): Remove this param once deadline based sweeping is in place.
Force bool
// ExclusiveGroup is an identifier that, if set, prevents other inputs
// with the same identifier from being batched together.
ExclusiveGroup *uint64
// DeadlineHeight specifies an absolute block height that this input
// should be confirmed by. This value is used by the fee bumper to
// decide its urgency and adjust its feerate used.
DeadlineHeight fn.Option[int32]
// Budget specifies the maximum amount of satoshis that can be spent on
// fees for this sweep.
Budget btcutil.Amount
}
// ParamsUpdate contains a new set of parameters to update a pending sweep with.
@@ -196,6 +207,11 @@ type pendingInput struct {
rbf fn.Option[RBFInfo]
}
// String returns a human readable interpretation of the pending input.
func (p *pendingInput) String() string {
return fmt.Sprintf("%v (%v)", p.Input.OutPoint(), p.Input.WitnessType())
}
// parameters returns the sweep parameters for this input.
//
// NOTE: Part of the txInput interface.