lightning 9.11.0 → 9.11.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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Versions
2
2
 
3
- ## 9.11.0
3
+ ## 9.11.2
4
4
 
5
5
  - `openChannel`: Add `inputs` to select inputs for channel open funding
6
6
 
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  AuthenticatedLightningArgs,
3
3
  AuthenticatedLightningMethod,
4
+ Routes,
4
5
  } from '../../typescript';
5
6
 
6
7
  export type CreateHodlInvoiceArgs = AuthenticatedLightningArgs<{
@@ -22,6 +23,7 @@ export type CreateHodlInvoiceArgs = AuthenticatedLightningArgs<{
22
23
  is_including_private_channels?: boolean;
23
24
  /** Millitokens */
24
25
  mtokens?: string;
26
+ routes?: Routes;
25
27
  /** Tokens */
26
28
  tokens?: number;
27
29
  }>;
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  AuthenticatedLightningArgs,
3
3
  AuthenticatedLightningMethod,
4
+ Routes,
4
5
  } from '../../typescript';
5
6
 
6
7
  export type CreateInvoiceArgs = AuthenticatedLightningArgs<{
@@ -22,6 +23,7 @@ export type CreateInvoiceArgs = AuthenticatedLightningArgs<{
22
23
  secret?: string;
23
24
  /** Millitokens */
24
25
  mtokens?: string;
26
+ routes?: Routes;
25
27
  /** Tokens */
26
28
  tokens?: number;
27
29
  }>;
@@ -1,6 +1,7 @@
1
1
  import type {
2
2
  AuthenticatedLightningArgs,
3
3
  AuthenticatedLightningMethod,
4
+ Routes,
4
5
  } from '../../typescript';
5
6
 
6
7
  export type DecodePaymentRequestArgs = AuthenticatedLightningArgs<{
@@ -8,21 +9,6 @@ export type DecodePaymentRequestArgs = AuthenticatedLightningArgs<{
8
9
  request: string;
9
10
  }>;
10
11
 
11
- export type DecodePaymentRouteEdge = {
12
- /** Base Routing Fee In Millitokens */
13
- base_fee_mtokens?: string;
14
- /** Standard Format Channel Id */
15
- channel?: string;
16
- /** CLTV Blocks Delta */
17
- cltv_delta?: number;
18
- /** Fees Charged in Millitokens Per Million */
19
- fee_rate?: number;
20
- /** Forward Edge Public Key Hex */
21
- public_key: string;
22
- };
23
-
24
- export type DecodePaymentRoutes = DecodePaymentRouteEdge[][];
25
-
26
12
  export type DecodePaymentRequestResult = {
27
13
  /** Fallback Chain Address */
28
14
  chain_address: string;
@@ -52,7 +38,7 @@ export type DecodePaymentRequestResult = {
52
38
  mtokens: string;
53
39
  /** Payment Identifier Hex Encoded */
54
40
  payment?: string;
55
- routes: DecodePaymentRoutes;
41
+ routes: Routes;
56
42
  /** Requested Tokens Rounded Up */
57
43
  safe_tokens: number;
58
44
  /** Requested Tokens Rounded Down */
@@ -2,15 +2,15 @@ import type {MergeExclusive} from 'type-fest';
2
2
  import type {
3
3
  AuthenticatedLightningArgs,
4
4
  AuthenticatedLightningMethod,
5
+ RouteNode,
5
6
  } from '../../typescript';
6
- import type {DecodePaymentRouteEdge} from './decode_payment_request';
7
7
 
8
- export type ProbeForRouteRouteEdge = DecodePaymentRouteEdge & {
8
+ export type ProbeForRouteNode = RouteNode & {
9
9
  /** Channel Capacity Tokens Number */
10
10
  channel_capacity?: number;
11
11
  };
12
12
 
13
- export type ProbeForRouteRoutes = ProbeForRouteRouteEdge[][];
13
+ export type ProbeForRouteRoutes = ProbeForRouteNode[][];
14
14
 
15
15
  export type ProbeForRouteArgs = AuthenticatedLightningArgs<
16
16
  {
@@ -201,6 +201,7 @@ module.exports = args => {
201
201
 
202
202
  const emitter = new EventEmitter();
203
203
  const ignore = [];
204
+ let isErrored = false;
204
205
  let isFinal = false;
205
206
  let isTimedOut = false;
206
207
  const temporaryChannelFailures = [];
@@ -213,10 +214,13 @@ module.exports = args => {
213
214
  }
214
215
 
215
216
  const emitError = err => {
216
- if (!emitter.listenerCount('error')) {
217
+ if (isErrored || !emitter.listenerCount('error')) {
217
218
  return;
218
219
  }
219
220
 
221
+ // Safeguard against returning multiple errors
222
+ isErrored = true;
223
+
220
224
  return emitter.emit('error', err);
221
225
  };
222
226
 
@@ -3,6 +3,13 @@ import {
3
3
  AuthenticatedLightningMethod,
4
4
  } from '../../typescript';
5
5
 
6
+ export type ChannelOpenOptionsInput = {
7
+ /** Fund With Unspent Transaction Id Hex String */
8
+ transaction_id: string
9
+ /** Fund With Unspent Transaction Output Index Number */
10
+ transaction_vout: number
11
+ }
12
+
6
13
  export type ChannelOpenOptions = {
7
14
  /** Routing Base Fee Millitokens Charged String */
8
15
  base_fee_mtokens?: string;
@@ -16,6 +23,9 @@ export type ChannelOpenOptions = {
16
23
  fee_rate?: number;
17
24
  /** Tokens to Gift To Partner */
18
25
  give_tokens?: number;
26
+ inputs?: ChannelOpenOptionsInput[]
27
+ /** Use Maximal Chain Funds For Local Funding Bool */
28
+ is_max_funding?: boolean;
19
29
  /** Channel is Private */
20
30
  is_private?: boolean;
21
31
  /** Peer Should Avoid Waiting For Confirmation */
@@ -26,10 +36,10 @@ export type ChannelOpenOptions = {
26
36
  min_confirmations?: number;
27
37
  /** Minimum HTLC Millitokens */
28
38
  min_htlc_mtokens?: string;
29
- /** Public Key Hex */
30
- partner_public_key: string;
31
39
  /** Peer Output CSV Delay */
32
40
  partner_csv_delay?: number;
41
+ /** Public Key Hex */
42
+ partner_public_key: string;
33
43
  /** Peer Connection Host:Port */
34
44
  partner_socket?: string;
35
45
  };
@@ -54,8 +64,18 @@ export type OpenChannelResult = {
54
64
  *
55
65
  * External funding requires LND compiled with `walletrpc` build tag
56
66
  *
67
+ * `is_trusted_funding` is not supported on LND 0.15.0 and below and requires
68
+ * `--protocol.option-scid-alias` and `--protocol.zero-conf` set on both sides
69
+ * as well as a channel open request listener to accept the trusted funding.
70
+ *
57
71
  * `base_fee_mtokens` is not supported on LND 0.15.5 and below
58
72
  * `fee_rate` is not supported on LND 0.15.5 and below
73
+ *
74
+ * `is_max_funding` is not supported on LND 0.16.4 and below
75
+ *
76
+ * `description` is not supported on LND 0.16.4 and below
77
+ *
78
+ * `inputs` is not supported on LND 0.16.4 and below
59
79
  */
60
80
  export const openChannel: AuthenticatedLightningMethod<
61
81
  OpenChannelArgs,
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "@grpc/grpc-js": "1.9.0",
11
11
  "@grpc/proto-loader": "0.7.8",
12
12
  "@types/express": "4.17.17",
13
- "@types/node": "20.4.6",
13
+ "@types/node": "20.5.0",
14
14
  "@types/request": "2.48.8",
15
15
  "@types/ws": "8.5.5",
16
16
  "async": "3.2.4",
@@ -26,7 +26,7 @@
26
26
  "invoices": "3.0.0",
27
27
  "psbt": "3.0.0",
28
28
  "tiny-secp256k1": "2.2.3",
29
- "type-fest": "4.1.0"
29
+ "type-fest": "4.2.0"
30
30
  },
31
31
  "description": "Lightning Network client library",
32
32
  "devDependencies": {
@@ -59,5 +59,5 @@
59
59
  "directory": "test/typescript"
60
60
  },
61
61
  "types": "index.d.ts",
62
- "version": "9.11.0"
62
+ "version": "9.11.2"
63
63
  }
@@ -68,6 +68,11 @@ const tests = [
68
68
  description: 'Open request missing channel reserve',
69
69
  error: 'ExpectedChannelReserveForChannelRequest',
70
70
  },
71
+ {
72
+ args: makeArgs({commitment_type: undefined}),
73
+ description: 'Open request missing commitment type',
74
+ error: 'ExpectedCommitmentTypeForChannelRequest',
75
+ },
71
76
  {
72
77
  args: makeArgs({csv_delay: undefined}),
73
78
  description: 'Open request missing csv delay',
@@ -1,6 +1,7 @@
1
1
  import {expectError, expectType} from 'tsd';
2
2
  import {AuthenticatedLnd} from '../../lnd_grpc';
3
3
  import {createHodlInvoice, CreateHodlInvoiceResult} from '../../lnd_methods';
4
+ import {Routes} from '../../typescript';
4
5
 
5
6
  const lnd = {} as AuthenticatedLnd;
6
7
  const cltv_delta = 1;
@@ -12,6 +13,13 @@ const is_fallback_nested = true;
12
13
  const is_including_private_channels = true;
13
14
  const mtokens = '1000';
14
15
  const tokens = 1;
16
+ const routes: Routes = [[{
17
+ base_fee_mtokens: '1',
18
+ channel: '0',
19
+ cltv_delta: 1,
20
+ fee_rate: 1,
21
+ public_key: 'pubkey'
22
+ }]];
15
23
 
16
24
  expectError(createHodlInvoice());
17
25
  expectError(createHodlInvoice({}));
@@ -29,13 +37,13 @@ expectType<CreateHodlInvoiceResult>(
29
37
  is_including_private_channels,
30
38
  mtokens,
31
39
  tokens,
32
- })
40
+ })
33
41
  );
34
42
 
35
43
  expectType<void>(
36
44
  createHodlInvoice({lnd}, (error, result) => {
37
45
  expectType<CreateHodlInvoiceResult>(result);
38
- })
46
+ })
39
47
  );
40
48
  expectType<void>(
41
49
  createHodlInvoice(
@@ -49,10 +57,11 @@ expectType<void>(
49
57
  is_fallback_nested,
50
58
  is_including_private_channels,
51
59
  mtokens,
60
+ routes,
52
61
  tokens,
53
- },
62
+ },
54
63
  (error, result) => {
55
64
  expectType<CreateHodlInvoiceResult>(result);
56
- }
65
+ }
57
66
  )
58
67
  );
@@ -1,6 +1,7 @@
1
1
  import {expectError, expectType} from 'tsd';
2
2
  import {AuthenticatedLnd} from '../../lnd_grpc';
3
3
  import {createInvoice, CreateInvoiceResult} from '../../lnd_methods';
4
+ import {Routes} from '../../typescript';
4
5
 
5
6
  const lnd = {} as AuthenticatedLnd;
6
7
  const cltv_delta = 1;
@@ -12,6 +13,13 @@ const is_including_private_channels = true;
12
13
  const secret = Buffer.alloc(32).toString('hex');
13
14
  const mtokens = '1000';
14
15
  const tokens = 1;
16
+ const routes: Routes = [[{
17
+ base_fee_mtokens: '1',
18
+ channel: '0',
19
+ cltv_delta: 1,
20
+ fee_rate: 1,
21
+ public_key: 'pubkey'
22
+ }]];
15
23
 
16
24
  expectError(createInvoice());
17
25
  expectError(createInvoice({}));
@@ -29,13 +37,13 @@ expectType<CreateInvoiceResult>(
29
37
  secret,
30
38
  mtokens,
31
39
  tokens,
32
- })
40
+ })
33
41
  );
