ListPayments
ListPayments returns a list of all outgoing payments.
Source: lightning.proto
gRPC
rpc ListPayments (ListPaymentsRequest) returns (ListPaymentsResponse);
REST
HTTP Method | Path |
---|---|
GET | /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 = {
include_incomplete: <bool>,
index_offset: <uint64>,
max_payments: <uint64>,
reversed: <bool>,
count_total_payments: <bool>,
creation_date_start: <uint64>,
creation_date_end: <uint64>,
};
client.listPayments(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "payments": <Payment>,
// "first_index_offset": <uint64>,
// "last_index_offset": <uint64>,
// "total_num_payments": <uint64>,
// }
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.ListPaymentsRequest(
include_incomplete=<bool>,
index_offset=<uint64>,
max_payments=<uint64>,
reversed=<bool>,
count_total_payments=<bool>,
creation_date_start=<uint64>,
creation_date_end=<uint64>,
)
response = stub.ListPayments(request)
print(response)
# {
# "payments": <Payment>,
# "first_index_offset": <uint64>,
# "last_index_offset": <uint64>,
# "total_num_payments": <uint64>,
# }
- 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.get(options, function(error, response, body) {
console.log(body);
});
// Console output:
// {
// "payments": <array>, // <Payment>
// "first_index_offset": <string>, // <uint64>
// "last_index_offset": <string>, // <uint64>
// "total_num_payments": <string>, // <uint64>
// }
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.get(url, headers=headers, verify=TLS_PATH)
print(r.json())
# {
# "payments": <Payment>,
# "first_index_offset": <uint64>,
# "last_index_offset": <uint64>,
# "total_num_payments": <uint64>,
# }
$ lncli listpayments --help
NAME:
lncli listpayments - List all outgoing payments.
USAGE:
lncli listpayments [command options] [arguments...]
CATEGORY:
Payments
DESCRIPTION:
This command enables the retrieval of payments stored
in the database.
Pagination is supported by the usage of index_offset in combination with
the paginate_forwards flag.
Reversed pagination is enabled by default to receive current payments
first. Pagination can be resumed by using the returned last_index_offset
(for forwards order), or first_index_offset (for reversed order) as the
offset_index.
Because counting all payments in the payment database can take a long
time on systems with many payments, the count is not returned by
default. That feature can be turned on with the --count_total_payments
flag.
OPTIONS:
--include_incomplete if set to true, payments still in flight (or failed) will be returned as well, keepingindices for payments the same as without the flag
--index_offset value The index of a payment that will be used as either the start (in forwards mode) or end (in reverse mode) of a query to determine which payments should be returned in the response, where the index_offset is excluded. If index_offset is set to zero in reversed mode, the query will end with the last payment made. (default: 0)
--max_payments value the max number of payments to return, by default, all completed payments are returned (default: 0)
--paginate_forwards if set, payments succeeding the index_offset will be returned, allowing forwards pagination
--count_total_payments if set, all payments (complete or incomplete, independent of max_payments parameter) will be counted; can take a long time on systems with many payments
--creation_date_start value timestamp in seconds, if set, filter payments with creation date greater than or equal to it (default: 0)
--creation_date_end value timestamp in seconds, if set, filter payments with creation date less than or equal to it (default: 0)
Messages
lnrpc.ListPaymentsRequest
Source: lightning.proto
Field | gRPC Type | REST Type | REST Placement |
---|---|---|---|
include_incomplete | bool | boolean | query |
index_offset | uint64 | string | query |
max_payments | uint64 | string | query |
reversed | bool | boolean | query |
count_total_payments | bool | boolean | query |
creation_date_start | uint64 | string | query |
creation_date_end | uint64 | string | query |
lnrpc.ListPaymentsResponse
Source: lightning.proto
Field | gRPC Type | REST Type |
---|---|---|
payments | Payment[] | array |
first_index_offset | uint64 | string |
last_index_offset | uint64 | string |
total_num_payments | uint64 | string |
Nested Messages
lnrpc.AMPRecord
Field | gRPC Type | REST Type |
---|---|---|
root_share | bytes | string |
set_id | bytes | string |
child_index | uint32 | integer |
lnrpc.ChannelUpdate
Field | gRPC Type | REST Type |
---|---|---|
signature | bytes | string |
chain_hash | bytes | string |
chan_id | uint64 | string |
timestamp | uint32 | integer |
message_flags | uint32 | integer |
channel_flags | uint32 | integer |
time_lock_delta | uint32 | integer |
htlc_minimum_msat | uint64 | string |
base_fee | uint32 | integer |
fee_rate | uint32 | integer |
htlc_maximum_msat | uint64 | string |
extra_opaque_data | bytes | string |
lnrpc.Failure
Field | gRPC Type | REST Type |
---|---|---|
code | FailureCode | string |
channel_update | ChannelUpdate | object |
htlc_msat | uint64 | string |
onion_sha_256 | bytes | string |
cltv_expiry | uint32 | integer |
flags | uint32 | integer |
failure_source_index | uint32 | integer |
height | uint32 | integer |
lnrpc.Hop
Field | gRPC Type | REST Type |
---|---|---|
chan_id | uint64 | string |
chan_capacity | int64 | string |
amt_to_forward | int64 | string |
fee | int64 | string |
expiry | uint32 | integer |
amt_to_forward_msat | int64 | string |
fee_msat | int64 | string |
pub_key | string | string |
tlv_payload | bool | boolean |
mpp_record | MPPRecord | object |
amp_record | AMPRecord | object |
custom_records | CustomRecordsEntry[] | object |
metadata | bytes | string |
blinding_point | bytes | string |
encrypted_data | bytes | string |
total_amt_msat | uint64 | string |
lnrpc.Hop.CustomRecordsEntry
Field | gRPC Type | REST Type |
---|---|---|
key | uint64 | unknown |
value | bytes | unknown |
lnrpc.HTLCAttempt
Field | gRPC Type | REST Type |
---|---|---|
attempt_id | uint64 | string |
status | HTLCStatus | string |
route | Route | object |
attempt_time_ns | int64 | string |
resolve_time_ns | int64 | string |
failure | Failure | object |
preimage | bytes | string |
lnrpc.MPPRecord
Field | gRPC Type | REST Type |
---|---|---|
payment_addr | bytes | string |
total_amt_msat | int64 | string |
lnrpc.Payment
Field | gRPC Type | REST Type |
---|---|---|
payment_hash | string | string |
value deprecated | int64 | string |
creation_date deprecated | int64 | string |
fee deprecated | int64 | string |
payment_preimage | string | string |
value_sat | int64 | string |
value_msat | int64 | string |
payment_request | string | string |
status | PaymentStatus | string |
fee_sat | int64 | string |
fee_msat | int64 | string |
creation_time_ns | int64 | string |
htlcs | HTLCAttempt[] | array |
payment_index | uint64 | string |
failure_reason | PaymentFailureReason | string |
first_hop_custom_records | FirstHopCustomRecordsEntry[] | object |
lnrpc.Payment.FirstHopCustomRecordsEntry
Field | gRPC Type | REST Type |
---|---|---|
key | uint64 | unknown |
value | bytes | unknown |
lnrpc.Route
Field | gRPC Type | REST Type |
---|---|---|
total_time_lock | uint32 | integer |
total_fees | int64 | string |
total_amt | int64 | string |
hops | Hop[] | array |
total_fees_msat | int64 | string |
total_amt_msat | int64 | string |
first_hop_amount_msat | int64 | string |
custom_channel_data | bytes | string |
Enums
lnrpc.Failure.FailureCode
Name | Number |
---|---|
RESERVED | 0 |
INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS | 1 |
INCORRECT_PAYMENT_AMOUNT | 2 |
FINAL_INCORRECT_CLTV_EXPIRY | 3 |
FINAL_INCORRECT_HTLC_AMOUNT | 4 |
FINAL_EXPIRY_TOO_SOON | 5 |
INVALID_REALM | 6 |
EXPIRY_TOO_SOON | 7 |
INVALID_ONION_VERSION | 8 |
INVALID_ONION_HMAC | 9 |
INVALID_ONION_KEY | 10 |
AMOUNT_BELOW_MINIMUM | 11 |
FEE_INSUFFICIENT | 12 |
INCORRECT_CLTV_EXPIRY | 13 |
CHANNEL_DISABLED | 14 |
TEMPORARY_CHANNEL_FAILURE | 15 |
REQUIRED_NODE_FEATURE_MISSING | 16 |
REQUIRED_CHANNEL_FEATURE_MISSING | 17 |
UNKNOWN_NEXT_PEER | 18 |
TEMPORARY_NODE_FAILURE | 19 |
PERMANENT_NODE_FAILURE | 20 |
PERMANENT_CHANNEL_FAILURE | 21 |
EXPIRY_TOO_FAR | 22 |
MPP_TIMEOUT | 23 |
INVALID_ONION_PAYLOAD | 24 |
INVALID_ONION_BLINDING | 25 |
INTERNAL_FAILURE | 997 |
UNKNOWN_FAILURE | 998 |
UNREADABLE_FAILURE | 999 |
lnrpc.HTLCAttempt.HTLCStatus
Name | Number |
---|---|
IN_FLIGHT | 0 |
SUCCEEDED | 1 |
FAILED | 2 |
lnrpc.Payment.PaymentStatus
Name | Number |
---|---|
UNKNOWN deprecated | 0 |
IN_FLIGHT | 1 |
SUCCEEDED | 2 |
FAILED | 3 |
INITIATED | 4 |
lnrpc.PaymentFailureReason
Name | Number |
---|---|
FAILURE_REASON_NONE | 0 |
FAILURE_REASON_TIMEOUT | 1 |
FAILURE_REASON_NO_ROUTE | 2 |
FAILURE_REASON_ERROR | 3 |
FAILURE_REASON_INCORRECT_PAYMENT_DETAILS | 4 |
FAILURE_REASON_INSUFFICIENT_BALANCE | 5 |
FAILURE_REASON_CANCELED | 6 |