lnrpc 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -13
  3. data/examples.rb +5 -5
  4. data/generate-grpc-service-files.sh +30 -0
  5. data/lib/grpc_services/autopilotrpc/autopilot_pb.rb +48 -0
  6. data/lib/grpc_services/autopilotrpc/autopilot_services_pb.rb +40 -0
  7. data/lib/grpc_services/chainrpc/chainnotifier_pb.rb +67 -0
  8. data/lib/grpc_services/chainrpc/chainnotifier_services_pb.rb +51 -0
  9. data/lib/grpc_services/invoicesrpc/invoices_pb.rb +48 -0
  10. data/lib/grpc_services/invoicesrpc/invoices_services_pb.rb +41 -0
  11. data/lib/grpc_services/lnclipb/lncli_pb.rb +18 -0
  12. data/lib/grpc_services/routerrpc/router_pb.rb +229 -0
  13. data/lib/{lnrpc → grpc_services/routerrpc}/router_services_pb.rb +33 -16
  14. data/lib/grpc_services/rpc_pb.rb +1265 -0
  15. data/lib/{lnrpc → grpc_services}/rpc_services_pb.rb +83 -115
  16. data/lib/grpc_services/signrpc/signer_pb.rb +83 -0
  17. data/lib/grpc_services/signrpc/signer_services_pb.rb +68 -0
  18. data/lib/grpc_services/verrpc/verrpc_pb.rb +27 -0
  19. data/lib/grpc_services/verrpc/verrpc_services_pb.rb +27 -0
  20. data/lib/grpc_services/walletrpc/walletkit_pb.rb +149 -0
  21. data/lib/grpc_services/walletrpc/walletkit_services_pb.rb +115 -0
  22. data/lib/grpc_services/walletunlocker_pb.rb +51 -0
  23. data/lib/grpc_services/walletunlocker_services_pb.rb +72 -0
  24. data/lib/grpc_services/watchtowerrpc/watchtower_pb.rb +21 -0
  25. data/lib/grpc_services/watchtowerrpc/watchtower_services_pb.rb +28 -0
  26. data/lib/grpc_services/wtclientrpc/wtclient_pb.rb +75 -0
  27. data/lib/grpc_services/wtclientrpc/wtclient_services_pb.rb +43 -0
  28. data/lib/lnrpc.rb +6 -2
  29. data/lib/lnrpc/client.rb +50 -9
  30. data/lib/lnrpc/grpc_wrapper.rb +19 -42
  31. data/lib/lnrpc/version.rb +1 -1
  32. data/lnrpc.gemspec +1 -1
  33. metadata +27 -8
  34. data/lib/lnrpc/router.proto +0 -560
  35. data/lib/lnrpc/router_pb.rb +0 -198
  36. data/lib/lnrpc/rpc.proto +0 -3687
  37. data/lib/lnrpc/rpc_pb.rb +0 -1248
