sweep: allow specifying starting fee rate for fee func
This commit is contained in:
8 files changed
+140
-20
No files matched your search
@@ -77,6 +77,10 @@ type InputSet interface {
|
||||
// Budget givens the total amount that can be used as fees by this
|
||||
// input set.
|
||||
Budget() btcutil.Amount
|
||||
|
||||
// StartingFeeRate returns the max starting fee rate found in the
|
||||
// inputs.
|
||||
StartingFeeRate() fn.Option[chainfee.SatPerKWeight]
|
||||
}
|
||||
|
||||
type txInputSetState struct {
|
||||
@@ -205,6 +209,13 @@ func (t *txInputSet) DeadlineHeight() int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
// StartingFeeRate returns the max starting fee rate found in the inputs.
|
||||
//
|
||||
// NOTE: this field is only used for `BudgetInputSet`.
|
||||
func (t *txInputSet) StartingFeeRate() fn.Option[chainfee.SatPerKWeight] {
|
||||
return fn.None[chainfee.SatPerKWeight]()
|
||||
}
|
||||
|
||||
// NeedWalletInput returns true if the input set needs more wallet inputs.
|
||||
func (t *txInputSet) NeedWalletInput() bool {
|
||||
return !t.enoughInput()
|
||||
@@ -800,3 +811,21 @@ func (b *BudgetInputSet) Inputs() []input.Input {
|
||||
|
||||
return inputs
|
||||
}
|
||||
|
||||
// StartingFeeRate returns the max starting fee rate found in the inputs.
|
||||
//
|
||||
// NOTE: part of the InputSet interface.
|
||||
func (b *BudgetInputSet) StartingFeeRate() fn.Option[chainfee.SatPerKWeight] {
|
||||
maxFeeRate := chainfee.SatPerKWeight(0)
|
||||
startingFeeRate := fn.None[chainfee.SatPerKWeight]()
|
||||
|
||||
for _, inp := range b.inputs {
|
||||
feerate := inp.params.StartingFeeRate.UnwrapOr(0)
|
||||
if feerate > maxFeeRate {
|
||||
maxFeeRate = feerate
|
||||
startingFeeRate = fn.Some(maxFeeRate)
|
||||
}
|
||||
}
|
||||
|
||||
return startingFeeRate
|
||||
}
|
||||
Reference in new issue
Block a user