Skip to main content

DeleteAttempts

DeleteAttempts removes terminal (settled or failed) payment attempt records from the server's attempt store. The client explicitly names the attempt IDs to delete, enabling online garbage collection of completed attempt data.

The server processes each attempt ID independently and reports per-ID results. Pending (in-flight) attempts are never deleted; they are reported with a DELETION_PENDING status. Unknown attempt IDs are reported with DELETION_NOT_FOUND. Unprocessable records are reported with DELETION_FAILED. The overall RPC succeeds (gRPC OK) as long as the request could be processed, even if individual attempts were not deleted.

Clients MUST only delete attempts whose outcome (settled or failed) has been durably recorded and will never need to be retried. Deleting an attempt removes the server's idempotency protection for that attempt ID.

Source: switchrpc/switch.proto

gRPC​

rpc DeleteAttempts (DeleteAttemptsRequest) returns (DeleteAttemptsResponse);

REST​

HTTP MethodPath
POST /v2/switch/deleteattempts

Code Samples​

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', 'switchrpc/switch.proto'], loaderOptions);
const switchrpc = grpc.loadPackageDefinition(packageDefinition).switchrpc;
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 switchrpc.Switch(GRPC_HOST, creds);
let request = {
attempt_ids: <uint64>,
};
client.deleteAttempts(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "results": <AttemptDeletionResult>,
// }

Messages​

switchrpc.DeleteAttemptsRequest​

Source: switchrpc/switch.proto

FieldgRPC TypeREST TypeREST Placement
attempt_ids
uint64[]arraybody

switchrpc.DeleteAttemptsResponse​

Source: switchrpc/switch.proto

FieldgRPC TypeREST Type
results
AttemptDeletionResult[]array

Nested Messages​

switchrpc.AttemptDeletionResult​

FieldgRPC TypeREST Type
attempt_id
uint64string
status
AttemptDeletionStatusstring

Enums​

switchrpc.AttemptDeletionStatus​

NameNumber
DELETION_OK
0
DELETION_PENDING
1
DELETION_NOT_FOUND
2
DELETION_FAILED
3