@@ -0,0 +1,51 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: walletunlocker.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'rpc_pb'
7
+ Google::Protobuf::DescriptorPool.generated_pool.build do
8
+ add_file("walletunlocker.proto", :syntax => :proto3) do
9
+ add_message "lnrpc.GenSeedRequest" do
10
+ optional :aezeed_passphrase, :bytes, 1
11
+ optional :seed_entropy, :bytes, 2
12
+ end
13
+ add_message "lnrpc.GenSeedResponse" do
14
+ repeated :cipher_seed_mnemonic, :string, 1
15
+ optional :enciphered_seed, :bytes, 2
16
+ end
17
+ add_message "lnrpc.InitWalletRequest" do
18
+ optional :wallet_password, :bytes, 1
19
+ repeated :cipher_seed_mnemonic, :string, 2
20
+ optional :aezeed_passphrase, :bytes, 3
21
+ optional :recovery_window, :int32, 4
22
+ optional :channel_backups, :message, 5, "lnrpc.ChanBackupSnapshot"
23
+ end
24
+ add_message "lnrpc.InitWalletResponse" do
25
+ end
26
+ add_message "lnrpc.UnlockWalletRequest" do
27
+ optional :wallet_password, :bytes, 1
28
+ optional :recovery_window, :int32, 2
29
+ optional :channel_backups, :message, 3, "lnrpc.ChanBackupSnapshot"
30
+ end
31
+ add_message "lnrpc.UnlockWalletResponse" do
32
+ end
33
+ add_message "lnrpc.ChangePasswordRequest" do
34
+ optional :current_password, :bytes, 1
35
+ optional :new_password, :bytes, 2
36
+ end
37
+ add_message "lnrpc.ChangePasswordResponse" do
38
+ end
39
+ end
40
+ end
41
+
42
+ module Lnrpc
43
+ GenSeedRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("lnrpc.GenSeedRequest").msgclass
44
+ GenSeedResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("lnrpc.GenSeedResponse").msgclass
45
+ InitWalletRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("lnrpc.InitWalletRequest").msgclass
46
+ InitWalletResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("lnrpc.InitWalletResponse").msgclass
47
+ UnlockWalletRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("lnrpc.UnlockWalletRequest").msgclass
48
+ UnlockWalletResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("lnrpc.UnlockWalletResponse").msgclass
49
+ ChangePasswordRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("lnrpc.ChangePasswordRequest").msgclass
50
+ ChangePasswordResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("lnrpc.ChangePasswordResponse").msgclass
51
+ end
@@ -0,0 +1,72 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: walletunlocker.proto for package 'lnrpc'
3
+
4
+ require 'grpc'
5
+ require 'walletunlocker_pb'
6
+
7
+ module Lnrpc
8
+ module WalletUnlocker
9
+ #
10
+ # Comments in this file will be directly parsed into the API
11
+ # Documentation as descriptions of the associated method, message, or field.
12
+ # These descriptions should go right above the definition of the object, and
13
+ # can be in either block or // comment format.
14
+ #
15
+ # An RPC method can be matched to an lncli command by placing a line in the
16
+ # beginning of the description in exactly the following format:
17
+ # lncli: `methodname`
18
+ #
19
+ # Failure to specify the exact name of the command will cause documentation
20
+ # generation to fail.
21
+ #
22
+ # More information on how exactly the gRPC documentation is generated from
23
+ # this proto file can be found here:
24
+ # https://github.com/lightninglabs/lightning-api
25
+ #
26
+ # WalletUnlocker is a service that is used to set up a wallet password for
27
+ # lnd at first startup, and unlock a previously set up wallet.
28
+ class Service
29
+
30
+ include GRPC::GenericService
31
+
32
+ self.marshal_class_method = :encode
33
+ self.unmarshal_class_method = :decode
34
+ self.service_name = 'lnrpc.WalletUnlocker'
35
+
36
+ #
37
+ # GenSeed is the first method that should be used to instantiate a new lnd
38
+ # instance. This method allows a caller to generate a new aezeed cipher seed
39
+ # given an optional passphrase. If provided, the passphrase will be necessary
40
+ # to decrypt the cipherseed to expose the internal wallet seed.
41
+ #
42
+ # Once the cipherseed is obtained and verified by the user, the InitWallet
43
+ # method should be used to commit the newly generated seed, and create the
44
+ # wallet.
45
+ rpc :GenSeed, GenSeedRequest, GenSeedResponse
46
+ #
47
+ # InitWallet is used when lnd is starting up for the first time to fully
48
+ # initialize the daemon and its internal wallet. At the very least a wallet
49
+ # password must be provided. This will be used to encrypt sensitive material
50
+ # on disk.
51
+ #
52
+ # In the case of a recovery scenario, the user can also specify their aezeed
53
+ # mnemonic and passphrase. If set, then the daemon will use this prior state
54
+ # to initialize its internal wallet.
55
+ #
56
+ # Alternatively, this can be used along with the GenSeed RPC to obtain a
57
+ # seed, then present it to the user. Once it has been verified by the user,
58
+ # the seed can be fed into this RPC in order to commit the new wallet.
59
+ rpc :InitWallet, InitWalletRequest, InitWalletResponse
60
+ # lncli: `unlock`
61
+ # UnlockWallet is used at startup of lnd to provide a password to unlock
62
+ # the wallet database.
63
+ rpc :UnlockWallet, UnlockWalletRequest, UnlockWalletResponse
64
+ # lncli: `changepassword`
65
+ # ChangePassword changes the password of the encrypted wallet. This will
66
+ # automatically unlock the wallet database if successful.
67
+ rpc :ChangePassword, ChangePasswordRequest, ChangePasswordResponse
68
+ end
69
+
70
+ Stub = Service.rpc_stub_class
71
+ end
72
+ end
@@ -0,0 +1,21 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: watchtowerrpc/watchtower.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ Google::Protobuf::DescriptorPool.generated_pool.build do
7
+ add_file("watchtowerrpc/watchtower.proto", :syntax => :proto3) do
8
+ add_message "watchtowerrpc.GetInfoRequest" do
9
+ end
10
+ add_message "watchtowerrpc.GetInfoResponse" do
11
+ optional :pubkey, :bytes, 1
12
+ repeated :listeners, :string, 2
13
+ repeated :uris, :string, 3
14
+ end
15
+ end
16
+ end
17
+
18
+ module Watchtowerrpc
19
+ GetInfoRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("watchtowerrpc.GetInfoRequest").msgclass
20
+ GetInfoResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("watchtowerrpc.GetInfoResponse").msgclass
21
+ end
@@ -0,0 +1,28 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: watchtowerrpc/watchtower.proto for package 'watchtowerrpc'
3
+
4
+ require 'grpc'
5
+ require 'watchtowerrpc/watchtower_pb'
6
+
7
+ module Watchtowerrpc
8
+ module Watchtower
9
+ # Watchtower is a service that grants access to the watchtower server
10
+ # functionality of the daemon.
11
+ class Service
12
+
13
+ include GRPC::GenericService
14
+
15
+ self.marshal_class_method = :encode
16
+ self.unmarshal_class_method = :decode
17
+ self.service_name = 'watchtowerrpc.Watchtower'
18
+
19
+ # lncli: tower info
20
+ # GetInfo returns general information concerning the companion watchtower
21
+ # including its public key and URIs where the server is currently
22
+ # listening for clients.
23
+ rpc :GetInfo, GetInfoRequest, GetInfoResponse
24
+ end
25
+
26
+ Stub = Service.rpc_stub_class
27
+ end
28
+ end
@@ -0,0 +1,75 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: wtclientrpc/wtclient.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ Google::Protobuf::DescriptorPool.generated_pool.build do
7
+ add_file("wtclientrpc/wtclient.proto", :syntax => :proto3) do
8
+ add_message "wtclientrpc.AddTowerRequest" do
9
+ optional :pubkey, :bytes, 1
10
+ optional :address, :string, 2
11
+ end
12
+ add_message "wtclientrpc.AddTowerResponse" do
13
+ end
14
+ add_message "wtclientrpc.RemoveTowerRequest" do
15
+ optional :pubkey, :bytes, 1
16
+ optional :address, :string, 2
17
+ end
18
+ add_message "wtclientrpc.RemoveTowerResponse" do
19
+ end
20
+ add_message "wtclientrpc.GetTowerInfoRequest" do
21
+ optional :pubkey, :bytes, 1
22
+ optional :include_sessions, :bool, 2
23
+ end
24
+ add_message "wtclientrpc.TowerSession" do
25
+ optional :num_backups, :uint32, 1
26
+ optional :num_pending_backups, :uint32, 2
27
+ optional :max_backups, :uint32, 3
28
+ optional :sweep_sat_per_byte, :uint32, 4
29
+ end
30
+ add_message "wtclientrpc.Tower" do
31
+ optional :pubkey, :bytes, 1
32
+ repeated :addresses, :string, 2
33
+ optional :active_session_candidate, :bool, 3
34
+ optional :num_sessions, :uint32, 4
35
+ repeated :sessions, :message, 5, "wtclientrpc.TowerSession"
36
+ end
37
+ add_message "wtclientrpc.ListTowersRequest" do
38
+ optional :include_sessions, :bool, 1
39
+ end
40
+ add_message "wtclientrpc.ListTowersResponse" do
41
+ repeated :towers, :message, 1, "wtclientrpc.Tower"
42
+ end
43
+ add_message "wtclientrpc.StatsRequest" do
44
+ end
45
+ add_message "wtclientrpc.StatsResponse" do
46
+ optional :num_backups, :uint32, 1
47
+ optional :num_pending_backups, :uint32, 2
48
+ optional :num_failed_backups, :uint32, 3
49
+ optional :num_sessions_acquired, :uint32, 4
50
+ optional :num_sessions_exhausted, :uint32, 5
51
+ end
52
+ add_message "wtclientrpc.PolicyRequest" do
53
+ end
54
+ add_message "wtclientrpc.PolicyResponse" do
55
+ optional :max_updates, :uint32, 1
56
+ optional :sweep_sat_per_byte, :uint32, 2
57
+ end
58
+ end
59
+ end
60
+
61
+ module Wtclientrpc
62
+ AddTowerRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.AddTowerRequest").msgclass
63
+ AddTowerResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.AddTowerResponse").msgclass
64
+ RemoveTowerRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.RemoveTowerRequest").msgclass
65
+ RemoveTowerResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.RemoveTowerResponse").msgclass
66
+ GetTowerInfoRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.GetTowerInfoRequest").msgclass
67
+ TowerSession = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.TowerSession").msgclass
68
+ Tower = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.Tower").msgclass
69
+ ListTowersRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.ListTowersRequest").msgclass
70
+ ListTowersResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.ListTowersResponse").msgclass
71
+ StatsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.StatsRequest").msgclass
72
+ StatsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.StatsResponse").msgclass
73
+ PolicyRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.PolicyRequest").msgclass
74
+ PolicyResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.PolicyResponse").msgclass
75
+ end
@@ -0,0 +1,43 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: wtclientrpc/wtclient.proto for package 'wtclientrpc'
3
+
4
+ require 'grpc'
5
+ require 'wtclientrpc/wtclient_pb'
6
+
7
+ module Wtclientrpc
8
+ module WatchtowerClient
9
+ # WatchtowerClient is a service that grants access to the watchtower client
10
+ # functionality of the daemon.
11
+ class Service
12
+
13
+ include GRPC::GenericService
14
+
15
+ self.marshal_class_method = :encode
16
+ self.unmarshal_class_method = :decode
17
+ self.service_name = 'wtclientrpc.WatchtowerClient'
18
+
19
+ #
20
+ # AddTower adds a new watchtower reachable at the given address and
21
+ # considers it for new sessions. If the watchtower already exists, then
22
+ # any new addresses included will be considered when dialing it for
23
+ # session negotiations and backups.
24
+ rpc :AddTower, AddTowerRequest, AddTowerResponse
25
+ #
26
+ # RemoveTower removes a watchtower from being considered for future session
27
+ # negotiations and from being used for any subsequent backups until it's added
28
+ # again. If an address is provided, then this RPC only serves as a way of
29
+ # removing the address from the watchtower instead.
30
+ rpc :RemoveTower, RemoveTowerRequest, RemoveTowerResponse
31
+ # ListTowers returns the list of watchtowers registered with the client.
32
+ rpc :ListTowers, ListTowersRequest, ListTowersResponse
33
+ # GetTowerInfo retrieves information for a registered watchtower.
34
+ rpc :GetTowerInfo, GetTowerInfoRequest, Tower
35
+ # Stats returns the in-memory statistics of the client since startup.
36
+ rpc :Stats, StatsRequest, StatsResponse
37
+ # Policy returns the active watchtower client policy configuration.
38
+ rpc :Policy, PolicyRequest, PolicyResponse
39
+ end
40
+
41
+ Stub = Service.rpc_stub_class
42
+ end
43
+ end
@@ -1,6 +1,10 @@
1
1
  require 'lnrpc/version'
