lightning 5.0.0 → 5.2.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.
Files changed (32) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +0 -4
  3. package/lnd_methods/address/create_chain_address.d.ts +2 -2
  4. package/lnd_methods/info/constants.json +1 -0
  5. package/lnd_methods/offchain/get_pending_channels.js +2 -0
  6. package/lnd_methods/offchain/get_route_through_hops.d.ts +2 -2
  7. package/lnd_methods/offchain/subscribe_to_pay.d.ts +157 -53
  8. package/lnd_methods/offchain/subscribe_to_pay_via_details.d.ts +23 -135
  9. package/lnd_methods/offchain/subscribe_to_pay_via_request.d.ts +21 -113
  10. package/lnd_methods/offchain/subscribe_to_pay_via_routes.d.ts +8 -6
  11. package/lnd_methods/offchain/update_connected_watchtower.d.ts +2 -2
  12. package/lnd_methods/offchain/update_routing_fees.d.ts +2 -2
  13. package/lnd_methods/onchain/close_channel.d.ts +8 -5
  14. package/lnd_methods/onchain/fund_pending_channels.js +13 -13
  15. package/lnd_methods/onchain/fund_psbt.d.ts +2 -2
  16. package/lnd_methods/onchain/open_channel.js +2 -2
  17. package/lnd_methods/onchain/open_channels.d.ts +2 -0
  18. package/lnd_methods/onchain/open_channels.js +17 -11
  19. package/lnd_methods/onchain/request_chain_fee_increase.d.ts +2 -2
  20. package/lnd_methods/onchain/script_from_chain_address.d.ts +3 -3
  21. package/lnd_methods/onchain/send_to_chain_address.d.ts +3 -3
  22. package/lnd_methods/onchain/send_to_chain_addresses.d.ts +2 -2
  23. package/lnd_methods/onchain/send_to_chain_output_scripts.d.ts +1 -1
  24. package/lnd_methods/onchain/set_autopilot.d.ts +5 -2
  25. package/lnd_methods/onchain/subscribe_to_chain_address.d.ts +2 -2
  26. package/lnd_methods/onchain/subscribe_to_chain_spend.d.ts +2 -2
  27. package/lnd_responses/pending_as_pending_channels.js +2 -0
  28. package/package.json +8 -7
  29. package/test/lnd_responses/test_pending_as_pending_channels.js +1 -0
  30. package/test/typescript/create_chain_address.test-d.ts +6 -1
  31. package/typescript/shared.d.ts +2 -2
  32. package/typescript/util.d.ts +0 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Versions
2
2
 
3
+ ## 5.2.0
4
+
5
+ - `getPendingChannels`: Add support for channel `capacity`
6
+
7
+ ## 5.1.1
8
+
9
+ - `openChannels`: Fix `cooperative_close_address` not being set on channels
10
+
11
+ ## 5.1.0
12
+
13
+ - Add support for LND 0.14.1
14
+ - `openChannels`: Add `is_avoiding_broadcast` to avoid all funding broadcast
15
+
16
+ ## 5.0.1
17
+
18
+ - `createChainAddress`: Fix type hints to reflect optionality of `format`
19
+
3
20
  ## 5.0.0
4
21
 
5
22
  - Removed support for determining the type of channel to support LND 0.14.0.
package/README.md CHANGED
@@ -52,10 +52,6 @@ To access unauthenticated methods like the wallet unlocker, use
52
52
 
53
53
  ## Methods
54
54
 
