lnrpc 0.5.2 → 0.6.1

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: 4079c08041cc28f7f4f489ac59fb3223aab2621845c994b7bcad33fc36bef99b
4
- data.tar.gz: d01a5e679555dab57793833fe1614fafd9cc7fe9c25961eee2ea72795e16b169
3
+ metadata.gz: 0bfe878e75df63ffd268631872089510d05b50af1a8979c1ccfa2fd54f9dbb78
4
+ data.tar.gz: e391ec669a7bf1a4c8cba736b82c3bed14857e1c625693ed030cf122e2ba991d
5
5
  SHA512:
6
- metadata.gz: 3488c416c8ff54a371e81256dfe9cc7a9f2144a8d7a53f7f73f8c48b7410899f1c4a26be01ce51a840d2de1aacdc0030e3668d183a2930213c79ef051ed4cf93
7
- data.tar.gz: 270b6e3681a5e59ca790b94f2ed35381e936b39b20b50524ffe9c8b44965fcfc4d1095d3957df4360a4315fcfce21ef165322ca12e825a6463396c867e84180d
6
+ metadata.gz: 86cc73ea507f2a0bddd3c07568e8ff8cc73241b65e6398194973562e1536fa2425b3a1ccd5cd4d557c88af1d35129e288c231800f2dbbf9ed9a1dacf42b0bfe7
7
+ data.tar.gz: e382d37d143abbaac9e9b7d1d67634c224ce867c70949b76f408a53682521663d264c231fa06a0747727ebced9f381f4a716b5a51e132b431cd679b1437afdc3
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lnrpc (0.5.2.beta)
4
+ lnrpc (0.5.2)
5
5
  google-protobuf (>= 3.7)
6
6
  grpc (>= 1.19.0)
7
7
 
@@ -9,10 +9,10 @@ GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  diff-lcs (1.3)
12
- google-protobuf (3.7.0)
12
+ google-protobuf (3.7.0-x86_64-linux)
13
13
  googleapis-common-protos-types (1.0.3)
14
14
  google-protobuf (~> 3.0)
15
- grpc (1.19.0)
15
+ grpc (1.19.0-x86_64-linux)
16
16
  google-protobuf (~> 3.1)
17
17
  googleapis-common-protos-types (~> 1.0.0)
18
18
  rake (10.5.0)
data/README.md CHANGED
@@ -30,7 +30,7 @@ This gem makes the gRPC client classes created from the [LND service defintions]
30
30
  ```ruby
31
31
  require "lnrpc"
32
32
 
33
- # the gRPC client is available under the Lnrpc namespace, e.g.
33
+ # the gRPC client is available under the Lnrpc namespace, e.g.
34
34
 
35
35
  Lnrpc::Lightning::Stub
36
36
  Lnrpc::GetInfoRequest
@@ -45,7 +45,7 @@ The LND API reference can be found here: [https://api.lightning.community/](http
45
45
  ```ruby
46
46
  require "lnrpc"
47
47
 
48
- credentials = File.read("/path/to/tls.cert")
48
+ credentials = File.read("/path/to/tls.cert")
49
49
  macaroon = File.read("/path/to/readonly.macaroon").unpack("H*")
50
50
 
51
51
  # initialize a new client