2
- require 'lnrpc/rpc_services_pb'
3
- require 'lnrpc/router_services_pb'
2
+
3
+ # require GRPC services
4
+ Dir[File.join(File.expand_path(File.dirname(__FILE__)), 'grpc_services/**/*_services_pb.rb')].each do |file|
5
+ require file
6
+ end
7
+
4
8
  require 'securerandom'
5
9
 
6
10
  module Lnrpc
@@ -27,17 +27,47 @@ module Lnrpc
27
27
  end
28
28
 
29
29
  def lightning
30
- @lightning ||= GrpcWrapper.new(Lnrpc::Lightning::Stub.new(address,
31
- GRPC::Core::ChannelCredentials.new(credentials),
32
- interceptors: [Lnrpc::MacaroonInterceptor.new(macaroon)]
33
- ))
30
+ @lightning ||= grpc_wrapper_for(Lnrpc::Lightning)
31
+ end
32
+
33
+ def autopilot
34
+ @autopilot ||= grpc_wrapper_for(Autopilotrpc::Autopilot)
35
+ end
36
+
37
+ def chain_notifier
38
+ @chain_notifier ||= grpc_wrapper_for(Chainrpc::ChainNotifier)
39
+ end
40
+
41
+ def invoices
42
+ @invoices ||= grpc_wrapper_for(Invoicesrpc::Invoices)
34
43
  end
