DeleteAllPayments
DeleteAllPayments deletes all outgoing payments from DB. Note that it will not attempt to delete In-Flight payments, since that would be unsafe.
Source: lightning.proto
gRPC
rpc DeleteAllPayments (DeleteAllPaymentsRequest) returns (DeleteAllPaymentsResponse);
REST
| HTTP Method | Path | 
|---|---|
| DELETE | /v1/payments | 
Code Samples
- gRPC
- REST
- Shell
- Javascript
- Python
const fs = require('fs');
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');
const GRPC_HOST = 'localhost:10009'
const MACAROON_PATH = 'LND_DIR/data/chain/bitcoin/regtest/admin.macaroon'
const TLS_PATH = 'LND_DIR/tls.cert'
const loaderOptions = {
  keepCase: true,
  longs: String,
  enums: String,
  defaults: true,
  oneofs: true,
};
const packageDefinition = protoLoader.loadSync('lightning.proto', loaderOptions);
const lnrpc = grpc.loadPackageDefinition(packageDefinition).lnrpc;
process.env.GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA';
const tlsCert = fs.readFileSync(TLS_PATH);
const sslCreds = grpc.credentials.createSsl(tlsCert);
const macaroon = fs.readFileSync(MACAROON_PATH).toString('hex');
const macaroonCreds = grpc.credentials.createFromMetadataGenerator(function(args, callback) {
  let metadata = new grpc.Metadata();
  metadata.add('macaroon', macaroon);
  callback(null, metadata);
});
let creds = grpc.credentials.combineChannelCredentials(sslCreds, macaroonCreds);
let client = new lnrpc.Lightning(GRPC_HOST, creds);
let request = {
  failed_payments_only: <bool>,
  failed_htlcs_only: <bool>,
  all_payments: <bool>,
};
client.deleteAllPayments(request, function(err, response) {
  console.log(response);
});
// Console output:
//  {
//    "status": <string>,
//  }
import codecs, grpc, os
# Generate the following 2 modules by compiling the lightning.proto with the grpcio-tools.
# See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions.
import lightning_pb2 as lnrpc, lightning_pb2_grpc as lightningstub
GRPC_HOST = 'localhost:10009'
MACAROON_PATH = 'LND_DIR/data/chain/bitcoin/regtest/admin.macaroon'
TLS_PATH = 'LND_DIR/tls.cert'
# create macaroon credentials
macaroon = codecs.encode(open(MACAROON_PATH, 'rb').read(), 'hex')
def metadata_callback(context, callback):
  callback([('macaroon', macaroon)], None)
auth_creds = grpc.metadata_call_credentials(metadata_callback)
# create SSL credentials
os.environ['GRPC_SSL_CIPHER_SUITES'] = 'HIGH+ECDSA'
cert = open(TLS_PATH, 'rb').read()
ssl_creds = grpc.ssl_channel_credentials(cert)
# combine macaroon and SSL credentials
combined_creds = grpc.composite_channel_credentials(ssl_creds, auth_creds)
# make the request
channel = grpc.secure_channel(GRPC_HOST, combined_creds)
stub = lightningstub.LightningStub(channel)
request = lnrpc.DeleteAllPaymentsRequest(
  failed_payments_only=<bool>,
  failed_htlcs_only=<bool>,
  all_payments=<bool>,
)
response = stub.DeleteAllPayments(request)
print(response)
# {
#    "status": <string>,
# }
- Javascript
- Python
const fs = require('fs');
const request = require('request');
const REST_HOST = 'localhost:8080'
const MACAROON_PATH = 'LND_DIR/data/chain/bitcoin/regtest/admin.macaroon'
let options = {
  url: `https://${REST_HOST}/v1/payments`,
  // Work-around for self-signed certificates.
  rejectUnauthorized: false,
  json: true,
  headers: {
    'Grpc-Metadata-macaroon': fs.readFileSync(MACAROON_PATH).toString('hex'),
  },
}
request.delete(options, function(error, response, body) {
  console.log(body);
});
// Console output:
//  {
//    "status": <string>, // <string> 
//  }
import base64, codecs, json, requests
REST_HOST = 'localhost:8080'
MACAROON_PATH = 'LND_DIR/data/chain/bitcoin/regtest/admin.macaroon'
TLS_PATH = 'LND_DIR/tls.cert'
url = f'https://{REST_HOST}/v1/payments'
macaroon = codecs.encode(open(MACAROON_PATH, 'rb').read(), 'hex')
headers = {'Grpc-Metadata-macaroon': macaroon}
r = requests.delete(url, headers=headers, verify=TLS_PATH)
print(r.json())
# {
#    "status": <string>,
# }
$ lncli deletepayments --all --help
NAME:
   lncli deletepayments - Delete a single or multiple payments from the database.
USAGE:
   lncli deletepayments [command options] --all [--failed_htlcs_only --include_non_failed] | --payment_hash hash [--failed_htlcs_only]
CATEGORY:
   Payments
DESCRIPTION:
   
  This command either deletes all failed payments or a single payment from
  the database to reclaim disk space.
  If the --all flag is used, then all failed payments are removed. If so
  desired, _ALL_ payments (even the successful ones) can be deleted
  by additionally specifying --include_non_failed.
  If a --payment_hash is specified, that single payment is deleted,
  independent of its state.
  If --failed_htlcs_only is specified then the payments themselves (or the
  single payment itself if used with --payment_hash) is not deleted, only
  the information about any failed HTLC attempts during the payment.
  NOTE: Removing payments from the database does free up disk space within
  the internal bbolt database. But that disk space is only reclaimed after
  compacting the database. Users might want to turn on auto compaction
  (db.bolt.auto-compact=true in the config file or --db.bolt.auto-compact
  as a command line flag) and restart lnd after deleting a large number of
  payments to see a reduction in the file size of the channel.db file.
  
OPTIONS:
   --all                 delete all failed payments
   --payment_hash value  delete a specific payment identified by its payment hash
   --failed_htlcs_only   only delete failed HTLCs from payments, not the payment itself
   --include_non_failed  delete ALL payments, not just the failed ones
   
Messages
lnrpc.DeleteAllPaymentsRequest
Source: lightning.proto
| Field | gRPC Type | REST Type | REST Placement | 
|---|---|---|---|
| failed_payments_only | bool | boolean | query | 
| failed_htlcs_only | bool | boolean | query | 
| all_payments | bool | boolean | query | 
lnrpc.DeleteAllPaymentsResponse
Source: lightning.proto
| Field | gRPC Type | REST Type | 
|---|---|---|
| status | string | string |