34
42
 
35
43
  expectType<void>(
36
44
  createInvoice({lnd}, (error, result) => {
37
45
  expectType<CreateInvoiceResult>(result);
38
- })
46
+ })
39
47
  );
40
48
  expectType<void>(
41
49
  createInvoice(
@@ -49,10 +57,11 @@ expectType<void>(
49
57
  is_including_private_channels,
50
58
  secret,
51
59
  mtokens,
60
+ routes,
52
61
  tokens,
53
- },
62
+ },
54
63
  (error, result) => {
55
64
  expectType<CreateInvoiceResult>(result);
56
- }
65
+ }
57
66
  )
58
67
  );
@@ -10,6 +10,9 @@ const chain_fee_tokens_per_vbyte = 1;
10
10
  const cooperative_close_address = 'close_address';
11
11
  const give_tokens = 1;
12
12
 
13
+ const is_max_funding = true;
14
+ const inputs = [{transaction_id: 'id', transaction_vout: 0}];
15
+
13
16
  expectError(openChannel());
14
17
  expectError(openChannel({}));
15
18
  expectError(openChannel({local_tokens}));
@@ -29,6 +32,8 @@ expectType<OpenChannelResult>(
29
32
  chain_fee_tokens_per_vbyte,
30
33
  cooperative_close_address,
31
34
  give_tokens,
35
+ is_max_funding,
36
+ inputs,
32
37
  })
33
38
  );
34
39
 
@@ -46,6 +51,8 @@ expectType<void>(
46
51
  chain_fee_tokens_per_vbyte,
47
52
  cooperative_close_address,
48
53
  give_tokens,
54
+ is_max_funding,
55
+ inputs,
49
56
  },
50
57
  (error, result) => {
51
58
  expectType<OpenChannelResult>(result);
@@ -101,3 +101,20 @@ export type DateRangeFilterArgs = {
101
101
  /** Creation Date Before or Equal to ISO 8601 Date String */
102
102
  created_before?: string;
103
103
  };
104
+
105
+ export type RouteNode = {
106
+ /** Base Routing Fee In Millitokens */
107
+ base_fee_mtokens?: string;
108
+ /** Standard Format Channel Id */
109
+ channel?: string;
110
+ /** CLTV Blocks Delta */
111
+ cltv_delta?: number;
112
+ /** Fees Charged in Millitokens Per Million */
113
+ fee_rate?: number;
114
+ /** Forward Edge Public Key Hex */
115
+ public_key: string;
116
+ }
117
+
118
+ export type Route = RouteNode[]
119
+
120
+ export type Routes = Route[]