lightning 4.13.1 → 4.13.2

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 (27) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/grpc/protos/lightning.proto +18 -6
  3. package/lnd_methods/macaroon/accept_rpc_request.js +1 -1
  4. package/lnd_methods/macaroon/handle_rpc_request_update.js +6 -3
  5. package/lnd_methods/macaroon/reject_rpc_request.js +1 -1
  6. package/lnd_methods/macaroon/subscribe_to_rpc_requests.d.ts +4 -2
  7. package/lnd_methods/macaroon/subscribe_to_rpc_requests.js +8 -6
  8. package/lnd_methods/offchain/delete_failed_pay_attempts.js +1 -1
  9. package/lnd_methods/offchain/delete_payment.d.ts +1 -1
  10. package/lnd_methods/offchain/delete_payment.js +1 -1
  11. package/lnd_methods/offchain/subscribe_to_forwards.js +1 -1
  12. package/lnd_methods/offchain/subscribe_to_past_payments.d.ts +1 -1
  13. package/lnd_methods/offchain/subscribe_to_past_payments.js +1 -1
  14. package/lnd_methods/offchain/subscribe_to_peer_messages.d.ts +1 -1
  15. package/lnd_methods/offchain/subscribe_to_peer_messages.js +1 -1
  16. package/lnd_methods/offchain/update_routing_fees.d.ts +1 -1
  17. package/lnd_methods/offchain/update_routing_fees.js +1 -1
  18. package/lnd_methods/unauthenticated/get_wallet_status.d.ts +1 -1
  19. package/lnd_methods/unauthenticated/get_wallet_status.js +1 -1
  20. package/lnd_methods/unauthenticated/subscribe_to_wallet_status.d.ts +1 -1
  21. package/lnd_methods/unauthenticated/subscribe_to_wallet_status.js +1 -1
  22. package/lnd_responses/rpc_channel_as_old_rpc_channel.js +1 -1
  23. package/lnd_responses/rpc_request_update_as_event.js +12 -2
  24. package/package.json +3 -3
  25. package/test/lnd_methods/macaroon/test_handle_rpc_request_update.js +4 -0
  26. package/test/lnd_methods/macaroon/test_subscribe_to_rpc_requests.js +5 -2
  27. package/test/lnd_responses/test_rpc_request_update_as_event.js +7 -1
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Versions
2
2
 
3
- ## 4.13.1
3
+ ## 4.13.2
4
4
 
5
5
  - Add `sendMessageToPeer` to send a peer to peer message to a connected peer
6
6
  - Add `subscribeToPeerMessages` to listen to messages from connected peers
