1
0
mirror of https://github.com/bumi/lnrpc synced 2026-02-23 18:50:52 +00:00

5 Commits

Author SHA1 Message Date
f3366b2d7e gitignore build .gem files 2020-05-09 14:25:30 +02:00
7f7d125be6 v0.10.0 with support for routerrpc 2020-05-08 00:40:49 +02:00
2d5e0d0de4 v0.10.0 2020-05-02 20:51:40 +02:00
ef17006051 v0.9.0 2020-04-19 22:50:22 +02:00
54dd714064 Update rpc files for v0.9.0-beta 2020-04-19 22:46:25 +02:00
3 changed files with 14 additions and 35 deletions

View File

@@ -15,7 +15,7 @@ GEM
grpc (1.24.0) grpc (1.24.0)
google-protobuf (~> 3.8) google-protobuf (~> 3.8)
googleapis-common-protos-types (~> 1.0) googleapis-common-protos-types (~> 1.0)
rake (13.0.1) rake (10.5.0)
rspec (3.9.0) rspec (3.9.0)
rspec-core (~> 3.9.0) rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0) rspec-expectations (~> 3.9.0)
@@ -36,7 +36,7 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
bundler (~> 1.17) bundler (~> 1.17)
lnrpc! lnrpc!
rake (~> 13.0) rake (~> 10.0)
rspec (~> 3.0) rspec (~> 3.0)
BUNDLED WITH BUNDLED WITH

View File

