• Stars
    star
    130
  • Rank 277,575 (Top 6 %)
  • Language
    Go
  • License
    MIT License
  • Created about 5 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Lightning Channel Management & Optimization Tool

faraday

MIT licensed

Faraday is a suite of tools built to help node operators and businesses run lnd, the leading implementation of the Lightning Network. Faraday’s tools decrease the operational overhead of running a Lightning node and make it easier to build businesses on Lightning. The current features in the Faraday suite provide insight into node channel performance and support for accounting with both on-chain and off-chain reports for lnd.

LND

Note that Faraday requires lnd to be built with all of its subservers and requires running at least v0.11.1. Download the official release binary or see the instructions in the lnd repo for more detailed installation instructions. If you choose to build lnd from source, following command to enable all the relevant subservers:

make install tags="signrpc walletrpc chainrpc invoicesrpc"

Installation

A Makefile is provided. To install faraday and all its dependencies, run:

git clone https://github.com/lightninglabs/faraday.git
cd faraday
make && make install

Usage

Faraday connects to a single instance of lnd. It requires access to lnd's admin.macaroon (or a custom scoped macaroon, see below) and a valid TLS certificate. It will attempt to use the default lnd values if no command line flags are specified.

./faraday                                                   \
--lnd.macaroonpath={full path to lnd's admin.macaroon}   \
--lnd.tlscertpath={path to lnd cert}                        \
--lnd.rpcserver={host:port of lnd's rpcserver} 

By default, faraday runs on mainnet. The --network flag can be used to run in test environments.

Baking a custom macaroon for Faraday

Faraday needs to derive a shared key with lnd to create an encryption password for its macaroon database. That's why on top of the permissions in the readonly.macaroon the uri:/signrpc.Signer/DeriveSharedKey is also required. A custom scoped macaroon just for Faraday can be baked with:

lncli bakemacaroon onchain:read offchain:read address:read peers:read info:read invoices:read uri:/signrpc.Signer/DeriveSharedKey

Authentication and transport security

The gRPC and REST connections of faraday are encrypted with TLS and secured with macaroon authentication the same way lnd is.

If no custom faraday directory is set then the TLS certificate is stored in ~/.faraday/<network>/tls.cert and the base macaroon in ~/.faraday/<network>/faraday.macaroon.

The frcli command will pick up these file automatically on mainnet if no custom faraday directory is used. For other networks it should be sufficient to add the --network flag to tell the CLI in what sub directory to look for the files.

For more information on macaroons, see the macaroon documentation of lnd.

NOTE: Faraday's macaroons are independent from lnd's. The same macaroon cannot be used for both faraday and lnd.

Chain Backend

Faraday offers node accounting services which require access to a Bitcoin node with --txindex set so that it can perform transaction lookup. Currently the CloseReport endpoint requires this connection, and will fail if it is not present. It is strongly recommended to provide this connection when utilizing the NodeAudit endpoint, but it is not required. This connection is optional, and all other endpoints will function if it is not configured.

To connect Faraday to bitcoind:

--connect_bitcoin                       \
--bitcoin.host={host:port of bitcoind}  \
--bitcoin.user={bitcoind username}      \
--bitcoin.password={bitcoind  password}

To connect Faraday to btcd:

--connect_bitcoin                   \
--bitcoin.host={host:port of btcd}  \
--bitcoin.user={btcd username}      \
--bitcoin.password={btcd password}  \
--bitcoin.usetls                    \
--bitcoin.tlspath={path to btcd cert}

RPCServer

Faraday serves requests over grpc by default on localhost:8465. This default can be overwritten:

--rpclisten={host:port to listen for requests}

Cli Tool

The RPC server can be conveniently accessed using a command line tool.

  1. Run faraday as detailed above
./frcli {command}
Commands
  • insights: expose metrics gathered for one or many channels.
  • revenue: generate a revenue report over a time period for one or many channels.
  • outliers: close recommendations based whether channels are outliers based on a variety of metrics.
  • threshold: close recommendations based on thresholds a variety of metrics.
  • audit: produce an accounting report for your node over a period of time, please see the accounting documentation for details. Chain backend strongly recommended, fee entries for channel closes and sweeps will be missing if a chain connection is not provided.
  • fiat: get the USD price for an amount of Bitcoin at a given time, currently obtained from CoinCap's historical price API.
  • closereport: provides a channel specific fee report, including fees paid on chain. This endpoint is currently only implemented for cooperative closes. Requires chain backend.