@@ -54,12 +54,12 @@ client = Lnrpc::Lightning::Stub.new("localhost:10009", GRPC::Core::ChannelCreden
54
54
  # perform a request
55
55
  request = Lnrpc::GetInfoRequest.new
56
56
  response = client.get_info(request, { metadata: { macaroon: macaroon } }) #=> Lnrpc::GetInfoResponse
57
- puts response.alias
57
+ puts response.alias
58
58
  ```
59
59
 
60
60
  ### Client wrapper
61
61
 
62
- An optional client wrapper ([Lnrpc::Client](https://github.com/bumi/lnrpc/blob/master/lib/lnrpc/client.rb")) makes
62
+ An optional client wrapper ([Lnrpc::Client](https://github.com/bumi/lnrpc/blob/master/lib/lnrpc/client.rb)) makes
63
63
  initializing the gRPC client easier and removes the need for some boilerplate code for calling RPC methods.
64
64
 
65
65
  #### Example
@@ -72,23 +72,25 @@ Also have a look at [examples.rb](https://github.com/bumi/lnrpc/blob/master/exam
72
72
 
73
73
  #### Initializing a new client
74
74
 
75
- The Lnrpc::Client constructor allows the following options:
75
+ The Lnrpc::Client constructor allows the following options:
76
76
 
77
- * credentials:
78
- - `credentials` : the credentials data as string
79
- - `credentials_path` : the path to a credentials file (tls.cert) as string
80
- * macaroon:
77
+ * credentials:
78
+ - `credentials` : the credentials data as string (pass nil if a "trusted" cert (e.g. from letsencrypt is used)
79
+ - `credentials_path` : the path to a credentials file (tls.cert) as string (default: `"#{LND_HOME_DIR}/tls.cert"` )
80
+ * macaroon:
81
81
  - `macaroon` : the macaroon as hex string
82
- - `macaroon_path` : the path to the macaroon file created by lnd as string
82
+ - `macaroon_path` : the path to the macaroon file created by lnd as string (default: `"#{LND_HOME_DIR}/data/chain/bitcoin/mainnet/admin.macaroon"`)
83
83
  * address:
84
- - `address` : lnd address as string. format: address:port, e.g. default: localhost:10009
84
+ - `address` : lnd address as string. format: address:port, e.g. localhost:10009 (default)
85
85
 
86
+ If no credentials or no macaroon is provided default files are assumed in `ENV['LND_HOME'] || "~/.lnd"`.
87
+ A macaroon is required.
86
88
 
87
89
  ```ruby
88
90
  require 'lnrpc'
89
91
 
90
92
  lnd = Lnrpc::Client.new({
91
- credentials_path: '/path/to.cert.cls',
93
+ credentials_path: '/path/to.cert.cls',
92
94
  macaroon_path: '/path/to/admin.macaroon',
93
95
  address: 'host:port'
94
96
  })
@@ -101,33 +103,54 @@ lnd.grpc_client
101
103
 
102
104
  The client wrapper passes any supported RPC method call to the gRPC client applying the following conventions:
103
105
 
104
- If the first parameter is a hash or blank the corresponding gRPC request object will be instantiated.
106
+ If the first parameter is a hash or blank the corresponding gRPC request object will be instantiated.
105
107
 
106
108
  Example:
107
109
 
108
110
  ```ruby
109
111
  client.get_info
110
- # is the same as:
112
+ # is the same as:
111
113
  client.grpc_client.get_info(Lnrpc::GetInfoRequest.new)
112
114
 
113
115
  client.list_channels(inactive_only: true)
114
- # is the same as:
116
+ # is the same as:
115
117
  request = Lnrpc::ListChannelsRequest.new(inactive_only: true)
116
118
  client.grpc_client.list_channels(request)
117
119
 
118
120
  client.wallet_balance.total_balance
119
- # is the same as:
121
+ # is the same as:
120
122
  request = Lnrpc::WalletBalanceRequest.new()
121
123
  client.grpc_client.wallet_balance(request).total_balance
122
124
  ```
123
125
 
126
+ ## Using with BTC Pay Server
127
+ If you have a running BTC Pay Server with LND support, integrating with lnrpc is easy.
128
+
129
+ - Navigate to the domain associated with your BTC Pay Server
130
+ - Navigate to Services on the Server Settings page
131
+ - Click "see information" for your gRPC Server
132
+ - The link by "More details..." will expose the address and various macaroon hex strings
133
+ - Initialize your client with the options detailed above. BTC Pay Server utilizes LetsEncrypt for trusted TLC Certificates so set that option to nil.
134
+
135
+ Don't have a BTC Pay Server? [Setting one up is easy.](https://medium.com/@BtcpayServer/launch-btcpay-server-via-web-interface-and-deploy-full-bitcoin-node-lnd-in-less-than-a-minute-dc8bc6f06a3)
136
+
124
137
 
125
138
  ## Versioning
126
139
 
127
- This gem follows the LND versions and will update the gRPC service definitions accordingly.
140
+ This gem follows the LND versions and will update the gRPC service definitions accordingly.
128
141
  e.g. gem version 0.5.2 includes the gRPC service definitions from LND v0.5.2
129
142
 
130
143
 
144
+ ### Update service definitions
145
+
146
+ 1. Generate `prc_pb.rb` and `rpc_services_pb.rb`
147
+
148
+ $ grpc_tools_ruby_protoc -I/usr/local/include -I. -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --ruby_out=plugins=grpc,paths=source_relative:. --grpc_out=. rpc.proto
149
+
150
+ 2. Copy `rpc.proto`, `rpc_pb.rb` and `rpc_services_pb.rb` to `lib`
151
+
152
+ 3. Update `rpc_services_pb.rb` to use `require_relative` to load `rpc_pb`
153
+
131
154
  ## Other resources
132
155
 
133
156
  * [LND gRPC API Reference](https://api.lightning.community)
@@ -13,3 +13,7 @@ lnd.send_payment_sync(payment_request: pay_request)
13
13
 
14
14
  invoice_res = lnd.add_invoice(value: 1000, memo: 'I :heart: ruby')
15
15
  puts invoice_res.payment_request
16
+
17
+ lnd.subscribe_invoices(settle_index: 1).each do |invoice|
18
+ puts invoice.payment_request
19
+ end
@@ -2,7 +2,8 @@ require "grpc"
2
2
  require "lnrpc/macaroon_interceptor"
3
3
  module Lnrpc
4
4
  class Client
5
- attr_accessor :address, :credentials, :macaroon, :grpc_client
5
+ attr_accessor :address, :credentials, :macaroon
6
+ attr_writer :grpc_client
6
7
 
7
8
  LND_HOME_DIR = ENV['LND_HOME'] || "~/.lnd"
8
9
  DEFAULT_ADDRESS = 'localhost:10009'
@@ -31,19 +32,25 @@ module Lnrpc
31
32
  def initialize(options={})
32
33
  self.address = options[:address] || DEFAULT_ADDRESS
33
34
 
34
- options[:credentials] ||= ::File.read(::File.expand_path(options[:credentials_path] || DEFAULT_CREDENTIALS_PATH))
35
- self.credentials = options[:credentials]
35
+ if options.has_key?(:credentials)
36
+ self.credentials = options[:credentials]
37
+ elsif File.exists?(::File.expand_path(options[:credentials_path] || DEFAULT_CREDENTIALS_PATH))
38
+ self.credentials = ::File.read(::File.expand_path(options[:credentials_path] || DEFAULT_CREDENTIALS_PATH))
39
+ else
40
+ self.credentials = nil
41
+ end
36
42
 
37
- options[:macaroon] ||= begin
38
- macaroon_binary = ::File.read(::File.expand_path(options[:macaroon_path] || DEFAULT_MACAROON_PATH))
39
- macaroon_binary.unpack("H*")
43
+ if !options.has_key?(:macaroon) && File.exists?(::File.expand_path(options[:macaroon_path] || DEFAULT_MACAROON_PATH))
44
+ options[:macaroon] = ::File.read(::File.expand_path(options[:macaroon_path] || DEFAULT_MACAROON_PATH)).unpack("H*")
40
45
  end
41
46
  self.macaroon = options[:macaroon]
47
+ end
42
48
 
43
- self.grpc_client = Lnrpc::Lightning::Stub.new(self.address,
49
+ def grpc_client
50
+ @grpc_client ||= Lnrpc::Lightning::Stub.new(self.address,
44
51
  GRPC::Core::ChannelCredentials.new(self.credentials),
45
52
  interceptors: [Lnrpc::MacaroonInterceptor.new(self.macaroon)]
46
- )
53
+ )
47
54
  end
48
55
 
49
56
  def pay(payreq)
@@ -55,7 +62,7 @@ module Lnrpc
55
62
  params = args[0]
56
63
 
57
64
  args[0] = params.nil? ? request_class_for(m).new : request_class_for(m).new(params)
58
- self.grpc_client.send(m, *args)
65
+ self.grpc_client.send(m, *args, &block)
59
66
  else
60
67
  super
61
68
  end
@@ -3,6 +3,9 @@ syntax = "proto3";
3
3
  import "google/api/annotations.proto";
4
4
 
5
5
  package lnrpc;
6
+
7
+ option go_package = "github.com/lightningnetwork/lnd/lnrpc";
8
+
6
9
  /**
7
10
  * Comments in this file will be directly parsed into the API
8
11
  * Documentation as descriptions of the associated method, message, or field.
@@ -142,11 +145,21 @@ message InitWalletRequest {
142
145
  /**
143
146
  recovery_window is an optional argument specifying the address lookahead
144
147
  when restoring a wallet seed. The recovery window applies to each
145
- invdividual branch of the BIP44 derivation paths. Supplying a recovery
148
+ individual branch of the BIP44 derivation paths. Supplying a recovery
146
149
  window of zero indicates that no addresses should be recovered, such after
147
150
  the first initialization of the wallet.
148
151
  */
149
152
  int32 recovery_window = 4;
153
+
154
+ /**
155
+ channel_backups is an optional argument that allows clients to recover the
156
+ settled funds within a set of channels. This should be populated if the
157
+ user was unable to close out all channels and sweep funds before partial or
158
+ total data loss occurred. If specified, then after on-chain recovery of
159
+ funds, lnd begin to carry out the data loss recovery protocol in order to
160
+ recover the funds in each channel from a remote force closed transaction.
161
+ */
162
+ ChanBackupSnapshot channel_backups = 5;
150
163
  }
151
164
  message InitWalletResponse {
152
165
  }
@@ -167,6 +180,16 @@ message UnlockWalletRequest {
167
180
  the first initialization of the wallet.
168
181
  */
169
182
  int32 recovery_window = 2;
183
+
184
+ /**
185
+ channel_backups is an optional argument that allows clients to recover the
186
+ settled funds within a set of channels. This should be populated if the
187
+ user was unable to close out all channels and sweep funds before partial or
188
+ total data loss occurred. If specified, then after on-chain recovery of
189
+ funds, lnd begin to carry out the data loss recovery protocol in order to
190
+ recover the funds in each channel from a remote force closed transaction.
191
+ */
192
+ ChanBackupSnapshot channel_backups = 3;
170
193
  }
171
194
  message UnlockWalletResponse {}
172
195
 
@@ -217,6 +240,16 @@ service Lightning {
217
240
  };
218
241
  }
