lightning 10.13.1 → 10.14.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,6 +1,11 @@
1
1
  # Versions
2
2
 
3
- ## 10.13.1
3
+ ## 10.14.0
4
+
5
+ - `getChannel`: Add support for specifying `transaction_id` and
6
+ `transaction_vout` instead of `id`
7
+
8
+ ## 10.13.2
4
9
 
5
10
  - `getWalletInfo`: Add support for LND 0.18.0
6
11
 
@@ -3443,6 +3443,10 @@ message ChanInfoRequest {
3443
3443
  output index for the channel.
3444
3444
  */
3445
3445
  uint64 chan_id = 1 [jstype = JS_STRING];
3446
+
3447
+ // The channel point of the channel in format funding_txid:output_index. If
3448
+ // chan_id is specified, this field is ignored.
3449
+ string chan_point = 2;
3446
3450
  }
3447
3451
 
3448
3452
  message NetworkInfoRequest {
@@ -7,17 +7,28 @@ const {isLnd} = require('./../../lnd_requests');
7
7
 
8
8
  const edgeIsZombieErrorMessage = 'edge marked as zombie';
9
9
  const edgeNotFoundErrorMessage = 'edge not found';
10
+ const method = 'getChanInfo';
11
+ const type = 'default';
10
12
 
11
13
  /** Get graph information about a channel on the network
12
14
 
15
+ Either channel `id` or a `transaction_id` and `transaction_vout` is required
16
+
13
17
  Requires `info:read` permission
14
18
 
15
19
  `inbound_base_discount_mtokens` is not supported on LND 0.17.5 and below
20
+
16
21
  `inbound_rate_discount` is not supported on LND 0.17.5 and below
17
22
 
23
+ `transaction_id` is not supported on LND 0.18.0 and below
24
+
25
+ `transaction_vout` is not supported on LND 0.18.0 and below
26
+
18
27
  {
19
- id: <Standard Format Channel Id String>
28
+ [id]: <Standard Format Channel Id String>
20
29
  lnd: <Authenticated LND API Object>
30
+ [transaction_id]: <Funding Outpoint Transaction Id Hex String>
31
+ [transaction_vout]: <Funding Outpoint Transaction Output Index Number>
21
32
  }
22
33
 
23
34
  @returns via cbk or Promise
@@ -41,30 +52,45 @@ const edgeNotFoundErrorMessage = 'edge not found';
41
52
  [updated_at]: <Channel Last Updated At ISO 8601 Date String>
42
53
  }
43
54
  */
44
- module.exports = ({id, lnd}, cbk) => {
55
+ module.exports = (args, cbk) => {
45
56
  return new Promise((resolve, reject) => {
46
57
  return asyncAuto({
47
58
  // Check arguments
48
59
  validate: cbk => {
49
- try {
50
- chanNumber({channel: id}).number
51
- } catch (err) {
52
- return cbk([400, 'ExpectedValidChannelIdToGetChannel', {err}]);
60
+ if (!!args.id && !!args.transaction_id) {
61
+ return cbk([400, 'ExpectedEitherChannelIdOrOutpointToGetChannel']);
62
+ }
63
+
64
+ if (!args.id && !args.transaction_id) {
65
+ return cbk([400, 'ExpectedChannelIdOrFundingOutpointToGetChannel']);
53
66
  }
54
67
 
55
- if (!isLnd({lnd, method: 'getChanInfo', type: 'default'})) {
68
+ if (!isLnd({lnd: args.lnd, method: 'getChanInfo', type: 'default'})) {
56
69
  return cbk([400, 'ExpectedLndToGetChannelDetails']);
57
70
  }
58
71
 
72
+ if (!!args.transaction_id && args.transaction_vout === undefined) {
73
+ return cbk([400, 'ExpectedChannelFundingOutputIndexToGetChannel']);
74
+ }
75
+
59
76
  return cbk();
60
77
  },
61
78
 
79
+ // Channel arguments
80
+ request: ['validate', ({}, cbk) => {
81
+ // Exit early when a channel id is specified
82
+ if (!!args.id) {
83
+ return cbk(null, {chan_id: chanNumber({channel: args.id}).number});
84
+ }
85
+
86
+ return cbk(null, {
87
+ chan_point: `${args.transaction_id}:${args.transaction_vout}`,
88
+ });
89
+ }],
90
+
62
91
  // Get channel
63
- getChannel: ['validate', ({}, cbk) => {
64
- return lnd.default.getChanInfo({
65
- chan_id: chanNumber({channel: id}).number,
66
- },
67
- (err, response) => {
92
+ getChannel: ['request', ({request}, cbk) => {
93
+ return args.lnd[type][method](request, (err, response) => {
68
94
  if (!!err && err.details === edgeIsZombieErrorMessage) {
69
95
  return cbk([404, 'FullChannelDetailsNotFound']);
70
96
  }
@@ -38,6 +38,10 @@ export type UpdateRoutingFeesArgs = AuthenticatedLightningArgs<
38
38
  max_htlc_mtokens?: string;
39
39
  /** Minimum HTLC Millitokens to Forward */
40
40
  min_htlc_mtokens?: string;
41
+ /** Inbound Fee Millitokens Reduction String */
42
+ inbound_base_discount_mtokens?: string;
43
+ /** Source Millitokens Per Million Discount Number */
44
+ inbound_rate_discount?: number;
41
45
  }
42
46
  >;
43
47
 
@@ -23,6 +23,10 @@ const type = 'default';
23
23
 
24
24
  `failures` are not returned on LND 0.13.4 and below
25
25
 
26
+ `inbound_base_discount_mtokens` is not supported on LND 0.17.5 and below
27
+
28
+ `inbound_rate_discount` is not supported on LND 0.17.5 and below
29
+
26
30
  Requires `offchain:write` permission
27
31
 
28
32
  {
@@ -0,0 +1,58 @@
1
+ import type {
2
+ AuthenticatedLightningArgs,
3
+ AuthenticatedLightningMethod,
4
+ } from '../../typescript';
5
+
6
+ export type CreateFundedPsbtArgs = AuthenticatedLightningArgs<{
7
+ /** Chain Fee Tokens Per Virtual Byte Number */
8
+ fee_tokens_per_vbyte?: number;
9
+ inputs?: Array<{
10
+ /** Sequence Number */
11
+ sequence?: number;
12
+ /** Unspent Transaction Id Hex String */
13
+ transaction_id: string;
14
+ /** Unspent Transaction Output Index Number */
15
+ transaction_vout: number;
16
+ }>;
17
+ /** Select Inputs With Minimum Confirmations Number */
18
+ min_confirmations?: number;
19
+ outputs?: Array<{
20
+ /** Use This Output For Change Bool */
21
+ is_change?: boolean;
22
+ /** Output Script Hex String> */
23
+ script: string;
24
+ /** Send Tokens Tokens Number */
25
+ tokens: number;
26
+ }>;
27
+ /** Blocks To Wait for Confirmation Number */
28
+ target_confirmations?: number;
29
+ /** Spendable Lock Time on Transaction Number */
30
+ timelock?: number;
31
+ /** Select Inputs Using Selection Methodology Type String */
32
+ utxo_selection?: string;
33
+ /** Transaction Version Number */
34
+ version?: number;
35
+ }>;
36
+
37
+ export interface CreateFundedPsbtResult {
38
+ /** Unsigned PSBT Hex String */
39
+ psbt: string;
40
+ }
41
+
42
+ /**
43
+ * Create an unsigned funded PSBT given inputs or outputs
44
+ *
45
+ * When specifying local inputs, they must be locked before using
46
+ *
47
+ * `utxo_selection` methods: 'largest', 'random'
48
+ *
49
+ * Requires `onchain:write` permission
50
+ *
51
+ * Requires LND built with `walletrpc` tag
52
+ *
53
+ * This method is not supported on LND 0.17.5 or below
54
+ */
55
+ export const createFundedPsbt: AuthenticatedLightningMethod<
56
+ CreateFundedPsbtArgs,
57
+ CreateFundedPsbtResult
58
+ >;
@@ -1,6 +1,7 @@
1
1
  export * from './broadcast_chain_transaction';
2
2
  export * from './cancel_pending_channel';
3
3
  export * from './close_channel';
4
+ export * from './create_funded_psbt';
4
5
  export * from './delete_chain_transaction';
5
6
  export * from './fund_pending_channels';
6
7
  export * from './fund_psbt';
package/package.json CHANGED
@@ -9,20 +9,20 @@
9
9
  "dependencies": {
10
10
  "@grpc/grpc-js": "1.10.8",
11
11
  "@grpc/proto-loader": "0.7.13",
12
- "@types/node": "20.12.13",
12
+ "@types/node": "20.14.2",
13
13
  "@types/request": "2.48.12",
14
14
  "@types/ws": "8.5.10",
15
15
  "async": "3.2.5",
16
16
  "asyncjs-util": "1.2.12",
17
17
  "bitcoinjs-lib": "6.1.5",
18
18
  "bn.js": "5.2.1",
19
- "bolt07": "1.8.4",
19
+ "bolt07": "1.9.2",
20
20
  "bolt09": "2.1.0",
21
21
  "ecpair": "2.1.0",
22
22
  "invoices": "3.0.0",
23
23
  "psbt": "3.0.0",
24
24
  "tiny-secp256k1": "2.2.3",
25
- "type-fest": "4.18.3"
25
+ "type-fest": "4.20.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.13.1"
56
+ "version": "10.14.0"
57
57
  }
@@ -8,13 +8,30 @@ const tests = [
8
8
  {
9
9
  args: {},
10
10
  description: 'An id for a channel is required',
11
- error: [400, 'ExpectedValidChannelIdToGetChannel'],
11
+ error: [400, 'ExpectedChannelIdOrFundingOutpointToGetChannel'],
12
12
  },
13
13
  {
14
14
  args: {id: 'id'},
15
15
  description: 'LND is required to get the channel',
16
16
  error: [400, 'ExpectedLndToGetChannelDetails'],
17
17
  },
18
+ {
19
+ args: {id: 'id', transaction_id: '00'},
20
+ description: 'Only one identifier is required to get channel',
21
+ error: [400, 'ExpectedEitherChannelIdOrOutpointToGetChannel'],
22
+ },
23
+ {
24
+ args: {
25
+ lnd: {
26
+ default: {
27
+ getChanInfo: ({}, cbk) => cbk({details: 'edge marked as zombie'}),
28
+ },
29
+ },
30
+ transaction_id: '00',
31
+ },
32
+ description: 'A transaction output index is required',
33
+ error: [400, 'ExpectedChannelFundingOutputIndexToGetChannel'],
34
+ },
18
35
  {
19
36
  args: {
20
37
  id: 'id',
@@ -154,6 +171,77 @@ const tests = [
154
171
  updated_at: new Date(1000).toISOString(),
155
172
  },
156
173
  },
174
+ {
175
+ args: {
176
+ lnd: {
177
+ default: {
178
+ getChanInfo: ({}, cbk) => {
179
+ return cbk(null, {
180
+ capacity: '1',
181
+ chan_point: `${Buffer.alloc(32).toString('hex')}:0`,
182
+ channel_id: '000000000',
183
+ node1_policy: {
184
+ disabled: true,
185
+ fee_base_msat: '1',
186
+ fee_rate_milli_msat: '1',
187
+ last_update: 1,
188
+ max_htlc_msat: '1',
189
+ min_htlc: '1',
190
+ time_lock_delta: 1,
191
+ },
192
+ node1_pub: Buffer.alloc(33).toString('hex'),
193
+ node2_policy: {
194
+ disabled: false,
195
+ fee_base_msat: '2',
196
+ fee_rate_milli_msat: '2',
197
+ last_update: 1,
198
+ max_htlc_msat: '2',
199
+ min_htlc: '2',
200
+ time_lock_delta: 2,
201
+ },
202
+ node2_pub: Buffer.alloc(33, 1).toString('hex'),
203
+ });
204
+ },
205
+ },
206
+ },
207
+ transaction_id: Buffer.alloc(32).toString('hex'),
208
+ transaction_vout: 0,
209
+ },
210
+ description: 'Gets graph channel details',
211
+ expected: {
212
+ capacity: 1,
213
+ id: '0x0x0',
214
+ policies: [
215
+ {
216
+ base_fee_mtokens: '1',
217
+ cltv_delta: 1,
218
+ fee_rate: 1,
219
+ inbound_base_discount_mtokens: '0',
220
+ inbound_rate_discount: 0,
221
+ is_disabled: true,
222
+ max_htlc_mtokens: '1',
223
+ min_htlc_mtokens: '1',
224
+ public_key: Buffer.alloc(33).toString('hex'),
225
+ updated_at: new Date(1000).toISOString(),
226
+ },
227
+ {
228
+ base_fee_mtokens: '2',
229
+ cltv_delta: 2,
230
+ fee_rate: 2,
231
+ inbound_base_discount_mtokens: '0',
232
+ inbound_rate_discount: 0,
233
+ is_disabled: false,
234
+ max_htlc_mtokens: '2',
235
+ min_htlc_mtokens: '2',
236
+ public_key: Buffer.alloc(33, 1).toString('hex'),
237
+ updated_at: new Date(1000).toISOString(),
238
+ },
239
+ ],
240
+ transaction_id: Buffer.alloc(32).toString('hex'),
241
+ transaction_vout: 0,
242
+ updated_at: new Date(1000).toISOString(),
243
+ },
244
+ },
157
245
  ];
158
246
 
159
247
  tests.forEach(({args, description, error, expected}) => {