lnrpc+sweep: make FeeEstimateInfo an optional param

This is needed as we soon will remove the usage of the fee preference
when sweeping inputs.
This commit is contained in:
yyforyongyu committed 2024-04-19 21:33:31 +08:00
1 parent 658ba445ea
commit 0b30d4ba3e
2 files changed
+27 -14

No files matched your search

+22 -13
View File
@@ -883,25 +883,34 @@ func (w *WalletKit) PendingSweeps(ctx context.Context,
satPerVbyte := uint64(sweeperInput.LastFeeRate.FeePerVByte()) satPerVbyte := uint64(sweeperInput.LastFeeRate.FeePerVByte())
broadcastAttempts := uint32(sweeperInput.BroadcastAttempts) broadcastAttempts := uint32(sweeperInput.BroadcastAttempts)
feePref := sweeperInput.Params.Fee ps := &PendingSweep{
requestedFee, ok := feePref.(sweep.FeeEstimateInfo)
if !ok {
return nil, fmt.Errorf("unknown fee preference type: "+
"%v", feePref)
}
requestedFeeRate := uint64(requestedFee.FeeRate.FeePerVByte())
rpcPendingSweeps = append(rpcPendingSweeps, &PendingSweep{
Outpoint: op, Outpoint: op,
WitnessType: witnessType, WitnessType: witnessType,
AmountSat: amountSat, AmountSat: amountSat,
SatPerVbyte: satPerVbyte, SatPerVbyte: satPerVbyte,
BroadcastAttempts: broadcastAttempts, BroadcastAttempts: broadcastAttempts,
RequestedSatPerVbyte: requestedFeeRate,
RequestedConfTarget: requestedFee.ConfTarget,
Force: sweeperInput.Params.Force, Force: sweeperInput.Params.Force,
}) }
feePref := sweeperInput.Params.Fee
// If there's no fee preference specified, we can move to the
// next record.
if feePref == nil {
rpcPendingSweeps = append(rpcPendingSweeps, ps)
continue
}
requestedFee, ok := feePref.(sweep.FeeEstimateInfo)
if !ok {
return nil, fmt.Errorf("unknown fee "+
"preference type: "+"%v", feePref)
}
requestedFeeRate := uint64(requestedFee.FeeRate.FeePerVByte())
ps.RequestedSatPerVbyte = requestedFeeRate
ps.RequestedConfTarget = requestedFee.ConfTarget
rpcPendingSweeps = append(rpcPendingSweeps, ps)
} }
return &PendingSweepsResponse{ return &PendingSweepsResponse{
+5 -1
View File
@@ -514,12 +514,16 @@ func (s *UtxoSweeper) SweepInput(input input.Input,
} }
// Ensure the client provided a sane fee preference. // Ensure the client provided a sane fee preference.
//
// TODO(yy): remove this check?
if params.Fee != nil {
_, err := params.Fee.Estimate( _, err := params.Fee.Estimate(
s.cfg.FeeEstimator, s.cfg.MaxFeeRate.FeePerKWeight(), s.cfg.FeeEstimator, s.cfg.MaxFeeRate.FeePerKWeight(),
) )
if err != nil { if err != nil {
return nil, err return nil, err
} }
}
absoluteTimeLock, _ := input.RequiredLockTime() absoluteTimeLock, _ := input.RequiredLockTime()
log.Infof("Sweep request received: out_point=%v, witness_type=%v, "+ log.Infof("Sweep request received: out_point=%v, witness_type=%v, "+
@@ -1580,7 +1584,7 @@ func (s *UtxoSweeper) sweepPendingInputs(inputs InputsMap) {
} }
if err != nil { if err != nil {
log.Errorf("Sweep new inputs: %v", err) log.Errorf("Failed to sweep %v: %v", set, err)
} }
} }
} }