lnd-client 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +15 -0
  4. data/Gemfile +16 -0
  5. data/Gemfile.lock +62 -0
  6. data/LICENSE +21 -0
  7. data/README.md +107 -0
  8. data/Rakefile +10 -0
  9. data/components/grpc/autopilotrpc/autopilot_pb.rb +48 -0
  10. data/components/grpc/autopilotrpc/autopilot_services_pb.rb +40 -0
  11. data/components/grpc/chainrpc/chainkit_pb.rb +36 -0
  12. data/components/grpc/chainrpc/chainkit_services_pb.rb +34 -0
  13. data/components/grpc/chainrpc/chainnotifier_pb.rb +69 -0
  14. data/components/grpc/chainrpc/chainnotifier_services_pb.rb +53 -0
  15. data/components/grpc/devrpc/dev_pb.rb +17 -0
  16. data/components/grpc/devrpc/dev_services_pb.rb +25 -0
  17. data/components/grpc/invoicesrpc/invoices_pb.rb +66 -0
  18. data/components/grpc/invoicesrpc/invoices_services_pb.rb +45 -0
  19. data/components/grpc/lightning_pb.rb +1621 -0
  20. data/components/grpc/lightning_services_pb.rb +441 -0
  21. data/components/grpc/lnclipb/lncli_pb.rb +19 -0
  22. data/components/grpc/neutrinorpc/neutrino_pb.rb +106 -0
  23. data/components/grpc/neutrinorpc/neutrino_services_pb.rb +51 -0
  24. data/components/grpc/peersrpc/peers_pb.rb +48 -0
  25. data/components/grpc/peersrpc/peers_services_pb.rb +27 -0
  26. data/components/grpc/routerrpc/router_pb.rb +299 -0
  27. data/components/grpc/routerrpc/router_services_pb.rb +115 -0
  28. data/components/grpc/signrpc/signer_pb.rb +172 -0
  29. data/components/grpc/signrpc/signer_services_pb.rb +134 -0
  30. data/components/grpc/stateservice_pb.rb +35 -0
  31. data/components/grpc/stateservice_services_pb.rb +46 -0
  32. data/components/grpc/verrpc/verrpc_pb.rb +27 -0
  33. data/components/grpc/verrpc/verrpc_services_pb.rb +27 -0
  34. data/components/grpc/walletrpc/walletkit_pb.rb +328 -0
  35. data/components/grpc/walletrpc/walletkit_services_pb.rb +230 -0
  36. data/components/grpc/walletunlocker_pb.rb +75 -0
  37. data/components/grpc/walletunlocker_services_pb.rb +72 -0
  38. data/components/grpc/watchtowerrpc/watchtower_pb.rb +21 -0
  39. data/components/grpc/watchtowerrpc/watchtower_services_pb.rb +28 -0
  40. data/components/grpc/wtclientrpc/wtclient_pb.rb +83 -0
  41. data/components/grpc/wtclientrpc/wtclient_services_pb.rb +43 -0
  42. data/components/grpc.rb +9 -0
  43. data/controllers/client.rb +31 -0
  44. data/controllers/config.rb +35 -0
  45. data/controllers/documentation.rb +45 -0
  46. data/controllers/grpc_generator.rb +80 -0
  47. data/controllers/service.rb +35 -0
  48. data/lnd-client.gemspec +35 -0
  49. data/logic/string.rb +11 -0
  50. data/ports/dsl/lnd-client.rb +14 -0
  51. data/static/spec.rb +13 -0
  52. metadata +110 -0
