Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions cmd/lncli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -2822,3 +2822,74 @@ func restoreChanBackup(ctx *cli.Context) error {

return nil
}

var deletePaymentsCommand = cli.Command{
Name: "delpayments",
Category: "payments",
Usage: "Delete all payments, only failed payments, or only the HTLCs associated with faild payments",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Usage: "Delete all payments, only failed payments, or only the HTLCs associated with faild payments",
Usage: "Delete all payments, only failed payments, or only the HTLCs associated with failed payments",

Typo: missing e

Description: `
Delete payments on disk to free up disk space. Failed payments include the
1.3KB onion route associated with each payment route so over time they can
take up space. Repeated payment attempt result in
failed payments that are never automatically deleted.

This command allows you to either delete all payments, only failed
payments, or only the HTLCs associated with failed payments.
`,
ArgsUsage: "[--all | --failed | --filed_htlc]",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "all",
Usage: "delete ALL payments, which includes successful and failed ones",
},
cli.BoolFlag{
Name: "failed",
Usage: "only delete FAILED payments",
},
cli.BoolFlag{
Name: "failed_htlc",
Usage: "only delete the HTLC data associated with failed payments",
},
},
Action: deletePayments,
}

func deletePayments(ctx *cli.Context) error {
ctxc := getContext()
client, cleanUp := getClient(ctx)
defer cleanUp()

// Show command help if no arguments provided
if ctx.NArg() == 0 && ctx.NumFlags() == 0 {
cli.ShowCommandHelp(ctx, "delpayments")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW golinter errcheck flags this line

cmd/lncli/commands.go:2864:22: Error return value of `cli.ShowCommandHelp` is not checked (errcheck)
		cli.ShowCommandHelp(ctx, "delpayments")
		                   ^

return nil
}

req := &lnrpc.DeleteAllPaymentsRequest{}
var delType string
switch {
case ctx.Bool("all"):
delType = "all payments"
break

case ctx.Bool("failed"):
delType = "failed payments"
req.FailedPaymentsOnly = true

case ctx.Bool("failed_htlc"):
delType = "failed HTLCs"
req.FailedHtlcsOnly = true

default:
return fmt.Errorf("must specify one of the selector flags")
}

fmt.Printf("Deleting %v...\n", delType)
_, err := client.DeleteAllPayments(ctxc, req)
if err != nil {
return err
}

fmt.Printf("%v successfully deleted!\n", delType)
return nil
}
1 change: 1 addition & 0 deletions cmd/lncli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ func main() {
versionCommand,
profileSubCommand,
getStateCommand,
deletePaymentsCommand,
}

// Add any extra commands determined by build flags.
Expand Down
6 changes: 5 additions & 1 deletion docs/release-notes/release-notes-0.14.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ the remote peer supports said channel type and agrees, the previous implicit
negotiation based on the shared set of feature bits is bypassed, and the
proposed channel type is used.

## RPC Server
## RPC Server & `lncli`

* [Return payment address and add index from
addholdinvoice call](https://github.com/lightningnetwork/lnd/pull/5533).
Expand Down Expand Up @@ -106,6 +106,10 @@ proposed channel type is used.
requests made with custom macaroons (and also the responses to those
requests).

* [A new lncli command has been added to expose the RPC command to delete
payments over the command
line](https://github.com/lightningnetwork/lnd/pull/5778): `delpayments`.

### Batched channel funding

[Multiple channels can now be opened in a single
Expand Down
2 changes: 1 addition & 1 deletion lnrpc/lightning.proto
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ service Lightning {
*/
rpc DeletePayment (DeletePaymentRequest) returns (DeletePaymentResponse);

/*
/* lncli: `delpayments`
DeleteAllPayments deletes all outgoing payments from DB. Note that it will
not attempt to delete In-Flight payments, since that would be unsafe.
*/
Expand Down
2 changes: 1 addition & 1 deletion lnrpc/lightning.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1859,7 +1859,7 @@
]
},
"delete": {
"summary": "DeleteAllPayments deletes all outgoing payments from DB. Note that it will\nnot attempt to delete In-Flight payments, since that would be unsafe.",
"summary": "lncli: `delpayments`\nDeleteAllPayments deletes all outgoing payments from DB. Note that it will\nnot attempt to delete In-Flight payments, since that would be unsafe.",
"operationId": "Lightning_DeleteAllPayments",
"responses": {
"200": {
Expand Down
4 changes: 2 additions & 2 deletions lnrpc/lightning_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.