lightning 4.11.1 → 4.13.0

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,5 +1,15 @@
1
1
  # Versions
2
2
 
3
+ ## 4.13.0
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
9
+
10
+ - `probeForRoute`, `subscribeToProbeForRoute`, `subscribeToPayViaRoutes`,
11
+ `payViaRoutes`: When probing (no hash), delete the payment failure record after the probe
12
+
3
13
  ## 4.11.1
4
14
 
5
15
  - `getFailedPayments`: Add method to get past failed payments
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):
@@ -589,11 +589,14 @@ message CustomMessage {
589
589
  message SendCustomMessageRequest {
590
590
  // Peer to send the message to
591
591
  bytes peer = 1;
592
+
592
593
  // Message type. This value needs to be in the custom range (>= 32768).
593
594
  uint32 type = 2;
595
+
594
596
  // Raw message data.
595
597
  bytes data = 3;
596
598
  }
599
+
597
600
  message SendCustomMessageResponse {
598
601
  }
599
602
 
@@ -872,6 +875,9 @@ message ChannelAcceptRequest {
872
875
  // A bit-field which the initiator uses to specify proposed channel
873
876
  // behavior.
874
877
  uint32 channel_flags = 13;
878
+
879
+ // The commitment type the initiator wishes to use for the proposed channel.
880
+ CommitmentType commitment_type = 14;
875
881
  }
876
882
 
877
883
  message ChannelAcceptResponse {
@@ -1226,6 +1232,15 @@ enum CommitmentType {
1226
1232
  been broadcast.
1227
1233
  */
1228
1234
  ANCHORS = 2;
1235
+
1236
+ /*
1237
+ A channel that uses a commitment type that builds upon the anchors
1238
+ commitment format, but in addition requires a CLTV clause to spend outputs
1239
+ paying to the channel initiator. This is intended for use on leased channels
1240
+ to guarantee that the channel initiator has no incentives to close a leased
1241
+ channel before its maturity date.
1242
+ */
1243
+ SCRIPT_ENFORCED_LEASE = 4;
1229
1244
  }
1230
1245
 
1231
1246
  message ChannelConstraints {
@@ -193,6 +193,12 @@ message SignMessageReq {
193
193
 
194
194
  // Double-SHA256 hash instead of just the default single round.
195
195
  bool double_hash = 3;
196
+
197
+ /*
198
+ Use the compact (pubkey recoverable) format instead of the raw lnwire
199
+ format.
200
+ */
201
+ bool compact_sig = 4;
196
202
  }
197
203
  message SignMessageResp {
198
204
  /*
@@ -286,6 +286,16 @@ message AddrRequest {
286
286
  default wallet account is used.
287
287
  */
288
288
  string account = 1;
289
+
290
+ /*
291
+ The type of address to derive.
292
+ */
293
+ AddressType type = 2;
294
+
295
+ /*
296
+ Whether a change address should be derived.
297
+ */
298
+ bool change = 3;
289
299
  }
290
300
  message AddrResponse {
291
301
  /*
@@ -176,6 +176,15 @@ message InitWalletRequest {
176
176
  mainnet).
177
177
  */
178
178
  uint64 extended_master_key_birthday_timestamp = 8;
179
+
180
+ /*
181
+ watch_only is the third option of initializing a wallet: by importing
182
+ account xpubs only and therefore creating a watch-only wallet that does not
183
+ contain any private keys. That means the wallet won't be able to sign for
184
+ any of the keys and _needs_ to be run with a remote signer that has the
185
+ corresponding private keys and can serve signing RPC requests.
186
+ */
187
+ WatchOnly watch_only = 9;
179
188
  }
180
189
  message InitWalletResponse {
181
190
  /*
@@ -188,6 +197,63 @@ message InitWalletResponse {
188
197
  bytes admin_macaroon = 1;
189
198
  }
190
199
 
200
+ message WatchOnly {
201
+ /*
202
+ The unix timestamp in seconds of when the master key was created. lnd will
203
+ only start scanning for funds in blocks that are after the birthday which
204
+ can speed up the process significantly. If the birthday is not known, this
205
+ should be left at its default value of 0 in which case lnd will start
206
+ scanning from the first SegWit block (481824 on mainnet).
207
+ */
208
+ uint64 master_key_birthday_timestamp = 1;
209
+
210
+ /*
211
+ The fingerprint of the root key (also known as the key with derivation path
212
+ m/) from which the account public keys were derived from. This may be
213
+ required by some hardware wallets for proper identification and signing. The
214
+ bytes must be in big-endian order.
215
+ */
216
+ bytes master_key_fingerprint = 2;
217
+
218
+ /*
219
+ The list of accounts to import. There _must_ be an account for all of lnd's
220
+ main key scopes: BIP49/BIP84 (m/49'/0'/0', m/84'/0'/0', note that the
221
+ coin type is always 0, even for testnet/regtest) and lnd's internal key
222
+ scope (m/1017'/<coin_type>'/<account>'), where account is the key family as
223
+ defined in `keychain/derivation.go` (currently indices 0 to 9).
224
+ */
225
+ repeated WatchOnlyAccount accounts = 3;
226
+ }
227
+
228
+ message WatchOnlyAccount {
229
+ /*
230
+ Purpose is the first number in the derivation path, must be either 49, 84
231
+ or 1017.
232
+ */
233
+ uint32 purpose = 1;
234
+
235
+ /*
236
+ Coin type is the second number in the derivation path, this is _always_ 0
237
+ for purposes 49 and 84. It only needs to be set to 1 for purpose 1017 on
238
+ testnet or regtest.
239
+ */
240
+ uint32 coin_type = 2;
241
+
242
+ /*
243
+ Account is the third number in the derivation path. For purposes 49 and 84
244
+ at least the default account (index 0) needs to be created but optional
245
+ additional accounts are allowed. For purpose 1017 there needs to be exactly
246
+ one account for each of the key families defined in `keychain/derivation.go`
247
+ (currently indices 0 to 9)
248
+ */
249
+ uint32 account = 3;
250
+
251
+ /*
252
+ The extended public key at depth 3 for the given account.
253
+ */
254
+ string xpub = 4;
255
+ }
256
+
191
257
  message UnlockWalletRequest {
192
258
  /*
193
259
  wallet_password should be the current valid passphrase for the daemon. This
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,
@@ -443,6 +443,7 @@
443
443
  "type": "router"
444
444
  },
445
445
  "subscribeToPayViaRoutes": {
446
+ "depends_on": ["deletePayment"],
446
447
  "method": "SendToRouteV2",
447
448
  "type": "router"
448
449
  },
@@ -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
 
@@ -16,6 +16,7 @@ const {rpcRouteFromRoute} = require('./../../lnd_requests');
16
16
  const msAsISO = ms => new Date(ms).toISOString();
17
17
  const {isArray} = Array;
18
18
  const isHash = n => /^[0-9A-F]{64}$/i.test(n);
19
+ const hexAsBytes = hex => Buffer.from(hex, 'hex');
19
20
  const method = 'sendToRouteV2';
20
21
  const notFoundIndex = -1;
21
22
  const {now} = Date;
@@ -292,6 +293,27 @@ module.exports = args => {
292
293
  return cbk(null, keys);
293
294
  }],
294
295
 
296
+ // Attempt to clean up failed probe state
297
+ deleteProbe: ['attempt', ({attempt}, cbk) => {
298
+ // Exit early when the payment didn't fail
299
+ if (!attempt.failure) {
300
+ return cbk();
301
+ }
302
+
303
+ // Exit early when this is a real payment
304
+ if (!!args.id) {
305
+ return cbk();
306
+ }
307
+
308
+ args.lnd.default.deletePayment({
309
+ payment_hash: hexAsBytes(id),
310
+ },
311
+ err => {
312
+ // Ignore errors trying to clean up probe data
313
+ return cbk();
314
+ });
315
+ }],
316
+
295
317
  // Parsed out failure
296
318
  failure: ['attempt', 'keys', ({attempt, keys}, cbk) => {
297
319
  if (!attempt.failure) {
@@ -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.1",
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.11.1"
59
+ "version": "4.13.0"
60
60
  }
@@ -4,6 +4,8 @@ const {payViaRoutes} = require('./../../../');
4
4
 
5
5
  const preimage = Buffer.alloc(32);
6
6
 
7
+ const deletePayment = ({}, cbk) => cbk();
8
+
7
9
  const getInfo = ({}, cbk) => {
8
10
  return cbk(null, {
9
11
  alias: '',
@@ -37,7 +39,7 @@ const tests = [
37
39
  {
38
40
  args: {
39
41
  lnd: {
40
- default: {getInfo},
42
+ default: {deletePayment, getInfo},
41
43
  router: {sendToRouteV2: ({}, cbk) => cbk(null, {})},
42
44
  },
43
45
  },
@@ -47,7 +49,7 @@ const tests = [
47
49
  {
48
50
  args: {
49
51
  lnd: {
50
- default: {getInfo},
52
+ default: {deletePayment, getInfo},
51
53
  router: {sendToRouteV2: ({}, cbk) => cbk(null, {})},
52
54
  },
53
55
  routes: [],
@@ -58,7 +60,7 @@ const tests = [
58
60
  {
59
61
  args: {
60
62
  lnd: {
61
- default: {getInfo},
63
+ default: {deletePayment, getInfo},
62
64
  router: {sendToRouteV2: ({}, cbk) => cbk(null, {})},
63
65
  },
64
66
  routes: [{
@@ -85,7 +87,7 @@ const tests = [
85
87
  {
86
88
  args: {
87
89
  lnd: {
88
- default: {getInfo},
90
+ default: {deletePayment, getInfo},
89
91
  router: {sendToRouteV2: ({}, cbk) => cbk('err')},
90
92
  },
91
93
  routes: [{
@@ -116,7 +118,7 @@ const tests = [
116
118
  {
117
119
  args: {
118
120
  lnd: {
119
- default: {getInfo},
121
+ default: {deletePayment, getInfo},
120
122
  router: {sendToRouteV2: ({}, cbk) => cbk(null, {})},
121
123
  },
122
124
  routes: [{
@@ -142,7 +144,7 @@ const tests = [
142
144
  {
143
145
  args: {
144
146
  lnd: {
145
- default: {getInfo},
147
+ default: {deletePayment, getInfo},
146
148
  router: {sendToRouteV2: ({}, cbk) => cbk(null, {})},
147
149
  },
148
150
  routes: [{
@@ -169,7 +171,7 @@ const tests = [
169
171
  {
170
172
  args: {
171
173
  lnd: {
172
- default: {getInfo},
174
+ default: {deletePayment, getInfo},
173
175
  router: {
174
176
  sendToRouteV2: ({}, cbk) => {
175
177
  return cbk(null, {
@@ -223,7 +225,7 @@ const tests = [
223
225
  {
224
226
  args: {
225
227
  lnd: {
226
- default: {getInfo},
228
+ default: {deletePayment, getInfo},
227
229
  router: {
228
230
  sendToRouteV2: ({}, cbk) => {
229
231
  return cbk(null, {
@@ -319,7 +321,7 @@ const tests = [
319
321
  {
320
322
  args: {
321
323
  lnd: {
322
- default: {getInfo},
324
+ default: {deletePayment, getInfo},
323
325
  router: {sendToRouteV2: ({}, cbk) => cbk(null, {preimage})},
324
326
  },
325
327
  routes: [{
@@ -2,6 +2,8 @@ const {test} = require('@alexbosworth/tap');
2
2
 
3
3
  const {subscribeToPayViaRoutes} = require('./../../../');
4
4
 
5
+ const deletePayment = ({}, cbk) => cbk();
6
+
5
7
  const route = {
6
8
  fee: 1,
7
9
  fee_mtokens: '1000',
@@ -27,28 +29,39 @@ const tests = [
27
29
  error: 'ExpectedAuthenticatedLndToPayViaRoutes',
28
30
  },
29
31
  {
30
- args: {lnd: {router: {sendToRouteV2: ({}) => {}}}},
32
+ args: {
33
+ lnd: {default: {deletePayment}, router: {sendToRouteV2: ({}) => {}}},
34
+ },
31
35
  description: 'Routes are required',
32
36
  error: 'ExpectedArrayOfPaymentRoutesToPayViaRoutes',
33
37
  },
34
38
  {
35
- args: {lnd: {router: {sendToRouteV2: ({}) => {}}}, routes: []},
39
+ args: {
40
+ lnd: {default: {deletePayment}, router: {sendToRouteV2: ({}) => {}}},
41
+ routes: [],
42
+ },
36
43
  description: 'Non empty routes are required',
37
44
  error: 'ExpectedArrayOfPaymentRoutesToPayViaRoutes',
38
45
  },
39
46
  {
40
- args: {lnd: {router: {sendToRouteV2: ({}) => {}}}, routes: [{}]},
47
+ args: {
48
+ lnd: {default: {deletePayment}, router: {sendToRouteV2: ({}) => {}}},
49
+ routes: [{}],
50
+ },
41
51
  description: 'Route must have hops',
42
52
  error: 'ExpectedRouteHopsToPayViaRoutes',
43
53
  },
44
54
  {
45
- args: {lnd: {router: {sendToRouteV2: ({}) => {}}}, routes: [{hops: [{}]}]},
55
+ args: {
56
+ lnd: {default: {deletePayment}, router: {sendToRouteV2: ({}) => {}}},
57
+ routes: [{hops: [{}]}],
58
+ },
46
59
  description: 'Hops must have public keys',
47
60
  error: 'ExpectedPublicKeyInPayViaRouteHops',
48
61
  },
49
62
  {
50
63
  args: {
51
- lnd: {router: {sendToRouteV2: ({}) => {}}},
64
+ lnd: {default: {deletePayment}, router: {sendToRouteV2: ({}) => {}}},
52
65
  routes: [{hops: [{public_key: 'public_key'}]}],
53
66
  },
54
67
  description: 'Hops must have channel ids',
@@ -56,7 +69,7 @@ const tests = [
56
69
  },
57
70
  {
58
71
  args: {
59
- lnd: {router: {sendToRouteV2: ({}) => {}}},
72
+ lnd: {default: {deletePayment}, router: {sendToRouteV2: ({}) => {}}},
60
73
  routes: [{hops: [{public_key: 'public_key'}]}],
61
74
  },
62
75
  description: 'Hops must have channel ids',
@@ -65,6 +78,7 @@ const tests = [
65
78
  {
66
79
  args: {
67
80
  lnd: {
81
+ default: {deletePayment},
68
82
  router: {
69
83
  sendToRouteV2: ({}, cbk) => cbk({details: 'unknown wire error'}),
70
84
  },
@@ -77,6 +91,7 @@ const tests = [
77
91
  {
78
92
  args: {
79
93
  lnd: {
94
+ default: {deletePayment},
80
95
  router: {
81
96
  sendToRouteV2: ({}, cbk) => cbk({
82
97
  details: 'payment attempt not completed before timeout',
@@ -90,7 +105,10 @@ const tests = [
90
105
  },
91
106
  {
92
107
  args: {
93
- lnd: {router: {sendToRouteV2: ({}, cbk) => cbk('err')}},
108
+ lnd: {
109
+ default: {deletePayment},
110
+ router: {sendToRouteV2: ({}, cbk) => cbk('err')},
111
+ },
94
112
  routes: [route],
95
113
  },
96
114
  description: 'An unexpected payment error is passed back',
@@ -102,7 +120,10 @@ const tests = [
102
120
  },
103
121
  {
104
122
  args: {
105
- lnd: {router: {sendToRouteV2: ({}, cbk) => cbk()}},
123
+ lnd: {
124
+ default: {deletePayment},
125
+ router: {sendToRouteV2: ({}, cbk) => cbk()},
126
+ },
106
127
  routes: [route],
107
128
  },
108
129
  description: 'A result is expected from sendToRoute',
@@ -115,9 +136,14 @@ const tests = [
115
136
  {
116
137
  args: {
117
138
  id: Buffer.alloc(32).toString('hex'),
118
- lnd: {router: {sendToRouteV2: ({}, cbk) => cbk(null, {
119
- preimage: Buffer.alloc(32),
120
- })}},
139
+ lnd: {
140
+ default: {deletePayment},
141
+ router: {
142
+ sendToRouteV2: ({}, cbk) => cbk(null, {
143
+ preimage: Buffer.alloc(32),
144
+ }),
145
+ },
146
+ },
121
147
  routes: [route, route],
122
148
  },
123
149
  description: 'A success is returned',
@@ -142,9 +168,14 @@ const tests = [
142
168
  {
143
169
  args: {
144
170
  id: Buffer.alloc(32).toString('hex'),
145
- lnd: {router: {sendToRouteV2: ({}, cbk) => cbk(null, {
146
- preimage: 'preimage',
147
- })}},
171
+ lnd: {
172
+ default: {deletePayment},
173
+ router: {
174
+ sendToRouteV2: ({}, cbk) => cbk(null, {
175
+ preimage: 'preimage',
176
+ }),
177
+ },
178
+ },
148
179
  routes: [route],
149
180
  },
150
181
  description: 'A success is returned',
@@ -156,13 +187,18 @@ const tests = [
156
187
  },
157
188
  {
158
189
  args: {
159
- lnd: {router: {sendToRouteV2: ({}, cbk) => cbk(null, {
160
- failure: {
161
- chan_id: '1',
162
- code: 'UNKNOWN_FAILURE',
190
+ lnd: {
191
+ default: {deletePayment},
192
+ router: {
193
+ sendToRouteV2: ({}, cbk) => cbk(null, {
194
+ failure: {
195
+ chan_id: '1',
196
+ code: 'UNKNOWN_FAILURE',
197
+ },
198
+ preimage: Buffer.alloc(Number()),
199
+ }),
163
200
  },
164
- preimage: Buffer.alloc(Number()),
165
- })}},
201
+ },
166
202
  routes: [route],
167
203
  },
168
204
  description: 'A routing failure is returned',
@@ -184,14 +220,19 @@ const tests = [
184
220
  },
185
221
  {
186
222
  args: {
187
- lnd: {router: {sendToRouteV2: ({}, cbk) => cbk(null, {
188
- failure: {
189
- chan_id: '1',
190
- code: 'UNKNOWN_FAILURE',
191
- failure_source_index: 2,
223
+ lnd: {
224
+ default: {deletePayment},
225
+ router: {
226
+ sendToRouteV2: ({}, cbk) => cbk(null, {
227
+ failure: {
228
+ chan_id: '1',
229
+ code: 'UNKNOWN_FAILURE',
230
+ failure_source_index: 2,
231
+ },
232
+ preimage: Buffer.alloc(Number()),
233
+ }),
192
234
  },
193
- preimage: Buffer.alloc(Number()),
194
- })}},
235
+ },
195
236
  routes: [
196
237
  {
197
238
  fee: 1,
@@ -280,14 +321,19 @@ const tests = [
280
321
  },
281
322
  {
282
323
  args: {
283
- lnd: {router: {sendToRouteV2: ({}, cbk) => cbk(null, {
284
- failure: {
285
- chan_id: '1',
286
- code: 'UNKNOWN_FAILURE',
287
- failure_source_index: 1,
324
+ lnd: {
325
+ default: {deletePayment},
326
+ router: {
327
+ sendToRouteV2: ({}, cbk) => cbk(null, {
328
+ failure: {
329
+ chan_id: '1',
330
+ code: 'UNKNOWN_FAILURE',
331
+ failure_source_index: 1,
332
+ },
333
+ preimage: Buffer.alloc(Number()),
334
+ }),
288
335
  },
289
- preimage: Buffer.alloc(Number()),
290
- })}},
336
+ },
291
337
  routes: [route],
292
338
  },
293
339
  description: 'A routing failure is returned from the destination',
@@ -310,6 +356,7 @@ const tests = [
310
356
  {
311
357
  args: {
312
358
  lnd: {
359
+ default: {deletePayment},
313
360
  router: {
314
361
  sendToRouteV2: ({}, cbk) => {
315
362
  return setTimeout(() => cbk({details: 'unknown wire error'}), 100);
@@ -4,6 +4,8 @@ const {getInfoResponse} = require('./../fixtures');
4
4
  const {queryRoutesResponse} = require('./../fixtures');
5
5
  const {subscribeToProbeForRoute} = require('./../../../');
6
6
 
7
+ const deletePayment = ({}, cbk) => cbk();
8
+
7
9
  const expectedRoute = {
8
10
  confidence: 1000000,
9
11
  fee: 0,
@@ -41,6 +43,7 @@ const makeLnd = ({count, getInfo, sendToRouteV2}) => {
41
43
 
42
44
  const lnd = {
43
45
  default: {
46
+ deletePayment,
44
47
  getInfo: getInfo || (({}, cbk) => cbk(null, getInfoResponse)),
45
48
  queryRoutes: ({}, cbk) => {
46
49
  if (returnedRoutes === (count || 1)) {
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "overrides": [
3
- ["lightning", 1168],
4
- ["lightning", 1174],
5
- ["lightning", 1182],
6
- ["lightning", 1189],
7
- ["lightning", 3378],
3
+ ["lightning", 1212],
4
+ ["lightning", 1218],
5
+ ["lightning", 1226],
6
+ ["lightning", 1233],
7
+ ["lightning", 3431],
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}));