@@ -0,0 +1,230 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: walletrpc/walletkit.proto for package 'walletrpc'
3
+
4
+ require 'grpc'
5
+ require_relative 'walletrpc/walletkit_pb'
6
+
7
+ module Walletrpc
8
+ module WalletKit
9
+ # WalletKit is a service that gives access to the core functionalities of the
10
+ # daemon's wallet.
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 = 'walletrpc.WalletKit'
18
+
19
+ #
20
+ # ListUnspent returns a list of all utxos spendable by the wallet with a
21
+ # number of confirmations between the specified minimum and maximum. By
22
+ # default, all utxos are listed. To list only the unconfirmed utxos, set
23
+ # the unconfirmed_only to true.
24
+ rpc :ListUnspent, ::Walletrpc::ListUnspentRequest, ::Walletrpc::ListUnspentResponse
25
+ #
26
+ # LeaseOutput locks an output to the given ID, preventing it from being
27
+ # available for any future coin selection attempts. The absolute time of the
28
+ # lock's expiration is returned. The expiration of the lock can be extended by
29
+ # successive invocations of this RPC. Outputs can be unlocked before their
30
+ # expiration through `ReleaseOutput`.
31
+ rpc :LeaseOutput, ::Walletrpc::LeaseOutputRequest, ::Walletrpc::LeaseOutputResponse
32
+ #
33
+ # ReleaseOutput unlocks an output, allowing it to be available for coin
34
+ # selection if it remains unspent. The ID should match the one used to
35
+ # originally lock the output.
36
+ rpc :ReleaseOutput, ::Walletrpc::ReleaseOutputRequest, ::Walletrpc::ReleaseOutputResponse
37
+ #
38
+ # ListLeases lists all currently locked utxos.
39
+ rpc :ListLeases, ::Walletrpc::ListLeasesRequest, ::Walletrpc::ListLeasesResponse
40
+ #
41
+ # DeriveNextKey attempts to derive the *next* key within the key family
42
+ # (account in BIP43) specified. This method should return the next external
43
+ # child within this branch.
44
+ rpc :DeriveNextKey, ::Walletrpc::KeyReq, ::Signrpc::KeyDescriptor
45
+ #
46
+ # DeriveKey attempts to derive an arbitrary key specified by the passed
47
+ # KeyLocator.
48
+ rpc :DeriveKey, ::Signrpc::KeyLocator, ::Signrpc::KeyDescriptor
49
+ #
50
+ # NextAddr returns the next unused address within the wallet.
51
+ rpc :NextAddr, ::Walletrpc::AddrRequest, ::Walletrpc::AddrResponse
52
+ #
53
+ # ListAccounts retrieves all accounts belonging to the wallet by default. A
54
+ # name and key scope filter can be provided to filter through all of the
55
+ # wallet accounts and return only those matching.
56
+ rpc :ListAccounts, ::Walletrpc::ListAccountsRequest, ::Walletrpc::ListAccountsResponse
57
+ #
58
+ # RequiredReserve returns the minimum amount of satoshis that should be kept
59
+ # in the wallet in order to fee bump anchor channels if necessary. The value
60
+ # scales with the number of public anchor channels but is capped at a maximum.
61
+ rpc :RequiredReserve, ::Walletrpc::RequiredReserveRequest, ::Walletrpc::RequiredReserveResponse
62
+ #
63
+ # ListAddresses retrieves all the addresses along with their balance. An
64
+ # account name filter can be provided to filter through all of the
65
+ # wallet accounts and return the addresses of only those matching.
66
+ rpc :ListAddresses, ::Walletrpc::ListAddressesRequest, ::Walletrpc::ListAddressesResponse
67
+ #
68
+ # ImportAccount imports an account backed by an account extended public key.
69
+ # The master key fingerprint denotes the fingerprint of the root key
70
+ # corresponding to the account public key (also known as the key with
71
+ # derivation path m/). This may be required by some hardware wallets for
72
+ # proper identification and signing.
73
+ #
74
+ # The address type can usually be inferred from the key's version, but may be
75
+ # required for certain keys to map them into the proper scope.
76
+ #
77
+ # For BIP-0044 keys, an address type must be specified as we intend to not
78
+ # support importing BIP-0044 keys into the wallet using the legacy
79
+ # pay-to-pubkey-hash (P2PKH) scheme. A nested witness address type will force
80
+ # the standard BIP-0049 derivation scheme, while a witness address type will
81
+ # force the standard BIP-0084 derivation scheme.
82
+ #
83
+ # For BIP-0049 keys, an address type must also be specified to make a
84
+ # distinction between the standard BIP-0049 address schema (nested witness
85
+ # pubkeys everywhere) and our own BIP-0049Plus address schema (nested pubkeys
86
+ # externally, witness pubkeys internally).
87
+ #
88
+ # NOTE: Events (deposits/spends) for keys derived from an account will only be
89
+ # detected by lnd if they happen after the import. Rescans to detect past
90
+ # events will be supported later on.
91
+ rpc :ImportAccount, ::Walletrpc::ImportAccountRequest, ::Walletrpc::ImportAccountResponse
92
+ #
93
+ # ImportPublicKey imports a public key as watch-only into the wallet. The
94
+ # public key is converted into a simple address of the given type and that
95
+ # address script is watched on chain. For Taproot keys, this will only watch
96
+ # the BIP-0086 style output script. Use ImportTapscript for more advanced key
97
+ # spend or script spend outputs.
98
+ #
99
+ # NOTE: Events (deposits/spends) for a key will only be detected by lnd if
100
+ # they happen after the import. Rescans to detect past events will be
101
+ # supported later on.
102
+ rpc :ImportPublicKey, ::Walletrpc::ImportPublicKeyRequest, ::Walletrpc::ImportPublicKeyResponse
103
+ #
104
+ # ImportTapscript imports a Taproot script and internal key and adds the
105
+ # resulting Taproot output key as a watch-only output script into the wallet.
106
+ # For BIP-0086 style Taproot keys (no root hash commitment and no script spend
107
+ # path) use ImportPublicKey.
108
+ #
109
+ # NOTE: Events (deposits/spends) for a key will only be detected by lnd if
110
+ # they happen after the import. Rescans to detect past events will be
111
+ # supported later on.
112
+ #
113
+ # NOTE: Taproot keys imported through this RPC currently _cannot_ be used for
114
+ # funding PSBTs. Only tracking the balance and UTXOs is currently supported.
115
+ rpc :ImportTapscript, ::Walletrpc::ImportTapscriptRequest, ::Walletrpc::ImportTapscriptResponse
116
+ #
117
+ # PublishTransaction attempts to publish the passed transaction to the
118
+ # network. Once this returns without an error, the wallet will continually
119
+ # attempt to re-broadcast the transaction on start up, until it enters the
120
+ # chain.
121
+ rpc :PublishTransaction, ::Walletrpc::Transaction, ::Walletrpc::PublishResponse
122
+ #
123
+ # SendOutputs is similar to the existing sendmany call in Bitcoind, and
124
+ # allows the caller to create a transaction that sends to several outputs at
125
+ # once. This is ideal when wanting to batch create a set of transactions.
126
+ rpc :SendOutputs, ::Walletrpc::SendOutputsRequest, ::Walletrpc::SendOutputsResponse
127
+ #
128
+ # EstimateFee attempts to query the internal fee estimator of the wallet to
129
+ # determine the fee (in sat/kw) to attach to a transaction in order to
130
+ # achieve the confirmation target.
131
+ rpc :EstimateFee, ::Walletrpc::EstimateFeeRequest, ::Walletrpc::EstimateFeeResponse
132
+ #
133
+ # PendingSweeps returns lists of on-chain outputs that lnd is currently
134
+ # attempting to sweep within its central batching engine. Outputs with similar
135
+ # fee rates are batched together in order to sweep them within a single
136
+ # transaction.
137
+ #
138
+ # NOTE: Some of the fields within PendingSweepsRequest are not guaranteed to
139
+ # remain supported. This is an advanced API that depends on the internals of
140
+ # the UtxoSweeper, so things may change.
141
+ rpc :PendingSweeps, ::Walletrpc::PendingSweepsRequest, ::Walletrpc::PendingSweepsResponse
142
+ #
143
+ # BumpFee bumps the fee of an arbitrary input within a transaction. This RPC
144
+ # takes a different approach than bitcoind's bumpfee command. lnd has a
145
+ # central batching engine in which inputs with similar fee rates are batched
146
+ # together to save on transaction fees. Due to this, we cannot rely on
147
+ # bumping the fee on a specific transaction, since transactions can change at
148
+ # any point with the addition of new inputs. The list of inputs that
149
+ # currently exist within lnd's central batching engine can be retrieved
150
+ # through the PendingSweeps RPC.
151
+ #
152
+ # When bumping the fee of an input that currently exists within lnd's central
153
+ # batching engine, a higher fee transaction will be created that replaces the
154
+ # lower fee transaction through the Replace-By-Fee (RBF) policy. If it
155
+ #
156
+ # This RPC also serves useful when wanting to perform a Child-Pays-For-Parent
157
+ # (CPFP), where the child transaction pays for its parent's fee. This can be
158
+ # done by specifying an outpoint within the low fee transaction that is under
159
+ # the control of the wallet.
160
+ #
161
+ # The fee preference can be expressed either as a specific fee rate or a delta
162
+ # of blocks in which the output should be swept on-chain within. If a fee
163
+ # preference is not explicitly specified, then an error is returned.
164
+ #
165
+ # Note that this RPC currently doesn't perform any validation checks on the
166
+ # fee preference being provided. For now, the responsibility of ensuring that
167
+ # the new fee preference is sufficient is delegated to the user.
168
+ rpc :BumpFee, ::Walletrpc::BumpFeeRequest, ::Walletrpc::BumpFeeResponse
169
+ #
170
+ # ListSweeps returns a list of the sweep transactions our node has produced.
171
+ # Note that these sweeps may not be confirmed yet, as we record sweeps on
172
+ # broadcast, not confirmation.
173
+ rpc :ListSweeps, ::Walletrpc::ListSweepsRequest, ::Walletrpc::ListSweepsResponse
174
+ #
175
+ # LabelTransaction adds a label to a transaction. If the transaction already
176
+ # has a label the call will fail unless the overwrite bool is set. This will
177
+ # overwrite the exiting transaction label. Labels must not be empty, and
178
+ # cannot exceed 500 characters.
179
+ rpc :LabelTransaction, ::Walletrpc::LabelTransactionRequest, ::Walletrpc::LabelTransactionResponse
180
+ #
181
+ # FundPsbt creates a fully populated PSBT that contains enough inputs to fund
182
+ # the outputs specified in the template. There are two ways of specifying a
183
+ # template: Either by passing in a PSBT with at least one output declared or
184
+ # by passing in a raw TxTemplate message.
185
+ #
186
+ # If there are no inputs specified in the template, coin selection is
187
+ # performed automatically. If the template does contain any inputs, it is
188
+ # assumed that full coin selection happened externally and no additional
189
+ # inputs are added. If the specified inputs aren't enough to fund the outputs
190
+ # with the given fee rate, an error is returned.
191
+ #
192
+ # After either selecting or verifying the inputs, all input UTXOs are locked
193
+ # with an internal app ID.
194
+ #
195
+ # NOTE: If this method returns without an error, it is the caller's
196
+ # responsibility to either spend the locked UTXOs (by finalizing and then
197
+ # publishing the transaction) or to unlock/release the locked UTXOs in case of
198
+ # an error on the caller's side.
199
+ rpc :FundPsbt, ::Walletrpc::FundPsbtRequest, ::Walletrpc::FundPsbtResponse
200
+ #
201
+ # SignPsbt expects a partial transaction with all inputs and outputs fully
202
+ # declared and tries to sign all unsigned inputs that have all required fields
203
+ # (UTXO information, BIP32 derivation information, witness or sig scripts)
204
+ # set.
205
+ # If no error is returned, the PSBT is ready to be given to the next signer or
206
+ # to be finalized if lnd was the last signer.
207
+ #
208
+ # NOTE: This RPC only signs inputs (and only those it can sign), it does not
209
+ # perform any other tasks (such as coin selection, UTXO locking or
210
+ # input/output/fee value validation, PSBT finalization). Any input that is
211
+ # incomplete will be skipped.
212
+ rpc :SignPsbt, ::Walletrpc::SignPsbtRequest, ::Walletrpc::SignPsbtResponse
213
+ #
214
+ # FinalizePsbt expects a partial transaction with all inputs and outputs fully
215
+ # declared and tries to sign all inputs that belong to the wallet. Lnd must be
216
+ # the last signer of the transaction. That means, if there are any unsigned
217
+ # non-witness inputs or inputs without UTXO information attached or inputs
218
+ # without witness data that do not belong to lnd's wallet, this method will
219
+ # fail. If no error is returned, the PSBT is ready to be extracted and the
220
+ # final TX within to be broadcast.
221
+ #
222
+ # NOTE: This method does NOT publish the transaction once finalized. It is the
223
+ # caller's responsibility to either publish the transaction on success or
224
+ # unlock/release any locked UTXOs in case of an error in this method.
225
+ rpc :FinalizePsbt, ::Walletrpc::FinalizePsbtRequest, ::Walletrpc::FinalizePsbtResponse
226
+ end
227
+
228
+ Stub = Service.rpc_stub_class
229
+ end
230
+ end
@@ -0,0 +1,75 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: walletunlocker.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require_relative 'lightning_pb'
7
+
8
+ Google::Protobuf::DescriptorPool.generated_pool.build do
9
+ add_file("walletunlocker.proto", :syntax => :proto3) do
10
+ add_message "lnrpc.GenSeedRequest" do
11
+ optional :aezeed_passphrase, :bytes, 1
12
+ optional :seed_entropy, :bytes, 2
13
+ end
14
+ add_message "lnrpc.GenSeedResponse" do
15
+ repeated :cipher_seed_mnemonic, :string, 1
16
+ optional :enciphered_seed, :bytes, 2
17
+ end
18
+ add_message "lnrpc.InitWalletRequest" do
19
+ optional :wallet_password, :bytes, 1
20
+ repeated :cipher_seed_mnemonic, :string, 2
21
+ optional :aezeed_passphrase, :bytes, 3
22
+ optional :recovery_window, :int32, 4
23
+ optional :channel_backups, :message, 5, "lnrpc.ChanBackupSnapshot"
24
+ optional :stateless_init, :bool, 6
25
+ optional :extended_master_key, :string, 7
26
+ optional :extended_master_key_birthday_timestamp, :uint64, 8
27
+ optional :watch_only, :message, 9, "lnrpc.WatchOnly"
28
+ optional :macaroon_root_key, :bytes, 10
29
+ end
30
+ add_message "lnrpc.InitWalletResponse" do
31
+ optional :admin_macaroon, :bytes, 1
32
+ end
33
+ add_message "lnrpc.WatchOnly" do
34
+ optional :master_key_birthday_timestamp, :uint64, 1
35
+ optional :master_key_fingerprint, :bytes, 2
36
+ repeated :accounts, :message, 3, "lnrpc.WatchOnlyAccount"
37
+ end
38
+ add_message "lnrpc.WatchOnlyAccount" do
39
+ optional :purpose, :uint32, 1
40
+ optional :coin_type, :uint32, 2
41
+ optional :account, :uint32, 3
42
+ optional :xpub, :string, 4
43
+ end
44
+ add_message "lnrpc.UnlockWalletRequest" do
45
+ optional :wallet_password, :bytes, 1
46
+ optional :recovery_window, :int32, 2
47
+ optional :channel_backups, :message, 3, "lnrpc.ChanBackupSnapshot"
48
+ optional :stateless_init, :bool, 4
49
+ end
50
+ add_message "lnrpc.UnlockWalletResponse" do
51
+ end
52
+ add_message "lnrpc.ChangePasswordRequest" do
53
+ optional :current_password, :bytes, 1
54
+ optional :new_password, :bytes, 2
55
+ optional :stateless_init, :bool, 3
56
+ optional :new_macaroon_root_key, :bool, 4
57
+ end
58
+ add_message "lnrpc.ChangePasswordResponse" do
59
+ optional :admin_macaroon, :bytes, 1
60
+ end
61
+ end
62
+ end
63
+
64
+ module Lnrpc
65
+ GenSeedRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("lnrpc.GenSeedRequest").msgclass
66
+ GenSeedResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("lnrpc.GenSeedResponse").msgclass
67
+ InitWalletRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("lnrpc.InitWalletRequest").msgclass
68
+ InitWalletResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("lnrpc.InitWalletResponse").msgclass
69
+ WatchOnly = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("lnrpc.WatchOnly").msgclass
70
+ WatchOnlyAccount = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("lnrpc.WatchOnlyAccount").msgclass
71
+ UnlockWalletRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("lnrpc.UnlockWalletRequest").msgclass
72
+ UnlockWalletResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("lnrpc.UnlockWalletResponse").msgclass
73
+ ChangePasswordRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("lnrpc.ChangePasswordRequest").msgclass
74
+ ChangePasswordResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("lnrpc.ChangePasswordResponse").msgclass
75
+ 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_relative '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, ::Lnrpc::GenSeedRequest, ::Lnrpc::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, ::Lnrpc::InitWalletRequest, ::Lnrpc::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, ::Lnrpc::UnlockWalletRequest, ::Lnrpc::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, ::Lnrpc::ChangePasswordRequest, ::Lnrpc::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_relative '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, ::Watchtowerrpc::GetInfoRequest, ::Watchtowerrpc::GetInfoResponse
24
+ end
25
+
26
+ Stub = Service.rpc_stub_class
27
+ end
28
+ end
@@ -0,0 +1,83 @@
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
+ optional :sweep_sat_per_vbyte, :uint32, 5
30
+ end
31
+ add_message "wtclientrpc.Tower" do
32
+ optional :pubkey, :bytes, 1
33
+ repeated :addresses, :string, 2
34
+ optional :active_session_candidate, :bool, 3
35
+ optional :num_sessions, :uint32, 4
36
+ repeated :sessions, :message, 5, "wtclientrpc.TowerSession"
37
+ end
38
+ add_message "wtclientrpc.ListTowersRequest" do
39
+ optional :include_sessions, :bool, 1
40
+ end
41
+ add_message "wtclientrpc.ListTowersResponse" do
42
+ repeated :towers, :message, 1, "wtclientrpc.Tower"
43
+ end
44
+ add_message "wtclientrpc.StatsRequest" do
45
+ end
46
+ add_message "wtclientrpc.StatsResponse" do
47
+ optional :num_backups, :uint32, 1
48
+ optional :num_pending_backups, :uint32, 2
49
+ optional :num_failed_backups, :uint32, 3
50
+ optional :num_sessions_acquired, :uint32, 4
51
+ optional :num_sessions_exhausted, :uint32, 5
52
+ end
53
+ add_message "wtclientrpc.PolicyRequest" do
54
+ optional :policy_type, :enum, 1, "wtclientrpc.PolicyType"
55
+ end
56
+ add_message "wtclientrpc.PolicyResponse" do
57
+ optional :max_updates, :uint32, 1
58
+ optional :sweep_sat_per_byte, :uint32, 2
59
+ optional :sweep_sat_per_vbyte, :uint32, 3
60
+ end
61
+ add_enum "wtclientrpc.PolicyType" do
62
+ value :LEGACY, 0
63
+ value :ANCHOR, 1
64
+ end
65
+ end
66
+ end
67
+
68
+ module Wtclientrpc
69
+ AddTowerRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.AddTowerRequest").msgclass
70
+ AddTowerResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.AddTowerResponse").msgclass
71
+ RemoveTowerRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.RemoveTowerRequest").msgclass
72
+ RemoveTowerResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.RemoveTowerResponse").msgclass
73
+ GetTowerInfoRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.GetTowerInfoRequest").msgclass
74
+ TowerSession = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.TowerSession").msgclass
75
+ Tower = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.Tower").msgclass
76
+ ListTowersRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.ListTowersRequest").msgclass
77
+ ListTowersResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.ListTowersResponse").msgclass
78
+ StatsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.StatsRequest").msgclass
79
+ StatsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.StatsResponse").msgclass
80
+ PolicyRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.PolicyRequest").msgclass
81
+ PolicyResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.PolicyResponse").msgclass
82
+ PolicyType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("wtclientrpc.PolicyType").enummodule
83
+ 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_relative '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, ::Wtclientrpc::AddTowerRequest, ::Wtclientrpc::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, ::Wtclientrpc::RemoveTowerRequest, ::Wtclientrpc::RemoveTowerResponse
31
+ # ListTowers returns the list of watchtowers registered with the client.
32
+ rpc :ListTowers, ::Wtclientrpc::ListTowersRequest, ::Wtclientrpc::ListTowersResponse
33
+ # GetTowerInfo retrieves information for a registered watchtower.
34
+ rpc :GetTowerInfo, ::Wtclientrpc::GetTowerInfoRequest, ::Wtclientrpc::Tower
35
+ # Stats returns the in-memory statistics of the client since startup.
36
+ rpc :Stats, ::Wtclientrpc::StatsRequest, ::Wtclientrpc::StatsResponse
37
+ # Policy returns the active watchtower client policy configuration.
38
+ rpc :Policy, ::Wtclientrpc::PolicyRequest, ::Wtclientrpc::PolicyResponse
39
+ end
40
+
41
+ Stub = Service.rpc_stub_class
42
+ end
43
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './grpc/lightning_services_pb'
4
+
5
+ module GRPC
6
+ SERVICES = {
7
+ lightning: Lnrpc::Lightning
8
+ }.freeze
9
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../components/grpc'
4
+ require_relative 'config'
5
+ require_relative 'service'
6
+
7
+ class ClientController
8
+ attr_reader :config, :doc
9
+
10
+ def initialize(options)
11
+ @config = ConfigController.new(self, options)
12
+ @services = {}
13
+
14
+ doc = Struct.new(:services)
15
+ @doc = doc.new(GRPC::SERVICES.keys.map(&:to_s))
16
+ end
17
+
18
+ def respond_to_missing?(method_name, include_private = false)
19
+ service_key = method_name.to_sym
20
+
21
+ GRPC::SERVICES.include?(service_key) || super
22
+ end
23
+
24
+ def method_missing(method_name, *_args)
25
+ service_key = method_name.to_sym
26
+
27
+ raise ArgumentError, "Method `#{method_name}` doesn't exist." unless GRPC::SERVICES.include?(service_key)
28
+
29
+ @services[service_key] ||= ServiceController.new(self, GRPC::SERVICES[service_key])
30
+ end
31
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'grpc'
4
+
5
+ class ConfigController
6
+ attr_reader :socket_address, :credentials, :certificate, :macaroon
7
+
8
+ def initialize(client, options)
9
+ @client = client
10
+
11
+ @certificate_path = options[:certificate_path]
12
+ @certificate = options[:certificate]
13
+
14
+ @macaroon_path = options[:macaroon_path]
15
+ @macaroon = options[:macaroon]
16
+
17
+ @socket_address = options[:socket_address] || '127.0.0.1:10009'
18
+
19
+ setup_certificate!
20
+ setup_macaroon!
21
+ end
22
+
23
+ def setup_certificate!
24
+ raise 'conflicting options for certificate' if @certificate && @certificate_path
25
+
26
+ @certificate = File.read(@certificate_path) if @certificate_path
27
+ @credentials = GRPC::Core::ChannelCredentials.new(@certificate)
28
+ end
29
+
30
+ def setup_macaroon!
31
+ raise 'conflicting options for macaroon' if @macaroon && @macaroon_path
32
+
33
+ @macaroon = File.read(@macaroon_path).unpack('H*') if @macaroon_path
34
+ end
35
+ end