You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Go to file
bumi f3366b2d7e
gitignore build .gem files
3 years ago
bin hello lnd world 4 years ago
lib v0.10.0 with support for routerrpc 3 years ago
spec hello lnd world 4 years ago
.gitignore gitignore build .gem files 3 years ago
.rspec hello lnd world 4 years ago
Gemfile hello lnd world 4 years ago
Gemfile.lock v0.10.0 with support for routerrpc 3 years ago
LICENSE.txt hello lnd world 4 years ago v0.10.0 with support for routerrpc 3 years ago
Rakefile hello lnd world 4 years ago
examples.rb Add subscription example 4 years ago
lnrpc.gemspec v0.7.1 3 years ago

Lnrpc - ruby gRPC client for LND

Gem Version

a gRPC client for LND, the Lightning Network Daemon packed as ruby gem.


Note: there is still an GRPC/protobuf issue with Ruby 2.7. So lnrpc requires Ruby < 2.7.

Add this line to your application's Gemfile:

gem 'lnrpc', '~> 0.7.0'

lnrpc follows the lnd versioning, thus it is recommended to specify the exact version you need for your lnd node as dependency (see #Versioning).

And then execute:

$ bundle

Or install it yourself as:

$ gem install lnrpc
# or for pre releases:
$ gem install lnrcp --pre


This gem makes the gRPC client classes created from the LND service defintions available.

require "lnrpc"

# the gRPC client is available under the Lnrpc namespace, e.g.


Learn more about gRPC on

The LND API reference can be found here:


require "lnrpc"

credentials ="/path/to/tls.cert")
macaroon ="/path/to/readonly.macaroon").unpack("H*")

# initialize a new client
client ="localhost:10009",

# perform a request
request =
response = client.get_info(request, { metadata: { macaroon: macaroon } }) #=> Lnrpc::GetInfoResponse
puts response.alias

Client wrapper

An optional client wrapper (Lnrpc::Client) makes initializing the gRPC client easier and removes the need for some boilerplate code for calling RPC methods.


lnd ={credentials_path: '/path/to.cert.cls', macaroon_path: '/path/to/admin.macaroon'})

Also have a look at examples.rb

Initializing a new client

The Lnrpc::Client constructor allows the following options:

  • credentials:
    • credentials : the credentials data as string (pass nil if a "trusted" cert (e.g. from letsencrypt is used)
    • credentials_path : the path to a credentials file (tls.cert) as string (default: "#{LND_HOME_DIR}/tls.cert" )
  • macaroon:
    • macaroon : the macaroon as hex string
    • macaroon_path : the path to the macaroon file created by lnd as string (default: "#{LND_HOME_DIR}/data/chain/bitcoin/mainnet/admin.macaroon")
  • address:
    • address : lnd address as string. format: address:port, e.g. localhost:10009 (default)

If no credentials or no macaroon is provided default files are assumed in ENV['LND_HOME'] || "~/.lnd". A macaroon is required.

require 'lnrpc'

lnd ={
  credentials_path: '/path/to.cert.cls',
  macaroon_path: '/path/to/admin.macaroon',
  address: 'host:port'

# the actual gRPC client is available through:

Calling RPC methods

The client wrapper passes any supported RPC method call to the gRPC client applying the following conventions:

If the first parameter is a hash or blank the corresponding gRPC request object will be instantiated.


# is the same as:

client.list_channels(inactive_only: true)
# is the same as:
request = true)

# is the same as:
request =

Using with BTC Pay Server

If you have a running BTC Pay Server with LND support, integrating with lnrpc is easy.

  • Navigate to the domain associated with your BTC Pay Server
  • Navigate to Services on the Server Settings page
  • Click "see information" for your gRPC Server
  • The link by "More details..." will expose the address and various macaroon hex strings
  • Initialize your client with the options detailed above. BTC Pay Server utilizes LetsEncrypt for trusted TLC Certificates so set that option to nil.

Don't have a BTC Pay Server? Setting one up is easy.


This gem follows the LND versions and will update the gRPC service definitions accordingly. e.g. gem version 0.5.2 includes the gRPC service definitions from LND v0.5.2

see rubygems for all available releases.

Update service definitions

  1. Generate prc_pb.rb and rpc_services_pb.rb

    $ grpc_tools_ruby_protoc -I/usr/local/include -I. -I$GOPATH/src/ --ruby_out=plugins=grpc,paths=source_relative:. --grpc_out=. rpc.proto

  2. Copy rpc.proto, rpc_pb.rb and rpc_services_pb.rb to lib

  3. Update rpc_services_pb.rb to use require_relative to load rpc_pb

Other resources


Bug reports and pull requests are welcome on GitHub at


The gem is available as open source under the terms of the MIT License.