NodeAudit
Get a report of your node's activity over a period.
Example request: http://localhost:8466/v1/faraday/nodeaudit
Source: faraday.proto
gRPC
rpc NodeAudit (NodeAuditRequest) returns (NodeAuditResponse);
REST
HTTP Method | Path |
---|---|
GET | /v1/faraday/nodeaudit |
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 = {
start_time: <uint64>,
end_time: <uint64>,
disable_fiat: <bool>,
granularity: <Granularity>,
custom_categories: <CustomCategory>,
fiat_backend: <FiatBackend>,
custom_prices: <BitcoinPrice>,
};
client.nodeAudit(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "reports": <ReportEntry>,
// }
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.NodeAuditRequest(
start_time=<uint64>,
end_time=<uint64>,
disable_fiat=<bool>,
granularity=<Granularity>,
custom_categories=<CustomCategory>,
fiat_backend=<FiatBackend>,
custom_prices=<BitcoinPrice>,
)
response = stub.NodeAudit(request)
print(response)
# {
# "reports": <ReportEntry>,
# }
- 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/nodeaudit`,
// 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:
// {
// "reports": <array>, // <ReportEntry>
// }
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/nodeaudit'
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())
# {
# "reports": <ReportEntry>,
# }
# There is no CLI command for this RPC
Messages
frdrpc.NodeAuditRequest
Source: faraday.proto
Field | gRPC Type | REST Type | REST Placement |
---|---|---|---|
start_time | uint64 | string | query |
end_time | uint64 | string | query |
disable_fiat | bool | boolean | query |
granularity | Granularity | string | query |
custom_categories | CustomCategory[] | array | unknown |
fiat_backend | FiatBackend | string | query |
custom_prices | BitcoinPrice[] | array | unknown |
frdrpc.NodeAuditResponse
Source: faraday.proto
Field | gRPC Type | REST Type |
---|---|---|
reports | ReportEntry[] | array |
Nested Messages
frdrpc.BitcoinPrice
Field | gRPC Type | REST Type |
---|---|---|
price | string | string |
price_timestamp | uint64 | string |
currency | string | string |
frdrpc.CustomCategory
Field | gRPC Type | REST Type |
---|---|---|
name | string | string |
on_chain | bool | boolean |
off_chain | bool | boolean |
label_patterns | string[] | array |
frdrpc.ReportEntry
Field | gRPC Type | REST Type |
---|---|---|
timestamp | uint64 | string |
on_chain | bool | boolean |
amount | uint64 | string |
credit | bool | boolean |
asset | string | string |
type | EntryType | string |
custom_category | string | string |
txid | string | string |
fiat | string | string |
reference | string | string |
note | string | string |
btc_price | BitcoinPrice | object |
Enums
frdrpc.EntryType
Name | Number |
---|---|
UNKNOWN | 0 |
LOCAL_CHANNEL_OPEN | 1 |
REMOTE_CHANNEL_OPEN | 2 |
CHANNEL_OPEN_FEE | 3 |
CHANNEL_CLOSE | 4 |
RECEIPT | 5 |
PAYMENT | 6 |
FEE | 7 |
CIRCULAR_RECEIPT | 8 |
FORWARD | 9 |
FORWARD_FEE | 10 |
CIRCULAR_PAYMENT | 11 |
CIRCULAR_FEE | 12 |
SWEEP | 13 |
SWEEP_FEE | 14 |
CHANNEL_CLOSE_FEE | 15 |
frdrpc.FiatBackend
Name | Number |
---|---|
UNKNOWN_FIATBACKEND | 0 |
COINCAP | 1 |
COINDESK | 2 |
CUSTOM | 3 |
COINGECKO | 4 |
frdrpc.Granularity
Name | Number |
---|---|
UNKNOWN_GRANULARITY | 0 |
MINUTE | 1 |
FIVE_MINUTES | 2 |
FIFTEEN_MINUTES | 3 |
THIRTY_MINUTES | 4 |
HOUR | 5 |
SIX_HOURS | 6 |
TWELVE_HOURS | 7 |
DAY | 8 |