35
44
 
36
45
  def router
37
- @router ||= GrpcWrapper.new(Routerrpc::Router::Stub.new(address,
38
- GRPC::Core::ChannelCredentials.new(credentials),
39
- interceptors: [Lnrpc::MacaroonInterceptor.new(macaroon)]
40
- ))
46
+ @router ||= grpc_wrapper_for(Routerrpc::Router)
47
+ end
48
+
49
+ def signer
50
+ @signer ||= grpc_wrapper_for(Signrpc::Signer)
51
+ end
52
+
53
+ def versioner
54
+ @versioner ||= grpc_wrapper_for(Verrpc::Versioner)
55
+ end
56
+
57
+ def wallet_kit
58
+ @wallet_kit ||= grpc_wrapper_for(Walletrpc::WalletKit)
59
+ end
60
+
61
+ def wallet_unlocker
62
+ @wallet_unlocker ||= grpc_wrapper_for(Lnrpc::WalletUnlocker)
63
+ end
64
+
65
+ def watchtower
66
+ @watchtower ||= grpc_wrapper_for(Watchtowerrpc::Watchtower)
67
+ end
68
+
69
+ def watchtower_client
70
+ @watchtower_client ||= grpc_wrapper_for(Wtclientrpc::WatchtowerClient)
41
71
  end
