1
0
mirror of https://github.com/bumi/lnrpc synced 2026-02-23 10:40:51 +00:00

9 Commits

Author SHA1 Message Date
b6e048455d Add funding metadata to gemspec 2020-05-09 14:57:47 +02:00
9b6342becc Update README for v0.10.0 2020-05-09 14:50:11 +02:00
3765d9f4a6 gitignore build .gem files 2020-05-09 14:37:08 +02:00
c9e4f23cf4 v0.10.0 with support for routerrpc 2020-05-09 14:37:08 +02:00
9b098ef53e v0.10.0 2020-05-09 14:37:08 +02:00
c8a7a6e657 v0.9.0 2020-05-09 14:35:47 +02:00
e2bad78744 Update rpc files for v0.9.0-beta 2020-05-09 14:35:47 +02:00
24a6390f89 Merge pull request #10 from bumi/dependabot/bundler/rake-tw-13.0
Update rake requirement from ~> 10.0 to ~> 13.0
2020-04-19 20:29:24 +02:00
dependabot[bot]
50cda0406c Update rake requirement from ~> 10.0 to ~> 13.0
Updates the requirements on [rake](https://github.com/ruby/rake) to permit the latest version.
- [Release notes](https://github.com/ruby/rake/releases)
- [Changelog](https://github.com/ruby/rake/blob/master/History.rdoc)
- [Commits](https://github.com/ruby/rake/compare/v10.5.0...v13.0.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-02-29 15:34:03 +00:00
3 changed files with 35 additions and 14 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 (10.5.0) rake (13.0.1)
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 (~> 10.0) rake (~> 13.0)
rspec (~> 3.0) rspec (~> 3.0)
BUNDLED WITH BUNDLED WITH

View File

@@ -3,7 +3,6 @@
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).
@@ -12,7 +11,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.7.0' gem 'lnrpc', '~> 0.10.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)).
@@ -33,10 +32,12 @@ This gem makes the gRPC client classes created from the [LND service defintions]
```ruby ```ruby
require "lnrpc" require "lnrpc"
# the gRPC client is available under the Lnrpc namespace, e.g. # With the changes in LND v.10.0 this load the `Lnrpc` and `Routerrpc` namespace
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/).
@@ -58,17 +59,26 @@ 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.get_info lnd.lightning # => Lnrpc::Lightning::Stub
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)
@@ -99,7 +109,8 @@ lnd = Lnrpc::Client.new({
}) })
# the actual gRPC client is available through: # the actual gRPC client is available through:
lnd.grpc_client lnd.lightning.grpc
lnd.router.grpc
``` ```
#### Calling RPC methods #### Calling RPC methods
@@ -111,19 +122,19 @@ If the first parameter is a hash or blank the corresponding gRPC request object
Example: Example:
```ruby ```ruby
client.get_info client.lightning.get_info
# is the same as: # is the same as:
client.grpc_client.get_info(Lnrpc::GetInfoRequest.new) client.lightning.grpc.get_info(Lnrpc::GetInfoRequest.new)
client.list_channels(inactive_only: true) client.lightning.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.grpc_client.list_channels(request) client.lightning.grpc.list_channels(request)
client.wallet_balance.total_balance client.lightning.wallet_balance.total_balance
# is the same as: # is the same as:
request = Lnrpc::WalletBalanceRequest.new() request = Lnrpc::WalletBalanceRequest.new()
client.grpc_client.wallet_balance(request).total_balance client.lightning.grpc.wallet_balance(request).total_balance
``` ```
## Using with BTC Pay Server ## Using with BTC Pay Server
@@ -156,6 +167,14 @@ 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,6 +14,8 @@ 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
@@ -24,7 +26,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", "~> 10.0" spec.add_development_dependency "rake", "~> 13.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"