@@ -3,6 +3,7 @@
a [gRPC](https://grpc.io/) client for [LND, the Lightning Network Daemon](https://github.com/lightningnetwork/lnd/) packed as ruby gem. a [gRPC](https://grpc.io/) client for [LND, the Lightning Network Daemon](https://github.com/lightningnetwork/lnd/) packed as ruby gem.
## Installation ## Installation
Note: there is still an GRPC/protobuf [issue with Ruby 2.7](https://github.com/protocolbuffers/protobuf/issues/7070). Note: there is still an GRPC/protobuf [issue with Ruby 2.7](https://github.com/protocolbuffers/protobuf/issues/7070).
@@ -11,7 +12,7 @@ So lnrpc requires Ruby < 2.7.
Add this line to your application's Gemfile: Add this line to your application's Gemfile:
```ruby ```ruby
gem 'lnrpc', '~> 0.10.0' 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](#Versioning)). lnrpc follows the lnd versioning, thus it is recommended to specify the exact version you need for your lnd node as dependency (see [#Versioning](#Versioning)).
@@ -32,12 +33,10 @@ This gem makes the gRPC client classes created from the [LND service defintions]
```ruby ```ruby
require "lnrpc" require "lnrpc"
# With the changes in LND v.10.0 this load the `Lnrpc` and `Routerrpc` namespace # the gRPC client is available under the Lnrpc namespace, e.g.
Lnrpc::Lightning::Stub Lnrpc::Lightning::Stub
Routerrpc:::Routerrpc::Stub
Lnrpc::GetInfoRequest Lnrpc::GetInfoRequest
...
``` ```
Learn more about [gRPC](https://grpc.io/) on [gRPC.io](https://grpc.io/). Learn more about [gRPC](https://grpc.io/) on [gRPC.io](https://grpc.io/).
@@ -59,26 +58,17 @@ client = Lnrpc::Lightning::Stub.new("localhost:10009", GRPC::Core::ChannelCreden
request = Lnrpc::GetInfoRequest.new request = Lnrpc::GetInfoRequest.new
response = client.get_info(request, { metadata: { macaroon: macaroon } }) #=> Lnrpc::GetInfoResponse response = client.get_info(request, { metadata: { macaroon: macaroon } }) #=> Lnrpc::GetInfoResponse
puts response.alias puts response.alias
router = Routerprc::Router::Stub.new("localhost:10009", GRPC::Core::ChannelCredentials.new(self.credentials))
...
``` ```
### Client wrapper ### Client wrapper
NOTE: v10.0 has breaking changes!
An optional client wrapper ([Lnrpc::Client](https://github.com/bumi/lnrpc/blob/master/lib/lnrpc/client.rb)) makes An optional client wrapper ([Lnrpc::Client](https://github.com/bumi/lnrpc/blob/master/lib/lnrpc/client.rb)) makes
initializing the gRPC client easier and removes the need for some boilerplate code for calling RPC methods. initializing the gRPC client easier and removes the need for some boilerplate code for calling RPC methods.
#### Example #### Example
```ruby ```ruby
lnd = Lnrpc::Client.new({credentials_path: '/path/to.cert.cls', macaroon_path: '/path/to/admin.macaroon'}) lnd = Lnrpc::Client.new({credentials_path: '/path/to.cert.cls', macaroon_path: '/path/to/admin.macaroon'})
lnd.lightning # => Lnrpc::Lightning::Stub lnd.get_info
lnd.router # => Lnrpc::Router::Stub
lnd.ligthning.get_info
``` ```
Also have a look at [examples.rb](https://github.com/bumi/lnrpc/blob/master/examples.rb) Also have a look at [examples.rb](https://github.com/bumi/lnrpc/blob/master/examples.rb)
@@ -109,8 +99,7 @@ lnd = Lnrpc::Client.new({
}) })
# the actual gRPC client is available through: # the actual gRPC client is available through:
lnd.lightning.grpc lnd.grpc_client
lnd.router.grpc
``` ```
#### Calling RPC methods #### Calling RPC methods
@@ -122,19 +111,19 @@ If the first parameter is a hash or blank the corresponding gRPC request object
Example: Example:
```ruby ```ruby
client.lightning.get_info client.get_info
# is the same as: # is the same as:
client.lightning.grpc.get_info(Lnrpc::GetInfoRequest.new) client.grpc_client.get_info(Lnrpc::GetInfoRequest.new)
client.lightning.list_channels(inactive_only: true) client.list_channels(inactive_only: true)
# is the same as: # is the same as:
request = Lnrpc::ListChannelsRequest.new(inactive_only: true) request = Lnrpc::ListChannelsRequest.new(inactive_only: true)
client.lightning.grpc.list_channels(request) client.grpc_client.list_channels(request)
client.lightning.wallet_balance.total_balance client.wallet_balance.total_balance
# is the same as: # is the same as:
request = Lnrpc::WalletBalanceRequest.new() request = Lnrpc::WalletBalanceRequest.new()
client.lightning.grpc.wallet_balance(request).total_balance client.grpc_client.wallet_balance(request).total_balance
``` ```
## Using with BTC Pay Server ## Using with BTC Pay Server
@@ -167,14 +156,6 @@ see [rubygems](https://rubygems.org/gems/lnrpc) for all available releases.
3. Update `rpc_services_pb.rb` to use `require_relative` to load `rpc_pb` 3. Update `rpc_services_pb.rb` to use `require_relative` to load `rpc_pb`
4. Generate `router_pb.rb` and `router_services_pb.rb`
$ grpc_tools_ruby_protoc -I/usr/local/include -I. -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis -I$GOPATH/src/github.com/lightningnetwork/lnd/lnrpc --ruby_out=plugins=grpc,paths=source_relative:. --grpc_out=. router.proto
5. Copy `router.proto`, `router_pb.rb` and `router_services_pb.rb` to `lib`
6. Update `router_services_pb.rb` to use `require_relative` to load `router_pb`
## Other resources ## Other resources
* [LND gRPC API Reference](https://api.lightning.community) * [LND gRPC API Reference](https://api.lightning.community)

View File

@@ -14,8 +14,6 @@ Gem::Specification.new do |spec|
spec.homepage = "https://github.com/bumi/lnrpc" spec.homepage = "https://github.com/bumi/lnrpc"
spec.license = "MIT" spec.license = "MIT"
spec.metadata['funding'] = 'lightning:02ad33d99d0bb3bf3bb8ec8e089cbefa8fd7de23a13cfa59aec9af9730816be76f'
# Specify which files should be added to the gem when it is released. # Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git. # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
@@ -26,7 +24,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"] spec.require_paths = ["lib"]
spec.add_development_dependency "bundler", "~> 1.17" spec.add_development_dependency "bundler", "~> 1.17"
spec.add_development_dependency "rake", "~> 13.0" spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rspec", "~> 3.0" spec.add_development_dependency "rspec", "~> 3.0"
spec.add_dependency "grpc", ">= 1.19.0" spec.add_dependency "grpc", ">= 1.19.0"