mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-12 14:12:27 +02:00
lnd: add DeletePayment to the RPC
The RPC DeletePayment allows deleteing single payment from its ID. When calling with `FailedHtlcsOnly` set in the request only failed HTLCs of this payment will be deleted.
This commit is contained in:
29
rpcserver.go
29
rpcserver.go
@ -442,6 +442,10 @@ func MainRPCServerPermissions() map[string][]bakery.Op {
|
||||
Entity: "offchain",
|
||||
Action: "read",
|
||||
}},
|
||||
"/lnrpc.Lightning/DeletePayment": {{
|
||||
Entity: "offchain",
|
||||
Action: "write",
|
||||
}},
|
||||
"/lnrpc.Lightning/DeleteAllPayments": {{
|
||||
Entity: "offchain",
|
||||
Action: "write",
|
||||
@ -5934,6 +5938,31 @@ func (r *rpcServer) ListPayments(ctx context.Context,
|
||||
return paymentsResp, nil
|
||||
}
|
||||
|
||||
// DeletePayment deletes a payment from the DB given its payment hash. If
|
||||
// failedHtlcsOnly is set, only failed HTLC attempts of the payment will be
|
||||
// deleted.
|
||||
func (r *rpcServer) DeletePayment(ctx context.Context,
|
||||
req *lnrpc.DeletePaymentRequest) (
|
||||
*lnrpc.DeletePaymentResponse, error) {
|
||||
|
||||
hash, err := lntypes.MakeHash(req.PaymentHash)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rpcsLog.Infof("[DeletePayment] payment_identifier=%v, "+
|
||||
"failed_htlcs_only=%v", hash, req.FailedHtlcsOnly)
|
||||
|
||||
err = r.server.chanStateDB.DeletePayment(
|
||||
hash, req.FailedHtlcsOnly,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &lnrpc.DeletePaymentResponse{}, nil
|
||||
}
|
||||
|
||||
// DeleteAllPayments deletes all outgoing payments from DB.
|
||||
func (r *rpcServer) DeleteAllPayments(ctx context.Context,
|
||||
req *lnrpc.DeleteAllPaymentsRequest) (
|
||||
|
Reference in New Issue
Block a user