Ruby Lightning Network Daemon Client: Straightforward access to lnd gRPC API
This is a low-level client library. For a better experience, you may want to check out the Lighstorm abstraction.
Add to your Gemfile
:
gem 'lnd-client', '~> 0.0.9'
require 'lnd-client'
puts LNDClient.version # => 0.0.9
client = LNDClient.new(
'lndconnect://127.0.0.1:10009?cert=MIICJz...JBEERQ&macaroon=AgEDbG...45ukJ4'
)
client.lightning.wallet_balance.total_balance # => 101527
client.lightning.wallet_balance.to_h # =>
# { total_balance: 101_527,
# confirmed_balance: 101_527,
# unconfirmed_balance: 0,
# locked_balance: 0,
# reserved_balance_anchor_chan: 20_000,
# account_balance: {
# 'default' => {
# confirmed_balance: 101_527,
# unconfirmed_balance: 0 } } }
client.lightning.get_node_info(
pub_key: '02d3c80335a8ccb2ed364c06875f32240f36f7edb37d80f8dbe321b4c364b6e997'
).node.alias # => 'icebaker/old-stone'
client.lightning.subscribe_channel_graph do |data|
puts data.inspect # => { ... }
end
client.router.subscribe_htlc_events do |data|
puts data.inspect # => { ... }
end
Check the full documentation.
- autopilot
- chain_kit
- chain_notifier
- dev
- invoices
- lightning
- neutrino_kit
- peers
- router
- signer
- state
- versioner
- wallet_kit
- wallet_unlocker
- watchtower
- watchtower_client
Copy the .env.example
file to .env
and provide the required data.
# Gemfile
gem 'lnd-client', path: '/home/user/lnd-client'
# demo.rb
require 'lnd-client'
puts LNDClient.version
bundle
rubocop -A
bundle exec rake grpc:upgrade
bundle exec rake grpc:docs
npm i docsify-cli -g
docsify serve ./docs
gem build lnd-client.gemspec
gem signin
gem push lnd-client-0.0.9.gem