55
- There are two libraries, [ln-service](https://github.com/alexbosworth/ln-service) and this library.
56
-
57
- Methods exported by this library support typescript, but ln-service includes additional metthods.
58
-
59
55
  - [addPeer](https://github.com/alexbosworth/ln-service#addpeer): Connect to a new peer
60
56
  - [authenticatedLndGrpc](https://github.com/alexbosworth/ln-service#authenticatedlndgrpc):
61
57
  Instantiate connection to authenticated lnd methods.
@@ -5,14 +5,14 @@ import {
5
5
 
6
6
  export type CreateChainAddressArgs = AuthenticatedLightningArgs<{
7
7
  /** Receive Address Type */
8
- format: 'np2wpkh' | 'p2wpkh';
8
+ format?: 'np2wpkh' | 'p2wpkh';
9
9
  /** Get As-Yet Unused Address */
10
10
  is_unused?: boolean;
11
11
  }>;
12
12
 
13
13
  export type CreateChainAddressResult = {
14
14
  /** Chain Address */
15
- address?: string;
15
+ address: string;
16
16
  };
17
17
 
18
18
  /**
@@ -24,6 +24,7 @@
24
24
  "4f567577db9d85b6f392f960b3aabddcad3cd02c": "0.13.3-beta",
25
25
  "52bb3f33707b81972c67937c7a89addcdf00991c": "0.10.1-beta",
26
26
  "596fd90ef310cd7abbf2251edaae9ba4d5f8a689": "0.13.1-beta",
27
+ "6042004edaaa5b3cad0a0808ff23dba4716f7178": "0.14.1-beta",
27
28
  "61c34683058f2cc8dc10f49392a0057440d831c4": "0.13.4-beta",
28
29
  "725ff104808f49f0a5247bfdb4b6b5da7f488d38": "0.13.0-beta",
29
30
  "7f34774529fa0964d47fc418d4d2965435cbfdc0": "0.11.1-beta",
@@ -25,6 +25,7 @@ const type = 'default';
25
25
  @returns via cbk or Promise
26
26
  {
27
27
  pending_channels: [{
28
+ capacity: <Channel Capacity Tokens Number>
28
29
  [close_transaction_id]: <Channel Closing Transaction Id String>
29
30
  is_active: <Channel Is Active Bool>
30
31
  is_closing: <Channel Is Closing Bool>
@@ -68,6 +69,7 @@ module.exports = ({lnd}, cbk) => {
68
69
  return cbk();
69
70
  },
70
71
 
72
+ // Get pending channels
71
73
  getPending: ['validate', ({}, cbk) => {
72
74
  return lnd[type][method]({}, (err, res) => {
73
75
  if (!!err) {
@@ -2,9 +2,9 @@ import {
2
2
  AuthenticatedLightningArgs,
3
3
  AuthenticatedLightningMethod,
4
4
  } from '../../typescript';
5
- import {Xor} from '../../typescript/util';
5
+ import {MergeExclusive} from 'type-fest';
6
6
 
7
- type Tokens = Xor<
7
+ type Tokens = MergeExclusive<
8
8
  {
9
9
  /** Millitokens to Send */
10
10
  mtokens?: string;
@@ -2,75 +2,83 @@ import {
2
2
  AuthenticatedLightningArgs,
3
3
  AuthenticatedLightningSubscription,
4
4
  } from '../../typescript';
5
+ import {MergeExclusive} from 'type-fest';
5
6
 
6
- type SubscribeToPayWithDestination = {
7
+ export type SubscribeToPayWithDestinationArgs = {
7
8
  /** Destination Public Key String> */
8
9
  destination: string;
9
10
  /** Payment Request Hash Hex String> */
10
11
  id: string;
11
12
  /** Final CLTV Delta Number> */
12
13
  cltv_delta?: number;
13
- request?: never;
14
14
  };
15
15
 
16
- type SubscribeToPayWithRequest = {
16
+ export type SubscribeToPayWithRequestArgs = {
17
17
  /** BOLT 11 Payment Request String> */
18
18
  request: string;
19
- cltv_delta?: never;
19
+ };
20
+
21
+ export type SubscribeToPayWithDestinationOrRequestArgs = MergeExclusive<
22
+ SubscribeToPayWithDestinationArgs,
23
+ SubscribeToPayWithRequestArgs
24
+ >;
25
+
26
+ export type SubscribeToPayOptionsArgs = {
27
+ features?: {
28
+ /** Feature Bit Number> */
29
+ bit: number;
30
+ }[];
31
+ /** Pay Through Specific Final Hop Public Key Hex String> */
32
+ incoming_peer?: string;
33
+ /** Maximum Fee Tokens To Pay Number> */
34
+ max_fee?: number;
35
+ /** Maximum Fee Millitokens to Pay String> */
36
+ max_fee_mtokens?: string;
37
+ /** Maximum Millitokens For A Multi-Path Path */
38
+ max_path_mtokens?: string;
39
+ /** Maximum Simultaneous Paths Number> */
40
+ max_paths?: number;
41
+ /** Maximum Height of Payment Timeout Number> */
42
+ max_timeout_height?: number;
43
+ messages?: {
44
+ /** Message Type Number String> */
45
+ type: string;
46
+ /** Message Raw Value Hex Encoded String> */
47
+ value: string;
48
+ }[];
49
+ /** Millitokens to Pay String> */
50
+ mtokens?: string;
51
+ /** Pay Out of Outgoing Channel Id String> */
52
+ outgoing_channel?: string;
53
+ /** Pay Out of Outgoing Channel Ids String> */
54
+ outgoing_channels?: string[];
55
+ /** Time to Spend Finding a Route Milliseconds Number> */
56
+ pathfinding_timeout?: number;
57
+ /** Payment Identifier Hex String> */
58
+ payment?: string;
59
+ routes?: {
60
+ /** Base Routing Fee In Millitokens String> */
61
+ base_fee_mtokens?: string;
62
+ /** Standard Format Channel Id String> */
63
+ channel?: string;
64
+ /** CLTV Blocks Delta Number> */
65
+ cltv_delta?: number;
66
+ /** Fee Rate In Millitokens Per Million Number> */
67
+ fee_rate?: number;
68
+ /** Forward Edge Public Key Hex String> */
69
+ public_key: string;
70
+ }[][];
71
+ /** Tokens to Pay Number> */
72
+ tokens?: number;
20
73
  };
21
74
 
22
75
  export type SubscribeToPayArgs = AuthenticatedLightningArgs<
23
- (SubscribeToPayWithDestination | SubscribeToPayWithRequest) & {
24
- features?: {
25
- /** Feature Bit Number> */
26
- bit: number;
27
- }[];
28
- /** Pay Through Specific Final Hop Public Key Hex String> */
29
- incoming_peer?: string;
30
- /** Maximum Fee Tokens To Pay Number> */
31
- max_fee?: number;
32
- /** Maximum Fee Millitokens to Pay String> */
33
- max_fee_mtokens?: string;
34
- /** Maximum Millitokens For A Multi-Path Path */
35
- max_path_mtokens?: string;
36
- /** Maximum Simultaneous Paths Number> */
37
- max_paths?: number;
38
- /** Maximum Height of Payment Timeout Number> */
39
- max_timeout_height?: number;
40
- messages?: {
41
- /** Message Type Number String> */
42
- type: string;
43
- /** Message Raw Value Hex Encoded String> */
44
- value: string;
45
- }[];
46
- /** Millitokens to Pay String> */
47
- mtokens?: string;
48
- /** Pay Out of Outgoing Channel Id String> */
49
- outgoing_channel?: string;
50
- /** Pay Out of Outgoing Channel Ids String> */
51
- outgoing_channels?: string[];
52
- /** Time to Spend Finding a Route Milliseconds Number> */
53
- pathfinding_timeout?: number;
54
- /** Payment Identifier Hex String> */
55
- payment?: string;
56
- routes?: {
57
- /** Base Routing Fee In Millitokens String> */
58
- base_fee_mtokens?: string;
59
- /** Standard Format Channel Id String> */
60
- channel?: string;
61
- /** CLTV Blocks Delta Number> */
62
- cltv_delta?: number;
63
- /** Fee Rate In Millitokens Per Million Number> */
64
- fee_rate?: number;
65
- /** Forward Edge Public Key Hex String> */
66
- public_key: string;
67
- }[][];
68
- /** Tokens to Probe Number> */
69
- tokens?: number;
70
- }
76
+ SubscribeToPayWithDestinationOrRequestArgs & SubscribeToPayOptionsArgs
71
77
  >;
72
78
 
73
79
  export type SubscribeToPayConfirmedEvent = {
80
+ /** Payment Confirmed At ISO 8601 Date String */
81
+ confirmed_at: string;
74
82
  /** Total Fee Tokens Paid Rounded Down Number> */
75
83
  fee: number;
76
84
  /** Total Fee Millitokens Paid String> */
@@ -174,7 +182,103 @@ export type SubscribeToPayFailedEvent = {
174
182
  };
175
183
  };
176
184
 
177
- export type SubscribeToPayPayingEvent = {[key: string]: never};
185
+ export type SubscribeToPayPayingEvent = {
186
+ /** Payment Created At ISO 8601 Date String> */
187
+ created_at: string;
188
+ /** Payment Destination Hex String> */
189
+ destination: string;
190
+ /** Payment Hash Hex String> */
191
+ id: string;
192
+ /** Total Millitokens Pending String> */
193
+ mtokens: string;
194
+ paths: {
195
+ /** Total Fee Tokens Pending Number> */
196
+ fee: number;
197
+ /** Total Fee Millitokens Pending String> */
198
+ fee_mtokens: string;
199
+ hops: {
200
+ /** Standard Format Channel Id String> */
201
+ channel: string;
202
+ /** Channel Capacity Tokens Number> */
203
+ channel_capacity: number;
204
+ /** Fee Tokens Rounded Down Number> */
205
+ fee: number;
206
+ /** Fee Millitokens String> */
207
+ fee_mtokens: string;
208
+ /** Forward Tokens Number> */
209
+ forward: number;
210
+ /** Forward Millitokens String> */
211
+ forward_mtokens: string;
212
+ /** Public Key Hex String> */
213
+ public_key: string;
214
+ /** Timeout Block Height Number> */
215
+ timeout: number;
216
+ }[];
217
+ /** Total Millitokens Pending String> */
218
+ mtokens: string;
219
+ /** Total Fee Tokens Pending Rounded Up Number> */
220
+ safe_fee: number;
221
+ /** Total Tokens Pending, Rounded Up Number> */
222
+ safe_tokens: number;
223
+ /** Expiration Block Height Number> */
224
+ timeout: number;
225
+ }[];
226
+ /** BOLT 11 Encoded Payment Request String> */
227
+ request?: string;
228
+ /** Total Tokens Pending, Rounded Up Number> */
229
+ safe_tokens: number;
230
+ /** Expiration Block Height Number> */
231
+ timeout?: number;
232
+ /** Total Tokens Pending Rounded Down Number> */
233
+ tokens: number;
234
+ };
235
+
236
+ export type SubscribeToRoutingFailureEvent = {
237
+ /** Standard Format Channel Id String> */
238
+ channel?: string;
239
+ /** Failure Index Number> */
240
+ index: number;
241
+ /** Millitokens String> */
242
+ mtokens?: string;
243
+ /** Public Key Hex String> */
244
+ public_key?: string;
245
+ /** Failure Reason String> */
246
+ reason: string;
247
+ route: {
248
+ /** Total Route Fee Tokens To Pay Number> */
249
+ fee: number;
250
+ /** Total Route Fee Millitokens To Pay String> */
251
+ fee_mtokens: string;
252
+ hops: {
253
+ /** Standard Format Channel Id String> */
254
+ channel: string;
255
+ /** Channel Capacity Tokens Number> */
256
+ channel_capacity: number;
257
+ /** Fee Number> */
258
+ fee: number;
259
+ /** Fee Millitokens String> */
260
+ fee_mtokens: string;
261
+ /** Forward Tokens Number> */
262
+ forward: number;
263
+ /** Forward Millitokens String> */
264
+ forward_mtokens: string;
265
+ /** Public Key Hex String> */
266
+ public_key: string;
267
+ /** Timeout Block Height Number> */
268
+ timeout: number;
269
+ }[];
270
+ /** Total Route Millitokens String> */
271
+ mtokens: string;
272
+ /** Payment Identifier Hex String> */
273
+ payment?: string;
274
+ /** Expiration Block Height Number> */
275
+ timeout: number;
276
+ /** Total Route Tokens Number> */
277
+ tokens: number;
278
+ /** Total Millitokens String> */
279
+ total_mtokens?: string;
280
+ };
281
+ };
178
282
 
179
283
  /**
180
284
  * Initiate and subscribe to the outcome of a payment
@@ -1,146 +1,34 @@
1
+ import {SetOptional} from 'type-fest';
1
2
  import {
2
3
  AuthenticatedLightningArgs,
3
4
  AuthenticatedLightningSubscription,
4
5
  } from '../../typescript';
6
+ import {
7
+ SubscribeToPayConfirmedEvent,
8
+ SubscribeToPayFailedEvent,
9
+ SubscribeToPayOptionsArgs,
10
+ SubscribeToPayPayingEvent,
11
+ SubscribeToPayWithDestinationArgs,
12
+ SubscribeToRoutingFailureEvent,
13
+ } from './subscribe_to_pay';
14
+
15
+ export type SubscribeToPayViaDetailsArgs = AuthenticatedLightningArgs<
16
+ SetOptional<SubscribeToPayWithDestinationArgs, 'id'> &
17
+ SubscribeToPayOptionsArgs
18
+ >;
5
19
 
6
- export type SubscribeToPayViaDetailsArgs = AuthenticatedLightningArgs<{
7
- /** Final CLTV Delta */
8
- cltv_delta?: number;
9
- /** Destination Public Key */
10
- destination: string;
11
- features?: {
12
- /** Feature Bit */
13
- bit: number;
14
- }[];
15
- /** Payment Request Hash Hex */
16
- id?: string;
17
- /** Pay Through Specific Final Hop Public Key Hex */
18
- incoming_peer?: string;
19
- /** Maximum Fee Tokens To Pay */
20
- max_fee?: number;
21
- /** Maximum Fee Millitokens to Pay */
22
- max_fee_mtokens?: string;
23
- /** Maximum Millitokens For A Multi-Path Path */
24
- max_path_mtokens?: string;
25
- /** Maximum Simultaneous Paths */
26
- max_paths?: number;
27
- /** Maximum Height of Payment Timeout */
28
- max_timeout_height?: number;
29
- messages?: {
30
- /** Message Type number */
31
- type: string;
32
- /** Message Raw Value Hex Encoded */
33
- value: string;
34
- }[];
35
- /** Millitokens to Pay */
36
- mtokens?: string;
37
- /** Pay Out of Outgoing Channel Id */
38
- outgoing_channel?: string;
39
- /** Pay Out of Outgoing Channel Ids */
40
- outgoing_channels?: string[];
41
- /** Time to Spend Finding a Route Milliseconds */
42
- pathfinding_timeout?: number;
43
- /** Payment Identifier Hex String */
44
- payment?: string;
45
- routes?: [
46
- {
47
- /** Base Routing Fee In Millitokens */
48
- base_fee_mtokens?: string;
49
- /** Standard Format Channel Id */
50
- channel?: string;
51
- /** CLTV Blocks Delta */
52
- cltv_delta?: number;
53
- /** Fee Rate In Millitokens Per Million */
54
- fee_rate?: number;
55
- /** Forward Edge Public Key Hex */
56
- public_key: string;
57
- }[]
58
- ];
59
- /** Tokens to Pay */
60
- tokens?: number;
61
- }>;
20
+ export type SubscribeToPayViaDetailsConfirmedEvent =
21
+ SubscribeToPayConfirmedEvent;
62
22
 
63
- export type SubscribeToPayViaDetailsConfirmedEvent = {
64
- /** Confirmed at ISO-8601 Date */
65
- confirmed_at: string;
66
- /** Fee Tokens Paid */
67
- fee: number;
68
- /** Total Fee Millitokens Paid */
69
- fee_mtokens: string;
70
- hops: {
71
- /** Standard Format Channel Id */
72
- channel: string;
73
- /** Channel Capacity Tokens */
74
- channel_capacity: number;
75
- /** Fee Millitokens */
76
- fee_mtokens: string;
77
- /** Forward Millitokens */
78
- forward_mtokens: string;
79
- /** Public Key Hex */
80
- public_key: string;
81
- /** Timeout Block Height */
82
- timeout: number;
83
- }[];
84
- /** Payment Hash Hex */
85
- id?: string;
86
- /** Total Millitokens To Pay */
87
- mtokens: string;
88
- /** Payment Forwarding Fee Rounded Up Tokens */
89
- safe_fee: number;
90
- /** Payment Tokens Rounded Up */
91
- safe_tokens: number;
92
- /** Payment Preimage Hex */
93
- secret: string;
94
- /** Total Tokens Paid Rounded Down */
95
- tokens: number;
96
- };
23
+ export type SubscribeToPayViaDetailsFailedEvent = SubscribeToPayFailedEvent;
97
24
 
98
- export type SubscribeToPayViaDetailsFailedEvent = {
99
- /** Failed Due To Lack of Balance */
100
- is_insufficient_balance: boolean;
101
- /** Failed Due to Invalid Payment */
102
- is_invalid_payment: boolean;
103
- /** Failed Due to Pathfinding Timeout */
104
- is_pathfinding_timeout: boolean;
105
- /** Failed Due to Route Not Found */
106
- is_route_not_found: boolean;
107
- route?: {
108
- /** Route Total Fee Tokens Rounded Down */
109
- fee: number;
110
- /** Route Total Fee Millitokens */
111
- fee_mtokens: string;
112
- hops: {
113
- /** Standard Format Channel Id */
114
- channel: string;
115
- /** Channel Capacity Tokens */
116
- channel_capacity: number;
117
- /** Hop Forwarding Fee Rounded Down Tokens */
118
- fee: number;
119
- /** Hop Forwarding Fee Millitokens */
120
- fee_mtokens: string;
121
- /** Hop Forwarding Tokens Rounded Down */
122
- forward: number;
123
- /** Hop Forwarding Millitokens */
124
- forward_mtokens: string;
125
- /** Hop Sending To Public Key Hex */
126
- public_key: string;
127
- /** Hop CTLV Expiration Height */
128
- timeout: number;
129
- }[];
130
- /** Payment Sending Millitokens */
131
- mtokens: string;
132
- /** Payment Forwarding Fee Rounded Up Tokens */
133
- safe_fee: number;
134
- /** Payment Sending Tokens Rounded Up */
135
- safe_tokens: number;
136
- /** Payment CLTV Expiration Height */
137
- timeout: number;
138
- /** Payment Sending Tokens Rounded Down */
139
- tokens: number;
140
- };
141
- };
25
+ export type SubscribeToPayViaDetailsPayingEvent = Omit<
26
+ SubscribeToPayPayingEvent,
27
+ 'request'
28
+ >;
142
29
 
143
- export type SubscribeToPayViaDetailsPayingEvent = {[key: string]: never};
30
+ export type SubscribeToPayViaDetailsRoutingFailure =
31
+ SubscribeToRoutingFailureEvent;
144
32
 
145
33
  /**
146
34
  * Subscribe to the flight of a payment
@@ -2,123 +2,31 @@ import {
2
2
  AuthenticatedLightningArgs,
3
3
  AuthenticatedLightningSubscription,
4
4
  } from '../../typescript';
5
+ import {
6
+ SubscribeToPayConfirmedEvent,
7
+ SubscribeToPayFailedEvent,
8
+ SubscribeToPayOptionsArgs,
9
+ SubscribeToPayPayingEvent,
10
+ SubscribeToPayWithRequestArgs,
11
+ SubscribeToRoutingFailureEvent,
12
+ } from './subscribe_to_pay';
13
+
14
+ export type SubscribeToPayViaRequestArgs = AuthenticatedLightningArgs<
15
+ SubscribeToPayWithRequestArgs &
16
+ Omit<SubscribeToPayOptionsArgs, 'omit' | 'routes'>
17
+ >;
5
18
 
6
- export type SubscribeToPayViaRequestArgs = AuthenticatedLightningArgs<{
7
- /** Pay Through Specific Final Hop Public Key Hex */
8
- incoming_peer?: string;
9
- /** Maximum Fee Tokens To Pay */
10
- max_fee?: number;
11
- /** Maximum Fee Millitokens to Pay */
12
- max_fee_mtokens?: string;
13
- /** Maximum Millitokens For A Multi-Path Path */
14
- max_path_mtokens?: string;
15
- /** Maximum Simultaneous Paths */
16
- max_paths?: number;
17
- /** Maximum Height of Payment Timeout */
18
- max_timeout_height?: number;
19
- messages?: {
20
- /** Message Type number */
21
- type: string;
22
- /** Message Raw Value Hex Encoded */
23
- value: string;
24
- }[];
25
- /** Millitokens to Pay */
26
- mtokens?: string;
27
- /** Pay Out of Outgoing Channel Id */
28
- outgoing_channel?: string;
29
- /** Pay Out of Outgoing Channel Ids */
30
- outgoing_channels?: string[];
31
- /** Time to Spend Finding a Route Milliseconds */
32
- pathfinding_timeout?: number;
33
- /** BOLT 11 Payment Request */
34
- request: string;
35
- /** Tokens To Pay */
36
- tokens?: number;
37
- }>;
19
+ export type SubscribeToPayViaRequestConfirmedEvent = Omit<
20
+ SubscribeToPayConfirmedEvent,
21
+ 'paths'
22
+ >;
38
23
 
39
- export type SubscribeToPayViaRequestConfirmedEvent = {
40
- /** Confirmed at ISO-8601 Date */
41
- confirmed_at: string;
42
- /** Fee Tokens */
43
- fee: number;
44
- /** Total Fee Millitokens To Pay */
45
- fee_mtokens: string;
46
- hops: {
47
- /** Standard Format Channel Id */
48
- channel: string;
49
- /** Channel Capacity Tokens */
50
- channel_capacity: number;
51
- /** Fee Millitokens */
52
- fee_mtokens: string;
53
- /** Forward Millitokens */
54
- forward_mtokens: string;
55
- /** Public Key Hex */
56
- public_key: string;
57
- /** Timeout Block Height */
58
- timeout: number;
59
- }[];
60
- /** Payment Hash Hex */
61
- id: string;
62
- /** Total Millitokens Paid */
63
- mtokens: string;
64
- /** Payment Forwarding Fee Rounded Up Tokens */
65
- safe_fee: number;
66
- /** Payment Tokens Rounded Up */
67
- safe_tokens: number;
68
- /** Payment Preimage Hex */
69
- secret: string;
70
- /** Expiration Block Height */
71
- timeout: number;
72
- /** Total Tokens Paid */
73
- tokens: number;
74
- };
24
+ export type SubscribeToPayViaRequestFailedEvent = SubscribeToPayFailedEvent;
75
25
 
76
- export type SubscribeToPayViaRequestFailedEvent = {
77
- /** Failed Due To Lack of Balance */
78
- is_insufficient_balance: boolean;
79
- /** Failed Due to Invalid Payment */
80
- is_invalid_payment: boolean;
81
- /** Failed Due to Pathfinding Timeout */
82
- is_pathfinding_timeout: boolean;
83
- /** Failed Due to Route Not Found */
84
- is_route_not_found: boolean;
85
- route?: {
86
- /** Route Total Fee Tokens Rounded Down */
87
- fee: number;
88
- /** Route Total Fee Millitokens */
89
- fee_mtokens: string;
90
- hops: {
91
- /** Standard Format Channel Id */
92
- channel: string;
93
- /** Channel Capacity Tokens */
94
- channel_capacity: number;
95
- /** Hop Forwarding Fee Rounded Down Tokens */
96
- fee: number;
97
- /** Hop Forwarding Fee Millitokens */
98
- fee_mtokens: string;
99
- /** Hop Forwarding Tokens Rounded Down */
100
- forward: number;
101
- /** Hop Forwarding Millitokens */
102
- forward_mtokens: string;
103
- /** Hop Sending To Public Key Hex */
104
- public_key: string;
105
- /** Hop CTLV Expiration Height */
106
- timeout: number;
107
- }[];
108
- /** Payment Sending Millitokens */
109
- mtokens: string;
110
- /** Payment Forwarding Fee Rounded Up Tokens */
111
- safe_fee: number;
112
- /** Payment Sending Tokens Rounded Up */
113
- safe_tokens: number;
114
- /** Payment CLTV Expiration Height */
115
- timeout: number;
116
- /** Payment Sending Tokens Rounded Down */
117
- tokens: number;
118
- };
119
- };
26
+ export type SubscribeToPayViaRequestPayingEvent = SubscribeToPayPayingEvent;
120
27
 
121
- export type SubscribeToPayViaRequestPayingEvent = {[key: string]: never};
28
+ export type SubscribeToPayViaRequestRoutingFailureEvent =
29
+ SubscribeToRoutingFailureEvent;
122
30
 
123
31
  /**
124
32
  * Initiate and subscribe to the outcome of a payment request
@@ -172,15 +172,15 @@ export type SubscribeToPayViaRoutesRoutingFailureEvent = {
172
172
  }[];
173
173
  /** Total Millitokens To Pay */
174
174
  mtokens: string;
175
+ /** Payment Forwarding Fee Rounded Up Tokens Number */
176
+ safe_fee: number;
177
+ /** Payment Tokens Rounded Up Number */
178
+ safe_tokens: number;
175
179
  /** Expiration Block Height */
176
180
  timeout: number;
177
181
  /** Total Tokens To Pay */
178
182
  tokens: number;
179
183
  };
180
- /** Payment Forwarding Fee Rounded Up Tokens */
181
- safe_fee: number;
182
- /** Payment Tokens Rounded Up */
183
- safe_tokens: number;
184
184
  /** Failure Related CLTV Timeout Height */
185
185
  timeout_height?: number;
186
186
  update?: {
@@ -198,8 +198,6 @@ export type SubscribeToPayViaRoutesRoutingFailureEvent = {
198
198
  };
199
199
 
200
200
  export type SubscribeToPayViaRoutesSuccessEvent = {
201
- /** Payment Sent At ISO 8601 Date */
202
- confirmed_at: string;
203
201
  /** Fee Paid Tokens */
204
202
  fee: number;
205
203
  /** Fee Paid Millitokens */
@@ -249,6 +247,10 @@ export type SubscribeToPayViaRoutesSuccessEvent = {
249
247
  }[];
250
248
  /** Total Millitokens To Pay */
251
249
  mtokens: string;
250
+ /** Payment Forwarding Fee Rounded Up Tokens Number */
251
+ safe_fee: number;
252
+ /** Payment Tokens Rounded Up Number */
253
+ safe_tokens: number;
252
254
  /** Expiration Block Height */
253
255
  timeout: number;
254
256
  /** Total Tokens To Pay */
@@ -2,13 +2,13 @@ import {
2
2
  AuthenticatedLightningArgs,
3
3
  AuthenticatedLightningMethod,
4
4
  } from '../../typescript';
5
- import {Xor} from '../../typescript/util';
5
+ import {MergeExclusive} from 'type-fest';
6
6
 
7
7
  export type UpdateConnectedWatchtowerArgs = AuthenticatedLightningArgs<
8
8
  {
9
9
  /** Watchtower Public Key Hex String */
10
10
  public_key: string;
11
- } & Xor<
11
+ } & MergeExclusive<
12
12
  {
13
13
  /** Add Socket String */
14
14
  add_socket: string;
@@ -2,9 +2,9 @@ import {
2
2
  AuthenticatedLightningArgs,
3
3
  AuthenticatedLightningMethod,
4
4
  } from '../../typescript';
5
- import {Xor} from '../../typescript/util';
5
+ import {MergeExclusive} from 'type-fest';
6
6
 
7
- type BaseFeeTokens = Xor<
7
+ type BaseFeeTokens = MergeExclusive<
8
8
  {
9
9
  /** Base Fee Millitokens Charged */
10
10
  base_fee_mtokens?: string;
@@ -2,9 +2,9 @@ import {
2
2
  AuthenticatedLightningArgs,
3
3
  AuthenticatedLightningMethod,
4
4
  } from '../../typescript';
5
- import {Xor} from '../../typescript/util';
5
+ import {MergeExclusive} from 'type-fest';
6
6
 
7
- type ExpectedIdOfChannelToClose = Xor<
7
+ type ExpectedIdOfChannelToClose = MergeExclusive<
8
8
  {
9
9
  /** Standard Format Channel Id String */
10
10
  id: string;
@@ -17,7 +17,7 @@ type ExpectedIdOfChannelToClose = Xor<
17
17
  }
18
18
  >;
19
19
 
20
- type UnexpectedTokensPerVbyteForChannelClose = Xor<
20
+ type UnexpectedTokensPerVbyteForChannelClose = MergeExclusive<
21
21
  {
22
22
  /** Confirmation Target Number */
23
23
  target_confirmations?: number;
@@ -28,7 +28,7 @@ type UnexpectedTokensPerVbyteForChannelClose = Xor<
28
28
  }
29
29
  >;
30
30
 
31
- type ExpectedBothPublicKeyAndSocketForChannelClose = Xor<
31
+ type ExpectedBothPublicKeyAndSocketForChannelClose = MergeExclusive<
32
32
  {
33
33
  /** Peer Public Key String */
34
34
  public_key: string;
@@ -53,7 +53,10 @@ export type CoopCloseChannelArgs = AuthenticatedLightningArgs<
53
53
  UnexpectedTokensPerVbyteForChannelClose
54
54
  >;
55
55
 
56
- export type CloseChannelArgs = Xor<ForceCloseChannelArgs, CoopCloseChannelArgs>;
56
+ export type CloseChannelArgs = MergeExclusive<
57
+ ForceCloseChannelArgs,
58
+ CoopCloseChannelArgs
59
+ >;
57
60
 
58
61
  export type CloseChannelResult = {
59
62
  /** Closing Transaction Id Hex */
@@ -24,32 +24,32 @@ const type = 'default';
24
24
 
25
25
  @returns via cbk or Promise
26
26
  */
27
- module.exports = ({channels, funding, lnd}, cbk) => {
27
+ module.exports = (args, cbk) => {
28
28
  return new Promise((resolve, reject) => {
29
29
  return asyncAuto({
30
30
  // Check arguments
31
31
  validate: cbk => {
32
- if (!isArray(channels)) {
32
+ if (!isArray(args.channels)) {
33
33
  return cbk([400, 'ExpectedPendingChannelIdsToFundChannels']);
34
34
  }
35
35
 
36
- if (!channels.length) {
36
+ if (!args.channels.length) {
37
37
  return cbk([400, 'ExpectedPendingChannelIdsToFund']);
38
38
  }
39
39
 
40
- if (channels.filter(n => !n).length) {
40
+ if (args.channels.filter(n => !n).length) {
41
41
  return cbk([400, 'ExpectedNonEmptyPendingChannelIdsToFund']);
42
42
  }
43
43
 
44
- if (!!channels.find(n => !isHash(n))) {
44
+ if (!!args.channels.find(n => !isHash(n))) {
45
45
  return cbk([400, 'ExpectedPendingChannelIdOfChannelToFund']);
46
46
  }
47
47
 
48
- if (!isHex(funding)) {
48
+ if (!isHex(args.funding)) {
49
49
  return cbk([400, 'ExpectedFundingPsbtToFundChannel']);
50
50
  }
51
51
 
52
- if (!isLnd({lnd, method, type})) {
52
+ if (!isLnd({method, type, lnd: args.lnd})) {
53
53
  return cbk([400, 'ExpectedAuthenticatedLndToFundChannels']);
54
54
  }
55
55
 
@@ -57,12 +57,12 @@ module.exports = ({channels, funding, lnd}, cbk) => {
57
57
  },
58
58
 
59
59
  // Funded and signed PSBT
60
- psbt: ['validate', ({}, cbk) => cbk(null, bufferFromHex(funding))],
60
+ psbt: ['validate', ({}, cbk) => cbk(null, bufferFromHex(args.funding))],
61
61
 
62
62
  // Verify the funding for each pending channel
63
63
  verify: ['psbt', 'validate', ({psbt}, cbk) => {
64
- return asyncEach(channels, (id, cbk) => {
65
- return lnd[type][method]({
64
+ return asyncEach(args.channels, (id, cbk) => {
65
+ return args.lnd[type][method]({
66
66
  psbt_verify: {
67
67
  funded_psbt: psbt,
68
68
  pending_chan_id: bufferFromHex(id),
@@ -81,10 +81,10 @@ module.exports = ({channels, funding, lnd}, cbk) => {
81
81
 
82
82
  // Finalize the psbts
83
83
  finalize: ['psbt', 'verify', ({psbt}, cbk) => {
84
- const [lastChannel] = channels.slice().reverse();
84
+ const [lastChannel] = args.channels.slice().reverse();
85
85
 
86
- return asyncEachSeries(channels, (id, cbk) => {
87
- return lnd[type][method]({
86
+ return asyncEachSeries(args.channels, (id, cbk) => {
87
+ return args.lnd[type][method]({
88
88
  psbt_finalize: {
89
89
  no_publish: id !== lastChannel,
90
90
  pending_chan_id: bufferFromHex(id),
@@ -2,7 +2,7 @@ import {
2
2
  AuthenticatedLightningArgs,
3
3
  AuthenticatedLightningMethod,
4
4
  } from '../../typescript';
5
- import {Xor} from '../../typescript/util';
5
+ import {MergeExclusive} from 'type-fest';
6
6
 
7
7
  export type FundPsbtArgs = AuthenticatedLightningArgs<
8
8
  {
@@ -20,7 +20,7 @@ export type FundPsbtArgs = AuthenticatedLightningArgs<
20
20
 
21
21
  /** Confirmations To Wait */
22
22
  target_confirmations?: number;
23
- } & Xor<
23
+ } & MergeExclusive<
24
24
  {
25
25
  /** Existing PSBT Hex */
26
26
  psbt: string;
@@ -26,11 +26,11 @@ const type = 'default';
26
26
  [give_tokens]: <Tokens to Gift To Partner Number> // Defaults to zero
27
27
  [is_private]: <Channel is Private Bool> // Defaults to false
28
28
  lnd: <Authenticated LND API Object>
29
- local_tokens: <Local Tokens Number>
29
+ local_tokens: <Total Channel Capacity Tokens Number>
30
30
  [min_confirmations]: <Spend UTXOs With Minimum Confirmations Number>
31
31
  [min_htlc_mtokens]: <Minimum HTLC Millitokens String>
32
- partner_public_key: <Public Key Hex String>
33
32
  [partner_csv_delay]: <Peer Output CSV Delay Number>
33
+ partner_public_key: <Public Key Hex String>
34
34
  [partner_socket]: <Peer Connection Host:Port String>
35
35
  }
36
36
 
@@ -22,6 +22,8 @@ export type OpenChannelsArgs = AuthenticatedLightningArgs<{
22
22
  /** Peer Connection Host:Port */
23
23
  partner_socket?: string;
24
24
  }[];
25
+ /** Do not broadcast any channel funding transactions */
26
+ is_avoiding_broadcast?: boolean;
25
27
  }>;
26
28
 
27
29
  export type OpenChannelsResult = {
@@ -29,6 +29,9 @@ const type = 'default';
29
29
  If you do not fund the channels, be sure to `cancelPendingChannel` on each
30
30
  channel that was not funded.
31
31
 
32
+ Use `is_avoiding_broadcast` only when self-publishing the raw transaction
33
+ after the funding step.
34
+
32
35
  {
33
36
  channels: [{
34
37
  capacity: <Channel Capacity Tokens Number>
@@ -36,10 +39,11 @@ const type = 'default';
36
39
  [give_tokens]: <Tokens to Gift To Partner Number> // Defaults to zero
37
40
  [is_private]: <Channel is Private Bool> // Defaults to false
38
41
  [min_htlc_mtokens]: <Minimum HTLC Millitokens String>
39
- partner_public_key: <Public Key Hex String>
40
42
  [partner_csv_delay]: <Peer Output CSV Delay Number>
43
+ partner_public_key: <Public Key Hex String>
41
44
  [partner_socket]: <Peer Connection Host:Port String>
42
45
  }]
46
+ [is_avoiding_broadcast]: <Avoid Broadcast of All Channels Bool>
43
47
  lnd: <Authenticated LND API Object>
44
48
  }
45
49
 
@@ -52,28 +56,28 @@ const type = 'default';
52
56
  }]
53
57
  }
54
58
  */
55
- module.exports = ({channels, lnd}, cbk) => {
59
+ module.exports = (args, cbk) => {
56
60
  return new Promise((resolve, reject) => {
57
61
  return asyncAuto({
58
62
  // Check arguments
59
63
  validate: cbk => {
60
- if (!isArray(channels)) {
64
+ if (!isArray(args.channels)) {
61
65
  return cbk([400, 'ExpectedChannelsToOpenChannels']);
62
66
  }
63
67
 
64
- if (channels.filter(n => !!n).length !== channels.length) {
68
+ if (args.channels.filter(n => !!n).length !== args.channels.length) {
65
69
  return cbk([400, 'ExpectedChannelDetailsToOpenChannels']);
66
70
  }
67
71
 
68
- if (!!channels.find(n => !n.capacity)) {
72
+ if (!!args.channels.find(n => !n.capacity)) {
69
73
  return cbk([400, 'ExpectedCapacityOfChannelsToOpenChannels']);
70
74
  }
71
75
 
72
- if (!!channels.find(n => !isPublicKey(n.partner_public_key))) {
76
+ if (!!args.channels.find(n => !isPublicKey(n.partner_public_key))) {
73
77
  return cbk([400, 'ExpectedPeerPublicKeyToOpenChannels']);
74
78
  }
75
79
 
76
- if (!isLnd({lnd, method, type})) {
80
+ if (!isLnd({method, type, lnd: args.lnd})) {
77
81
  return cbk([400, 'ExpectedAuthenticatedLndToOpenChannels']);
78
82
  }
79
83
 
@@ -82,7 +86,7 @@ module.exports = ({channels, lnd}, cbk) => {
82
86
 
83
87
  // Channels to open
84
88
  toOpen: ['validate', ({}, cbk) => {
85
- return cbk(null, channels.map(channel => ({
89
+ return cbk(null, args.channels.map(channel => ({
86
90
  capacity: channel.capacity,
87
91
  id: makeId(),
88
92
  cooperative_close_address: channel.cooperative_close_address,
@@ -101,11 +105,13 @@ module.exports = ({channels, lnd}, cbk) => {
101
105
 
102
106
  return asyncMap(toOpen, (channel, cbk) => {
103
107
  let isDone = false;
108
+ const isSelfPublish = !!args.is_avoiding_broadcast;
104
109
 
105
- const channelOpen = lnd[type][method]({
110
+ const channelOpen = args.lnd[type][method]({
111
+ close_address: channel.cooperative_close_address || undefined,
106
112
  funding_shim: {
107
113
  psbt_shim: {
108
- no_publish: !channel.id.equals(lastChannel),
114
+ no_publish: !!isSelfPublish || !channel.id.equals(lastChannel),
109
115
  pending_chan_id: channel.id,
110
116
  },
111
117
  },
@@ -183,7 +189,7 @@ module.exports = ({channels, lnd}, cbk) => {
183
189
  return asyncEach(toOpen, (channel, cbk) => {
184
190
  const id = hexFromBuffer(channel.id);
185
191
 
186
- return cancelPendingChannel({id, lnd}, () => cbk());
192
+ return cancelPendingChannel({id, lnd: args.lnd}, () => cbk());
187
193
  },
188
194
  () => {
189
195
  return cbk([503, 'UnexpectedErrorOpeningChannels', {err}]);
@@ -2,7 +2,7 @@ import {
2
2
  AuthenticatedLightningArgs,
3
3
  AuthenticatedLightningMethod,
4
4
  } from '../../typescript';
5
- import {Xor} from '../../typescript/util';
5
+ import {MergeExclusive} from 'type-fest';
6
6
 
7
7
  export type RequestChainFeeIncreaseArgs = AuthenticatedLightningArgs<
8
8
  {
@@ -10,7 +10,7 @@ export type RequestChainFeeIncreaseArgs = AuthenticatedLightningArgs<
10
10
  transaction_id: string;
11
11
  /** Unconfirmed UTXO Transaction Index Number */
12
12
  transaction_vout: number;
13
- } & Xor<
13
+ } & MergeExclusive<
14
14
  {
15
15
  /** Chain Fee Tokens Per Virtual Byte Number */
16
16
  fee_tokens_per_vbyte: number;
@@ -1,11 +1,11 @@
1
- import {Xor} from '../../typescript/util';
1
+ import {MergeExclusive} from 'type-fest';
2
2
 
3
- export type ScriptFromChainAddressArgs = Xor<
3
+ export type ScriptFromChainAddressArgs = MergeExclusive<
4
4
  {
5
5
  /** Address String */
6
6
  bech32_address: string;
7
7
  },
8
- Xor<
8
+ MergeExclusive<
9
9
  {
10
10
  /** Address String */
11
11
  p2pkh_address: string;
@@ -4,9 +4,9 @@ import {
4
4
  AuthenticatedLightningMethod,
5
5
  LightningError,
6
6
  } from '../../typescript';
7
- import {Xor} from '../../typescript/util';
7
+ import {MergeExclusive} from 'type-fest';
8
8
 
9
- type ExpectedNoTokensSpecifiedWhenSendingAllFunds = Xor<
9
+ type ExpectedNoTokensSpecifiedWhenSendingAllFunds = MergeExclusive<
10
10
  {
11
11
  /** Tokens To Send */
12
12
  tokens: number;
@@ -16,7 +16,7 @@ type ExpectedNoTokensSpecifiedWhenSendingAllFunds = Xor<
16
16
  is_send_all: true;
17
17
  }
18
18
  >;
19
- type ExpectedLogFunctionForChainSendSocketAnnounce = Xor<
19
+ type ExpectedLogFunctionForChainSendSocketAnnounce = MergeExclusive<
20
20
  {
21
21
  /** Web Socket Servers */
22
22
  wss: ws.Server[];
@@ -4,9 +4,9 @@ import {
4
4
  AuthenticatedLightningMethod,
5
5
  LightningError,
6
6
  } from '../../typescript';
7
- import {Xor} from '../../typescript/util';
7
+ import {MergeExclusive} from 'type-fest';
8
8
 
9
- type ExpectedLogForChainSendWebSocketAnnouncement = Xor<
9
+ type ExpectedLogForChainSendWebSocketAnnouncement = MergeExclusive<
10
10
  {
11
11
  /** Web Socket Servers */
12
12
  wss: ws.Server[];
@@ -2,7 +2,7 @@ import {
2
2
  AuthenticatedLightningArgs,
3
3
  AuthenticatedLightningMethod,
4
4
  } from '../../typescript';
5
- import {Xor} from '../../typescript/util';
5
+ import {MergeExclusive} from 'type-fest';
6
6
 
7
7
  export type SendToChainOutputScriptsArgs = AuthenticatedLightningArgs<{
8
8
  /** Transaction Label String */
@@ -2,7 +2,7 @@ import {
2
2
  AuthenticatedLightningArgs,
3
3
  AuthenticatedLightningMethod,
4
4
  } from '../../typescript';
5
- import {Xor} from '../../typescript/util';
5
+ import {MergeExclusive} from 'type-fest';
6
6
 
7
7
  export type CandidateNode = {
8
8
  /** Node Public Key Hex */
@@ -22,7 +22,10 @@ type ExpectedNodesOrEnabledSettingToAdjustAutopilot =
22
22
  };
23
23
 
24
24
  export type SetAutopilotArgs = AuthenticatedLightningArgs<
25
- Xor<ExpectedNodesOrEnabledSettingToAdjustAutopilot, {is_enabled: false}>
25
+ MergeExclusive<
26
+ ExpectedNodesOrEnabledSettingToAdjustAutopilot,
27
+ {is_enabled: false}
28
+ >
26
29
  >;
27
30
 
28
31
  /**
@@ -2,10 +2,10 @@ import {
2
2
  AuthenticatedLightningArgs,
3
3
  AuthenticatedLightningSubscription,
4
4
  } from '../../typescript';
5
- import {Xor} from '../../typescript/util';
5
+ import {MergeExclusive} from 'type-fest';
6
6
  import {ScriptFromChainAddressArgs} from './script_from_chain_address';
7
7
 
8
- type ExpectedChainAddressToSubscribeForConfirmationEvents = Xor<
8
+ type ExpectedChainAddressToSubscribeForConfirmationEvents = MergeExclusive<
9
9
  {
10
10
  /** Output Script Hex */
11
11
  output_script: string;
@@ -2,10 +2,10 @@ import {
2
2
  AuthenticatedLightningArgs,
3
3
  AuthenticatedLightningSubscription,
4
4
  } from '../../typescript';
5
- import {Xor} from '../../typescript/util';
5
+ import {MergeExclusive} from 'type-fest';
6
6
  import {ScriptFromChainAddressArgs} from './script_from_chain_address';
7
7
 
8
- type ExpectOutputScriptOrAddress = Xor<
8
+ type ExpectOutputScriptOrAddress = MergeExclusive<
9
9
  {
10
10
  /** Output Script AKA ScriptPub Hex */
11
11
  output_script: string;
@@ -80,6 +80,7 @@ const outpointSeparator = ':';
80
80
  @returns
81
81
  {
82
82
  pending_channels: [{
83
+ capacity: <Channel Capacity Tokens Number>
83
84
  [close_transaction_id]: <Channel Closing Transaction Id String>
84
85
  is_active: <Channel Is Active Bool>
85
86
  is_closing: <Channel Is Closing Bool>
@@ -285,6 +286,7 @@ module.exports = args => {
285
286
  const pendingTokens = wait.pending_balance || forced.pending_balance;
286
287
 
287
288
  return {
289
+ capacity: Number(channel.capacity),
288
290
  close_transaction_id: endTx || undefined,
289
291
  is_active: false,
290
292
  is_closing: !chanOpen,
package/package.json CHANGED
@@ -10,12 +10,12 @@
10
10
  "@grpc/grpc-js": "1.4.4",
11
11
  "@grpc/proto-loader": "0.6.7",
12
12
  "@types/express": "4.17.13",
13
- "@types/node": "16.11.9",
13
+ "@types/node": "16.11.12",
14
14
  "@types/request": "2.48.7",
15
- "@types/ws": "8.2.0",
15
+ "@types/ws": "8.2.2",
16
16
  "async": "3.2.2",
17
17
  "asyncjs-util": "1.2.7",
18
- "bitcoinjs-lib": "6.0.0",
18
+ "bitcoinjs-lib": "6.0.1",
19
19
  "bn.js": "5.2.0",
20
20
  "body-parser": "1.19.0",
21
21
  "bolt07": "1.7.4",
@@ -23,7 +23,8 @@
23
23
  "cbor": "8.1.0",
24
24
  "express": "4.17.1",
25
25
  "invoices": "2.0.2",
26
- "psbt": "1.1.10"
26
+ "psbt": "1.1.10",
27
+ "type-fest": "2.8.0"
27
28
  },
28
29
  "description": "Lightning Network client library",
29
30
  "devDependencies": {
@@ -31,10 +32,10 @@
31
32
  "@alexbosworth/tap": "15.0.10",
32
33
  "tsd": "0.19.0",
33
34
  "typescript": "4.5.2",
34
- "ws": "8.2.3"
35
+ "ws": "8.3.0"
35
36
  },
36
37
  "engines": {
37
- "node": ">=12"
38
+ "node": ">=12.20"
38
39
  },
39
40
  "keywords": [
40
41
  "grpc",
@@ -56,5 +57,5 @@
56
57
  "directory": "test/typescript"
57
58
  },
58
59
  "types": "index.d.ts",
59
- "version": "5.0.0"
60
+ "version": "5.2.0"
60
61
  }
@@ -99,6 +99,7 @@ const makeArgs = overrides => {
99
99
 
100
100
  const makeExpectedPending = overrides => {
101
101
  const res = {
102
+ capacity: 1,
102
103
  close_transaction_id: Buffer.alloc(32).toString('hex'),
103
104
  is_active: false,
104
105
  is_closing: true,
@@ -8,9 +8,9 @@ const p2wpkh = 'p2wpkh';
8
8
 
9
9
  expectError(createChainAddress());
10
10
  expectError(createChainAddress({}));
11
- expectError(createChainAddress({}));
12
11
  expectError(createChainAddress({lnd, format: 'invalidFormat'}));
13
12
 
13
+ expectType<CreateChainAddressResult>(await createChainAddress({lnd}));
14
14
  expectType<CreateChainAddressResult>(
15
15
  await createChainAddress({lnd, format: np2wpkh})
16
16
  );
@@ -18,6 +18,11 @@ expectType<CreateChainAddressResult>(
18
18
  await createChainAddress({lnd, format: p2wpkh})
19
19
  );
20
20
 
21
+ expectType<void>(
22
+ createChainAddress({lnd}, (error, result) => {
23
+ expectType<CreateChainAddressResult>(result);
24
+ })
25
+ );
21
26
  expectType<void>(
22
27
  createChainAddress({lnd, format: np2wpkh}, (error, result) => {
23
28
  expectType<CreateChainAddressResult>(result);
@@ -1,6 +1,6 @@
1
1
  import * as events from 'events';
2
+ import {MergeExclusive} from 'type-fest';
2
3
  import {AuthenticatedLnd, UnauthenticatedLnd} from '../lnd_grpc';
3
- import {Xor} from './util';
4
4
 
5
5
  export type EmptyObject = {[key: string]: never};
6
6
 
@@ -84,7 +84,7 @@ export type PaymentState =
84
84
  | 'FAILED_TIMEOUT';
85
85
  export type PaymentStatus = CommonStatus | 'UNKNOWN';
86
86
 
87
- export type PaginationArgs = Xor<
87
+ export type PaginationArgs = MergeExclusive<
88
88
  {
89
89
  /** Page Result Limit */
90
90
  limit?: number;
@@ -1,7 +0,0 @@
1
- type Without<T, U> = {
2
- [KeyType in Exclude<keyof T, keyof U>]?: never;
3
- };
4
-
5
- export type Xor<T, U> = T | U extends object
6
- ? (Without<T, U> & U) | (Without<U, T> & T)
7
- : T | U;