219
242
 
243
+ /** lncli: `estimatefee`
244
+ EstimateFee asks the chain backend to estimate the fee rate and total fees
245
+ for a transaction that pays to multiple specified outputs.
246
+ */
247
+ rpc EstimateFee (EstimateFeeRequest) returns (EstimateFeeResponse) {
248
+ option (google.api.http) = {
249
+ get: "/v1/transactions/fee"
250
+ };
251
+ }
252
+
220
253
  /** lncli: `sendcoins`
221
254
  SendCoins executes a request to send coins to a particular address. Unlike
222
255
  SendMany, this RPC call only allows creating a single output at a time. If
@@ -231,6 +264,16 @@ service Lightning {
231
264
  };
232
265
  }
233
266
 
267
+ /** lncli: `listunspent`
268
+ ListUnspent returns a list of all utxos spendable by the wallet with a
269
+ number of confirmations between the specified minimum and maximum.
270
+ */
271
+ rpc ListUnspent (ListUnspentRequest) returns (ListUnspentResponse) {
272
+ option (google.api.http) = {
273
+ get: "/v1/utxos"
274
+ };
275
+ }
276
+
234
277
  /**
235
278
  SubscribeTransactions creates a uni-directional stream from the server to
236
279
  the client in which any newly discovered transactions relevant to the
@@ -260,7 +303,12 @@ service Lightning {
260
303
  signature string is `zbase32` encoded and pubkey recoverable, meaning that
261
304
  only the message digest and signature are needed for verification.
262
305
  */
263
- rpc SignMessage (SignMessageRequest) returns (SignMessageResponse);
306
+ rpc SignMessage (SignMessageRequest) returns (SignMessageResponse) {
307
+ option (google.api.http) = {
308
+ post: "/v1/signmessage"
309
+ body: "*"
310
+ };
311
+ }
264
312
 
