ListSessions
ListSessions returns all sessions known to the session store.
Source: lit-sessions.proto
gRPC
rpc ListSessions (ListSessionsRequest) returns (ListSessionsResponse);
REST
HTTP Method | Path |
---|---|
GET | /v1/sessions |
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:8443'
const MACAROON_PATH = 'LIT_DIR/regtest/lit.macaroon'
const TLS_PATH = 'LIT_DIR/tls.cert'
const loaderOptions = {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
};
const packageDefinition = protoLoader.loadSync('lit-sessions.proto', loaderOptions);
const litrpc = grpc.loadPackageDefinition(packageDefinition).litrpc;
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 litrpc.Sessions(GRPC_HOST, creds);
let request = {};
client.listSessions(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "sessions": <Session>,
// }
import codecs, grpc, os
# Generate the following 2 modules by compiling the lit-sessions.proto with the grpcio-tools.
# See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions.
import lit-sessions_pb2 as litrpc, lit-sessions_pb2_grpc as lit-sessionsstub
GRPC_HOST = 'localhost:8443'
MACAROON_PATH = 'LIT_DIR/regtest/lit.macaroon'
TLS_PATH = 'LIT_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 = lit-sessionsstub.SessionsStub(channel)
request = litrpc.ListSessionsRequest()
response = stub.ListSessions(request)
print(response)
# {
# "sessions": <Session>,
# }
- Javascript
- Python
const fs = require('fs');
const request = require('request');
const REST_HOST = 'localhost:8443'
const MACAROON_PATH = 'LIT_DIR/regtest/lit.macaroon'
let options = {
url: `https://${REST_HOST}/v1/sessions`,
// 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:
// {
// "sessions": <array>, // <Session>
// }
import base64, codecs, json, requests
REST_HOST = 'localhost:8443'
MACAROON_PATH = 'LIT_DIR/regtest/lit.macaroon'
TLS_PATH = 'LIT_DIR/tls.cert'
url = f'https://{REST_HOST}/v1/sessions'
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())
# {
# "sessions": <Session>,
# }
$ litcli sessions list --help
NAME:
litcli sessions list - List sessions.
USAGE:
litcli sessions list command [command options] [arguments...]
COMMANDS:
all, a List all Lightning Node Connect sessions.
revoked, r List revoked Lightning Node Connect sessions.
inuse, u List in-use Lightning Node Connect sessions.
expired, e List expired Lightning Node Connect sessions.
created, c List created Lightning Node Connect sessions.
OPTIONS:
--help, -h show help
Messages
litrpc.ListSessionsRequest
Source: lit-sessions.proto
note
This request has no parameters.
litrpc.ListSessionsResponse
Source: lit-sessions.proto
Field | gRPC Type | REST Type |
---|---|---|
sessions | Session[] | array |
Nested Messages
litrpc.ChannelConstraint
Field | gRPC Type | REST Type |
---|---|---|
min_capacity_sat | uint64 | string |
max_capacity_sat | uint64 | string |
max_push_sat | uint64 | string |
private_allowed | bool | boolean |
public_allowed | bool | boolean |
litrpc.ChannelPolicyBounds
Field | gRPC Type | REST Type |
---|---|---|
min_base_msat | uint64 | string |
max_base_msat | uint64 | string |
min_rate_ppm | uint32 | integer |
max_rate_ppm | uint32 | integer |
min_cltv_delta | uint32 | integer |
max_cltv_delta | uint32 | integer |
min_htlc_msat | uint64 | string |
max_htlc_msat | uint64 | string |
litrpc.ChannelRestrict
Field | gRPC Type | REST Type |
---|---|---|
channel_ids | uint64[] | array |
litrpc.HistoryLimit
Field | gRPC Type | REST Type |
---|---|---|
start_time | uint64 | string |
duration | uint64 | string |
litrpc.MacaroonPermission
Field | gRPC Type | REST Type |
---|---|---|
entity | string | string |
action | string | string |
litrpc.MacaroonRecipe
Field | gRPC Type | REST Type |
---|---|---|
permissions | MacaroonPermission[] | array |
caveats | string[] | array |
litrpc.OffChainBudget
Field | gRPC Type | REST Type |
---|---|---|
max_amt_msat | uint64 | string |
max_fees_msat | uint64 | string |
litrpc.OnChainBudget
Field | gRPC Type | REST Type |
---|---|---|
absolute_amt_sats | uint64 | string |
max_sat_per_v_byte | uint64 | string |
litrpc.PeerRestrict
Field | gRPC Type | REST Type |
---|---|---|
peer_ids | string[] | array |
litrpc.Rate
Field | gRPC Type | REST Type |
---|---|---|
iterations | uint32 | integer |
num_hours | uint32 | integer |
litrpc.RateLimit
Field | gRPC Type | REST Type |
---|---|---|
read_limit | Rate | object |
write_limit | Rate | object |
litrpc.RulesMap
Field | gRPC Type | REST Type |
---|---|---|
rules | RulesEntry[] | object |
litrpc.RulesMap.RulesEntry
Field | gRPC Type | REST Type |
---|---|---|
key | string | unknown |
value | RuleValue | unknown |
litrpc.RuleValue
Field | gRPC Type | REST Type |
---|---|---|
rate_limit | RateLimit | object |
chan_policy_bounds | ChannelPolicyBounds | object |
history_limit | HistoryLimit | object |
off_chain_budget | OffChainBudget | object |
on_chain_budget | OnChainBudget | object |
send_to_self | SendToSelf | object |
channel_restrict | ChannelRestrict | object |
peer_restrict | PeerRestrict | object |
channel_constraint | ChannelConstraint | object |
litrpc.SendToSelf
note
This response has no parameters.
litrpc.Session
Field | gRPC Type | REST Type |
---|---|---|
id | bytes | string |
label | string | string |
session_state | SessionState | string |
session_type | SessionType | string |
expiry_timestamp_seconds | uint64 | string |
mailbox_server_addr | string | string |
dev_server | bool | boolean |
pairing_secret | bytes | string |
pairing_secret_mnemonic | string | string |
local_public_key | bytes | string |
remote_public_key | bytes | string |
created_at | uint64 | string |
macaroon_recipe | MacaroonRecipe | object |
account_id | string | string |
autopilot_feature_info | AutopilotFeatureInfoEntry[] | object |
revoked_at | uint64 | string |
group_id | bytes | string |
feature_configs | FeatureConfigsEntry[] | object |
privacy_flags | uint64 | string |
litrpc.Session.AutopilotFeatureInfoEntry
Field | gRPC Type | REST Type |
---|---|---|
key | string | unknown |
value | RulesMap | unknown |
litrpc.Session.FeatureConfigsEntry
Field | gRPC Type | REST Type |
---|---|---|
key | string | unknown |
value | string | unknown |
Enums
litrpc.SessionState
Name | Number |
---|---|
STATE_CREATED | 0 |
STATE_IN_USE | 1 |
STATE_REVOKED | 2 |
STATE_EXPIRED | 3 |
litrpc.SessionType
Name | Number |
---|---|
TYPE_MACAROON_READONLY | 0 |
TYPE_MACAROON_ADMIN | 1 |
TYPE_MACAROON_CUSTOM | 2 |
TYPE_UI_PASSWORD | 3 |
TYPE_AUTOPILOT | 4 |
TYPE_MACAROON_ACCOUNT | 5 |