walletrpc+sweep: update PendingSweeps to return the new params

This commit is contained in:
yyforyongyu committed 2024-04-19 21:33:38 +08:00
1 parent 8804947179
commit 11a276e222
5 files changed
+524 -453

No files matched your search

+23 -33
View File
@@ -872,46 +872,36 @@ func (w *WalletKit) PendingSweeps(ctx context.Context,
// Convert them into their respective RPC format.
rpcPendingSweeps := make([]*PendingSweep, 0, len(inputsMap))
for _, sweeperInput := range inputsMap {
witnessType, ok := allWitnessTypes[sweeperInput.WitnessType]
for _, inp := range inputsMap {
witnessType, ok := allWitnessTypes[inp.WitnessType]
if !ok {
return nil, fmt.Errorf("unhandled witness type %v for "+
"input %v", sweeperInput.WitnessType,
sweeperInput.OutPoint)
"input %v", inp.WitnessType, inp.OutPoint)
}
op := lnrpc.MarshalOutPoint(&sweeperInput.OutPoint)
amountSat := uint32(sweeperInput.Amount)
satPerVbyte := uint64(sweeperInput.LastFeeRate.FeePerVByte())
broadcastAttempts := uint32(sweeperInput.BroadcastAttempts)
op := lnrpc.MarshalOutPoint(&inp.OutPoint)
amountSat := uint32(inp.Amount)
satPerVbyte := uint64(inp.LastFeeRate.FeePerVByte())
broadcastAttempts := uint32(inp.BroadcastAttempts)
// Get the requested starting fee rate, if set.
startingFeeRate := fn.MapOptionZ(
inp.Params.StartingFeeRate,
func(feeRate chainfee.SatPerKWeight) uint64 {
return uint64(feeRate.FeePerVByte())
})
ps := &PendingSweep{
Outpoint: op,
WitnessType: witnessType,
AmountSat: amountSat,
SatPerVbyte: satPerVbyte,
BroadcastAttempts: broadcastAttempts,
Immediate: sweeperInput.Params.Immediate,
Outpoint: op,
WitnessType: witnessType,
AmountSat: amountSat,
SatPerVbyte: satPerVbyte,
BroadcastAttempts: broadcastAttempts,
Immediate: inp.Params.Immediate,
Budget: uint64(inp.Params.Budget),
DeadlineHeight: inp.DeadlineHeight,
RequestedSatPerVbyte: startingFeeRate,
}
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)
}