265
313
  /** lncli: `verifymessage`
266
314
  VerifyMessage verifies a signature over a msg. The signature must be
@@ -268,7 +316,12 @@ service Lightning {
268
316
  channel database. In addition to returning the validity of the signature,
269
317
  VerifyMessage also returns the recovered pubkey from the signature.
270
318
  */
271
- rpc VerifyMessage (VerifyMessageRequest) returns (VerifyMessageResponse);
319
+ rpc VerifyMessage (VerifyMessageRequest) returns (VerifyMessageResponse) {
320
+ option (google.api.http) = {
321
+ post: "/v1/verifymessage"
322
+ body: "*"
323
+ };
324
+ }
272
325
 
273
326
  /** lncli: `connect`
274
327
  ConnectPeer attempts to establish a connection to a remote peer. This is at
@@ -336,6 +389,14 @@ service Lightning {
336
389
  };
337
390
  }
338
391
 
392
+ /** lncli: `subscribechannelevents`
393
+ SubscribeChannelEvents creates a uni-directional stream from the server to
394
+ the client in which any updates relevant to the state of the channels are
395
+ sent over. Events include new active channels, inactive channels, and closed
396
+ channels.
397
+ */
398
+ rpc SubscribeChannelEvents (ChannelEventSubscription) returns (stream ChannelEventUpdate);
399
+
339
400
  /** lncli: `closedchannels`
340
401
  ClosedChannels returns a description of all the closed channels that
341
402
  this node was a participant in.
@@ -455,10 +516,8 @@ service Lightning {
455
516
  paginated responses, allowing users to query for specific invoices through
456
517
  their add_index. This can be done by using either the first_index_offset or
457
518
  last_index_offset fields included in the response as the index_offset of the
458
- next request. The reversed flag is set by default in order to paginate
459
- backwards. If you wish to paginate forwards, you must explicitly set the
460
- flag to false. If none of the parameters are specified, then the last 100
461
- invoices will be returned.
519
+ next request. By default, the first 100 invoices created will be returned.
520
+ Backwards pagination is also supported through the Reversed flag.
462
521
  */