@@ -4175,8 +4175,10 @@ message CheckMacPermResponse {
4175
4175
 
4176
4176
  message RPCMiddlewareRequest {
4177
4177
  /*
4178
- The unique ID of the intercepted request. Useful for mapping request to
4179
- response when implementing full duplex message interception.
4178
+ The unique ID of the intercepted original gRPC request. Useful for mapping
4179
+ request to response when implementing full duplex message interception. For
4180
+ streaming requests, this will be the same ID for all incoming and outgoing
4181
+ middleware intercept messages of the _same_ stream.
4180
4182
  */
4181
4183
  uint64 request_id = 1;
4182
4184
 
@@ -4231,6 +4233,16 @@ message RPCMiddlewareRequest {
4231
4233
  */
4232
4234
  RPCMessage response = 6;
4233
4235
  }
4236
+
4237
+ /*
4238
+ The unique message ID of this middleware intercept message. There can be
4239
+ multiple middleware intercept messages per single gRPC request (one for the
4240
+ incoming request and one for the outgoing response) or gRPC stream (one for
4241
+ each incoming message and one for each outgoing response). This message ID
4242
+ must be referenced when responding (accepting/rejecting/modifying) to an
4243
+ intercept message.
4244
+ */
4245
+ uint64 msg_id = 7;
4234
4246
  }
4235
4247
 
4236
4248
  message StreamAuth {
@@ -4270,11 +4282,11 @@ message RPCMessage {
4270
4282
 
4271
4283
  message RPCMiddlewareResponse {
4272
4284
  /*
4273
- The unique ID of the intercepted request that this response refers to. Must
4274
- always be set when giving feedback to an intercept but is ignored for the
4275
- initial registration message.
4285
+ The request message ID this response refers to. Must always be set when
4286
+ giving feedback to an intercept but is ignored for the initial registration
4287
+ message.
4276
4288
  */
4277
- uint64 request_id = 1;
4289
+ uint64 ref_msg_id = 1;
4278
4290
 
4279
4291
  /*
4280
4292
  The middleware can only send two types of messages to lnd: The initial
@@ -30,7 +30,7 @@ module.exports = ({id, subscription}, cbk) => {
30
30
 
31
31
  // Send accept feedback to the stream
32
32
  accept: ['validate', ({}, cbk) => {
33
- return subscription.write({feedback, request_id: id}, err => {
33
+ return subscription.write({feedback, ref_msg_id: id}, err => {
34
34
  if (!!err) {
35
35
  return cbk([503, 'UnexpectedErrorAcceptingRpcRequest', {err}]);
36
36
  }
@@ -17,6 +17,7 @@ const isPayViaRoute = n => !!n && n === '/routerrpc.Router/SendToRouteV2';
17
17
  [is_intercepting_pay_via_routes_requests]: <Is Handling Route Reqs Bool>
18
18
  subscription: <Stream Subscription Object>
19
19
  update: {
20
+ msg_id: <Message Id Number String>
20
21
  request_id: <Request Id Number String>
21
22
  raw_macaroon: <Raw Macaroon Buffer Object>
22
23
  custom_caveat_condition: <Custom Caveat Condition String>
@@ -47,12 +48,13 @@ const isPayViaRoute = n => !!n && n === '/routerrpc.Router/SendToRouteV2';
47
48
  [accept]: ({}, cbk) => {}
48
49
  data: {
49
50
  [accept]: ({}, cbk) => {}
50
- id: <Request Id Number>
51
+ call: <Call Id Number>
52
+ id: <Message Id Number>
51
53
  [macaroon]: <Base64 Encoded Macaroon String>
52
54
  [reject]: ({}, cbk) => {}
53
55
  [request]: {
54
56
  [chain_fee_tokens_per_vbyte]: <Chain Fee Tokens Per VByte Number>
55
- [cooperative_close_address]: <Prefer Cooperative Close To Address String>
57
+ [cooperative_close_address]: <Prefer Cooperative Close Address String>
56
58
  [give_tokens]: <Tokens to Gift To Partner Number>
57
59
  [is_private]: <Channel is Private Bool>
58
60
  local_tokens: <Local Tokens Number>
@@ -72,6 +74,7 @@ module.exports = args => {
72
74
  const isInterceptOpenChans = !!args.is_intercepting_open_channel_requests;
73
75
  const isInterceptPayOnRoute = !!args.is_intercepting_pay_via_routes_requests;
74
76
 
77
+ const {call} = details;
75
78
  const {event} = details;
76
79
  const {id} = details;
77
80
  const {macaroon} = details;
@@ -144,5 +147,5 @@ module.exports = args => {
144
147
  };
145
148
  }
146
149
 
147
- return {accept, event, data: {id, macaroon, uri}};
150
+ return {accept, event, data: {call, id, macaroon, uri}};
148
151
  };
@@ -36,7 +36,7 @@ module.exports = ({id, message, subscription}, cbk) => {
36
36
  error: message || defaultRejectMessage,
37
37
  replace_response: false,
38
38
  },
39
- request_id: id,
39
+ ref_msg_id: id,
40
40
  },
41
41
  err => {
42
42
  if (!!err) {
@@ -21,7 +21,9 @@ export type SubscribeToRpcRequestsResult = {
21
21
  };
22
22
 
23
23
  export type SubscribeToRpcRequestsCommonEvent = {
24
- /** Request Id Number */
24
+ /** Call Id Number */
25
+ call: number;
26
+ /** Message Id Number */
25
27
  id: number;
26
28
  /** Base64 Encoded Macaroon String */
27
29
  macaroon?: string;
@@ -135,7 +137,7 @@ export type SubscribeToRpcRequestsResponseEvent =
135
137
  *
136
138
  * LND must be running with "RPC middleware" enabled: `rpcmiddleware.enable=1`
137
139
  *
138
- * This method is not supported in LND 0.13.3 and below
140
+ * This method is not supported in LND 0.13.4 and below
139
141
  */
140
142
  export const subscribeToRpcRequests: AuthenticatedLightningMethod<
141
143
  SubscribeToRpcRequestsArgs,
@@ -22,7 +22,7 @@ const type = 'default';
22
22
 
23
23
  LND must be running with "RPC middleware" enabled: `rpcmiddleware.enable=1`
24
24
 
25
- This method is not supported in LND 0.13.3 and below
25
+ This method is not supported in LND 0.13.4 and below
26
26
 
27
27
  {
28
28
  [id]: <RPC Middleware Interception Name String>
@@ -41,7 +41,7 @@ const type = 'default';
41
41
  @event 'close_channel_request'
42
42
  {
43
43
  accept: ({}, [cbk]) => {}
44
- id: <Request Id Number>
44
+ id: <Message Id Number>
45
45
  macaroon: <Base64 Encoded Macaroon String>
46
46
  reject: ({message: <Rejection String>}, [cbk]) => {}
47
47
  request: {
@@ -59,7 +59,7 @@ const type = 'default';
59
59
  @event 'open_channel_request'
60
60
  {
61
61
  accept: ({}, [cbk]) => {}
62
- id: <Request Id Number>
62
+ id: <Message Id Number>
63
63
  macaroon: <Base64 Encoded Macaroon String>
64
64
  reject: ({message: <Rejection String>}, [cbk]) => {}
65
65
  request: {
@@ -80,7 +80,7 @@ const type = 'default';
80
80
  @event 'pay_via_route_request'
81
81
  {
82
82
  accept: ({}, [cbk]) => {}
83
- id: <Request Id Number>
83
+ id: <Message Id Number>
84
84
  macaroon: <Base64 Encoded Macaroon String>
85
85
  reject: ({message: <Rejection String>}, [cbk]) => {}
86
86
  request: {
@@ -110,14 +110,16 @@ const type = 'default';
110
110
 
111
111
  @event 'request'
112
112
  {
113
- id: <Request Id Number>
113
+ call: <Call Identifier Number>
114
+ id: <Message Id Number>
114
115
  [macaroon]: <Base64 Encoded Macaroon String>
115
116
  [uri]: <RPC URI String>
116
117
  }
117
118
 
118
119
  @event 'response'
119
120
  {
120
- id: <Request Id Number>
121
+ call: <Call Identifier Number>
122
+ id: <Message Id Number>
121
123
  [macaroon]: <Base64 Encoded Macaroon String>
122
124
  [uri]: <RPC URI String>
123
125
  }
@@ -16,7 +16,7 @@ const type = 'default';
16
16
 
17
17
  Method not supported on LND 0.12.1 or below
18
18
 
19
- `id` is not supported on LND 0.13.3 or below
19
+ `id` is not supported on LND 0.13.4 or below
20
20
 
21
21
  {
22
22
  [id]: <Delete Only Failed Attempt Records For Payment With Hash Hex String>
@@ -13,6 +13,6 @@ export type DeletePaymentArgs = AuthenticatedLightningArgs<{
13
13
  *
14
14
  * Requires `offchain:write` permission
15
15
  *
16
- * Note: this method is not supported on LND 0.13.3 and below
16
+ * Note: this method is not supported on LND 0.13.4 and below
17
17
  */
18
18
  export const deletePayment: AuthenticatedLightningMethod<DeletePaymentArgs>;
@@ -13,7 +13,7 @@ const type = 'default';
13
13
 
14
14
  Requires `offchain:write` permission
15
15
 
16
- Note: this method is not supported on LND 0.13.3 and below
16
+ Note: this method is not supported on LND 0.13.4 and below
17
17
 
18
18
  {
19
19
  id: <Payment Preimage Hash Hex String>
@@ -16,7 +16,7 @@ const unknownFailureMessage = '2 UNKNOWN: unknown failure detail type: <nil>';
16
16
 
17
17
  Requires `offchain:read` permission
18
18
 
19
- Note: LND 0.13.3 and below do not return `secret` for forwards
19
+ Note: LND 0.13.4 and below do not return `secret` for forwards
20
20
 
21
21
  {
22
22
  lnd: <Authenticated LND API Object>
@@ -69,6 +69,6 @@ export type SubscribeToPastPaymentsPaymentEvent = {
69
69
  *
70
70
  * Requires `offchain:read` permission
71
71
  *
72
- * Note: Method not supported on LND 0.13.3 and below
72
+ * Note: Method not supported on LND 0.13.4 and below
73
73
  */
74
74
  export const subscribeToPastPayments: AuthenticatedLightningSubscription<SubscribeToPastPaymentsArgs>;
@@ -23,7 +23,7 @@ const unknownFailureMessage = '2 UNKNOWN: unknown failure detail type: <nil>';
23
23
 
24
24
  Requires `offchain:read` permission
25
25
 
26
- Note: Method not supported on LND 0.13.3 and below
26
+ Note: Method not supported on LND 0.13.4 and below
27
27
 
28
28
  {
29
29
  lnd: <Authenticated LND API Object>
@@ -13,6 +13,6 @@ export type SubscribeToPeerMessagesMessageReceivedEvent =
13
13
  *
14
14
  * Requires `offchain:read` permission
15
15
  *
16
- * This method is not supported in LND 0.13.3 and below
16
+ * This method is not supported in LND 0.13.4 and below
17
17
  */
18
18
  export const subscribeToPeerMessages: AuthenticatedLightningSubscription;
@@ -16,7 +16,7 @@ const type = 'default';
16
16
 
17
17
  Requires `offchain:read` permission
18
18
 
19
- This method is not supported in LND 0.13.3 and below
19
+ This method is not supported in LND 0.13.4 and below
20
20
 
21
21
  {
22
22
  lnd: <Authenticated LND API Object>
@@ -67,7 +67,7 @@ export type UpdateRoutingFeesResult = {
67
67
  *
68
68
  * Setting both `base_fee_tokens` and `base_fee_mtokens` is not supported
69
69
  *
70
- * `failures` are not returned on LND 0.13.3 and below
70
+ * `failures` are not returned on LND 0.13.4 and below
71
71
  *
72
72
  * Requires `offchain:write` permission
73
73
  */
@@ -20,7 +20,7 @@ const type = 'default';
20
20
 
21
21
  Setting both `base_fee_tokens` and `base_fee_mtokens` is not supported
22
22
 
23
- `failures` are not returned on LND 0.13.3 and below
23
+ `failures` are not returned on LND 0.13.4 and below
24
24
 
25
25
  Requires `offchain:write` permission
26
26
 
@@ -26,7 +26,7 @@ export type GetWalletStatusResult = {
26
26
  *
27
27
  * This method is not supported on LND 0.12.1 and below
28
28
  *
29
- * `is_ready` is not supported on LND 0.13.3 and below
29
+ * `is_ready` is not supported on LND 0.13.4 and below
30
30
  */
31
31
  export const getWalletStatus: UnauthenticatedLightningMethod<
32
32
  {lnd: UnauthenticatedLnd},
@@ -14,7 +14,7 @@ const unsupportedMessage = 'unknown service lnrpc.State';
14
14
 
15
15
  This method is not supported on LND 0.12.1 and below
16
16
 
17
- `is_ready` is not supported on LND 0.13.3 and below
17
+ `is_ready` is not supported on LND 0.13.4 and below
18
18
 
19
19
  {
20
20
  lnd: <Unauthenticated LND API Object>
@@ -25,6 +25,6 @@ export type SubscribeToWalletStatusStartingEvent = EmptyObject;
25
25
  *
26
26
  * This method is not supported on LND 0.12.1 and below
27
27
  *
28
- * `ready` is not supported on LND 0.13.3 and below
28
+ * `ready` is not supported on LND 0.13.4 and below
29
29
  */
30
30
  export const subscribeToWalletStatus: UnauthenticatedLightningSubscription;
@@ -18,7 +18,7 @@ const type = 'status';
18
18
 
19
19
  This method is not supported on LND 0.12.1 and below
20
20
 
21
- `ready` is not supported on LND 0.13.3 and below
21
+ `ready` is not supported on LND 0.13.4 and below
22
22
 
23
23
  {
24
24
  lnd: <Unauthenticated LND API Object>
@@ -23,6 +23,6 @@ module.exports = ({channel, version}) => {
23
23
 
24
24
  const type = adjustedChannelTypes[channel.commitment_type];
25
25
 
26
- // Versions of LND 0.13.3 and before use a different channel type value
26
+ // Versions of LND 0.13.4 and before use a different channel type value
27
27
  return assign(channel, {commitment_type: type || defaultChannelType});
28
28
  };
@@ -7,6 +7,7 @@ const streamAuth = 'stream_auth';
7
7
  /** Derive request details from an RPC request update
8
8
 
9
9
  {
10
+ msg_id: <Message Id Number String>
10
11
  request_id: <Request Id Number String>
11
12
  raw_macaroon: <Raw Macaroon Buffer Object>
12
13
  custom_caveat_condition: <Custom Caveat Condition String>
@@ -33,6 +34,7 @@ const streamAuth = 'stream_auth';
33
34
 
34
35
  @returns
35
36
  {
37
+ call: <Call Id Number>
36
38
  [event]: <Event Type String>
37
39
  id: <Request Id Number>
38
40
  [macaroon]: <Base64 Encoded Macaroon String>
@@ -52,6 +54,10 @@ module.exports = args => {
52
54
  throw new Error('ExpectedInterceptTypeInRpcRequestUpdate');
53
55
  }
54
56
 
57
+ if (args.msg_id === undefined) {
58
+ throw new Error('ExpectedMessageIdInRpcRequestUpdate');
59
+ }
60
+
55
61
  if (!isBuffer(args.raw_macaroon)) {
56
62
  throw new Error('ExpectedCompleteMacaroonCredentialsInRequestUpdate');
57
63
  }
@@ -60,7 +66,8 @@ module.exports = args => {
60
66
  throw new Error('ExpectedRequestIdInRpcRequestUpdate');
61
67
  }
62
68
 
63
- const id = Number(args.request_id);
69
+ const call = Number(args.request_id);
70
+ const id = Number(args.msg_id);
64
71
 
65
72
  switch (args.intercept_type) {
66
73
  // New subscription
@@ -74,6 +81,7 @@ module.exports = args => {
74
81
  }
75
82
 
76
83
  return {
84
+ call,
77
85
  id,
78
86
  event: request,
79
87
  macaroon: bufferAsBase64(args.raw_macaroon),
@@ -91,6 +99,7 @@ module.exports = args => {
91
99
  }
92
100
 
93
101
  return {
102
+ call,
94
103
  id,
95
104
  event: request,
96
105
  macaroon: bufferAsBase64(args.raw_macaroon),
@@ -108,6 +117,7 @@ module.exports = args => {
108
117
  }
109
118
 
110
119
  return {
120
+ call,
111
121
  id,
112
122
  event: response,
113
123
  macaroon: bufferAsBase64(args.raw_macaroon),
@@ -116,6 +126,6 @@ module.exports = args => {
116
126
 
117
127
  // Unknown update
118
128
  default:
119
- return {id, macaroon: bufferAsBase64(args.raw_macaroon)};
129
+ return {call, id, macaroon: bufferAsBase64(args.raw_macaroon)};
120
130
  }
121
131
  };
package/package.json CHANGED
@@ -7,10 +7,10 @@
7
7
  "url": "https://github.com/alexbosworth/lightning/issues"
8
8
  },
9
9
  "dependencies": {
10
- "@grpc/grpc-js": "1.4.2",
10
+ "@grpc/grpc-js": "1.4.4",
11
11
  "@grpc/proto-loader": "0.6.6",
12
12
  "@types/express": "4.17.13",
13
- "@types/node": "16.11.6",
13
+ "@types/node": "16.11.7",
14
14
  "@types/request": "2.48.7",
15
15
  "@types/ws": "8.2.0",
16
16
  "async": "3.2.2",
@@ -56,5 +56,5 @@
56
56
  "directory": "test/typescript"
57
57
  },
58
58
  "types": "index.d.ts",
59
- "version": "4.13.1"
59
+ "version": "4.13.2"
60
60
  }
@@ -24,6 +24,7 @@ const tests = [
24
24
  },
25
25
  subscription: {},
26
26
  update: {
27
+ msg_id: '1',
27
28
  request_id: '1',
28
29
  raw_macaroon: Buffer.alloc(0),
29
30
  custom_caveat_condition: '',
@@ -79,6 +80,7 @@ const tests = [
79
80
  },
80
81
  subscription: {},
81
82
  update: {
83
+ msg_id: '1',
82
84
  request_id: '1',
83
85
  raw_macaroon: Buffer.alloc(0),
84
86
  custom_caveat_condition: '',
@@ -141,6 +143,7 @@ const tests = [
141
143
  },
142
144
  subscription: {},
143
145
  update: {
146
+ msg_id: '1',
144
147
  request_id: '1',
145
148
  raw_macaroon: Buffer.alloc(0),
146
149
  custom_caveat_condition: '',
@@ -189,6 +192,7 @@ const tests = [
189
192
  args: {
190
193
  subscription: {},
191
194
  update: {
195
+ msg_id: '1',
192
196
  request_id: '1',
193
197
  raw_macaroon: Buffer.alloc(0),
194
198
  custom_caveat_condition: '',
@@ -18,6 +18,7 @@ const makeArgs = overrides => {
18
18
 
19
19
  process.nextTick(() => {
20
20
  emitter.emit('data', {
21
+ msg_id: '1',
21
22
  request_id: '1',
22
23
  raw_macaroon: Buffer.alloc(0),
23
24
  custom_caveat_condition: '',
@@ -86,6 +87,7 @@ const tests = [
86
87
 
87
88
  process.nextTick(() => {
88
89
  emitter.emit('data', {
90
+ msg_id: '1',
89
91
  request_id: '1',
90
92
  raw_macaroon: Buffer.alloc(0),
91
93
  custom_caveat_condition: '',
@@ -102,7 +104,7 @@ const tests = [
102
104
  description: 'RPC write errors are passed back',
103
105
  expected: {
104
106
  events: [
105
- {id: 1, macaroon: undefined, uri: 'method_full_uri'},
107
+ {call: 1, id: 1, macaroon: undefined, uri: 'method_full_uri'},
106
108
  [503, 'UnexpectedErrorAcceptingRpcRequest', {err: 'err'}],
107
109
  ],
108
110
  },
@@ -112,7 +114,7 @@ const tests = [
112
114
  description: 'RPC request subscription is returned',
113
115
  expected: {
114
116
  events: [
115
- {id: 1, macaroon: undefined, uri: 'method_full_uri'},
117
+ {call: 1, id: 1, macaroon: undefined, uri: 'method_full_uri'},
116
118
  [503, 'ExpectedCustomCaveatConditionInRpcRequestUpdate'],
117
119
  {details: 'Cancelled on client'},
118
120
  ],
@@ -161,6 +163,7 @@ const tests = [
161
163
 
162
164
  process.nextTick(() => {
163
165
  emitter.emit('data', {
166
+ msg_id: '1',
164
167
  request_id: '1',
165
168
  raw_macaroon: Buffer.alloc(0),
166
169
  custom_caveat_condition: '',
@@ -4,6 +4,7 @@ const method = require('./../../lnd_responses/rpc_request_update_as_event');
4
4
 
5
5
  const makeArgs = overrides => {
6
6
  const args = {
7
+ msg_id: '1',
7
8
  request_id: '1',
8
9
  raw_macaroon: Buffer.alloc(0),
9
10
  custom_caveat_condition: '',
@@ -16,7 +17,7 @@ const makeArgs = overrides => {
16
17
  };
17
18
 
18
19
  const makeExpected = overrides => {
19
- const expected = {id: 1, macaroon: undefined};
20
+ const expected = {call: 1, id: 1, macaroon: undefined};
20
21
 
21
22
  Object.keys(overrides).forEach(k => expected[k] = overrides[k]);
22
23
 
@@ -39,6 +40,11 @@ const tests = [
39
40
  description: 'An intercept type is expected',
40
41
  error: 'ExpectedInterceptTypeInRpcRequestUpdate',
41
42
  },
43
+ {
44
+ args: makeArgs({msg_id: undefined}),
45
+ description: 'A message id is expected',
46
+ error: 'ExpectedMessageIdInRpcRequestUpdate',
47
+ },
42
48
  {
43
49
  args: makeArgs({raw_macaroon: undefined}),
44
50
  description: 'A raw macaroon is expected',