lightning 4.12.0 → 4.13.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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Versions
2
2
 
3
- ## 4.12.0
3
+ ## 4.13.1
4
+
5
+ - Add `sendMessageToPeer` to send a peer to peer message to a connected peer
6
+ - Add `subscribeToPeerMessages` to listen to messages from connected peers
7
+
8
+ ## 4.12.2
4
9
 
5
10
  - `probeForRoute`, `subscribeToProbeForRoute`, `subscribeToPayViaRoutes`,
6
11
  `payViaRoutes`: When probing (no hash), delete the payment failure record after the probe
package/README.md CHANGED
@@ -225,6 +225,8 @@ Methods exported by this library support typescript, but ln-service includes add
225
225
  Ask for a CPFP chain fee rate increase on a pending confirm UTXO.
226
226
  - [revokeAccess](https://github.com/alexbosworth/ln-service#revokeaccess): Remove the access
227
227
  privileges of a previously issued access token macaroon credential.
228
+ - [sendMessageToPeer](https://github.com/alexbosworth/ln-service#sendmessagetopeer): Send
229
+ message to a connected peer.
228
230
  - [sendToChainAddress](https://github.com/alexbosworth/ln-service#sendtochainaddress): Send
229
231
  funds on-chain to an address.
230
232
  - [sendToChainAddresses](https://github.com/alexbosworth/ln-service#sendtochainaddresses):
@@ -277,6 +279,8 @@ Methods exported by this library support typescript, but ln-service includes add
277
279
  Make an off-chain payment using a payment request and subscribe to the payment status.
278
280
  - [subscribeToPayViaRoutes](https://github.com/alexbosworth/ln-service#subscribetopayviaroutes):
279
281
  Start an off-chain payment using specific payment routes and subscribe to the payment result.
282
+ - [subscribeToPeerMessages](https://github.com/alexbosworth/ln-service#subscribetopeermessages):
283
+ Listen for incoming peer messages.
280
284
  - [subscribeToPeers](https://github.com/alexbosworth/ln-service#subscribetopeers): Listen to peer
281
285
  disconnect and connect events.
282
286
  - [subscribeToProbeForRoute](https://github.com/alexbosworth/ln-service#subscribetoprobeforroute):
@@ -35,6 +35,12 @@ service Invoices {
35
35
  settled, this call will succeed.
36
36
  */
37
37
  rpc SettleInvoice (SettleInvoiceMsg) returns (SettleInvoiceResp);
38
+
39
+ /*
40
+ LookupInvoiceV2 attempts to look up at invoice. An invoice can be refrenced
41
+ using either its payment hash, payment address, or set ID.
42
+ */
43
+ rpc LookupInvoiceV2 (LookupInvoiceMsg) returns (lnrpc.Invoice);
38
44
  }
39
45
 
40
46
  message CancelInvoiceMsg {
@@ -134,4 +140,33 @@ message SubscribeSingleInvoiceRequest {
134
140
 
135
141
  // Hash corresponding to the (hold) invoice to subscribe to.
136
142
  bytes r_hash = 2;
143
+ }
144
+
145
+ enum LookupModifier {
146
+ // The default look up modifier, no look up behavior is changed.
147
+ DEFAULT = 0;
148
+
149
+ /*
150
+ Indicates that when a look up is done based on a set_id, then only that set
151
+ of HTLCs related to that set ID should be returned.
152
+ */
153
+ HTLC_SET_ONLY = 1;
154
+
155
+ /*
156
+ Indicates that when a look up is done using a payment_addr, then no HTLCs
157
+ related to the payment_addr should be returned. This is useful when one
158
+ wants to be able to obtain the set of associated setIDs with a given
159
+ invoice, then look up the sub-invoices "projected" by that set ID.
160
+ */
161
+ HTLC_SET_BLANK = 2;
162
+ }
163
+
164
+ message LookupInvoiceMsg {
165
+ oneof invoice_ref {
166
+ bytes payment_hash = 1;
167
+ bytes payment_addr = 2;
168
+ bytes set_id = 3;
169
+ }
170
+
171
+ LookupModifier lookup_modifier = 4;
137
172
  }
@@ -3056,6 +3056,10 @@ message HopHint {
3056
3056
  uint32 cltv_expiry_delta = 5;
3057
3057
  }
3058
3058
 
3059
+ message SetID {
3060
+ bytes set_id = 1;
3061
+ }
3062
+
3059
3063
  message RouteHint {
3060
3064
  /*
3061
3065
  A list of hop hints that when chained together can assist in reaching a
@@ -3064,6 +3068,20 @@ message RouteHint {
3064
3068
  repeated HopHint hop_hints = 1;
3065
3069
  }
3066
3070
 
3071
+ message AMPInvoiceState {
3072
+ // The state the HTLCs associated with this setID are in.
3073
+ InvoiceHTLCState state = 1;
3074
+
3075
+ // The settle index of this HTLC set, if the invoice state is settled.
3076
+ uint64 settle_index = 2;
3077
+
3078
+ // The time this HTLC set was settled expressed in unix epoch.
3079
+ int64 settle_time = 3;
3080
+
3081
+ // The total amount paid for the sub-invoice expressed in milli satoshis.
3082
+ int64 amt_paid_msat = 5;
3083
+ }
3084
+
3067
3085
  message Invoice {
3068
3086
  /*
3069
3087
  An optional memo to attach along with the invoice. Used for record keeping
@@ -3209,7 +3227,7 @@ message Invoice {
3209
3227
 
3210
3228
  /*
3211
3229
  The payment address of this invoice. This value will be used in MPP
3212
- payments, and also for newer invoies that always require the MPP paylaod
3230
+ payments, and also for newer invoices that always require the MPP payload
3213
3231
  for added end-to-end security.
3214
3232
  */
3215
3233
  bytes payment_addr = 26;
@@ -3218,6 +3236,16 @@ message Invoice {
3218
3236
  Signals whether or not this is an AMP invoice.
3219
3237
  */
3220
3238
  bool is_amp = 27;
3239
+
3240
+ /*
3241
+ [EXPERIMENTAL]:
3242
+
3243
+ Maps a 32-byte hex-encoded set ID to the sub-invoice AMP state for the
3244
+ given set ID. This field is always populated for AMP invoices, and can be
3245
+ used along side LookupInvoice to obtain the HTLC information related to a
3246
+ given sub-invoice.
3247
+ */
3248
+ map<string, AMPInvoiceState> amp_invoice_state = 28;
3221
3249
  }
3222
3250
 
3223
3251
  enum InvoiceHTLCState {
@@ -74,14 +74,14 @@ message KeyLocator {
74
74
 
75
75
  message KeyDescriptor {
76
76
  /*
77
- The raw bytes of the key being identified. Either this or the KeyLocator
78
- must be specified.
77
+ The raw bytes of the public key in the key pair being identified. Either
78
+ this or the KeyLocator must be specified.
79
79
  */
80
80
  bytes raw_key_bytes = 1;
81
81
 
82
82
  /*
83
- The key locator that identifies which key to use for signing. Either this
84
- or the raw bytes of the target key must be specified.
83
+ The key locator that identifies which private key to use for signing.
84
+ Either this or the raw bytes of the target public key must be specified.
85
85
  */
86
86
  KeyLocator key_loc = 2;
87
87
  }
package/index.js CHANGED
@@ -87,6 +87,7 @@ const {recoverFundsFromChannels} = require('./lnd_methods');
87
87
  const {removePeer} = require('./lnd_methods');
88
88
  const {requestChainFeeIncrease} = require('./lnd_methods');
89
89
  const {revokeAccess} = require('./lnd_methods');
90
+ const {sendMessageToPeer} = require('./lnd_methods');
90
91
  const {sendToChainAddress} = require('./lnd_methods');
91
92
  const {sendToChainAddresses} = require('./lnd_methods');
92
93
  const {sendToChainOutputScripts} = require('./lnd_methods');
@@ -113,6 +114,7 @@ const {subscribeToPastPayments} = require('./lnd_methods');
113
114
  const {subscribeToPayViaDetails} = require('./lnd_methods');
114
115
  const {subscribeToPayViaRequest} = require('./lnd_methods');
115
116
  const {subscribeToPayViaRoutes} = require('./lnd_methods');
117
+ const {subscribeToPeerMessages} = require('./lnd_methods');
116
118
  const {subscribeToPeers} = require('./lnd_methods');
117
119
  const {subscribeToProbeForRoute} = require('./lnd_methods');
118
120
  const {subscribeToRpcRequests} = require('./lnd_methods');
@@ -221,6 +223,7 @@ module.exports = {
221
223
  removePeer,
222
224
  requestChainFeeIncrease,
223
225
  revokeAccess,
226
+ sendMessageToPeer,
224
227
  sendToChainAddress,
225
228
  sendToChainAddresses,
226
229
  sendToChainOutputScripts,
@@ -247,6 +250,7 @@ module.exports = {
247
250
  subscribeToPayViaDetails,
248
251
  subscribeToPayViaRequest,
249
252
  subscribeToPayViaRoutes,
253
+ subscribeToPeerMessages,
250
254
  subscribeToPeers,
251
255
  subscribeToProbeForRoute,
252
256
  subscribeToRpcRequests,
@@ -32,6 +32,7 @@ export * from './pay';
32
32
  export * from './probe_for_route';
33
33
  export * from './recover_funds_from_channel';
34
34
  export * from './recover_funds_from_channels';
35
+ export * from './send_message_to_peer';
35
36
  export * from './subscribe_to_backups';
36
37
  export * from './subscribe_to_channels';
37
38
  export * from './subscribe_to_forward_requests';
@@ -42,6 +43,7 @@ export * from './subscribe_to_past_payments';
42
43
  export * from './subscribe_to_pay_via_details';
43
44
  export * from './subscribe_to_pay_via_request';
44
45
  export * from './subscribe_to_pay_via_routes';
46
+ export * from './subscribe_to_peer_messages';
45
47
  export * from './subscribe_to_probe_for_route';
46
48
  export * from './update_connected_watchtower';
47
49
  export * from './update_pathfinding_settings';
@@ -0,0 +1,28 @@
1
+ import {
2
+ AuthenticatedLightningArgs,
3
+ AuthenticatedLightningMethod,
4
+ } from '../../typescript';
5
+
6
+ export type LightningMessage = {
7
+ /** Message Hex String */
8
+ message: string;
9
+ /** To Peer Public Key Hex String */
10
+ public_key: string;
11
+ /** Message Type Number */
12
+ type?: number;
13
+ };
14
+
15
+ export type SendMessageToPeerArgs =
16
+ AuthenticatedLightningArgs<LightningMessage>;
17
+
18
+ /**
19
+ * Send a custom message to a connected peer
20
+ *
21
+ * If specified, message type is expected to be between 32768 and 65535
22
+ * Message data should not be larger than 65533 bytes
23
+ *
24
+ * Note: this method is not supported in LND versions 0.13.3 and below
25
+ *
26
+ * Requires `offchain:write` permission
27
+ */
28
+ export const sendMessageToPeer: AuthenticatedLightningMethod<SendMessageToPeerArgs>;
@@ -63,7 +63,6 @@ module.exports = (args, cbk) => {
63
63
  }
64
64
 
65
65
  if (!!err) {
66
- console.log("ERR", err)
67
66
  return cbk([503, 'UnexpectedErrorSendingMessageToPeer', {err}]);
68
67
  }
69
68
 
@@ -0,0 +1,18 @@
1
+ import {LightningMessage} from '.';
2
+ import {
3
+ AuthenticatedLightningArgs,
4
+ AuthenticatedLightningSubscription,
5
+ LightningError,
6
+ } from '../../typescript';
7
+
8
+ export type SubscribeToPeerMessagesMessageReceivedEvent =
9
+ Required<LightningMessage>;
10
+
11
+ /**
12
+ * Subscribe to incoming peer messages
13
+ *
14
+ * Requires `offchain:read` permission
15
+ *
16
+ * This method is not supported in LND 0.13.3 and below
17
+ */
18
+ export const subscribeToPeerMessages: AuthenticatedLightningSubscription;
package/package.json CHANGED
@@ -7,22 +7,22 @@
7
7
  "url": "https://github.com/alexbosworth/lightning/issues"
8
8
  },
9
9
  "dependencies": {
10
- "@grpc/grpc-js": "1.4.1",
10
+ "@grpc/grpc-js": "1.4.2",
11
11
  "@grpc/proto-loader": "0.6.6",
12
12
  "@types/express": "4.17.13",
13
- "@types/node": "16.11.4",
13
+ "@types/node": "16.11.6",
14
14
  "@types/request": "2.48.7",
15
15
  "@types/ws": "8.2.0",
16
- "async": "3.2.1",
17
- "asyncjs-util": "1.2.6",
16
+ "async": "3.2.2",
17
+ "asyncjs-util": "1.2.7",
18
18
  "bitcoinjs-lib": "5.2.0",
19
19
  "bn.js": "5.2.0",
20
20
  "body-parser": "1.19.0",
21
- "bolt07": "1.7.3",
21
+ "bolt07": "1.7.4",
22
22
  "bolt09": "0.2.0",
23
23
  "cbor": "8.0.2",
24
24
  "express": "4.17.1",
25
- "invoices": "2.0.0",
25
+ "invoices": "2.0.1",
26
26
  "psbt": "1.1.10"
27
27
  },
28
28
  "description": "Lightning Network client library",
@@ -56,5 +56,5 @@
56
56
  "directory": "test/typescript"
57
57
  },
58
58
  "types": "index.d.ts",
59
- "version": "4.12.0"
59
+ "version": "4.13.1"
60
60
  }
@@ -4,7 +4,7 @@
4
4
  ["lightning", 1218],
5
5
  ["lightning", 1226],
6
6
  ["lightning", 1233],
7
- ["lightning", 3431],
7
+ ["lightning", 3459],
8
8
  ["router", 100],
9
9
  ["walletkit", 3],
10
10
  ["walletunlocker", 2]
@@ -0,0 +1,24 @@
1
+ import {expectError, expectType} from 'tsd';
2
+ import {AuthenticatedLnd} from '../../lnd_grpc';
3
+ import {sendMessageToPeer} from '../../lnd_methods';
4
+
5
+ const lnd = {} as AuthenticatedLnd;
6
+ const message = 'msg';
7
+ const public_key = 'pubkey';
8
+ const type = 2;
9
+
10
+ expectError(sendMessageToPeer());
11
+ expectError(sendMessageToPeer({}));
12
+ expectError(sendMessageToPeer({lnd}));
13
+ expectError(sendMessageToPeer({lnd, message}));
14
+ expectError(sendMessageToPeer({lnd, public_key}));
15
+
16
+ expectType<void>(await sendMessageToPeer({lnd, message, public_key}));
17
+ expectType<void>(await sendMessageToPeer({lnd, message, public_key, type}));
18
+
19
+ expectType<void>(
20
+ sendMessageToPeer({lnd, message, public_key}, (error, result) => {})
21
+ );
22
+ expectType<void>(
23
+ sendMessageToPeer({lnd, message, public_key, type}, (error, result) => {})
24
+ );
@@ -0,0 +1,11 @@
1
+ import * as events from 'events';
2
+ import {expectError, expectType} from 'tsd';
3
+ import {AuthenticatedLnd} from '../../lnd_grpc';
4
+ import {subscribeToPeerMessages} from '../../lnd_methods';
5
+
6
+ const lnd = {} as AuthenticatedLnd;
7
+
8
+ expectError(subscribeToPeerMessages());
9
+ expectError(subscribeToPeerMessages({}));
10
+
11
+ expectType<events.EventEmitter>(subscribeToPeerMessages({lnd}));