lnrpc 0.1.0 → 0.5.2.beta

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a6856beac0959117bd74bbc4bea431878340a9c85c5205e528e1e48a0e40efb
4
- data.tar.gz: b4a38dd83d886483339e19fadee6933b517f2636ef0456f6b1b6718426dc9929
3
+ metadata.gz: c9f1749c1fa4257d3624d77aa15e4b8d47f1c6ef2bc19c33965a9bbc8c544b39
4
+ data.tar.gz: b7792de3c448b8a2d53376befe522bdfa819e15cecd0387934742233152a5912
5
5
  SHA512:
6
- metadata.gz: 06ecfcc4a060bc5106c5ac1d84118775a0aad48d2295d6cdbec830e3452bbc82536baebabf919e704c31b728cb1c5213f5cd1d6fbb3d57f8415b2258a52f85dd
7
- data.tar.gz: 9f5490c9ac4a325b70ad937f70565af6b00c077b7609c6093497a6e93432744e53014350d20b130b6eba3a7b9503add92df11504bdeb2072331741340569c671
6
+ metadata.gz: 27ebcf6544a548ab97d5bdeeb2452ebdaa5f5ea1a1870339e8c54e38e23b576c15dfb1ea6b0a5421e854beed8ccc645f8dbd5cc6c030e61f19d9a834b28e1f31
7
+ data.tar.gz: f3fa6207e3c74da86a8d4054163eb028be1b07ef146b4be10370da210c11684f46503c18d9d67ddfae332c67e1e61b34c8a3a9615a4161ced4a266e394751d64
data/Gemfile.lock CHANGED
@@ -39,4 +39,4 @@ DEPENDENCIES
39
39
  rspec (~> 3.0)
40
40
 
41
41
  BUNDLED WITH
42
- 1.17.2
42
+ 1.17.3
data/lib/lnrpc.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  require "lnrpc/version"
2
+ require "lnrpc/rpc_services_pb"
2
3
 
3
4
  module Lnrpc
4
5
  class Error < StandardError; end
5
- autoload :WalletUnlocker, 'lnrpc/rpc_services_pb'
6
- autoload :Lightning, 'lnrpc/rpc_services_pb'
7
6
  autoload :Client, 'lnrpc/client'
8
7
  end
8
+
9
+
data/lib/lnrpc/client.rb CHANGED
@@ -2,11 +2,12 @@ module Lnrpc
2
2
  class Client
3
3
  attr_accessor :address, :credentials, :macaroon, :grpc_client
4
4
 
5
+ LND_HOME_DIR = ENV['LND_HOME'] || "~/.lnd"
5
6
  DEFAULT_ADDRESS = 'localhost:10009'
6
- DEFAULT_CREDENTIALS_PATH = "~/.lnd/tls.cert"
7
- DEFAULT_MACAROON_PATH = "~/.lnd/data/chain/bitcoin/testnet/admin.macaroon"
7
+ DEFAULT_CREDENTIALS_PATH = "#{LND_HOME_DIR}/tls.cert"
8
+ DEFAULT_MACAROON_PATH = "#{LND_HOME_DIR}/data/chain/bitcoin/mainnet/admin.macaroon"
8
9
 
9
- def initialize(options)
10
+ def initialize(options={})
10
11
  self.address = options[:address] || DEFAULT_ADDRESS
11
12
 
12
13
  options[:credentials] ||= ::File.read(::File.expand_path(options[:credentials_path] || DEFAULT_CREDENTIALS_PATH))
@@ -14,21 +15,34 @@ module Lnrpc
14
15
 
15
16
  options[:macaroon] ||= begin
16
17
  macaroon_binary = ::File.read(::File.expand_path(options[:macaroon_path] || DEFAULT_MACAROON_PATH))
17
- macaroon_binary.each_byte.map { |b| b.to_s(16).rjust(2,'0') }.join
18
+ macaroon_binary.unpack("H*")
18
19
  end
19
20
  self.macaroon = options[:macaroon]
20
21
 
21
22
  self.grpc_client = Lnrpc::Lightning::Stub.new(self.address, GRPC::Core::ChannelCredentials.new(self.credentials))
