Skip to content

Commit 5c3015b

Browse files
rpcserver: validate DeleteAllPayments options
1 parent 4f48cc6 commit 5c3015b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

rpcserver.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6763,6 +6763,27 @@ func (r *rpcServer) DeleteAllPayments(ctx context.Context,
67636763
req *lnrpc.DeleteAllPaymentsRequest) (
67646764
*lnrpc.DeleteAllPaymentsResponse, error) {
67656765

6766+
switch {
6767+
// Since this is a destructive operation, at least one of the options
6768+
// must be set to true.
6769+
case !req.AllPayments && !req.FailedPaymentsOnly &&
6770+
!req.FailedHtlcsOnly:
6771+
6772+
return nil, fmt.Errorf("at least one of the options " +
6773+
"`all_payments`, `failed_payments_only`, or " +
6774+
"`failed_htlcs_only` must be set to true")
6775+
6776+
// `all_payments` cannot be true with `failed_payments_only` or
6777+
// `failed_htlcs_only`. `all_payments` includes all records, making
6778+
// these options contradictory.
6779+
case req.AllPayments &&
6780+
(req.FailedPaymentsOnly || req.FailedHtlcsOnly):
6781+
6782+
return nil, fmt.Errorf("`all_payments` cannot be set to true " +
6783+
"while either `failed_payments_only` or " +
6784+
"`failed_htlcs_only` is also set to true")
6785+
}
6786+
67666787
rpcsLog.Infof("[DeleteAllPayments] failed_payments_only=%v, "+
67676788
"failed_htlcs_only=%v", req.FailedPaymentsOnly,
67686789
req.FailedHtlcsOnly)

0 commit comments

Comments
 (0)