42
72
 
43
73
  def keysend(args)
@@ -54,8 +84,19 @@ module Lnrpc
54
84
  end
55
85
 
56
86
  def inspect
57
- "#{self.to_s} @address=\"#{self.address}\""
87
+ "#{self} @address=\"#{address}\""
58
88
  end
59
89
 
90
+ private
91
+
92
+ def grpc_wrapper_for(grpc_module)
93
+ stub = grpc_module.const_get(:Stub)
94
+ service = grpc_module.const_get(:Service)
95
+ GrpcWrapper.new(service: service,
96
+ grpc: stub.new(address,
97
+ GRPC::Core::ChannelCredentials.new(credentials),
98
+ interceptors: [Lnrpc::MacaroonInterceptor.new(macaroon)]
99
+ ))
100
+ end
60
101
  end
61
102
  end
@@ -1,66 +1,43 @@
1
1
  module Lnrpc
2
2
  class GrpcWrapper
3
- NON_CONVENTION_REQUEST_CLASSES = {
4
- add_invoice: Lnrpc::Invoice,
5
- decode_pay_req: Lnrpc::PayReqString,
6
- describe_graph: Lnrpc::ChannelGraphRequest,
7
- export_all_channel_backups: Lnrpc::ChanBackupExportRequest,
8
- funding_state_step: Lnrpc::FundingTransitionMsg,
9
- get_chan_info: Lnrpc::ChanInfoRequest,
10
- get_network_info: Lnrpc::NetworkInfoRequest,
11
- get_node_info: Lnrpc::NodeInfoRequest,
12
- get_node_metrics: Lnrpc::NodeMetricsRequest,
13
- lookup_invoice: Lnrpc::PaymentHash,
14
- open_channel_sync: Lnrpc::OpenChannelRequest,
15
- send_payment_sync: Lnrpc::SendRequest,
16
- send_to_route_sync: Lnrpc::SendToRouteRequest,
17
- stop_daemon: Lnrpc::StopRequest,
18
- subscribe_channel_backups: Lnrpc::ChannelBackupSubscription,
19
- subscribe_channel_event: Lnrpc::ChannelEventSubscription,
20
- subscribe_channel_graph: Lnrpc::GraphTopologySubscription,
21
- subscribe_invoices: Lnrpc::InvoiceSubscription,
22
- subscribe_peer_event: Lnrpc::PeerEventSubscription,
23
- subscribe_transactions: Lnrpc::GetTransactionsRequest,
24
- update_channel_policy: Lnrpc::PolicyUpdateResponse,
25
- varify_channel_backup: Lnrpc::ChanBackupSnapshot,
3
+ attr_reader :grpc, :service
26
4
 
27
- estimate_route_fee: Routerrpc::RouteFeeRequest,
28
- send_payment: Routerrpc::SendPaymentRequest,
29
- send_payment_v2: Routerrpc::SendPaymentRequest,
30
- track_payment_v2: Routerrpc::TrackPaymentRequest
31
- }
32
-
33
- attr_reader :grpc
34
-
35
- def initialize(grpc)
5
+ def initialize(service:, grpc:)
36
6
  @grpc = grpc
