ForwardingAbility
Get forwarding ability analysis of peer pairs.
Source: faraday.proto
gRPC
rpc ForwardingAbility (ForwardingAbilityRequest) returns (ForwardingAbilityResponse);
Code Samples
- gRPC
- Javascript
- Python
- grpcurl
const fs = require('fs');
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');
const GRPC_HOST = 'localhost:8465'
const MACAROON_PATH = 'FARADAY_DIR/regtest/faraday.macaroon'
const TLS_PATH = 'FARADAY_DIR/regtest/tls.cert'
const loaderOptions = {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
};
const packageDefinition = protoLoader.loadSync('faraday.proto', loaderOptions);
const frdrpc = grpc.loadPackageDefinition(packageDefinition).frdrpc;
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 frdrpc.FaradayServer(GRPC_HOST, creds);
let request = {
start_time: <uint64>,
end_time: <uint64>,
liquidity_floor_sat: <uint64>,
uptime_threshold: <double>,
};
client.forwardingAbility(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "peers": <bytes>,
// "entries": <ForwardingAbilityEntry>,
// "start_time": <int64>,
// "end_time": <int64>,
// "up_but_idle_bitmask": <bytes>,
// "uptime_threshold": <double>,
// }
import codecs, grpc, os
# Generate the following 2 modules by compiling the faraday.proto with the grpcio-tools.
# See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions.
import faraday_pb2 as frdrpc, faraday_pb2_grpc as faradaystub
GRPC_HOST = 'localhost:8465'
MACAROON_PATH = 'FARADAY_DIR/regtest/faraday.macaroon'
TLS_PATH = 'FARADAY_DIR/regtest/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 = faradaystub.FaradayServerStub(channel)
request = frdrpc.ForwardingAbilityRequest(
start_time=<uint64>,
end_time=<uint64>,
liquidity_floor_sat=<uint64>,
uptime_threshold=<double>,
)
response = stub.ForwardingAbility(request)
print(response)
# {
# "peers": <bytes>,
# "entries": <ForwardingAbilityEntry>,
# "start_time": <int64>,
# "end_time": <int64>,
# "up_but_idle_bitmask": <bytes>,
# "uptime_threshold": <double>,
# }
# grpcurl docs: https://github.com/fullstorydev/grpcurl
# Proto source: https://github.com/lightninglabs/faraday
GRPC_HOST=localhost:8465
FARADAY_DIR=~/.faraday
FARADAY_SOURCE=path/to/faraday
NETWORK=mainnet
MACAROON_PATH="$FARADAY_DIR/$NETWORK/faraday.macaroon"
TLS_PATH="$FARADAY_DIR/$NETWORK/tls.cert"
grpcurl \
-import-path $FARADAY_SOURCE/frdrpc/ \
-proto faraday.proto \
-cacert $TLS_PATH \
-H "macaroon: $(xxd -ps -u -c 1000 $MACAROON_PATH)" \
-d '{ "start_time": <uint64>, "end_time": <uint64>, "liquidity_floor_sat": <uint64>, "uptime_threshold": <double> }' \
$GRPC_HOST \
frdrpc.FaradayServer/ForwardingAbility
Messages
frdrpc.ForwardingAbilityRequest
Source: faraday.proto
| Field | gRPC Type | REST Type | REST Placement |
|---|---|---|---|
start_time | uint64 | unknown | unknown |
end_time | uint64 | unknown | unknown |
liquidity_floor_sat | uint64 | unknown | unknown |
uptime_threshold | double | unknown | unknown |
frdrpc.ForwardingAbilityResponse
Source: faraday.proto
| Field | gRPC Type | REST Type |
|---|---|---|
peers | bytes[] | array |
entries | ForwardingAbilityEntry[] | array |
start_time | int64 | string |
end_time | int64 | string |
up_but_idle_bitmask | bytes | string |
uptime_threshold | double | number |
Nested Messages
frdrpc.ForwardingAbilityEntry
| Field | gRPC Type | REST Type |
|---|---|---|
packed_idx | uint32 | integer |
effective_uptime_s | int64 | string |
forwarded_sat | int64 | string |