22
23
  end
23
24
 
25
+ def pay(payreq)
26
+ self.send_payment_sync(Lnrpc::SendRequest.new(payment_request: payreq))
27
+ end
28
+
24
29
  def method_missing(m, *args, &block)
25
- if args.last.is_a?(Hash)
26
- args[-1][:metadata] ||= {}
27
- args[-1][:metadata].merge!(macaroon: self.macaroon)
30
+ if self.grpc_client.respond_to?(m)
31
+ params = args[0]
32
+ options = args[1] || { metadata: { macaroon: self.macaroon } }
33
+
34
+ request = params.nil? ? request_class_for(m).new : request_class_for(m).new(params)
35
+ self.grpc_client.send(m, request, options)
28
36
  else
29
- args.push({metadata: { macaroon: self.macaroon }})
37
+ super
30
38
  end
31
- self.grpc_client.send(m, *args)
39
+ end
40
+
41
+ private
42
+ def request_class_for(method_name)
43
+ string = method_name.to_s.sub(/^[a-z\d]*/) { |match| match.capitalize }
44
+ string.gsub!(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{$2.capitalize}" }
45
+ Lnrpc.const_get("#{string}Request")
32
46
  end
33
47
  end
34
48
  end
data/lib/lnrpc/rpc.proto CHANGED
@@ -392,7 +392,7 @@ service Lightning {
392
392
  */
393
393
  rpc AbandonChannel (AbandonChannelRequest) returns (AbandonChannelResponse) {
394
394
  option (google.api.http) = {
395
- delete: "/v1/channels/{channel_point.funding_txid_str}/{channel_point.output_index}"
395
+ delete: "/v1/channels/abandon/{channel_point.funding_txid_str}/{channel_point.output_index}"
396
396
  };
397
397
  }
398
398
 
@@ -1090,6 +1090,8 @@ message GetInfoResponse {
1090
1090
  /// The version of the LND software that the node is running.
1091
1091
  string version = 14 [ json_name = "version" ];
1092
1092
 
1093
+ /// Number of inactive channels
1094
+ uint32 num_inactive_channels = 15 [json_name = "num_inactive_channels"];
1093
1095
  }
1094
1096
 
1095
1097
  message ConfirmationUpdate {
@@ -1365,6 +1367,12 @@ message Hop {
1365
1367
  uint32 expiry = 5 [json_name = "expiry"];
1366
1368
  int64 amt_to_forward_msat = 6 [json_name = "amt_to_forward_msat"];
1367
1369
  int64 fee_msat = 7 [json_name = "fee_msat"];
1370
+
1371
+ /**
1372
+ An optional public key of the hop. If the public key is given, the payment
1373
+ can be executed without relying on a copy of the channel graph.
1374
+ */
1375
+ string pub_key = 8 [json_name = "pub_key"];
1368
1376
  }
1369
1377
 
1370
1378
  /**
data/lib/lnrpc/rpc_pb.rb CHANGED
@@ -233,6 +233,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
233
233
  repeated :uris, :string, 12
234
234
  optional :best_header_timestamp, :int64, 13
235
235
  optional :version, :string, 14
236
+ optional :num_inactive_channels, :uint32, 15
236
237
  end
237
238
  add_message "lnrpc.ConfirmationUpdate" do
238
239
  optional :block_sha, :bytes, 1
@@ -362,6 +363,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
362
363
  optional :expiry, :uint32, 5
363
364
  optional :amt_to_forward_msat, :int64, 6
364
365
  optional :fee_msat, :int64, 7
366
+ optional :pub_key, :string, 8
365
367
  end
366
368
  add_message "lnrpc.Route" do
367
369
  optional :total_time_lock, :uint32, 1
data/lib/lnrpc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lnrpc
2
- VERSION = "0.1.0"
2
+ VERSION = "0.5.2.beta"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lnrpc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.5.2.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bumann
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-08 00:00:00.000000000 Z
11
+ date: 2019-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -105,9 +105,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
105
105
  version: '0'
106
106
  required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - ">"
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: 1.3.1
111
111
  requirements: []
112
112
  rubyforge_project:
113
113
  rubygems_version: 2.7.6