7
+ @service = service
37
8
  end
38
9
 
39
10
  def method_missing(m, *args, &block)
40
- if self.grpc.respond_to?(m)
41
- params = args[0]
11
+ if grpc.respond_to?(m)
12
+ params = args[0]
42
13
 
43
14
  args[0] = params.nil? ? request_class_for(m).new : request_class_for(m).new(params)
44
- self.grpc.send(m, *args, &block)
15
+ grpc.send(m, *args, &block)
45
16
  else
46
17
  super
47
18
  end
48
19
  end
49
20
 
50
21
  def inspect
51
- "#{self.to_s} @grpc=\"#{self.grpc.to_s}\""
22
+ "#{self} @grpc=\"#{grpc}\""
52
23
  end
53
24
 
54
25
  private
55
26
 
56
27
  def request_class_for(method_name)
57
- if NON_CONVENTION_REQUEST_CLASSES.key?(method_name.to_sym)
58
- NON_CONVENTION_REQUEST_CLASSES[method_name.to_sym]
59
- else
60
- klass = method_name.to_s.sub(/^[a-z\d]*/) { |match| match.capitalize }
61
- klass.gsub!(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{$2.capitalize}" }
62
- Module.const_get(grpc.class.name.to_s[/.+?(?=::)/]).const_get("#{klass}Request")
28
+ rpc_desc = service.rpc_descs[camelize(method_name).to_sym]
29
+ raise "Request class not found for: #{method_name}" unless rpc_desc
30
+
31
+ rpc_desc.input
32
+ end
33
+
34
+ def camelize(name)
35
+ str = name.to_s
36
+ separators = ['_', '\s']
37
+ separators.each do |s|
38
+ str = str.gsub(/(?:#{s}+)([a-z])/) { $1.upcase }
63
39
  end
40
+ str.gsub(/(\A|\s)([a-z])/) { $1 + $2.upcase }
64
41
  end
65
42
  end
66
43
  end