lnd/lnrpc
bitromortac 32373b76c7
htlcswitch+lnrpc: report node-ID next hop to the off-chain HTLC interceptor
When the switch forwards a blinded hop identified by node ID, it has not
yet resolved a concrete outgoing channel at interception time. Expose the
next hop to the interceptor: InterceptedForward.Packet() reports the
packet's outgoing channel as-is (hop.Exit, since none is selected yet) and
carries the requested pubkey in OutgoingNodeID.

At the RPC boundary, forwardInterceptor.onIntercept maps a node-ID hop to
the reserved NodeIDForwardSCID sentinel in outgoing_requested_chan_id and
the pubkey in outgoing_requested_node_id, so a client switching on a zero
channel ID to detect the exit hop does not misread the forward as a final
receive. The sentinel is a wire-only concern, applied where the request is
built rather than in the switch's internal InterceptedPacket, which stays
truthful (OutgoingNodeID.IsSome() is the node-ID discriminator).
2026-07-30 08:57:18 +00:00
..
autopilotrpc mod: bump protobuf hex display fork 2026-06-09 07:19:03 -03:00
chainrpc multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
devrpc multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
invoicesrpc chanstate: use channel types in consumers 2026-07-07 07:18:56 -03:00
lnclipb mod: bump protobuf hex display fork 2026-06-09 07:19:03 -03:00
neutrinorpc multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
peersrpc mod: bump protobuf hex display fork 2026-06-09 07:19:03 -03:00
routerrpc htlcswitch+lnrpc: report node-ID next hop to the off-chain HTLC interceptor 2026-07-30 08:57:18 +00:00
signrpc multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
verrpc mod: bump protobuf hex display fork 2026-06-09 07:19:03 -03:00
walletrpc chanstate: use channel type in wallet rpc 2026-07-07 07:18:57 -03:00
watchtowerrpc mod: bump protobuf hex display fork 2026-06-09 07:19:03 -03:00
wtclientrpc mod: bump protobuf hex display fork 2026-06-09 07:19:03 -03:00
.clang-format make+travis: verify compiled protos on travis 2020-03-10 13:03:01 +01:00
Dockerfile build: bump Go versions 2026-06-08 17:02:58 -03:00
file_utils.go invoicesrpc: add SubscribeSingleInvoice rpc 2019-02-01 09:43:17 +01:00
gen_protos.sh lnrpc/gen_protos: remove manual_imports 2024-08-05 16:00:00 +02:00
gen_protos_docker.sh build: bump Go versions 2026-06-08 17:02:58 -03:00
lightning.pb.go lnrpc: document reply_path verbatim passthrough on OnionMessageUpdate 2026-06-23 11:09:19 +02:00
lightning.pb.gw.go proto: remove deprecated SendPayment, SendToRoute, TrackPayment RPCs 2026-05-19 09:43:26 -03:00
lightning.pb.json.go proto: remove deprecated SendPayment, SendToRoute, TrackPayment RPCs 2026-05-19 09:43:26 -03:00
lightning.proto lnrpc: document reply_path verbatim passthrough on OnionMessageUpdate 2026-06-23 11:09:19 +02:00
lightning.swagger.json lnrpc: document reply_path verbatim passthrough on OnionMessageUpdate 2026-06-23 11:09:19 +02:00
lightning.yaml proto: remove deprecated SendPayment, SendToRoute, TrackPayment RPCs 2026-05-19 09:43:26 -03:00
lightning_grpc.pb.go proto: remove deprecated SendPayment, SendToRoute, TrackPayment RPCs 2026-05-19 09:43:26 -03:00
marshall_utils.go multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
metadata.go proto: remove deprecated SendPayment, SendToRoute, TrackPayment RPCs 2026-05-19 09:43:26 -03:00
README.md proto: remove deprecated SendPayment, SendToRoute, TrackPayment RPCs 2026-05-19 09:43:26 -03:00
rpc_utils.go multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
state.pb.json.go lnrpc/Dockerfile: update falafel version 2024-08-05 15:59:50 +02:00
stateservice.pb.go mod: bump protobuf hex display fork 2026-06-09 07:19:03 -03:00
stateservice.pb.gw.go build: add temporary kvdb mod replace 2025-04-01 12:40:32 +02:00
stateservice.proto Add comments for all wallet states [skip ci] 2022-09-15 09:14:36 -05:00
stateservice.swagger.json build: add temporary kvdb mod replace 2025-04-01 12:40:32 +02:00
stateservice.yaml lnrpc: split REST annotations into service files 2021-07-27 12:59:52 +02:00
stateservice_grpc.pb.go lnrpc: update grpc-gateway library to v2 2021-07-27 13:09:59 +02:00
sub_server.go lnrpc: update grpc-gateway library to v2 2021-07-27 13:09:59 +02:00
walletunlocker.pb.go mod: bump protobuf hex display fork 2026-06-09 07:19:03 -03:00
walletunlocker.pb.gw.go build: add temporary kvdb mod replace 2025-04-01 12:40:32 +02:00
walletunlocker.pb.json.go lnrpc/Dockerfile: update falafel version 2024-08-05 15:59:50 +02:00
walletunlocker.proto protolint: configure protolint and fix the protolinting issues 2024-01-22 22:00:00 +02:00
walletunlocker.swagger.json build: add temporary kvdb mod replace 2025-04-01 12:40:32 +02:00
walletunlocker.yaml lnrpc: split REST annotations into service files 2021-07-27 12:59:52 +02:00
walletunlocker_grpc.pb.go lnrpc: re-compile protos w/ Go 1.19 2022-08-24 11:43:00 -05:00
websocket_proxy.go multi: golang.org/x/net/context -> context 2025-08-30 14:13:44 -03:00

