# LND

Welcome to the API reference documentation for LND, the Lightning Network Daemon.

The Lightning Network Daemon (`lnd`) - is a complete implementation of a [Lightning Network](https://lightning.network/) node. `lnd` has several pluggable back-end chain services including [`btcd`](https://github.com/btcsuite/btcd) (a full-node), [`bitcoind`](https://github.com/bitcoin/bitcoin), and [`neutrino`](https://github.com/lightninglabs/neutrino) (a new experimental light client). The project's codebase uses the [btcsuite](https://github.com/btcsuite/) set of Bitcoin libraries, and also exports a large set of isolated re-usable Lightning Network related libraries within it. In the current state `lnd` is capable of:

- Creating channels.
- Closing channels.
- Completely managing all channel states (including the exceptional ones!).
- Maintaining a fully authenticated+validated channel graph.
- Performing path finding within the network, passively forwarding incoming payments.
- Sending outgoing [onion-encrypted payments](https://github.com/lightningnetwork/lightning-onion) through the network.
- Updating advertised fee schedules.
- Automatic channel management ( [`autopilot`](https://github.com/lightningnetwork/lnd/tree/master/autopilot)).

## Usage  
Learn how to install, configure, and use LND by viewing the documentation in the [Builder's Guide](https://docs.lightning.engineering/lightning-network-tools/lnd/run-lnd).

## Summary  
This site features the API documentation for `lncli` (CLI), [Python](https://dev.lightning.community/guides/python-grpc/), and [JavaScript](https://dev.lightning.community/guides/javascript-grpc/) in order to communicate with a local `lnd` instance through gRPC and REST. It is intended for those who already understand how to work with LND. If this is your first time or you need a refresher, you may consider perusing our LND developer site featuring a tutorial, resources and guides at [dev.lightning.community](https://dev.lightning.community/).

## gRPC  
The code samples assume that the there is a local `lnd` instance running and listening for gRPC connections on port `10009`. `LND_DIR` will be used as a placeholder to denote the base directory of the `lnd` instance. By default, this is `~/.lnd` on Linux and `~/Library/Application Support/Lnd` on macOS.

At the time of writing this documentation, two things are needed in order to make a gRPC request to an `lnd` instance: a TLS/SSL connection and a macaroon used for RPC authentication. The code samples will show how these can be used in order to make a successful, secure, and authenticated gRPC request.

The original `*.proto` files from which the gRPC documentation was generated can be found here:

- [`autopilotrpc/autopilot.proto`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/autopilotrpc/autopilot.proto)
- [`chainrpc/chainkit.proto`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/chainrpc/chainkit.proto)
- [`chainrpc/chainnotifier.proto`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/chainrpc/chainnotifier.proto)
- [`devrpc/dev.proto`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/devrpc/dev.proto)
- [`invoicesrpc/invoices.proto`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/invoicesrpc/invoices.proto)
- [`lightning.proto`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/lightning.proto)
- [`lnclipb/lncli.proto`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/lnclipb/lncli.proto)
- [`neutrinorpc/neutrino.proto`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/neutrinorpc/neutrino.proto)
- [`peersrpc/peers.proto`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/peersrpc/peers.proto)
- [`routerrpc/router.proto`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/routerrpc/router.proto)
- [`signrpc/signer.proto`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/signrpc/signer.proto)
- [`stateservice.proto`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/stateservice.proto)
- [`verrpc/verrpc.proto`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/verrpc/verrpc.proto)
- [`walletrpc/walletkit.proto`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/walletrpc/walletkit.proto)
- [`walletunlocker.proto`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/walletunlocker.proto)
- [`watchtowerrpc/watchtower.proto`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/watchtowerrpc/watchtower.proto)
- [`wtclientrpc/wtclient.proto`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/wtclientrpc/wtclient.proto)

## REST  
View a listing of all REST URLs on the [REST Endpoints](/content/api-docs/api/lnd/rest-endpoints/index.html) page.

The code samples assume that the there is a local `lnd` instance running and listening for REST connections on port `8080`. `LND_DIR` will be used as a placeholder to denote the base directory of the `lnd` instance. By default, this is `~/.lnd` on Linux and `~/Library/Application Support/Lnd` on macOS.

At the time of writing this documentation, two things are needed in order to make an HTTP request to an `lnd` instance: a TLS/SSL connection and a macaroon used for RPC authentication. The code samples will show how these can be used in order to make a successful, secure, and authenticated HTTP request.

The original `*.swagger.json` files from which the gRPC documentation was generated can be found here:

- [`autopilotrpc/autopilot.swagger.json`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/autopilotrpc/autopilot.swagger.json)
- [`chainrpc/chainkit.swagger.json`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/chainrpc/chainkit.swagger.json)
- [`chainrpc/chainnotifier.swagger.json`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/chainrpc/chainnotifier.swagger.json)
- [`devrpc/dev.swagger.json`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/devrpc/dev.swagger.json)
- [`invoicesrpc/invoices.swagger.json`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/invoicesrpc/invoices.swagger.json)
- [`lightning.swagger.json`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/lightning.swagger.json)
- [`lnclipb/lncli.swagger.json`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/lnclipb/lncli.swagger.json)
- [`neutrinorpc/neutrino.swagger.json`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/neutrinorpc/neutrino.swagger.json)
- [`peersrpc/peers.swagger.json`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/peersrpc/peers.swagger.json)
- [`routerrpc/router.swagger.json`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/routerrpc/router.swagger.json)
- [`signrpc/signer.swagger.json`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/signrpc/signer.swagger.json)
- [`stateservice.swagger.json`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/stateservice.swagger.json)
- [`verrpc/verrpc.swagger.json`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/verrpc/verrpc.swagger.json)
- [`walletrpc/walletkit.swagger.json`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/walletrpc/walletkit.swagger.json)
- [`walletunlocker.swagger.json`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/walletunlocker.swagger.json)
- [`watchtowerrpc/watchtower.swagger.json`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/watchtowerrpc/watchtower.swagger.json)
- [`wtclientrpc/wtclient.swagger.json`](https://github.com/lightningnetwork/lnd/blob/1a6ecebcbf490de5e8932c782b0d57c5d57c5679/lnrpc/wtclientrpc/wtclient.swagger.json)

### REST Encoding  
**NOTE**: The `byte` field type must be set as the base64 encoded string representation of a raw byte array. Also, any time this must be used in a URL path (ie. `/v1/abc/xyz/{payment_hash}`) the base64 string must be encoded using a [URL and Filename Safe Alphabet](https://tools.ietf.org/html/rfc4648#section-5). This means you must replace `+` with `-`, `/` with `_`, and keep the trailing `=` as is. Url encoding (ie. `%2F`) will not work.

This documentation was [generated automatically](https://github.com/lightninglabs/lightning-api-ng) against commit [`1a6ecebcbf490de5e8932c782b0d57c5d57c5679`](https://github.com/lightningnetwork/lnd/tree/1a6ecebcbf490de5e8932c782b0d57c5d57c5679).

## Experimental services  
The following RPCs/services are currently considered to be experimental. This means they are subject to change in the future. They also need to be enabled with a compile-time flag to be active (they are active in the official release binaries).

- [Service _Autopilot_](/content/api-docs/category/autopilot-service/index.html) (file: `autopilotrpc/autopilot.proto`)
- [Service _ChainKit_](/content/api-docs/category/chainkit-service/index.html) (file: `chainrpc/chainkit.proto`)
- [Service _ChainNotifier_](/content/api-docs/category/chainnotifier-service/index.html) (file: `chainrpc/chainnotifier.proto`)
- [Service _Invoices_](/content/api-docs/category/invoices-service/index.html) (file: `invoicesrpc/invoices.proto`)
- [Service _NeutrinoKit_](/content/api-docs/category/neutrinokit-service/index.html) (file: `neutrinorpc/neutrino.proto`)
- [Service _Peers_](/content/api-docs/category/peers-service/index.html) (file: `peersrpc/peers.proto`)
- [Service _Signer_](/content/api-docs/category/signer-service/index.html) (file: `signrpc/signer.proto`)
- [Service _WalletKit_](/content/api-docs/category/walletkit-service/index.html) (file: `walletrpc/walletkit.proto`)
- [Service _Watchtower_](/content/api-docs/category/watchtower-service/index.html) (file: `watchtowerrpc/watchtower.proto`)
