lnrpc 0.8.0.beta → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile.lock +3 -3
- data/README.md +28 -16
- data/examples.rb +6 -11
- data/generate-grpc-service-files.sh +30 -0
- data/lib/grpc_services/autopilotrpc/autopilot_pb.rb +48 -0
- data/lib/grpc_services/autopilotrpc/autopilot_services_pb.rb +40 -0
- data/lib/grpc_services/chainrpc/chainnotifier_pb.rb +67 -0
- data/lib/grpc_services/chainrpc/chainnotifier_services_pb.rb +51 -0
- data/lib/grpc_services/invoicesrpc/invoices_pb.rb +48 -0
- data/lib/grpc_services/invoicesrpc/invoices_services_pb.rb +41 -0
- data/lib/grpc_services/lnclipb/lncli_pb.rb +18 -0
- data/lib/grpc_services/routerrpc/router_pb.rb +229 -0
- data/lib/grpc_services/routerrpc/router_services_pb.rb +86 -0
- data/lib/grpc_services/rpc_pb.rb +1265 -0
- data/lib/{lnrpc → grpc_services}/rpc_services_pb.rb +115 -119
- data/lib/grpc_services/signrpc/signer_pb.rb +83 -0
- data/lib/grpc_services/signrpc/signer_services_pb.rb +68 -0
- data/lib/grpc_services/verrpc/verrpc_pb.rb +27 -0
- data/lib/grpc_services/verrpc/verrpc_services_pb.rb +27 -0
- data/lib/grpc_services/walletrpc/walletkit_pb.rb +149 -0
- data/lib/grpc_services/walletrpc/walletkit_services_pb.rb +115 -0
- data/lib/grpc_services/walletunlocker_pb.rb +51 -0
- data/lib/grpc_services/walletunlocker_services_pb.rb +72 -0
- data/lib/grpc_services/watchtowerrpc/watchtower_pb.rb +21 -0
- data/lib/grpc_services/watchtowerrpc/watchtower_services_pb.rb +28 -0
- data/lib/grpc_services/wtclientrpc/wtclient_pb.rb +75 -0
- data/lib/grpc_services/wtclientrpc/wtclient_services_pb.rb +43 -0
- data/lib/lnrpc.rb +19 -3
- data/lib/lnrpc/client.rb +60 -45
- data/lib/lnrpc/grpc_wrapper.rb +43 -0
- data/lib/lnrpc/version.rb +1 -1
- data/lnrpc.gemspec +4 -2
- metadata +35 -11
- data/lib/lnrpc/rpc.proto +0 -2580
- data/lib/lnrpc/rpc_pb.rb +0 -938
@@ -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
|
data/lib/lnrpc.rb
CHANGED
@@ -1,10 +1,26 @@
|
|
1
|
-
require
|
2
|
-
|
1
|
+
require 'lnrpc/version'
|
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
|
+
|
8
|
+
require 'securerandom'
|
3
9
|
|
4
10
|
module Lnrpc
|
5
11
|
class Error < StandardError; end
|
6
12
|
autoload :Client, 'lnrpc/client'
|
13
|
+
autoload :GrpcWrapper, 'lnrpc/grpc_wrapper'
|
7
14
|
autoload :MacaroonInterceptor, 'lnrpc/macaroon_interceptor'
|
8
|
-
end
|
9
15
|
|
16
|
+
PREIMAGE_BYTE_LENGTH = 32
|
17
|
+
KEY_SEND_PREIMAGE_TYPE = 5482373484
|
18
|
+
|
19
|
+
def self.create_preimage
|
20
|
+
SecureRandom.random_bytes(PREIMAGE_BYTE_LENGTH)
|
21
|
+
end
|
10
22
|
|
23
|
+
def self.to_byte_array(str)
|
24
|
+
[str].pack("H*")
|
25
|
+
end
|
26
|
+
end
|
data/lib/lnrpc/client.rb
CHANGED
@@ -3,32 +3,12 @@ require "lnrpc/macaroon_interceptor"
|
|
3
3
|
module Lnrpc
|
4
4
|
class Client
|
5
5
|
attr_accessor :address, :credentials, :macaroon
|
6
|
-
attr_writer :grpc_client
|
7
6
|
|
8
7
|
LND_HOME_DIR = ENV['LND_HOME'] || "~/.lnd"
|
9
8
|
DEFAULT_ADDRESS = 'localhost:10009'
|
10
9
|
DEFAULT_CREDENTIALS_PATH = "#{LND_HOME_DIR}/tls.cert"
|
11
10
|
DEFAULT_MACAROON_PATH = "#{LND_HOME_DIR}/data/chain/bitcoin/mainnet/admin.macaroon"
|
12
11
|
|
13
|
-
NON_CONVENTION_REQUEST_CLASSES = {
|
14
|
-
add_invoice: Lnrpc::Invoice,
|
15
|
-
send_payment: Lnrpc::SendRequest,
|
16
|
-
send_payment_sync: Lnrpc::SendRequest,
|
17
|
-
open_channel_sync: Lnrpc::OpenChannelRequest,
|
18
|
-
send_to_route_sync: Lnrpc::SendToRouteRequest,
|
19
|
-
lookup_invoice: Lnrpc::PaymentHash,
|
20
|
-
decode_pay_req: Lnrpc::PayReqString,
|
21
|
-
describe_graph: Lnrpc::ChannelGraphRequest,
|
22
|
-
get_chan_info: Lnrpc::ChanInfoRequest,
|
23
|
-
get_node_info: Lnrpc::NodeInfoRequest,
|
24
|
-
get_network_info: Lnrpc::NetworkInfoRequest,
|
25
|
-
stop_daemon: Lnrpc::StopRequest,
|
26
|
-
update_channel_policy: Lnrpc::PolicyUpdateResponse,
|
27
|
-
subscribe_channel_graph: Lnrpc::GraphTopologySubscription,
|
28
|
-
subscribe_invoices: Lnrpc::InvoiceSubscription,
|
29
|
-
subscribe_transactions: Lnrpc::GetTransactionsRequest
|
30
|
-
}
|
31
|
-
|
32
12
|
def initialize(options={})
|
33
13
|
self.address = options[:address] || DEFAULT_ADDRESS
|
34
14
|
|
@@ -46,42 +26,77 @@ module Lnrpc
|
|
46
26
|
self.macaroon = options[:macaroon]
|
47
27
|
end
|
48
28
|
|
49
|
-
def
|
50
|
-
@
|
51
|
-
GRPC::Core::ChannelCredentials.new(self.credentials),
|
52
|
-
interceptors: [Lnrpc::MacaroonInterceptor.new(self.macaroon)]
|
53
|
-
)
|
29
|
+
def lightning
|
30
|
+
@lightning ||= grpc_wrapper_for(Lnrpc::Lightning)
|
54
31
|
end
|
55
32
|
|
56
|
-
def
|
57
|
-
|
33
|
+
def autopilot
|
34
|
+
@autopilot ||= grpc_wrapper_for(Autopilotrpc::Autopilot)
|
58
35
|
end
|
59
36
|
|
60
|
-
def
|
61
|
-
|
62
|
-
|
37
|
+
def chain_notifier
|
38
|
+
@chain_notifier ||= grpc_wrapper_for(Chainrpc::ChainNotifier)
|
39
|
+
end
|
63
40
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
41
|
+
def invoices
|
42
|
+
@invoices ||= grpc_wrapper_for(Invoicesrpc::Invoices)
|
43
|
+
end
|
44
|
+
|
45
|
+
def router
|
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)
|
71
|
+
end
|
72
|
+
|
73
|
+
def keysend(args)
|
74
|
+
args[:dest_custom_records] ||= {}
|
75
|
+
args[:dest_custom_records][Lnrpc::KEY_SEND_PREIMAGE_TYPE] ||= Lnrpc.create_preimage
|
76
|
+
args[:payment_hash] ||= Digest::SHA256.digest(args[:dest_custom_records][Lnrpc::KEY_SEND_PREIMAGE_TYPE])
|
77
|
+
args[:timeout_seconds] ||= 60
|
78
|
+
router.send_payment_v2(args)
|
79
|
+
end
|
80
|
+
|
81
|
+
def pay(args)
|
82
|
+
args[:timeout_seconds] ||= 60
|
83
|
+
router.send_payment_v2(args)
|
69
84
|
end
|
70
85
|
|
71
86
|
def inspect
|
72
|
-
"#{self
|
87
|
+
"#{self} @address=\"#{address}\""
|
73
88
|
end
|
74
89
|
|
75
90
|
private
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
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
|
+
))
|
84
100
|
end
|
85
101
|
end
|
86
102
|
end
|
87
|
-
|