walletrpc+sweep: refactor BumpFee to properly handle sweep request
This commit is contained in:
3 files changed
+204
-79
No files matched your search
+4
-4
@@ -490,12 +490,12 @@ func (t *TxPublisher) createAndCheckTx(req *BumpRequest, f FeeFunction) (
|
||||
req.Inputs, req.DeliveryAddress, f.FeeRate(),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, 0, fmt.Errorf("create sweep tx: %w", err)
|
||||
return nil, fee, fmt.Errorf("create sweep tx: %w", err)
|
||||
}
|
||||
|
||||
// Sanity check the budget still covers the fee.
|
||||
if fee > req.Budget {
|
||||
return nil, 0, fmt.Errorf("%w: budget=%v, fee=%v",
|
||||
return nil, fee, fmt.Errorf("%w: budget=%v, fee=%v",
|
||||
ErrNotEnoughBudget, req.Budget, fee)
|
||||
}
|
||||
|
||||
@@ -522,8 +522,8 @@ func (t *TxPublisher) createAndCheckTx(req *BumpRequest, f FeeFunction) (
|
||||
return tx, fee, nil
|
||||
}
|
||||
|
||||
return nil, 0, fmt.Errorf("tx=%v failed mempool check: %w", tx.TxHash(),
|
||||
err)
|
||||
return nil, fee, fmt.Errorf("tx=%v failed mempool check: %w",
|
||||
tx.TxHash(), err)
|
||||
}
|
||||
|
||||
// broadcast takes a monitored tx and publishes it to the network. Prior to the
|
||||
|
||||
+8
-11
@@ -1087,14 +1087,6 @@ func (s *UtxoSweeper) handlePendingSweepsReq(
|
||||
func (s *UtxoSweeper) UpdateParams(input wire.OutPoint,
|
||||
params Params) (chan Result, error) {
|
||||
|
||||
// Ensure the client provided a sane fee preference.
|
||||
_, err := params.Fee.Estimate(
|
||||
s.cfg.FeeEstimator, s.cfg.MaxFeeRate.FeePerKWeight(),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
responseChan := make(chan *updateResp, 1)
|
||||
select {
|
||||
case s.updateReqs <- &updateReq{
|
||||
@@ -1140,9 +1132,14 @@ func (s *UtxoSweeper) handleUpdateReq(req *updateReq) (
|
||||
|
||||
// Create the updated parameters struct. Leave the exclusive group
|
||||
// unchanged.
|
||||
newParams := sweeperInput.params
|
||||
newParams.Fee = req.params.Fee
|
||||
newParams.Immediate = req.params.Immediate
|
||||
newParams := Params{
|
||||
Fee: req.params.Fee,
|
||||
StartingFeeRate: req.params.StartingFeeRate,
|
||||
Immediate: req.params.Immediate,
|
||||
Budget: req.params.Budget,
|
||||
DeadlineHeight: req.params.DeadlineHeight,
|
||||
ExclusiveGroup: sweeperInput.params.ExclusiveGroup,
|
||||
}
|
||||
|
||||
log.Debugf("Updating parameters for %v(state=%v) from (%v) to (%v)",
|
||||
req.input, sweeperInput.state, sweeperInput.params, newParams)
|
||||
|
||||
Reference in new issue
Block a user