lightning 10.3.1 → 10.4.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,9 @@
1
1
  # Versions
2
2
 
3
+ ## 10.4.0
4
+
5
+ - `getConnectedWatchtowers`: Add `is_taproot` to get P2TR channels
6
+
3
7
  ## 10.3.1
4
8
 
5
9
  - `getConfiguration`: Add method to get the configuration file options
@@ -193,6 +193,9 @@ enum PolicyType {
193
193
 
194
194
  // Selects the policy from the anchor tower client.
195
195
  ANCHOR = 1;
196
+
197
+ // Selects the policy from the taproot tower client.
198
+ TAPROOT = 2;
196
199
  }
197
200
 
198
201
  message PolicyRequest {
@@ -6,6 +6,8 @@ import {
6
6
  export type GetConnectedWatchTowersArgs = AuthenticatedLightningArgs<{
7
7
  /** Get Anchor Type Tower Info Bool */
8
8
  is_anchor?: boolean;
9
+ /** Get Taproot Type Tower Info Bool */
10
+ is_taproot?: boolean;
9
11
  }>;
10
12
 
11
13
  export type GetConnectedWatchTowersResult = {
@@ -53,6 +55,8 @@ export type GetConnectedWatchTowersResult = {
53
55
  * Requires `offchain:read` permission
54
56
  *
55
57
  * `is_anchor` flag is not supported on LND 0.11.1 and below
58
+ *
59
+ * `is_taproot` flag is not supported on LND 0.17.3 and below
56
60
  */
57
61
  export const getConnectedWatchtowers: AuthenticatedLightningMethod<
58
62
  GetConnectedWatchTowersArgs,
@@ -18,8 +18,11 @@ const unimplementedError = '12 UNIMPLEMENTED: unknown service wtclientrpc.Watcht
18
18
 
19
19
  `is_anchor` flag is not supported on LND 0.11.1 and below
20
20
 
21
+ `is_taproot` flag is not supported on LND 0.17.3 and below
22
+
21
23
  {
22
24
  [is_anchor]: <Get Anchor Type Tower Info Bool>
25
+ [is_taproot]: <Get Taproot Type Tower Info Bool>
23
26
  lnd: <Authenticated LND API Object>
24
27
  }
25
28
 
@@ -57,39 +60,6 @@ module.exports = (args, cbk) => {
57
60
  return cbk();
58
61
  },
59
62
 
60
- // Get policy
61
- getPolicy: ['validate', ({}, cbk) => {
62
- return args.lnd[type].policy({
63
- policy_type: !!args.is_anchor ? 'ANCHOR' : 'LEGACY',
64
- },
65
- (err, res) => {
66
- if (!!err && err.message === unimplementedError) {
67
- return cbk([503, 'ExpectedWatchtowerClientLndToGetPolicy']);
68
- }
69
-
70
- if (!!err) {
71
- return cbk([503, 'UnexpectedErrorGettingWatchtowerPolicy', {err}]);
72
- }
73
-
74
- if (!res) {
75
- return cbk([503, 'ExpectedResultForWatchtowerPolicy']);
76
- }
77
-
78
- if (res.max_updates === undefined) {
79
- return cbk([503, 'ExpectedMaxUpdateCountInWatchtowerPolicyInfo']);
80
- }
81
-
82
- if (res.sweep_sat_per_byte === undefined) {
83
- return cbk([503, 'ExpectedSweepSatsPerByteInWatchtowerPolicy']);
84
- }
85
-
86
- return cbk(null, {
87
- max_session_update_count: res.max_updates,
88
- sweep_tokens_per_vbyte: res.sweep_sat_per_byte,
89
- });
90
- });
91
- }],
92
-
93
63
  // Get stats
94
64
  getStats: ['validate', ({}, cbk) => {
95
65
  return args.lnd[type].stats({}, (err, res) => {
@@ -181,6 +151,49 @@ module.exports = (args, cbk) => {
181
151
  });
182
152
  }],
183
153
 
154
+ // Determine the policy type
155
+ policyType: ['validate', ({}, cbk) => {
156
+ if (!!args.is_anchor) {
157
+ return cbk(null, 'ANCHOR');
158
+ }
159
+
160
+ if (!!args.is_taproot) {
161
+ return cbk(null, 'TAPROOT');
162
+ }
163
+
164
+ return cbk(null, 'LEGACY');
165
+ }],
166
+
167
+ // Get policy
168
+ getPolicy: ['policyType', ({policyType}, cbk) => {
169
+ return args.lnd[type].policy({policy_type: policyType}, (err, res) => {
170
+ if (!!err && err.message === unimplementedError) {
171
+ return cbk([503, 'ExpectedWatchtowerClientLndToGetPolicy']);
172
+ }
173
+
174
+ if (!!err) {
175
+ return cbk([503, 'UnexpectedErrorGettingWatchtowerPolicy', {err}]);
176
+ }
177
+
178
+ if (!res) {
179
+ return cbk([503, 'ExpectedResultForWatchtowerPolicy']);
180
+ }
181
+
182
+ if (res.max_updates === undefined) {
183
+ return cbk([503, 'ExpectedMaxUpdateCountInWatchtowerPolicyInfo']);
184
+ }
185
+
186
+ if (res.sweep_sat_per_byte === undefined) {
187
+ return cbk([503, 'ExpectedSweepSatsPerByteInWatchtowerPolicy']);
188
+ }
189
+
190
+ return cbk(null, {
191
+ max_session_update_count: res.max_updates,
192
+ sweep_tokens_per_vbyte: res.sweep_sat_per_byte,
193
+ });
194
+ });
195
+ }],
196
+
184
197
  // Connected watchtowers
185
198
  watchtowers: [
186
199
  'getPolicy',
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "invoices": "3.0.0",
23
23
  "psbt": "3.0.0",
24
24
  "tiny-secp256k1": "2.2.3",
25
- "type-fest": "4.9.0"
25
+ "type-fest": "4.10.0"
26
26
  },
27
27
  "description": "Lightning Network client library",
28
28
  "devDependencies": {
@@ -53,5 +53,5 @@
53
53
  "directory": "test/typescript"
54
54
  },
55
55
  "types": "index.d.ts",
56
- "version": "10.3.1"
56
+ "version": "10.4.0"
57
57
  }
@@ -198,7 +198,7 @@ const tests = [
198
198
  error: [503, 'ExpectedResultForWatchtowerListing'],
199
199
  },
200
200
  {
201
- args: {lnd: makeLnd({towersRes: {}})},
201
+ args: {is_taproot: true, lnd: makeLnd({towersRes: {}})},
202
202
  description: 'Towers array is expected',
203
203
  error: [503, 'ExpectedArrayOfTowersForWatchtowerListing'],
204
204
  },
@@ -7,6 +7,7 @@ import {
7
7
 
8
8
  const lnd = {} as AuthenticatedLnd;
9
9
  const is_anchor = true;
10
+ const is_taproot = true;
10
11
 
11
12
  expectError(getConnectedWatchtowers());
12
13
  expectError(getConnectedWatchtowers({}));
@@ -16,6 +17,9 @@ expectType<GetConnectedWatchTowersResult>(await getConnectedWatchtowers({lnd}));
16
17
  expectType<GetConnectedWatchTowersResult>(
17
18
  await getConnectedWatchtowers({lnd, is_anchor})
18
19
  );
20
+ expectType<GetConnectedWatchTowersResult>(
21
+ await getConnectedWatchtowers({lnd, is_taproot})
22
+ );
19
23
 
20
24
  expectType<void>(
21
25
  getConnectedWatchtowers({lnd}, (error, result) => {
@@ -27,3 +31,8 @@ expectType<void>(
27
31
  expectType<GetConnectedWatchTowersResult>(result);
28
32
  })
29
33
  );
34
+ expectType<void>(
35
+ getConnectedWatchtowers({lnd, is_taproot}, (error, result) => {
36
+ expectType<GetConnectedWatchTowersResult>(result);
37
+ })
38
+ );