LND gRPC API Reference

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

This site features the API documentation for lncli (CLI), Python, and JavaScript in order to communicate with a local lnd instance through gRPC. 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.

The examples to the right 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 examples to the right 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:

This is the reference for the gRPC API. Alternatively, there is also a REST API which is documented here.

This documentation was generated automatically against commit 3ae46d81f4a2edad06ef778b2940d9b06386d93b .

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

ModifyStatus

Unary RPC

ModifyStatus is used to modify the status of the autopilot agent, like enabling or disabling it.

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/autopilotrpc/autopilot.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import autopilot_pb2 as autopilotrpc , autopilot_pb2_grpc as autopilotstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = autopilotstub . AutopilotStub ( channel ) >>> request = autopilotrpc . ModifyStatusRequest ( enable =< bool > , ) >>> response = stub . ModifyStatus ( request , metadata = [( 'macaroon' , macaroon )]) >>> print ( response ) { }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ([ 'rpc.proto' , 'autopilotrpc/autopilot.proto' ], loaderOptions ); const autopilotrpc = grpc . loadPackageDefinition ( packageDefinition ). autopilotrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 autopilot = new autopilotrpc . Autopilot ( 'localhost:10009' , creds ); let request = { enable : < bool > , }; autopilot . modifyStatus ( request , function ( err , response ) { console . log ( response ); }); // Console output: // { // }

Parameter Type Description enable bool Whether the autopilot agent should be enabled or not.

This response has no parameters.

QueryScores

Unary RPC

QueryScores queries all available autopilot heuristics, in addition to any active combination of these heruristics, for the scores they would give to the given nodes.

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/autopilotrpc/autopilot.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import autopilot_pb2 as autopilotrpc , autopilot_pb2_grpc as autopilotstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = autopilotstub . AutopilotStub ( channel ) >>> request = autopilotrpc . QueryScoresRequest ( pubkeys =< array string > , ignore_local_state =< bool > , ) >>> response = stub . QueryScores ( request , metadata = [( 'macaroon' , macaroon )]) >>> print ( response ) { "results" : < array HeuristicResult > , }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ([ 'rpc.proto' , 'autopilotrpc/autopilot.proto' ], loaderOptions ); const autopilotrpc = grpc . loadPackageDefinition ( packageDefinition ). autopilotrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 autopilot = new autopilotrpc . Autopilot ( 'localhost:10009' , creds ); let request = { pubkeys : < array string > , ignore_local_state : < bool > , }; autopilot . queryScores ( request , function ( err , response ) { console . log ( response ); }); // Console output: // { // "results": <array HeuristicResult>, // }

Parameter Type Description pubkeys array string ignore_local_state bool If set, we will ignore the local channel state when calculating scores.

Parameter Type Description results array HeuristicResult

SetScores

Unary RPC

SetScores attempts to set the scores used by the running autopilot agent, if the external scoring heuristic is enabled.

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/autopilotrpc/autopilot.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import autopilot_pb2 as autopilotrpc , autopilot_pb2_grpc as autopilotstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = autopilotstub . AutopilotStub ( channel ) >>> request = autopilotrpc . SetScoresRequest ( heuristic =< string > , scores =< array ScoresEntry > , ) >>> response = stub . SetScores ( request , metadata = [( 'macaroon' , macaroon )]) >>> print ( response ) { }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ([ 'rpc.proto' , 'autopilotrpc/autopilot.proto' ], loaderOptions ); const autopilotrpc = grpc . loadPackageDefinition ( packageDefinition ). autopilotrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 autopilot = new autopilotrpc . Autopilot ( 'localhost:10009' , creds ); let request = { heuristic : < string > , scores : < array ScoresEntry > , }; autopilot . setScores ( request , function ( err , response ) { console . log ( response ); }); // Console output: // { // }

Parameter Type Description heuristic string The name of the heuristic to provide scores to. scores array ScoresEntry A map from hex-encoded public keys to scores. Scores must be in the range [0.0, 1.0].

This response has no parameters.

Status

Unary RPC

Status returns whether the daemon's autopilot agent is active.

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/autopilotrpc/autopilot.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import autopilot_pb2 as autopilotrpc , autopilot_pb2_grpc as autopilotstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = autopilotstub . AutopilotStub ( channel ) >>> request = autopilotrpc . StatusRequest () >>> response = stub . Status ( request , metadata = [( 'macaroon' , macaroon )]) >>> print ( response ) { "active" : < bool > , }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ([ 'rpc.proto' , 'autopilotrpc/autopilot.proto' ], loaderOptions ); const autopilotrpc = grpc . loadPackageDefinition ( packageDefinition ). autopilotrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 autopilot = new autopilotrpc . Autopilot ( 'localhost:10009' , creds ); let request = {}; autopilot . status ( request , function ( err , response ) { console . log ( response ); }); // Console output: // { // "active": <bool>, // }

This request has no parameters.

Parameter Type Description active bool Indicates whether the autopilot is active or not.

Service ChainNotifier

RegisterBlockEpochNtfn

Server-streaming RPC

