CloseReport
Get a channel close report for a specific channel.
Example request: http://localhost:8466/v1/faraday/closereport
Source: faraday.proto
gRPC
rpc CloseReport (CloseReportRequest) returns (CloseReportResponse);
REST
HTTP Method | Path |
---|---|
GET | /v1/faraday/closereport |
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:8465'
const MACAROON_PATH = 'FARADAY_DIR/regtest/faraday.macaroon'
const TLS_PATH = 'FARADAY_DIR/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 = {
channel_point: <string>,
};
client.closeReport(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "channel_point": <string>,
// "channel_initiator": <bool>,
// "close_type": <string>,
// "close_txid": <string>,
// "open_fee": <string>,
// "close_fee": <string>,
// }
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/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.CloseReportRequest(
channel_point=<string>,
)
response = stub.CloseReport(request)
print(response)
# {
# "channel_point": <string>,
# "channel_initiator": <bool>,
# "close_type": <string>,
# "close_txid": <string>,
# "open_fee": <string>,
# "close_fee": <string>,
# }
- Javascript
- Python
const fs = require('fs');
const request = require('request');
const REST_HOST = 'localhost:8082'
const MACAROON_PATH = 'FARADAY_DIR/regtest/faraday.macaroon'
let options = {
url: `https://${REST_HOST}/v1/faraday/closereport`,
// 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:
// {
// "channel_point": <string>, // <string>
// "channel_initiator": <boolean>, // <bool>
// "close_type": <string>, // <string>
// "close_txid": <string>, // <string>
// "open_fee": <string>, // <string>
// "close_fee": <string>, // <string>
// }
import base64, codecs, json, requests
REST_HOST = 'localhost:8082'
MACAROON_PATH = 'FARADAY_DIR/regtest/faraday.macaroon'
TLS_PATH = 'FARADAY_DIR/tls.cert'
url = f'https://{REST_HOST}/v1/faraday/closereport'
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())
# {
# "channel_point": <string>,
# "channel_initiator": <bool>,
# "close_type": <string>,
# "close_txid": <string>,
# "open_fee": <string>,
# "close_fee": <string>,
# }
# There is no CLI command for this RPC
Messages
frdrpc.CloseReportRequest
Source: faraday.proto
Field | gRPC Type | REST Type | REST Placement |
---|---|---|---|
channel_point | string | string | query |
frdrpc.CloseReportResponse
Source: faraday.proto
Field | gRPC Type | REST Type |
---|---|---|
channel_point | string | string |
channel_initiator | bool | boolean |
close_type | string | string |
close_txid | string | string |
open_fee | string | string |
close_fee | string | string |