463
522
  rpc ListInvoices (ListInvoiceRequest) returns (ListInvoiceResponse) {
464
523
  option (google.api.http) = {
@@ -629,7 +688,7 @@ service Lightning {
629
688
 
630
689
  /** lncli: `fwdinghistory`
631
690
  ForwardingHistory allows the caller to query the htlcswitch for a record of
632
- all HTLC's forwarded within the target time range, and integer offset
691
+ all HTLCs forwarded within the target time range, and integer offset
633
692
  within that time range. If no time-range is specified, then the first chunk
634
693
  of the past 24 hrs of forwarding history are returned.
635
694
 
@@ -645,6 +704,90 @@ service Lightning {
645
704
  body: "*"
646
705
  };
647
706
  };
707
+
708
+ /** lncli: `exportchanbackup`
709
+ ExportChannelBackup attempts to return an encrypted static channel backup
710
+ for the target channel identified by it channel point. The backup is
711
+ encrypted with a key generated from the aezeed seed of the user. The
712
+ returned backup can either be restored using the RestoreChannelBackup
713
+ method once lnd is running, or via the InitWallet and UnlockWallet methods
714
+ from the WalletUnlocker service.
715
+ */
716
+ rpc ExportChannelBackup(ExportChannelBackupRequest) returns (ChannelBackup) {
717
+ option (google.api.http) = {
718
+ get: "/v1/channels/backup/{chan_point.funding_txid_str}/{chan_point.output_index}"
719
+ };
720
+ };
721
+
722
+ /**
723
+ ExportAllChannelBackups returns static channel backups for all existing
724
+ channels known to lnd. A set of regular singular static channel backups for
725
+ each channel are returned. Additionally, a multi-channel backup is returned
726
+ as well, which contains a single encrypted blob containing the backups of
727
+ each channel.
728
+ */
729
+ rpc ExportAllChannelBackups(ChanBackupExportRequest) returns (ChanBackupSnapshot) {
730
+ option (google.api.http) = {
731
+ get: "/v1/channels/backup"
732
+ };
733
+ };
734
+
735
+ /**
736
+ VerifyChanBackup allows a caller to verify the integrity of a channel backup
737
+ snapshot. This method will accept either a packed Single or a packed Multi.
738
+ Specifying both will result in an error.
739
+ */
740
+ rpc VerifyChanBackup(ChanBackupSnapshot) returns (VerifyChanBackupResponse) {
741
+ option (google.api.http) = {
742
+ post: "/v1/channels/backup/verify"
743
+ body: "*"
744
+ };
745
+ };
746
+
747
+ /** lncli: `restorechanbackup`
748
+ RestoreChannelBackups accepts a set of singular channel backups, or a
749
+ single encrypted multi-chan backup and attempts to recover any funds
750
+ remaining within the channel. If we are able to unpack the backup, then the
751
+ new channel will be shown under listchannels, as well as pending channels.
752
+ */
753
+ rpc RestoreChannelBackups(RestoreChanBackupRequest) returns (RestoreBackupResponse) {
754
+ option (google.api.http) = {
755
+ post: "/v1/channels/backup/restore"
756
+ body: "*"
757
+ };
758
+ };
759
+
760
+ /**
761
+ SubscribeChannelBackups allows a client to sub-subscribe to the most up to
762
+ date information concerning the state of all channel backups. Each time a
763
+ new channel is added, we return the new set of channels, along with a
764
+ multi-chan backup containing the backup info for all channels. Each time a
765
+ channel is closed, we send a new update, which contains new new chan back
766
+ ups, but the updated set of encrypted multi-chan backups with the closed
767
+ channel(s) removed.
768
+ */
769
+ rpc SubscribeChannelBackups(ChannelBackupSubscription) returns (stream ChanBackupSnapshot) {
770
+ };
771
+ }
772
+
773
+ message Utxo {
774
+ /// The type of address
775
+ AddressType type = 1 [json_name = "address_type"];
776
+
777
+ /// The address
778
+ string address = 2 [json_name = "address"];
779
+
780
+ /// The value of the unspent coin in satoshis
781
+ int64 amount_sat = 3 [json_name = "amount_sat"];
782
+
783
+ /// The pkscript in hex
784
+ string pk_script = 4 [json_name = "pk_script"];
785
+
786
+ /// The outpoint in format txid:n
787
+ OutPoint outpoint = 5 [json_name = "outpoint"];
788
+
789
+ /// The number of confirmations for the Utxo
790
+ int64 confirmations = 6 [json_name = "confirmations"];
648
791
  }
649
792
 
650
793
  message Transaction {
@@ -725,11 +868,25 @@ message SendRequest {
725
868
  send the payment.
726
869
  */
727
870
  FeeLimit fee_limit = 8;
871
+
872
+ /**
873
+ The channel id of the channel that must be taken to the first hop. If zero,
874
+ any channel may be used.
875
+ */
876
+ uint64 outgoing_chan_id = 9;
877
+
878
+ /**
879
+ An optional maximum total time lock for the route. If zero, there is no
880
+ maximum enforced.
881
+ */
882
+ uint32 cltv_limit = 10;
728
883
  }
884
+
729
885
  message SendResponse {
730
886
  string payment_error = 1 [json_name = "payment_error"];
731
887
  bytes payment_preimage = 2 [json_name = "payment_preimage"];
732
888
  Route payment_route = 3 [json_name = "payment_route"];
889
+ bytes payment_hash = 4 [json_name = "payment_hash"];
733
890
  }
734
891
 
735
892
  message SendToRouteRequest {
@@ -739,8 +896,16 @@ message SendToRouteRequest {
739
896
  /// An optional hex-encoded payment hash to be used for the HTLC.
740
897
  string payment_hash_string = 2;
741
898
 
742
- /// The set of routes that should be used to attempt to complete the payment.
743
- repeated Route routes = 3;
899
+ /**
900
+ Deprecated. The set of routes that should be used to attempt to complete the
901
+ payment. The possibility to pass in multiple routes is deprecated and
902
+ instead the single route field below should be used in combination with the
903
+ streaming variant of SendToRoute.
904
+ */
905
+ repeated Route routes = 3 [deprecated = true];
906
+
907
+ /// Route that should be used to attempt to complete the payment.
908
+ Route route = 4;
744
909
  }
745
910
 
746
911
  message ChannelPoint {
@@ -756,6 +921,17 @@ message ChannelPoint {
756
921
  uint32 output_index = 3 [json_name = "output_index"];
757
922
  }
758
923
 
924
+ message OutPoint {
925
+ /// Raw bytes representing the transaction id.
926
+ bytes txid_bytes = 1 [json_name = "txid_bytes"];
927
+
928
+ /// Reversed, hex-encoded string representing the transaction id.
929
+ string txid_str = 2 [json_name = "txid_str"];
930
+
931
+ /// The index of the output on the transaction.
932
+ uint32 output_index = 3 [json_name = "output_index"];
933
+ }
934
+
759
935
  message LightningAddress {
760
936
  /// The identity pubkey of the Lightning node
761
937
  string pubkey = 1 [json_name = "pubkey"];
@@ -764,6 +940,22 @@ message LightningAddress {
764
940
  string host = 2 [json_name = "host"];
765
941
  }
766
942
 
943
+ message EstimateFeeRequest {
944
+ /// The map from addresses to amounts for the transaction.
945
+ map<string, int64> AddrToAmount = 1;
946
+
947
+ /// The target number of blocks that this transaction should be confirmed by.
948
+ int32 target_conf = 2;
949
+ }
950
+
951
+ message EstimateFeeResponse {
952
+ /// The total fee in satoshis.
953
+ int64 fee_sat = 1 [json_name = "fee_sat"];
954
+
955
+ /// The fee rate in satoshi/byte.
956
+ int64 feerate_sat_per_byte = 2 [json_name = "feerate_sat_per_byte"];
957
+ }
958
+
767
959
  message SendManyRequest {
768
960
  /// The map from addresses to amounts
769
961
  map<string, int64> AddrToAmount = 1;
@@ -791,24 +983,45 @@ message SendCoinsRequest {
791
983
 
792
984
  /// A manual fee rate set in sat/byte that should be used when crafting the transaction.
793
985
  int64 sat_per_byte = 5;
986
+
987
+ /**
988
+ If set, then the amount field will be ignored, and lnd will attempt to
989
+ send all the coins under control of the internal wallet to the specified
990
+ address.
991
+ */
992
+ bool send_all = 6;
794
993
  }
795
994
  message SendCoinsResponse {
796
995
  /// The transaction ID of the transaction
797
996
  string txid = 1 [json_name = "txid"];
798
997
  }
799
998
 
999
+ message ListUnspentRequest {
1000
+ /// The minimum number of confirmations to be included.
1001
+ int32 min_confs = 1;
1002
+
1003
+ /// The maximum number of confirmations to be included.
1004
+ int32 max_confs = 2;
1005
+ }
1006
+ message ListUnspentResponse {
1007
+ /// A list of utxos
1008
+ repeated Utxo utxos = 1 [json_name = "utxos"];
1009
+ }
1010
+
800
1011
  /**
801
1012
  `AddressType` has to be one of:
802
1013
 
803
1014
  - `p2wkh`: Pay to witness key hash (`WITNESS_PUBKEY_HASH` = 0)
804
1015
  - `np2wkh`: Pay to nested witness key hash (`NESTED_PUBKEY_HASH` = 1)
805
1016
  */
806
- message NewAddressRequest {
807
- enum AddressType {
1017
+ enum AddressType {
808
1018
  WITNESS_PUBKEY_HASH = 0;
809
1019
  NESTED_PUBKEY_HASH = 1;
810
- }
1020
+ UNUSED_WITNESS_PUBKEY_HASH = 2;
1021
+ UNUSED_NESTED_PUBKEY_HASH = 3;
1022
+ }
811
1023
 
1024
+ message NewAddressRequest {
812
1025
  /// The address type
813
1026
  AddressType type = 1;
814
1027
  }
@@ -938,14 +1151,19 @@ message Channel {
938
1151
  repeated HTLC pending_htlcs = 15 [json_name = "pending_htlcs"];
939
1152
 
940
1153
  /**
941
- The CSV delay expressed in relative blocks. If the channel is force
942
- closed, we'll need to wait for this many blocks before we can regain our
943
- funds.
1154
+ The CSV delay expressed in relative blocks. If the channel is force closed,
1155
+ we will need to wait for this many blocks before we can regain our funds.
944
1156
  */
945
1157
  uint32 csv_delay = 16 [json_name = "csv_delay"];
946
1158
 
947
- /// Whether this channel is advertised to the network or not
1159
+ /// Whether this channel is advertised to the network or not.
948
1160
  bool private = 17 [json_name = "private"];
1161
+
1162
+ /// True if we were the ones that created the channel.
1163
+ bool initiator = 18 [json_name = "initiator"];
1164
+
1165
+ /// A set of flags showing the current state of the cahnnel.
1166
+ string chan_status_flags = 19 [json_name = "chan_status_flags"];
949
1167
  }
950
1168
 
951
1169
 
@@ -1038,6 +1256,26 @@ message Peer {
1038
1256
 
1039
1257
  /// Ping time to this peer
1040
1258
  int64 ping_time = 9 [json_name = "ping_time"];
1259
+
1260
+ enum SyncType {
1261
+ /**
1262
+ Denotes that we cannot determine the peer's current sync type.
1263
+ */
1264
+ UNKNOWN_SYNC = 0;
1265
+
1266
+ /**
1267
+ Denotes that we are actively receiving new graph updates from the peer.
1268
+ */
1269
+ ACTIVE_SYNC = 1;
1270
+
1271
+ /**
1272
+ Denotes that we are not receiving new graph updates from the peer.
1273
+ */
1274
+ PASSIVE_SYNC = 2;
1275
+ }
1276
+
1277
+ // The type of sync we are currently performing with this peer.
1278
+ SyncType sync_type = 10 [json_name = "sync_type"];
1041
1279
  }
1042
1280
 
1043
1281
  message ListPeersRequest {
@@ -1075,11 +1313,13 @@ message GetInfoResponse {
1075
1313
  /// Whether the wallet's view is synced to the main chain
1076
1314
  bool synced_to_chain = 9 [json_name = "synced_to_chain"];
1077
1315
 
1078
- /// Whether the current node is connected to testnet
1079
- bool testnet = 10 [json_name = "testnet"];
1316
+ /**
1317
+ Whether the current node is connected to testnet. This field is
1318
+ deprecated and the network field should be used instead
1319
+ **/
1320
+ bool testnet = 10 [json_name = "testnet", deprecated = true];
1080
1321
 
1081
- /// A list of active chains the node is connected to
1082
- repeated string chains = 11 [json_name = "chains"];
1322
+ reserved 11;
1083
1323
 
1084
1324
  /// The URIs of the current node.
1085
1325
  repeated string uris = 12 [json_name = "uris"];
@@ -1092,6 +1332,17 @@ message GetInfoResponse {
1092
1332
 
1093
1333
  /// Number of inactive channels
1094
1334
  uint32 num_inactive_channels = 15 [json_name = "num_inactive_channels"];
1335
+
1336
+ /// A list of active chains the node is connected to
1337
+ repeated Chain chains = 16 [json_name = "chains"];
1338
+ }
1339
+
1340
+ message Chain {
1341
+ /// The blockchain the node is on (eg bitcoin, litecoin)
1342
+ string chain = 1 [json_name = "chain"];
1343
+
1344
+ /// The network the node is on (eg regtest, testnet, mainnet)
1345
+ string network = 2 [json_name = "network"];
1095
1346
  }
1096
1347
 
1097
1348
  message ConfirmationUpdate {
@@ -1132,7 +1383,6 @@ message CloseChannelRequest {
1132
1383
  message CloseStatusUpdate {
1133
1384
  oneof update {
1134
1385
  PendingUpdate close_pending = 1 [json_name = "close_pending"];
1135
- ConfirmationUpdate confirmation = 2 [json_name = "confirmation"];
1136
1386
  ChannelCloseUpdate chan_close = 3 [json_name = "chan_close"];
1137
1387
  }
1138
1388
  }
@@ -1179,7 +1429,6 @@ message OpenChannelRequest {
1179
1429
  message OpenStatusUpdate {
1180
1430
  oneof update {
1181
1431
  PendingUpdate chan_pending = 1 [json_name = "chan_pending"];
1182
- ConfirmationUpdate confirmation = 2 [json_name = "confirmation"];
1183
1432
  ChannelOpenUpdate chan_open = 3 [json_name = "chan_open"];
1184
1433
  }
1185
1434
  }
@@ -1306,6 +1555,27 @@ message PendingChannelsResponse {
1306
1555
  repeated WaitingCloseChannel waiting_close_channels = 5 [ json_name = "waiting_close_channels" ];
1307
1556
  }
1308
1557
 
1558
+ message ChannelEventSubscription {
1559
+ }
1560
+
1561
+ message ChannelEventUpdate {
1562
+ oneof channel {
1563
+ Channel open_channel = 1 [ json_name = "open_channel" ];
1564
+ ChannelCloseSummary closed_channel = 2 [ json_name = "closed_channel" ];
1565
+ ChannelPoint active_channel = 3 [ json_name = "active_channel" ];
1566
+ ChannelPoint inactive_channel = 4 [ json_name = "inactive_channel" ];
1567
+ }
1568
+
1569
+ enum UpdateType {
1570
+ OPEN_CHANNEL = 0;
1571
+ CLOSED_CHANNEL = 1;
1572
+ ACTIVE_CHANNEL = 2;
1573
+ INACTIVE_CHANNEL = 3;
1574
+ }
1575
+
1576
+ UpdateType type = 5 [ json_name = "type" ];
1577
+ }
1578
+
1309
1579
  message WalletBalanceRequest {
1310
1580
  }
1311
1581
  message WalletBalanceResponse {
@@ -1336,8 +1606,11 @@ message QueryRoutesRequest {
1336
1606
  /// The amount to send expressed in satoshis
1337
1607
  int64 amt = 2;
1338
1608
 
1339
- /// The max number of routes to return.
1340
- int32 num_routes = 3;
1609
+ /**
1610
+ Deprecated. The max number of routes to return. In the future, QueryRoutes
1611
+ will only return a single route.
1612
+ */
1613
+ int32 num_routes = 3 [deprecated = true];
1341
1614
 
1342
1615
  /// An optional CLTV delta from the current height that should be used for the timelock of the final hop
1343
1616
  int32 final_cltv_delta = 4;
@@ -1349,7 +1622,37 @@ message QueryRoutesRequest {
1349
1622
  send the payment.
1350
1623
  */
1351
1624
  FeeLimit fee_limit = 5;
1625
+
1626
+ /**
1627
+ A list of nodes to ignore during path finding.
1628
+ */
1629
+ repeated bytes ignored_nodes = 6;
1630
+
1631
+ /**
1632
+ A list of edges to ignore during path finding.
1633
+ */
1634
+ repeated EdgeLocator ignored_edges = 7;
1635
+
1636
+ /**
1637
+ The source node where the request route should originated from. If empty,
1638
+ self is assumed.
1639
+ */
1640
+ string source_pub_key = 8;
1641
+ }
1642
+
1643
+ message EdgeLocator {
1644
+ /// The short channel id of this edge.
1645
+ uint64 channel_id = 1;
1646
+
1647
+ /**
1648
+ The direction of this edge. If direction_reverse is false, the direction
1649
+ of this edge is from the channel endpoint with the lexicographically smaller
1650
+ pub key to the endpoint with the larger pub key. If direction_reverse is
1651
+ is true, the edge goes the other way.
1652
+ */
1653
+ bool direction_reverse = 2;
1352
1654
  }
1655
+
1353
1656
  message QueryRoutesResponse {
1354
1657
  repeated Route routes = 1 [json_name = "routes"];
1355
1658
  }
@@ -1468,6 +1771,7 @@ message RoutingPolicy {
1468
1771
  int64 fee_base_msat = 3 [json_name = "fee_base_msat"];
1469
1772
  int64 fee_rate_milli_msat = 4 [json_name = "fee_rate_milli_msat"];
1470
1773
  bool disabled = 5 [json_name = "disabled"];
1774
+ uint64 max_htlc_msat = 6 [json_name = "max_htlc_msat"];
1471
1775
  }
1472
1776
 
1473
1777
  /**
@@ -1540,6 +1844,7 @@ message NetworkInfo {
1540
1844
  double avg_channel_size = 7 [json_name = "avg_channel_size"];
1541
1845
  int64 min_channel_size = 8 [json_name = "min_channel_size"];
1542
1846
  int64 max_channel_size = 9 [json_name = "max_channel_size"];
1847
+ int64 median_channel_size_sat = 10 [json_name = "median_channel_size_sat"];
1543
1848
 
1544
1849
  // TODO(roasbeef): fee rate info, expiry
1545
1850
  // * also additional RPC for tracking fee info once in
@@ -1626,8 +1931,10 @@ message Invoice {
1626
1931
  */
1627
1932
  string memo = 1 [json_name = "memo"];
1628
1933
 
1629
- /// An optional cryptographic receipt of payment
1630
- bytes receipt = 2 [json_name = "receipt"];
1934
+ /** Deprecated. An optional cryptographic receipt of payment which is not
1935
+ implemented.
1936
+ */
1937
+ bytes receipt = 2 [json_name = "receipt", deprecated = true];
1631
1938
 
1632
1939
  /**
1633
1940
  The hex-encoded preimage (32 byte) which will allow settling an incoming
@@ -1642,7 +1949,7 @@ message Invoice {
1642
1949
  int64 value = 5 [json_name = "value"];
1643
1950
 
1644
1951
  /// Whether this invoice has been fulfilled
1645
- bool settled = 6 [json_name = "settled"];
1952
+ bool settled = 6 [json_name = "settled", deprecated = true];
1646
1953
 
1647
1954
  /// When this invoice was created
1648
1955
  int64 creation_date = 7 [json_name = "creation_date"];
@@ -1720,7 +2027,20 @@ message Invoice {
1720
2027
  here as well.
1721
2028
  */
1722
2029
  int64 amt_paid_msat = 20 [json_name = "amt_paid_msat"];
2030
+
2031
+ enum InvoiceState {
2032
+ OPEN = 0;
2033
+ SETTLED = 1;
2034
+ CANCELED = 2;
2035
+ ACCEPTED = 3;
2036
+ }
2037
+
2038
+ /**
2039
+ The state the invoice is in.
2040
+ */
2041
+ InvoiceState state = 21 [json_name = "state"];
1723
2042
  }
2043
+
1724
2044
  message AddInvoiceResponse {
1725
2045
  bytes r_hash = 1 [json_name = "r_hash"];
1726
2046
 
@@ -1953,15 +2273,18 @@ message ForwardingEvent {
1953
2273
  /// The outgoing channel ID that carried the preimage that completed the circuit.
1954
2274
  uint64 chan_id_out = 4 [json_name = "chan_id_out"];
1955
2275
 
1956
- /// The total amount of the incoming HTLC that created half the circuit.
2276
+ /// The total amount (in satoshis) of the incoming HTLC that created half the circuit.
1957
2277
  uint64 amt_in = 5 [json_name = "amt_in"];
1958
2278
 
1959
- /// The total amount of the outgoign HTLC that created the second half of the circuit.
2279
+ /// The total amount (in satoshis) of the outgoing HTLC that created the second half of the circuit.
1960
2280
  uint64 amt_out = 6 [json_name = "amt_out"];
1961
2281
 
1962
- /// The total fee that this payment circuit carried.
2282
+ /// The total fee (in satoshis) that this payment circuit carried.
1963
2283
  uint64 fee = 7 [json_name = "fee"];
1964
2284
 
2285
+ /// The total fee (in milli-satoshis) that this payment circuit carried.
2286
+ uint64 fee_msat = 8 [json_name = "fee_msat"];
2287
+
1965
2288
  // TODO(roasbeef): add settlement latency?
1966
2289
  // * use FPE on the chan id?
1967
2290
  // * also list failures?
@@ -1973,3 +2296,72 @@ message ForwardingHistoryResponse {
1973
2296
  /// The index of the last time in the set of returned forwarding events. Can be used to seek further, pagination style.
1974
2297
  uint32 last_offset_index = 2 [json_name = "last_offset_index"];
1975
2298
  }
2299
+
2300
+ message ExportChannelBackupRequest {
2301
+ /// The target chanenl point to obtain a back up for.
2302
+ ChannelPoint chan_point = 1;
2303
+ }
2304
+
2305
+ message ChannelBackup {
2306
+ /**
2307
+ Identifies the channel that this backup belongs to.
2308
+ */
2309
+ ChannelPoint chan_point = 1 [ json_name = "chan_point" ];
2310
+
2311
+ /**
2312
+ Is an encrypted single-chan backup. this can be passed to
2313
+ RestoreChannelBackups, or the WalletUnlocker Innit and Unlock methods in
2314
+ order to trigger the recovery protocol.
2315
+ */
2316
+ bytes chan_backup = 2 [ json_name = "chan_backup" ];
2317
+ }
2318
+
2319
+ message MultiChanBackup {
2320
+ /**
2321
+ Is the set of all channels that are included in this multi-channel backup.
2322
+ */
2323
+ repeated ChannelPoint chan_points = 1 [ json_name = "chan_points" ];
2324
+
2325
+ /**
2326
+ A single encrypted blob containing all the static channel backups of the
2327
+ channel listed above. This can be stored as a single file or blob, and
2328
+ safely be replaced with any prior/future versions.
2329
+ */
2330
+ bytes multi_chan_backup = 2 [ json_name = "multi_chan_backup" ];
2331
+ }
2332
+
2333
+ message ChanBackupExportRequest {}
2334
+ message ChanBackupSnapshot {
2335
+ /**
2336
+ The set of new channels that have been added since the last channel backup
2337
+ snapshot was requested.
2338
+ */
2339
+ ChannelBackups single_chan_backups = 1 [ json_name = "single_chan_backups" ];
2340
+
2341
+ /**
2342
+ A multi-channel backup that covers all open channels currently known to
2343
+ lnd.
2344
+ */
2345
+ MultiChanBackup multi_chan_backup = 2 [ json_name = "multi_chan_backup" ];
2346
+ }
2347
+
2348
+ message ChannelBackups {
2349
+ /**
2350
+ A set of single-chan static channel backups.
2351
+ */
2352
+ repeated ChannelBackup chan_backups = 1 [ json_name = "chan_backups" ];
2353
+ }
2354
+
2355
+ message RestoreChanBackupRequest {
2356
+ oneof backup {
2357
+ ChannelBackups chan_backups = 1 [ json_name = "chan_backups" ];
2358
+
2359
+ bytes multi_chan_backup = 2 [ json_name = "multi_chan_backup" ];
2360
+ }
2361
+ }
2362
+ message RestoreBackupResponse {}
2363
+
2364
+ message ChannelBackupSubscription {}
2365
+
2366
+ message VerifyChanBackupResponse {
2367
+ }