mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-29 18:10:48 +02:00
channeldb+lnd: rpc server filters payments by date
This commit is contained in:
24
rpcserver.go
24
rpcserver.go
@ -6359,6 +6359,16 @@ func (r *rpcServer) ListPayments(ctx context.Context,
|
||||
|
||||
rpcsLog.Debugf("[ListPayments]")
|
||||
|
||||
// If both dates are set, we check that the start date is less than the
|
||||
// end date, otherwise we'll get an empty result.
|
||||
if req.CreationDateStart != 0 && req.CreationDateEnd != 0 {
|
||||
if req.CreationDateStart >= req.CreationDateEnd {
|
||||
return nil, fmt.Errorf("start date(%v) must be before "+
|
||||
"end date(%v)", req.CreationDateStart,
|
||||
req.CreationDateEnd)
|
||||
}
|
||||
}
|
||||
|
||||
query := channeldb.PaymentsQuery{
|
||||
IndexOffset: req.IndexOffset,
|
||||
MaxPayments: req.MaxPayments,
|
||||
@ -6367,6 +6377,20 @@ func (r *rpcServer) ListPayments(ctx context.Context,
|
||||
CountTotal: req.CountTotalPayments,
|
||||
}
|
||||
|
||||
// Attach the start date if set.
|
||||
if req.CreationDateStart != 0 {
|
||||
query.CreationDateStart = time.Unix(
|
||||
int64(req.CreationDateStart), 0,
|
||||
)
|
||||
}
|
||||
|
||||
// Attach the end date if set.
|
||||
if req.CreationDateEnd != 0 {
|
||||
query.CreationDateEnd = time.Unix(
|
||||
int64(req.CreationDateEnd), 0,
|
||||
)
|
||||
}
|
||||
|
||||
// If the maximum number of payments wasn't specified, then we'll
|
||||
// default to return the maximal number of payments representable.
|
||||
if req.MaxPayments == 0 {
|
||||
|
Reference in New Issue
Block a user