lnrpc

MIT licensed GoDoc

This lnrpc package implements both a client and server for lnds RPC system which is based off of the high-performance cross-platform gRPC RPC framework. By default, only the Go client+server libraries are compiled within the package. In order to compile the client side libraries for other supported languages, the protoc tool will need to be used to generate the compiled protos for a specific language.

The following languages are supported as clients to lnrpc: C++, Go, Node.js, Java, Ruby, Android Java, PHP, Python, C#, Objective-C.

Service: Lightning

The list of defined RPCs on the service Lightning are the following (with a brief description):

  • WalletBalance
    • Returns the wallet's current confirmed balance in BTC.
  • ChannelBalance
    • Returns the daemons' available aggregate channel balance in BTC.
  • GetTransactions
    • Returns a list of on-chain transactions that pay to or are spends from lnd.
  • SendCoins
    • Sends an amount of satoshis to a specific address.
  • ListUnspent
    • Lists available utxos within a range of confirmations.
  • SubscribeTransactions
    • Returns a stream which sends async notifications each time a transaction is created or one is received that pays to us.
  • SendMany
    • Allows the caller to create a transaction with an arbitrary fan-out (many outputs).
  • NewAddress
    • Returns a new address, the following address types are supported: pay-to-witness-key-hash (p2wkh) and nested-pay-to-witness-key-hash (np2wkh).
  • SignMessage
    • Signs a message with the node's identity key and returns a zbase32 encoded signature.
  • VerifyMessage
    • Verifies a signature signed by another node on a message. The other node must be an active node in the channel database.
  • ConnectPeer
    • Connects to a peer identified by a public key and host.
  • DisconnectPeer
    • Disconnects a peer identified by a public key.
  • ListPeers
    • Lists all available connected peers.
  • GetInfo
    • Returns basic data concerning the daemon.
  • GetRecoveryInfo
    • Returns information about recovery process.
  • PendingChannels
    • List the number of pending (not fully confirmed) channels.
  • ListChannels
    • List all active channels the daemon manages.
  • OpenChannelSync
    • OpenChannelSync is a synchronous version of the OpenChannel RPC call.
  • OpenChannel
    • Attempts to open a channel to a target peer with a specific amount and push amount.
  • CloseChannel
    • Attempts to close a target channel. A channel can either be closed cooperatively if the channel peer is online, or using a "force" close to broadcast the latest channel state.
  • AddInvoice
    • Adds an invoice to the daemon. Invoices are automatically settled once seen as an incoming HTLC.
  • ListInvoices
    • Lists all stored invoices.
  • LookupInvoice
    • Attempts to look up an invoice by payment hash (r-hash).
  • SubscribeInvoices
    • Creates a uni-directional stream which receives async notifications as the daemon settles invoices
  • DecodePayReq
    • Decode a payment request, returning a full description of the conditions encoded within the payment request.
  • ListPayments
    • List all outgoing Lightning payments the daemon has made.
  • DeleteAllPayments
    • Deletes all outgoing payments from DB.
  • DescribeGraph
    • Returns a description of the known channel graph from the PoV of the node.
  • GetChanInfo
    • Returns information for a specific channel identified by channel ID.
  • GetNodeInfo
    • Returns information for a particular node identified by its identity public key.
  • QueryRoutes
    • Queries for a possible route to a target peer which can carry a certain amount of payment.
  • GetNetworkInfo
    • Returns some network level statistics.
  • StopDaemon
    • Sends a shutdown request to the interrupt handler, triggering a graceful shutdown of the daemon.
  • SubscribeChannelGraph
    • Creates a stream which receives async notifications upon any changes to the channel graph topology from the point of view of the responding node.
  • DebugLevel
    • Set logging verbosity of lnd programmatically
  • FeeReport
    • Allows the caller to obtain a report detailing the current fee schedule enforced by the node globally for each channel.
  • UpdateChannelPolicy
    • Allows the caller to update the fee schedule and channel policies for all channels globally, or a particular channel.
  • ForwardingHistory
    • ForwardingHistory allows the caller to query the htlcswitch for a record of all HTLCs forwarded.
  • BakeMacaroon
    • Bakes a new macaroon with the provided list of permissions and restrictions
  • ListMacaroonIDs
    • List all the macaroon root key IDs that are in use.
  • DeleteMacaroonID
    • Remove a specific macaroon root key ID from the database and invalidates all macaroons derived from the key with that ID.

Service: WalletUnlocker

The list of defined RPCs on the service WalletUnlocker are the following (with a brief description):

  • CreateWallet
    • Set encryption password for the wallet database.
  • UnlockWallet
    • Provide a password to unlock the wallet database.

Installation and Updating

$  go get -u github.com/lightningnetwork/lnd/lnrpc

Generate protobuf definitions

To compile the lnrpc/**/*.proto files and generate the protobuf definitions, you need to have Docker and make installed.

Simply run make rpc to start the compilation process.

Format .proto files

We use clang-format to make sure the .proto files are formatted correctly.

When running the make rpc command, the .proto files are also formatted. To format the files without also compiling them, you can install the clang-format formatter on Ubuntu by running apt install clang-format or on Mac by running brew install clang-format. The make format command should then produce the correct result.

Consult this page to find binaries for other operating systems or distributions.

Makefile commands

The following commands are available with make:

  • rpc: Compile and format all .proto files using Docker (calls lnrpc/gen_protos_docker.sh).
  • rpc-format: Formats all .proto files according to our formatting rules. Requires clang-format, see previous chapter.
  • rpc-check: Runs both previous commands and makes sure the git work tree is not dirty. This can be used to check that the .proto files are formatted and compiled properly.