Metrics currently tracked

The following metrics are tracked in faraday and exposed via insights and used for outliers and threshold close recommendations.

  • Uptime
  • Revenue
  • Total Volume
  • Incoming Volume
  • Outgoing Volume

Development

If you would like to contribute to Faraday, please see our issues page for currently open issues. If a feature that you would like to add is not covered by an existing issue, please open an issue to discuss the proposed addition. Contributions are hugely appreciated, and we will do our best to review pull requests timeously.

Tests

To run all the unit tests in the repo:

make check

To run Faraday's itests locally, you will need docker installed. To run all itests:

make itest

Individual itests can also be run using:

./run_itest.sh {test name}

More Repositories

1

lightning-app

An easy-to-use cross-platform Lightning wallet
JavaScript
901
star
2

neutrino

Privacy-Preserving Bitcoin Light Client
Go
899
star
3

loop

Lightning Loop: A Non-Custodial Off/On Chain Bridge
Go
558
star
4

lightning-terminal

Lightning Terminal: Your Home for Lightning Liquidity
Go
499
star
5

taproot-assets

A layer 1 daemon, for the Taproot Assets Protocol specification, written in Go (golang)
Go
458
star
6

pool

Lightning Pool: a non-custodial batched uniform clearing-price auction for Lightning Channel Leases (LCL). An LCL packages up inbound channel liquidity (ability to receive funds) as a fixed income asset with a maturity date expressed in blocks.
Go
253
star
7

aperture

⚡️L402 (Lightning HTTP 402) Reverse Proxy ⚡️
Go
233
star
8

chantools

A loose collection of tools all somehow related to lnd and Lightning Network channels.
Go
219
star
9

lndmon

🔎lndmon: A drop-in monitoring solution for your lnd node using Prometheus+Grafana
Go
151
star
10

LangChainBitcoin

AI tools for giving LangChain agents access to Bitcoin and the ability to traverse L402 APIs
Python
128
star
11

lightning-node-connect

Go
78
star
12

L402

lsat protocol specification
71
star
13

lightning-faucet

A faucet for the Lightning Network!
Go
71
star
14

lightning-coindesk

A tutorial news app exemplifying Lightning Network micropayments integration
Python
54
star
15

docs.lightning.engineering

Building lapps, running lnd, and more
Markdown
50
star
16

lndclient

Golang client library for lnd
Go
48
star
17

lnc-web

Lightning Node Connect npm module for web
TypeScript
48
star
18

lightning-api

JavaScript
35
star
19

falafel

Go tool to generate go APIs for gRPC services for use on mobile/WASM platforms.
Go
34
star
20

lndinit

cloud infra tooling for lnd provisioning/unlocking
Go
26
star
21

lightning-dev-site

Lightning Network Daemon Developer Site
CSS
25
star
22

builders-guide-sample-app

TypeScript
14
star
23

lightninglabs.github.io

CSS
13
star
24

pool-paper

Lightning Pool: A Non-Custodial Channel Lease Marketplace
TeX
11
star
25

chanleakcheck

A tool to check if your lnd node was targeted by CVE-2019-12999
Go
10
star
26

lnc-rn

Lightning Node Connect npm module for React Native
TypeScript
8
star
27

lnc-core

Type definitions and utilities for Lightning Node Connect, leveraged by lnc-web and lnc-rn
TypeScript
7
star
28

dust-tool

dust exposure tool
Go
6
star
29

lightning-api-ng

Automated API-documentation generation source code for Lightning Lab's FOSS software suite
Go
5
star
30

lnd-fuzz

Shell
3
star
31

gh-actions

Vendored GitHub Action scripts
TypeScript
3
star
32

aezeedcheck

A offline CLI that allows one to verify their aezeed mnemonic
Go
2
star