RegisterBlockEpochNtfn is a synchronous response-streaming RPC that registers an intent for a client to be notified of blocks in the chain. The stream will return a hash and height tuple of a block for each new/stale block in the chain. It is the client's responsibility to determine whether the tuple returned is for a new or stale block in the chain. A client can also request a historical backlog of blocks from a particular point. This allows clients to be idempotent by ensuring that they do not missing processing a single block within the chain.

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/chainrpc/chainnotifier.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import chainnotifier_pb2 as chainrpc , chainnotifier_pb2_grpc as chainnotifierstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = chainnotifierstub . ChainNotifierStub ( channel ) >>> request = chainrpc . BlockEpoch ( hash =< bytes > , height =< uint32 > , ) >>> for response in stub . RegisterBlockEpochNtfn ( request , metadata = [( 'macaroon' , macaroon )]): print ( response ) { "hash" : < bytes > , "height" : < uint32 > , }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ([ 'rpc.proto' , 'chainrpc/chainnotifier.proto' ], loaderOptions ); const chainrpc = grpc . loadPackageDefinition ( packageDefinition ). chainrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 chainNotifier = new chainrpc . ChainNotifier ( 'localhost:10009' , creds ); let request = { hash : < bytes > , height : < uint32 > , }; let call = chainNotifier . registerBlockEpochNtfn ( request ); call . on ( 'data' , function ( response ) { // A response was received from the server. console . log ( response ); }); call . on ( 'status' , function ( status ) { // The current status of the stream. }); call . on ( 'end' , function () { // The server has closed the stream. }); // Console output: // { // "hash": <bytes>, // "height": <uint32>, // }

Parameter Type Description hash bytes The hash of the block. height uint32 The height of the block.

Parameter Type Description hash bytes The hash of the block. height uint32 The height of the block.

RegisterConfirmationsNtfn

Server-streaming RPC

RegisterConfirmationsNtfn is a synchronous response-streaming RPC that registers an intent for a client to be notified once a confirmation request has reached its required number of confirmations on-chain. A client can specify whether the confirmation request should be for a particular transaction by its hash or for an output script by specifying a zero hash.

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/chainrpc/chainnotifier.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import chainnotifier_pb2 as chainrpc , chainnotifier_pb2_grpc as chainnotifierstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = chainnotifierstub . ChainNotifierStub ( channel ) >>> request = chainrpc . ConfRequest ( txid =< bytes > , script =< bytes > , num_confs =< uint32 > , height_hint =< uint32 > , ) >>> for response in stub . RegisterConfirmationsNtfn ( request , metadata = [( 'macaroon' , macaroon )]): print ( response ) { "conf" : < ConfDetails > , "reorg" : < Reorg > , }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ([ 'rpc.proto' , 'chainrpc/chainnotifier.proto' ], loaderOptions ); const chainrpc = grpc . loadPackageDefinition ( packageDefinition ). chainrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 chainNotifier = new chainrpc . ChainNotifier ( 'localhost:10009' , creds ); let request = { txid : < bytes > , script : < bytes > , num_confs : < uint32 > , height_hint : < uint32 > , }; let call = chainNotifier . registerConfirmationsNtfn ( request ); call . on ( 'data' , function ( response ) { // A response was received from the server. console . log ( response ); }); call . on ( 'status' , function ( status ) { // The current status of the stream. }); call . on ( 'end' , function () { // The server has closed the stream. }); // Console output: // { // "conf": <ConfDetails>, // "reorg": <Reorg>, // }

Parameter Type Description txid bytes The transaction hash for which we should request a confirmation notification for. If set to a hash of all zeros, then the confirmation notification will be requested for the script instead. script bytes An output script within a transaction with the hash above which will be used by light clients to match block filters. If the transaction hash is set to a hash of all zeros, then a confirmation notification will be requested for this script instead. num_confs uint32 The number of desired confirmations the transaction/output script should reach before dispatching a confirmation notification. height_hint uint32 The earliest height in the chain for which the transaction/output script could have been included in a block. This should in most cases be set to the broadcast height of the transaction/output script.

Parameter Type Description conf ConfDetails An event that includes the confirmation details of the request (txid/ouput script). reorg Reorg An event send when the transaction of the request is reorged out of the chain.

RegisterSpendNtfn

Server-streaming RPC

RegisterSpendNtfn is a synchronous response-streaming RPC that registers an intent for a client to be notification once a spend request has been spent by a transaction that has confirmed on-chain. A client can specify whether the spend request should be for a particular outpoint or for an output script by specifying a zero outpoint.

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/chainrpc/chainnotifier.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import chainnotifier_pb2 as chainrpc , chainnotifier_pb2_grpc as chainnotifierstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = chainnotifierstub . ChainNotifierStub ( channel ) >>> request = chainrpc . SpendRequest ( outpoint =< Outpoint > , script =< bytes > , height_hint =< uint32 > , ) >>> for response in stub . RegisterSpendNtfn ( request , metadata = [( 'macaroon' , macaroon )]): print ( response ) { "spend" : < SpendDetails > , "reorg" : < Reorg > , }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ([ 'rpc.proto' , 'chainrpc/chainnotifier.proto' ], loaderOptions ); const chainrpc = grpc . loadPackageDefinition ( packageDefinition ). chainrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 chainNotifier = new chainrpc . ChainNotifier ( 'localhost:10009' , creds ); let request = { outpoint : < Outpoint > , script : < bytes > , height_hint : < uint32 > , }; let call = chainNotifier . registerSpendNtfn ( request ); call . on ( 'data' , function ( response ) { // A response was received from the server. console . log ( response ); }); call . on ( 'status' , function ( status ) { // The current status of the stream. }); call . on ( 'end' , function () { // The server has closed the stream. }); // Console output: // { // "spend": <SpendDetails>, // "reorg": <Reorg>, // }

Parameter Type Description outpoint Outpoint The outpoint for which we should request a spend notification for. If set to a zero outpoint, then the spend notification will be requested for the script instead. script bytes The output script for the outpoint above. This will be used by light clients to match block filters. If the outpoint is set to a zero outpoint, then a spend notification will be requested for this script instead. height_hint uint32 The earliest height in the chain for which the outpoint/output script could have been spent. This should in most cases be set to the broadcast height of the outpoint/output script.

Parameter Type Description spend SpendDetails An event that includes the details of the spending transaction of the request (outpoint/output script). reorg Reorg An event sent when the spending transaction of the request was reorged out of the chain.

Service Invoices

AddHoldInvoice

Unary RPC

AddHoldInvoice creates a hold invoice. It ties the invoice to the hash supplied in the request.

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/invoicesrpc/invoices.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import invoices_pb2 as invoicesrpc , invoices_pb2_grpc as invoicesstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = invoicesstub . InvoicesStub ( channel ) >>> request = invoicesrpc . AddHoldInvoiceRequest ( memo =< string > , hash =< bytes > , value =< int64 > , value_msat =< int64 > , description_hash =< bytes > , expiry =< int64 > , fallback_addr =< string > , cltv_expiry =< uint64 > , route_hints =< array RouteHint > , private =< bool > , ) >>> response = stub . AddHoldInvoice ( request , metadata = [( 'macaroon' , macaroon )]) >>> print ( response ) { "payment_request" : < string > , }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ([ 'rpc.proto' , 'invoicesrpc/invoices.proto' ], loaderOptions ); const invoicesrpc = grpc . loadPackageDefinition ( packageDefinition ). invoicesrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 invoices = new invoicesrpc . Invoices ( 'localhost:10009' , creds ); let request = { memo : < string > , hash : < bytes > , value : < int64 > , value_msat : < int64 > , description_hash : < bytes > , expiry : < int64 > , fallback_addr : < string > , cltv_expiry : < uint64 > , route_hints : < array RouteHint > , private : < bool > , }; invoices . addHoldInvoice ( request , function ( err , response ) { console . log ( response ); }); // Console output: // { // "payment_request": <string>, // }

Parameter Type Description memo string An optional memo to attach along with the invoice. Used for record keeping purposes for the invoice's creator, and will also be set in the description field of the encoded payment request if the description_hash field is not being used. hash bytes The hash of the preimage value int64 The value of this invoice in satoshis The fields value and value_msat are mutually exclusive. value_msat int64 The value of this invoice in millisatoshis The fields value and value_msat are mutually exclusive. description_hash bytes Hash (SHA-256) of a description of the payment. Used if the description of payment (memo) is too long to naturally fit within the description field of an encoded payment request. expiry int64 Payment request expiry time in seconds. Default is 3600 (1 hour). fallback_addr string Fallback on-chain address. cltv_expiry uint64 Delta to use for the time-lock of the CLTV extended to the final hop. route_hints array RouteHint Route hints that can each be individually used to assist in reaching the invoice's destination. private bool Whether this invoice should include routing hints for private channels.

Parameter Type Description payment_request string A bare-bones invoice for a payment within the Lightning Network. With the details of the invoice, the sender has all the data necessary to send a payment to the recipient.

CancelInvoice

Unary RPC

CancelInvoice cancels a currently open invoice. If the invoice is already canceled, this call will succeed. If the invoice is already settled, it will fail.

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/invoicesrpc/invoices.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import invoices_pb2 as invoicesrpc , invoices_pb2_grpc as invoicesstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = invoicesstub . InvoicesStub ( channel ) >>> request = invoicesrpc . CancelInvoiceMsg ( payment_hash =< bytes > , ) >>> response = stub . CancelInvoice ( request , metadata = [( 'macaroon' , macaroon )]) >>> print ( response ) { }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ([ 'rpc.proto' , 'invoicesrpc/invoices.proto' ], loaderOptions ); const invoicesrpc = grpc . loadPackageDefinition ( packageDefinition ). invoicesrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 invoices = new invoicesrpc . Invoices ( 'localhost:10009' , creds ); let request = { payment_hash : < bytes > , }; invoices . cancelInvoice ( request , function ( err , response ) { console . log ( response ); }); // Console output: // { // }

Parameter Type Description payment_hash bytes Hash corresponding to the (hold) invoice to cancel.

This response has no parameters.

SettleInvoice

Unary RPC

SettleInvoice settles an accepted invoice. If the invoice is already settled, this call will succeed.

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/invoicesrpc/invoices.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import invoices_pb2 as invoicesrpc , invoices_pb2_grpc as invoicesstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = invoicesstub . InvoicesStub ( channel ) >>> request = invoicesrpc . SettleInvoiceMsg ( preimage =< bytes > , ) >>> response = stub . SettleInvoice ( request , metadata = [( 'macaroon' , macaroon )]) >>> print ( response ) { }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ([ 'rpc.proto' , 'invoicesrpc/invoices.proto' ], loaderOptions ); const invoicesrpc = grpc . loadPackageDefinition ( packageDefinition ). invoicesrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 invoices = new invoicesrpc . Invoices ( 'localhost:10009' , creds ); let request = { preimage : < bytes > , }; invoices . settleInvoice ( request , function ( err , response ) { console . log ( response ); }); // Console output: // { // }

Parameter Type Description preimage bytes Externally discovered pre-image that should be used to settle the hold invoice.

This response has no parameters.

Server-streaming RPC

SubscribeSingleInvoice returns a uni-directional stream (server -> client) to notify the client of state transitions of the specified invoice. Initially the current invoice state is always sent out.

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/invoicesrpc/invoices.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import invoices_pb2 as invoicesrpc , invoices_pb2_grpc as invoicesstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = invoicesstub . InvoicesStub ( channel ) >>> request = invoicesrpc . SubscribeSingleInvoiceRequest ( r_hash =< bytes > , ) >>> for response in stub . SubscribeSingleInvoice ( request , metadata = [( 'macaroon' , macaroon )]): print ( response ) { "memo" : < string > , "r_preimage" : < bytes > , "r_hash" : < bytes > , "value" : < int64 > , "value_msat" : < int64 > , "settled" : < bool > , "creation_date" : < int64 > , "settle_date" : < int64 > , "payment_request" : < string > , "description_hash" : < bytes > , "expiry" : < int64 > , "fallback_addr" : < string > , "cltv_expiry" : < uint64 > , "route_hints" : < array RouteHint > , "private" : < bool > , "add_index" : < uint64 > , "settle_index" : < uint64 > , "amt_paid" : < int64 > , "amt_paid_sat" : < int64 > , "amt_paid_msat" : < int64 > , "state" : < InvoiceState > , "htlcs" : < array InvoiceHTLC > , "features" : < array FeaturesEntry > , "is_keysend" : < bool > , }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ([ 'rpc.proto' , 'invoicesrpc/invoices.proto' ], loaderOptions ); const invoicesrpc = grpc . loadPackageDefinition ( packageDefinition ). invoicesrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 invoices = new invoicesrpc . Invoices ( 'localhost:10009' , creds ); let request = { r_hash : < bytes > , }; let call = invoices . subscribeSingleInvoice ( request ); call . on ( 'data' , function ( response ) { // A response was received from the server. console . log ( response ); }); call . on ( 'status' , function ( status ) { // The current status of the stream. }); call . on ( 'end' , function () { // The server has closed the stream. }); // Console output: // { // "memo": <string>, // "r_preimage": <bytes>, // "r_hash": <bytes>, // "value": <int64>, // "value_msat": <int64>, // "settled": <bool>, // "creation_date": <int64>, // "settle_date": <int64>, // "payment_request": <string>, // "description_hash": <bytes>, // "expiry": <int64>, // "fallback_addr": <string>, // "cltv_expiry": <uint64>, // "route_hints": <array RouteHint>, // "private": <bool>, // "add_index": <uint64>, // "settle_index": <uint64>, // "amt_paid": <int64>, // "amt_paid_sat": <int64>, // "amt_paid_msat": <int64>, // "state": <InvoiceState>, // "htlcs": <array InvoiceHTLC>, // "features": <array FeaturesEntry>, // "is_keysend": <bool>, // }

Parameter Type Description r_hash bytes Hash corresponding to the (hold) invoice to subscribe to.

Parameter Type Description memo string An optional memo to attach along with the invoice. Used for record keeping purposes for the invoice's creator, and will also be set in the description field of the encoded payment request if the description_hash field is not being used. r_preimage bytes The hex-encoded preimage (32 byte) which will allow settling an incoming HTLC payable to this preimage. When using REST, this field must be encoded as base64. r_hash bytes The hash of the preimage. When using REST, this field must be encoded as base64. value int64 The value of this invoice in satoshis The fields value and value_msat are mutually exclusive. value_msat int64 The value of this invoice in millisatoshis The fields value and value_msat are mutually exclusive. settled bool Whether this invoice has been fulfilled creation_date int64 When this invoice was created settle_date int64 When this invoice was settled payment_request string A bare-bones invoice for a payment within the Lightning Network. With the details of the invoice, the sender has all the data necessary to send a payment to the recipient. description_hash bytes Hash (SHA-256) of a description of the payment. Used if the description of payment (memo) is too long to naturally fit within the description field of an encoded payment request. When using REST, this field must be encoded as base64. expiry int64 Payment request expiry time in seconds. Default is 3600 (1 hour). fallback_addr string Fallback on-chain address. cltv_expiry uint64 Delta to use for the time-lock of the CLTV extended to the final hop. route_hints array RouteHint Route hints that can each be individually used to assist in reaching the invoice's destination. private bool Whether this invoice should include routing hints for private channels. add_index uint64 The "add" index of this invoice. Each newly created invoice will increment this index making it monotonically increasing. Callers to the SubscribeInvoices call can use this to instantly get notified of all added invoices with an add_index greater than this one. settle_index uint64 The "settle" index of this invoice. Each newly settled invoice will increment this index making it monotonically increasing. Callers to the SubscribeInvoices call can use this to instantly get notified of all settled invoices with an settle_index greater than this one. amt_paid int64 Deprecated, use amt_paid_sat or amt_paid_msat. amt_paid_sat int64 The amount that was accepted for this invoice, in satoshis. This will ONLY be set if this invoice has been settled. We provide this field as if the invoice was created with a zero value, then we need to record what amount was ultimately accepted. Additionally, it's possible that the sender paid MORE that was specified in the original invoice. So we'll record that here as well. amt_paid_msat int64 The amount that was accepted for this invoice, in millisatoshis. This will ONLY be set if this invoice has been settled. We provide this field as if the invoice was created with a zero value, then we need to record what amount was ultimately accepted. Additionally, it's possible that the sender paid MORE that was specified in the original invoice. So we'll record that here as well. state InvoiceState The state the invoice is in. htlcs array InvoiceHTLC List of HTLCs paying to this invoice [EXPERIMENTAL]. features array FeaturesEntry List of features advertised on the invoice. is_keysend bool Indicates if this invoice was a spontaneous payment that arrived via keysend [EXPERIMENTAL].

Service Lightning

AbandonChannel

Unary RPC

AbandonChannel removes all channel state from the database except for a close summary. This method can be used to get rid of permanently unusable channels due to bugs fixed in newer versions of lnd. Only available when in debug builds of lnd.

# Removes all channel state from the database except for a close # summary. This method can be used to get rid of permanently unusable # channels due to bugs fixed in newer versions of lnd. # Only available when lnd is built in debug mode. # To view which funding_txids/output_indexes can be used for this command, # see the channel_point values within the listchannels command output. # The format for a channel_point is 'funding_txid:output_index'. $ lncli abandonchannel [ command options] funding_txid [ output_index] # --funding_txid value the txid of the channel's funding transaction # --output_index value the output index for the funding output of the funding transaction (default: 0)

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/rpc.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import rpc_pb2 as lnrpc , rpc_pb2_grpc as rpcstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = rpcstub . LightningStub ( channel ) >>> request = lnrpc . AbandonChannelRequest ( channel_point =< ChannelPoint > , ) >>> response = stub . AbandonChannel ( request , metadata = [( 'macaroon' , macaroon )]) >>> print ( response ) { }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ( 'rpc.proto' , loaderOptions ); const lnrpc = grpc . loadPackageDefinition ( packageDefinition ). lnrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 lightning = new lnrpc . Lightning ( 'localhost:10009' , creds ); let request = { channel_point : < ChannelPoint > , }; lightning . abandonChannel ( request , function ( err , response ) { console . log ( response ); }); // Console output: // { // }

Parameter Type Description channel_point ChannelPoint

This response has no parameters.

AddInvoice

Unary RPC

AddInvoice attempts to add a new invoice to the invoice database. Any duplicated invoices are rejected, therefore all invoices must have a unique payment preimage.

# Add a new invoice, expressing intent for a future payment. # Invoices without an amount can be created by not supplying any # parameters or providing an amount of 0. These invoices allow the payee # to specify the amount of satoshis they wish to send. $ lncli addinvoice [ command options] value preimage # --memo value a description of the payment to attach along with the invoice (default="") # --preimage value the hex-encoded preimage (32 byte) which will allow settling an incoming HTLC payable to this preimage. If not set, a random preimage will be created. # --amt value the amt of satoshis in this invoice (default: 0) # --description_hash value SHA-256 hash of the description of the payment. Used if the purpose of payment cannot naturally fit within the memo. If provided this will be used instead of the description(memo) field in the encoded invoice. # --fallback_addr value fallback on-chain address that can be used in case the lightning payment fails # --expiry value the invoice's expiry time in seconds. If not specified an expiry of 3600 seconds (1 hour) is implied. (default: 0) # --private encode routing hints in the invoice with private channels in order to assist the payer in reaching you

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/rpc.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import rpc_pb2 as lnrpc , rpc_pb2_grpc as rpcstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = rpcstub . LightningStub ( channel ) >>> request = lnrpc . Invoice ( memo =< string > , r_preimage =< bytes > , r_hash =< bytes > , value =< int64 > , value_msat =< int64 > , settled =< bool > , creation_date =< int64 > , settle_date =< int64 > , payment_request =< string > , description_hash =< bytes > , expiry =< int64 > , fallback_addr =< string > , cltv_expiry =< uint64 > , route_hints =< array RouteHint > , private =< bool > , add_index =< uint64 > , settle_index =< uint64 > , amt_paid =< int64 > , amt_paid_sat =< int64 > , amt_paid_msat =< int64 > , state =< InvoiceState > , htlcs =< array InvoiceHTLC > , features =< array FeaturesEntry > , is_keysend =< bool > , ) >>> response = stub . AddInvoice ( request , metadata = [( 'macaroon' , macaroon )]) >>> print ( response ) { "r_hash" : < bytes > , "payment_request" : < string > , "add_index" : < uint64 > , }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ( 'rpc.proto' , loaderOptions ); const lnrpc = grpc . loadPackageDefinition ( packageDefinition ). lnrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 lightning = new lnrpc . Lightning ( 'localhost:10009' , creds ); let request = { memo : < string > , r_preimage : < bytes > , r_hash : < bytes > , value : < int64 > , value_msat : < int64 > , settled : < bool > , creation_date : < int64 > , settle_date : < int64 > , payment_request : < string > , description_hash : < bytes > , expiry : < int64 > , fallback_addr : < string > , cltv_expiry : < uint64 > , route_hints : < array RouteHint > , private : < bool > , add_index : < uint64 > , settle_index : < uint64 > , amt_paid : < int64 > , amt_paid_sat : < int64 > , amt_paid_msat : < int64 > , state : < InvoiceState > , htlcs : < array InvoiceHTLC > , features : < array FeaturesEntry > , is_keysend : < bool > , }; lightning . addInvoice ( request , function ( err , response ) { console . log ( response ); }); // Console output: // { // "r_hash": <bytes>, // "payment_request": <string>, // "add_index": <uint64>, // }

Parameter Type Description memo string An optional memo to attach along with the invoice. Used for record keeping purposes for the invoice's creator, and will also be set in the description field of the encoded payment request if the description_hash field is not being used. r_preimage bytes The hex-encoded preimage (32 byte) which will allow settling an incoming HTLC payable to this preimage. When using REST, this field must be encoded as base64. r_hash bytes The hash of the preimage. When using REST, this field must be encoded as base64. value int64 The value of this invoice in satoshis The fields value and value_msat are mutually exclusive. value_msat int64 The value of this invoice in millisatoshis The fields value and value_msat are mutually exclusive. settled bool Whether this invoice has been fulfilled creation_date int64 When this invoice was created settle_date int64 When this invoice was settled payment_request string A bare-bones invoice for a payment within the Lightning Network. With the details of the invoice, the sender has all the data necessary to send a payment to the recipient. description_hash bytes Hash (SHA-256) of a description of the payment. Used if the description of payment (memo) is too long to naturally fit within the description field of an encoded payment request. When using REST, this field must be encoded as base64. expiry int64 Payment request expiry time in seconds. Default is 3600 (1 hour). fallback_addr string Fallback on-chain address. cltv_expiry uint64 Delta to use for the time-lock of the CLTV extended to the final hop. route_hints array RouteHint Route hints that can each be individually used to assist in reaching the invoice's destination. private bool Whether this invoice should include routing hints for private channels. add_index uint64 The "add" index of this invoice. Each newly created invoice will increment this index making it monotonically increasing. Callers to the SubscribeInvoices call can use this to instantly get notified of all added invoices with an add_index greater than this one. settle_index uint64 The "settle" index of this invoice. Each newly settled invoice will increment this index making it monotonically increasing. Callers to the SubscribeInvoices call can use this to instantly get notified of all settled invoices with an settle_index greater than this one. amt_paid int64 Deprecated, use amt_paid_sat or amt_paid_msat. amt_paid_sat int64 The amount that was accepted for this invoice, in satoshis. This will ONLY be set if this invoice has been settled. We provide this field as if the invoice was created with a zero value, then we need to record what amount was ultimately accepted. Additionally, it's possible that the sender paid MORE that was specified in the original invoice. So we'll record that here as well. amt_paid_msat int64 The amount that was accepted for this invoice, in millisatoshis. This will ONLY be set if this invoice has been settled. We provide this field as if the invoice was created with a zero value, then we need to record what amount was ultimately accepted. Additionally, it's possible that the sender paid MORE that was specified in the original invoice. So we'll record that here as well. state InvoiceState The state the invoice is in. htlcs array InvoiceHTLC List of HTLCs paying to this invoice [EXPERIMENTAL]. features array FeaturesEntry List of features advertised on the invoice. is_keysend bool Indicates if this invoice was a spontaneous payment that arrived via keysend [EXPERIMENTAL].

Parameter Type Description r_hash bytes payment_request string A bare-bones invoice for a payment within the Lightning Network. With the details of the invoice, the sender has all the data necessary to send a payment to the recipient. add_index uint64 The "add" index of this invoice. Each newly created invoice will increment this index making it monotonically increasing. Callers to the SubscribeInvoices call can use this to instantly get notified of all added invoices with an add_index greater than this one.

BakeMacaroon

Unary RPC

BakeMacaroon allows the creation of a new macaroon with custom read and write permissions. No first-party caveats are added since this can be done offline.

# Bake a new macaroon that grants the provided permissions and # optionally adds restrictions (timeout, IP address) to it. # The new macaroon can either be shown on command line in hex serialized # format or it can be saved directly to a file using the --save_to # argument. # A permission is a tuple of an entity and an action, separated by a # colon. Multiple operations can be added as arguments, for example: # lncli bakemacaroon info:read invoices:write foo:bar $ lncli bakemacaroon [ command options] [ --save_to =] [ --timeout =] [ --ip_address =] permissions... # --save_to value save the created macaroon to this file using the default binary format # --timeout value the number of seconds the macaroon will be valid before it times out (default: 0) # --ip_address value the IP address the macaroon will be bound to

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/rpc.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import rpc_pb2 as lnrpc , rpc_pb2_grpc as rpcstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = rpcstub . LightningStub ( channel ) >>> request = lnrpc . BakeMacaroonRequest ( permissions =< array MacaroonPermission > , ) >>> response = stub . BakeMacaroon ( request , metadata = [( 'macaroon' , macaroon )]) >>> print ( response ) { "macaroon" : < string > , }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ( 'rpc.proto' , loaderOptions ); const lnrpc = grpc . loadPackageDefinition ( packageDefinition ). lnrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 lightning = new lnrpc . Lightning ( 'localhost:10009' , creds ); let request = { permissions : < array MacaroonPermission > , }; lightning . bakeMacaroon ( request , function ( err , response ) { console . log ( response ); }); // Console output: // { // "macaroon": <string>, // }

Parameter Type Description permissions array MacaroonPermission The list of permissions the new macaroon should grant.

Parameter Type Description macaroon string The hex encoded macaroon, serialized in binary format.

ChannelAcceptor

Bidirectional-streaming RPC

ChannelAcceptor dispatches a bi-directional streaming RPC in which OpenChannel requests are sent to the client and the client responds with a boolean that tells LND whether or not to accept the channel. This allows node operators to specify their own criteria for accepting inbound channels through a single persistent connection.

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/rpc.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import rpc_pb2 as lnrpc , rpc_pb2_grpc as rpcstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = rpcstub . LightningStub ( channel ) # Define a generator that returns an Iterable of lnrpc.ChannelAcceptResponse objects. >>> def request_generator (): # Initialization code here. while True : # Parameters here can be set as arguments to the generator. request = lnrpc . ChannelAcceptResponse ( accept =< bool > , pending_chan_id =< bytes > , ) yield request # Do things between iterations here. >>> request_iterable = request_generator () >>> for response in stub . ChannelAcceptor ( request_iterable , metadata = [( 'macaroon' , macaroon )]): print ( response ) { "node_pubkey" : < bytes > , "chain_hash" : < bytes > , "pending_chan_id" : < bytes > , "funding_amt" : < uint64 > , "push_amt" : < uint64 > , "dust_limit" : < uint64 > , "max_value_in_flight" : < uint64 > , "channel_reserve" : < uint64 > , "min_htlc" : < uint64 > , "fee_per_kw" : < uint64 > , "csv_delay" : < uint32 > , "max_accepted_htlcs" : < uint32 > , "channel_flags" : < uint32 > , }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ( 'rpc.proto' , loaderOptions ); const lnrpc = grpc . loadPackageDefinition ( packageDefinition ). lnrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 lightning = new lnrpc . Lightning ( 'localhost:10009' , creds ); let request = { accept : < bool > , pending_chan_id : < bytes > , }; let call = lightning . channelAcceptor ({}); call . on ( 'data' , function ( response ) { // A response was received from the server. console . log ( response ); }); call . on ( 'status' , function ( status ) { // The current status of the stream. }); call . on ( 'end' , function () { // The server has closed the stream. }); call . write ( request ); // Console output: // { // "node_pubkey": <bytes>, // "chain_hash": <bytes>, // "pending_chan_id": <bytes>, // "funding_amt": <uint64>, // "push_amt": <uint64>, // "dust_limit": <uint64>, // "max_value_in_flight": <uint64>, // "channel_reserve": <uint64>, // "min_htlc": <uint64>, // "fee_per_kw": <uint64>, // "csv_delay": <uint32>, // "max_accepted_htlcs": <uint32>, // "channel_flags": <uint32>, // }

Parameter Type Description accept bool Whether or not the client accepts the channel. pending_chan_id bytes The pending channel id to which this response applies.

Parameter Type Description node_pubkey bytes The pubkey of the node that wishes to open an inbound channel. chain_hash bytes The hash of the genesis block that the proposed channel resides in. pending_chan_id bytes The pending channel id. funding_amt uint64 The funding amount in satoshis that initiator wishes to use in the channel. push_amt uint64 The push amount of the proposed channel in millisatoshis. dust_limit uint64 The dust limit of the initiator's commitment tx. max_value_in_flight uint64 The maximum amount of coins in millisatoshis that can be pending in this channel. channel_reserve uint64 The minimum amount of satoshis the initiator requires us to have at all times. min_htlc uint64 The smallest HTLC in millisatoshis that the initiator will accept. fee_per_kw uint64 The initial fee rate that the initiator suggests for both commitment transactions. csv_delay uint32 The number of blocks to use for the relative time lock in the pay-to-self output of both commitment transactions. max_accepted_htlcs uint32 The total number of incoming HTLC's that the initiator will accept. channel_flags uint32 A bit-field which the initiator uses to specify proposed channel behavior.

ChannelBalance

Unary RPC

ChannelBalance returns the total funds available across all open channels in satoshis.

# Returns the sum of the total available channel balance across all open channels. $ lncli channelbalance [ arguments...]

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/rpc.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import rpc_pb2 as lnrpc , rpc_pb2_grpc as rpcstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = rpcstub . LightningStub ( channel ) >>> request = lnrpc . ChannelBalanceRequest () >>> response = stub . ChannelBalance ( request , metadata = [( 'macaroon' , macaroon )]) >>> print ( response ) { "balance" : < int64 > , "pending_open_balance" : < int64 > , }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ( 'rpc.proto' , loaderOptions ); const lnrpc = grpc . loadPackageDefinition ( packageDefinition ). lnrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 lightning = new lnrpc . Lightning ( 'localhost:10009' , creds ); let request = {}; lightning . channelBalance ( request , function ( err , response ) { console . log ( response ); }); // Console output: // { // "balance": <int64>, // "pending_open_balance": <int64>, // }

This request has no parameters.

Parameter Type Description balance int64 Sum of channels balances denominated in satoshis pending_open_balance int64 Sum of channels pending balances denominated in satoshis

CloseChannel

Server-streaming RPC

CloseChannel attempts to close an active channel identified by its channel outpoint (ChannelPoint). The actions of this method can additionally be augmented to attempt a force close after a timeout period in the case of an inactive peer. If a non-force close (cooperative closure) is requested, then the user can specify either a target number of blocks until the closure transaction is confirmed, or a manual fee rate. If neither are specified, then a default lax, block confirmation target is used.

# Close an existing channel. The channel can be closed either cooperatively, # or unilaterally (--force). # A unilateral channel closure means that the latest commitment # transaction will be broadcast to the network. As a result, any settled # funds will be time locked for a few blocks before they can be spent. # In the case of a cooperative closure, one can manually set the fee to # be used for the closing transaction via either the --conf_target or # --sat_per_byte arguments. This will be the starting value used during # fee negotiation. This is optional. # In the case of a cooperative closure, one can manually set the address # to deliver funds to upon closure. This is optional, and may only be used # if an upfront shutdown address has not already been set. If neither are # set the funds will be delivered to a new wallet address. # To view which funding_txids/output_indexes can be used for a channel close, # see the channel_point values within the listchannels command output. # The format for a channel_point is 'funding_txid:output_index'. $ lncli closechannel [ command options] funding_txid [ output_index] # --funding_txid value the txid of the channel's funding transaction # --output_index value the output index for the funding output of the funding transaction (default: 0) # --force attempt an uncooperative closure # --block block until the channel is closed # --conf_target value (optional) the number of blocks that the transaction *should* confirm in, will be used for fee estimation (default: 0) # --sat_per_byte value (optional) a manual fee expressed in sat/byte that should be used when crafting the transaction (default: 0) # --delivery_addr value (optional) an address to deliver funds upon cooperative channel closing, may only be used if an upfront shutdown address is not already set

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/rpc.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import rpc_pb2 as lnrpc , rpc_pb2_grpc as rpcstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = rpcstub . LightningStub ( channel ) >>> request = lnrpc . CloseChannelRequest ( channel_point =< ChannelPoint > , force =< bool > , target_conf =< int32 > , sat_per_byte =< int64 > , delivery_address =< string > , ) >>> for response in stub . CloseChannel ( request , metadata = [( 'macaroon' , macaroon )]): print ( response ) { "close_pending" : < PendingUpdate > , "chan_close" : < ChannelCloseUpdate > , }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ( 'rpc.proto' , loaderOptions ); const lnrpc = grpc . loadPackageDefinition ( packageDefinition ). lnrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 lightning = new lnrpc . Lightning ( 'localhost:10009' , creds ); let request = { channel_point : < ChannelPoint > , force : < bool > , target_conf : < int32 > , sat_per_byte : < int64 > , delivery_address : < string > , }; let call = lightning . closeChannel ( request ); call . on ( 'data' , function ( response ) { // A response was received from the server. console . log ( response ); }); call . on ( 'status' , function ( status ) { // The current status of the stream. }); call . on ( 'end' , function () { // The server has closed the stream. }); // Console output: // { // "close_pending": <PendingUpdate>, // "chan_close": <ChannelCloseUpdate>, // }

Parameter Type Description channel_point ChannelPoint The outpoint (txid:index) of the funding transaction. With this value, Bob will be able to generate a signature for Alice's version of the commitment transaction. force bool If true, then the channel will be closed forcibly. This means the current commitment transaction will be signed and broadcast. target_conf int32 The target number of blocks that the closure transaction should be confirmed by. sat_per_byte int64 A manual fee rate set in sat/byte that should be used when crafting the closure transaction. delivery_address string An optional address to send funds to in the case of a cooperative close. If the channel was opened with an upfront shutdown script and this field is set, the request to close will fail because the channel must pay out to the upfront shutdown addresss.

Parameter Type Description close_pending PendingUpdate chan_close ChannelCloseUpdate

ClosedChannels

Unary RPC

ClosedChannels returns a description of all the closed channels that this node was a participant in.

# List all closed channels. $ lncli closedchannels [ command options] [ arguments...] # --cooperative list channels that were closed cooperatively # --local_force list channels that were force-closed by the local node # --remote_force list channels that were force-closed by the remote node # --breach list channels for which the remote node attempted to broadcast a prior revoked channel state # --funding_canceled list channels that were never fully opened # --abandoned list channels that were abandoned by the local node

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/rpc.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import rpc_pb2 as lnrpc , rpc_pb2_grpc as rpcstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = rpcstub . LightningStub ( channel ) >>> request = lnrpc . ClosedChannelsRequest ( cooperative =< bool > , local_force =< bool > , remote_force =< bool > , breach =< bool > , funding_canceled =< bool > , abandoned =< bool > , ) >>> response = stub . ClosedChannels ( request , metadata = [( 'macaroon' , macaroon )]) >>> print ( response ) { "channels" : < array ChannelCloseSummary > , }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ( 'rpc.proto' , loaderOptions ); const lnrpc = grpc . loadPackageDefinition ( packageDefinition ). lnrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 lightning = new lnrpc . Lightning ( 'localhost:10009' , creds ); let request = { cooperative : < bool > , local_force : < bool > , remote_force : < bool > , breach : < bool > , funding_canceled : < bool > , abandoned : < bool > , }; lightning . closedChannels ( request , function ( err , response ) { console . log ( response ); }); // Console output: // { // "channels": <array ChannelCloseSummary>, // }

Parameter Type Description cooperative bool local_force bool remote_force bool breach bool funding_canceled bool abandoned bool

Parameter Type Description channels array ChannelCloseSummary

ConnectPeer

Unary RPC

ConnectPeer attempts to establish a connection to a remote peer. This is at the networking level, and is used for communication between nodes. This is distinct from establishing a channel with a peer.

# Connect to a remote lnd peer. $ lncli connect [ command options] <pubkey>@host # --perm If set, the daemon will attempt to persistently connect to the target peer. # If not, the call will be synchronous.

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/rpc.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import rpc_pb2 as lnrpc , rpc_pb2_grpc as rpcstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = rpcstub . LightningStub ( channel ) >>> request = lnrpc . ConnectPeerRequest ( addr =< LightningAddress > , perm =< bool > , ) >>> response = stub . ConnectPeer ( request , metadata = [( 'macaroon' , macaroon )]) >>> print ( response ) { }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ( 'rpc.proto' , loaderOptions ); const lnrpc = grpc . loadPackageDefinition ( packageDefinition ). lnrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 lightning = new lnrpc . Lightning ( 'localhost:10009' , creds ); let request = { addr : < LightningAddress > , perm : < bool > , }; lightning . connectPeer ( request , function ( err , response ) { console . log ( response ); }); // Console output: // { // }

Parameter Type Description addr LightningAddress Lightning address of the peer, in the format <pubkey>@host perm bool If set, the daemon will attempt to persistently connect to the target peer. Otherwise, the call will be synchronous.

This response has no parameters.

DebugLevel

Unary RPC

DebugLevel allows a caller to programmatically set the logging verbosity of lnd. The logging can be targeted according to a coarse daemon-wide logging level, or in a granular fashion to specify the logging for a target sub-system.

# Logging level for all subsystems {trace, debug, info, warn, error, critical, off} # You may also specify <subsystem>=<level>,<subsystem2>=<level>,... to set the log level for individual subsystems # Use show to list available subsystems $ lncli debuglevel [ command options] [ arguments...] # --show if true, then the list of available sub-systems will be printed out # --level value the level specification to target either a coarse logging level, or granular set of specific sub-systems with logging levels for each

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/rpc.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import rpc_pb2 as lnrpc , rpc_pb2_grpc as rpcstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = rpcstub . LightningStub ( channel ) >>> request = lnrpc . DebugLevelRequest ( show =< bool > , level_spec =< string > , ) >>> response = stub . DebugLevel ( request , metadata = [( 'macaroon' , macaroon )]) >>> print ( response ) { "sub_systems" : < string > , }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ( 'rpc.proto' , loaderOptions ); const lnrpc = grpc . loadPackageDefinition ( packageDefinition ). lnrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 lightning = new lnrpc . Lightning ( 'localhost:10009' , creds ); let request = { show : < bool > , level_spec : < string > , }; lightning . debugLevel ( request , function ( err , response ) { console . log ( response ); }); // Console output: // { // "sub_systems": <string>, // }

Parameter Type Description show bool level_spec string

Parameter Type Description sub_systems string

DecodePayReq

Unary RPC

DecodePayReq takes an encoded payment request string and attempts to decode it, returning a full description of the conditions encoded within the payment request.

# Decode the passed payment request revealing the destination, payment hash and value of the payment request $ lncli decodepayreq [ command options] pay_req # --pay_req value the bech32 encoded payment request

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/rpc.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import rpc_pb2 as lnrpc , rpc_pb2_grpc as rpcstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = rpcstub . LightningStub ( channel ) >>> request = lnrpc . PayReqString ( pay_req =< string > , ) >>> response = stub . DecodePayReq ( request , metadata = [( 'macaroon' , macaroon )]) >>> print ( response ) { "destination" : < string > , "payment_hash" : < string > , "num_satoshis" : < int64 > , "timestamp" : < int64 > , "expiry" : < int64 > , "description" : < string > , "description_hash" : < string > , "fallback_addr" : < string > , "cltv_expiry" : < int64 > , "route_hints" : < array RouteHint > , "payment_addr" : < bytes > , "num_msat" : < int64 > , "features" : < array FeaturesEntry > , }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ( 'rpc.proto' , loaderOptions ); const lnrpc = grpc . loadPackageDefinition ( packageDefinition ). lnrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 lightning = new lnrpc . Lightning ( 'localhost:10009' , creds ); let request = { pay_req : < string > , }; lightning . decodePayReq ( request , function ( err , response ) { console . log ( response ); }); // Console output: // { // "destination": <string>, // "payment_hash": <string>, // "num_satoshis": <int64>, // "timestamp": <int64>, // "expiry": <int64>, // "description": <string>, // "description_hash": <string>, // "fallback_addr": <string>, // "cltv_expiry": <int64>, // "route_hints": <array RouteHint>, // "payment_addr": <bytes>, // "num_msat": <int64>, // "features": <array FeaturesEntry>, // }

Parameter Type Description pay_req string The payment request string to be decoded

Parameter Type Description destination string payment_hash string num_satoshis int64 timestamp int64 expiry int64 description string description_hash string fallback_addr string cltv_expiry int64 route_hints array RouteHint payment_addr bytes num_msat int64 features array FeaturesEntry

DeleteAllPayments

Unary RPC

DeleteAllPayments deletes all outgoing payments from DB.

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/rpc.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import rpc_pb2 as lnrpc , rpc_pb2_grpc as rpcstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = rpcstub . LightningStub ( channel ) >>> request = lnrpc . DeleteAllPaymentsRequest () >>> response = stub . DeleteAllPayments ( request , metadata = [( 'macaroon' , macaroon )]) >>> print ( response ) { }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ( 'rpc.proto' , loaderOptions ); const lnrpc = grpc . loadPackageDefinition ( packageDefinition ). lnrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 lightning = new lnrpc . Lightning ( 'localhost:10009' , creds ); let request = {}; lightning . deleteAllPayments ( request , function ( err , response ) { console . log ( response ); }); // Console output: // { // }

This request has no parameters.

This response has no parameters.

DescribeGraph

Unary RPC

DescribeGraph returns a description of the latest graph state from the point of view of the node. The graph information is partitioned into two components: all the nodes/vertexes, and all the edges that connect the vertexes themselves. As this is a directed graph, the edges also contain the node directional specific routing policy which includes: the time lock delta, fee information, etc.

# Prints a human readable version of the known channel graph from the PoV of the node $ lncli describegraph [ command options] [ arguments...] # --include_unannounced If set, unannounced channels will be included in the graph. Unannounced channels are both private channels, and public channels that are not yet announced to the network.

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/rpc.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import rpc_pb2 as lnrpc , rpc_pb2_grpc as rpcstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = rpcstub . LightningStub ( channel ) >>> request = lnrpc . ChannelGraphRequest ( include_unannounced =< bool > , ) >>> response = stub . DescribeGraph ( request , metadata = [( 'macaroon' , macaroon )]) >>> print ( response ) { "nodes" : < array LightningNode > , "edges" : < array ChannelEdge > , }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ( 'rpc.proto' , loaderOptions ); const lnrpc = grpc . loadPackageDefinition ( packageDefinition ). lnrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 lightning = new lnrpc . Lightning ( 'localhost:10009' , creds ); let request = { include_unannounced : < bool > , }; lightning . describeGraph ( request , function ( err , response ) { console . log ( response ); }); // Console output: // { // "nodes": <array LightningNode>, // "edges": <array ChannelEdge>, // }

Parameter Type Description include_unannounced bool Whether unannounced channels are included in the response or not. If set, unannounced channels are included. Unannounced channels are both private channels, and public channels that are not yet announced to the network.

Parameter Type Description nodes array LightningNode The list of LightningNode s in this channel graph edges array ChannelEdge The list of ChannelEdge s in this channel graph

DisconnectPeer

Unary RPC

DisconnectPeer attempts to disconnect one peer from another identified by a given pubKey. In the case that we currently have a pending or active channel with the target peer, then this action will be not be allowed.

# Disconnect a remote lnd peer identified by public key. $ lncli disconnect [ command options] <pubkey> # --node_key value The hex-encoded compressed public key of the peer to disconnect from

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/rpc.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import rpc_pb2 as lnrpc , rpc_pb2_grpc as rpcstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = rpcstub . LightningStub ( channel ) >>> request = lnrpc . DisconnectPeerRequest ( pub_key =< string > , ) >>> response = stub . DisconnectPeer ( request , metadata = [( 'macaroon' , macaroon )]) >>> print ( response ) { }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ( 'rpc.proto' , loaderOptions ); const lnrpc = grpc . loadPackageDefinition ( packageDefinition ). lnrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 lightning = new lnrpc . Lightning ( 'localhost:10009' , creds ); let request = { pub_key : < string > , }; lightning . disconnectPeer ( request , function ( err , response ) { console . log ( response ); }); // Console output: // { // }

Parameter Type Description pub_key string The pubkey of the node to disconnect from

This response has no parameters.

EstimateFee

Unary RPC

EstimateFee asks the chain backend to estimate the fee rate and total fees for a transaction that pays to multiple specified outputs. When using REST, the AddrToAmount map type can be set by appending &AddrToAmount[<address>]=<amount_to_send> to the URL. Unfortunately this map type doesn't appear in the REST API documentation because of a bug in the grpc-gateway library.

# Get fee estimates for sending a transaction paying the specified amount(s) to the passed address(es). # The send-json-string' param decodes addresses and the amount to send respectively in the following format: # '{"ExampleAddr": NumCoinsInSatoshis, "SecondAddr": NumCoins}' $ lncli estimatefee [ command options] send-json-string [ --conf_target = N] # --conf_target value (optional) the number of blocks that the transaction *should* confirm in (default: 0)

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/rpc.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import rpc_pb2 as lnrpc , rpc_pb2_grpc as rpcstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = rpcstub . LightningStub ( channel ) >>> request = lnrpc . EstimateFeeRequest ( AddrToAmount =< array AddrToAmountEntry > , target_conf =< int32 > , ) >>> response = stub . EstimateFee ( request , metadata = [( 'macaroon' , macaroon )]) >>> print ( response ) { "fee_sat" : < int64 > , "feerate_sat_per_byte" : < int64 > , }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ( 'rpc.proto' , loaderOptions ); const lnrpc = grpc . loadPackageDefinition ( packageDefinition ). lnrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 lightning = new lnrpc . Lightning ( 'localhost:10009' , creds ); let request = { AddrToAmount : < array AddrToAmountEntry > , target_conf : < int32 > , }; lightning . estimateFee ( request , function ( err , response ) { console . log ( response ); }); // Console output: // { // "fee_sat": <int64>, // "feerate_sat_per_byte": <int64>, // }

Parameter Type Description AddrToAmount array AddrToAmountEntry The map from addresses to amounts for the transaction. target_conf int32 The target number of blocks that this transaction should be confirmed by.

Parameter Type Description fee_sat int64 The total fee in satoshis. feerate_sat_per_byte int64 The fee rate in satoshi/byte.

ExportAllChannelBackups

Unary RPC

ExportAllChannelBackups returns static channel backups for all existing channels known to lnd. A set of regular singular static channel backups for each channel are returned. Additionally, a multi-channel backup is returned as well, which contains a single encrypted blob containing the backups of each channel.

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/rpc.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import rpc_pb2 as lnrpc , rpc_pb2_grpc as rpcstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = rpcstub . LightningStub ( channel ) >>> request = lnrpc . ChanBackupExportRequest () >>> response = stub . ExportAllChannelBackups ( request , metadata = [( 'macaroon' , macaroon )]) >>> print ( response ) { "single_chan_backups" : < ChannelBackups > , "multi_chan_backup" : < MultiChanBackup > , }

const fs = require ( 'fs' ); const grpc = require ( 'grpc' ); const protoLoader = require ( '@grpc/proto-loader' ); const loaderOptions = { keepCase : true , longs : String , enums : String , defaults : true , oneofs : true }; const packageDefinition = protoLoader . loadSync ( 'rpc.proto' , loaderOptions ); const lnrpc = grpc . loadPackageDefinition ( packageDefinition ). lnrpc ; const macaroon = fs . readFileSync ( "LND_DIR/data/chain/bitcoin/simnet/admin.macaroon" ). toString ( 'hex' ); process . env . GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' ; const lndCert = fs . readFileSync ( 'LND_DIR/tls.cert' ); const sslCreds = grpc . credentials . createSsl ( lndCert ); 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 lightning = new lnrpc . Lightning ( 'localhost:10009' , creds ); let request = {}; lightning . exportAllChannelBackups ( request , function ( err , response ) { console . log ( response ); }); // Console output: // { // "single_chan_backups": <ChannelBackups>, // "multi_chan_backup": <MultiChanBackup>, // }

This request has no parameters.

Parameter Type Description single_chan_backups ChannelBackups The set of new channels that have been added since the last channel backup snapshot was requested. multi_chan_backup MultiChanBackup A multi-channel backup that covers all open channels currently known to lnd.

ExportChannelBackup

Unary RPC

ExportChannelBackup attempts to return an encrypted static channel backup for the target channel identified by it channel point. The backup is encrypted with a key generated from the aezeed seed of the user. The returned backup can either be restored using the RestoreChannelBackup method once lnd is running, or via the InitWallet and UnlockWallet methods from the WalletUnlocker service.

# This command allows a user to export a Static Channel Backup (SCB) for # a selected channel. SCB's are encrypted backups of a channel's initial # state that are encrypted with a key derived from the seed of a user. In # the case of partial or complete data loss, the SCB will allow the user # to reclaim settled funds in the channel at its final state. The # exported channel backups can be restored at a later time using the # restorechanbackup command. # This command will return one of two types of channel backups depending # on the set of passed arguments: # * If a target channel point is specified, then a single channel # backup containing only the information for that channel will be # returned. # * If the --all flag is passed, then a multi-channel backup will be # returned. A multi backup is a single encrypted blob (displayed in # hex encoding) that contains several channels in a single cipher # text. # Both of the backup types can be restored using the restorechanbackup # command. $ lncli exportchanbackup [ command options] [ chan_point] [ --all] [ --output_file] # --chan_point value the target channel to obtain an SCB for # --all if specified, then a multi backup of all active channels will be returned # --output_file value if specified, then rather than printing a JSON output # of the static channel backup, a serialized version of # the backup (either Single or Multi) will be written to # the target file, this is the same format used by lnd in # its channels.backup file

>>> import codecs , grpc , os >>> # Generate the following 2 modules by compiling the lnrpc/rpc.proto with the grpcio-tools. >>> # See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions. >>> import rpc_pb2 as lnrpc , rpc_pb2_grpc as rpcstub >>> macaroon = codecs . encode ( open ( 'LND_DIR/data/chain/bitcoin/simnet/admin.macaroon' , 'rb' ) . read (), 'hex' ) >>> os . environ [ 'GRPC_SSL_CIPHER_SUITES' ] = 'HIGH+ECDSA' >>> cert = open ( 'LND_DIR/tls.cert' , 'rb' ) . read () >>> ssl_creds = grpc . ssl_channel_credentials ( cert ) >>> channel = grpc . secure_channel ( 'localhost:10009' , ssl_creds ) >>> stub = rpcstub . LightningStub ( channel ) >>> request = lnrpc . ExportChannelBackupRequest ( chan_point =< ChannelPoint > , ) >>> response = stub . ExportChannelBackup ( request , metadata = [( 'macaroon' , macaroon )]) >>> print ( response ) { "chan_point" : < ChannelPoint > , "chan_backup" : < bytes > , }

const fs = r