lightning 4.14.4 → 5.0.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,17 @@
1
1
  # Versions
2
2
 
3
+ ## 5.0.0
4
+
5
+ - Removed support for determining the type of channel to support LND 0.14.0.
6
+
7
+ - `createChainAddress`: Make address format optional and add p2wpkh as default
8
+ - `sendToChainOutputScripts`: Fix specification of `fee_tokens_per_vbyte`
9
+
10
+ ### Breaking Changes
11
+
12
+ - `getChannels`, `getPendingChannels`, `subscribeToChannels`: Remove
13
+ attributes `is_anchor`, `is_static_remote_key`, `is_variable_remote_key`.
14
+
3
15
  ## 4.14.4
4
16
 
5
17
  - `getPayment`, `subscribeToPastPayment`: Add `pending` for pending payment details
@@ -12,7 +12,7 @@ export type CreateChainAddressArgs = AuthenticatedLightningArgs<{
12
12
 
13
13
  export type CreateChainAddressResult = {
14
14
  /** Chain Address */
15
- address: string;
15
+ address?: string;
16
16
  };
17
17
 
18
18
  /**
@@ -5,6 +5,7 @@ const addressFormats = require('./address_formats');
5
5
  const {isLnd} = require('./../../lnd_requests');
6
6
 
7
7
  const connectFailMessage = '14 UNAVAILABLE: Connect Failed';
8
+ const defaultAddressFormat = 'p2wpkh';
8
9
  const method = 'newAddress';
9
10
  const type = 'default';
10
11
 
@@ -13,7 +14,7 @@ const type = 'default';
13
14
  Requires `address:write` permission
14
15
 
15
16
  {
16
- format: <Receive Address Type String> // "np2wpkh" || "p2wpkh"
17
+ [format]: <Receive Address Type String> // "np2wpkh" || "p2wpkh"
17
18
  [is_unused]: <Get As-Yet Unused Address Bool>
18
19
  lnd: <Authenticated LND API Object>
19
20
  }
@@ -28,7 +29,7 @@ module.exports = (args, cbk) => {
28
29
  return asyncAuto({
29
30
  // Check arguments
30
31
  validate: cbk => {
31
- if (!args.format || addressFormats[args.format] === undefined) {
32
+ if (!!args.format && addressFormats[args.format] === undefined) {
32
33
  return cbk([400, 'ExpectedKnownAddressFormat']);
33
34
  }
34
35
 
@@ -41,11 +42,13 @@ module.exports = (args, cbk) => {
41
42
 
42
43
  // Type
43
44
  type: ['validate', ({}, cbk) => {
45
+ const format = args.format || defaultAddressFormat;
46
+
44
47
  if (!args.is_unused) {
45
- return cbk(null, addressFormats[args.format]);
48
+ return cbk(null, addressFormats[format]);
46
49
  }
47
50
 
48
- return cbk(null, addressFormats[`unused_${args.format}`]);
51
+ return cbk(null, addressFormats[`unused_${format}`]);
49
52
  }],
50
53
 
51
54
  // Get the address
@@ -31,7 +31,8 @@
31
31
  "86114c575c2dff9dff1e1bb4df961c64aea9fc1c": "0.10.4-beta",
32
32
  "d176d2d65fc06e6631c4dc9478592be8545a21de": "0.12.0-beta",
33
33
  "d233f61383f2f950aa06f5b09da5b0e78e784fae": "0.12.1-beta",
34
- "d62c575f8499a314eb27f12462d20500b6bda2c7": "0.10.3-beta"
34
+ "d62c575f8499a314eb27f12462d20500b6bda2c7": "0.10.3-beta",
35
+ "df0b82f0165f19bde8832bacd1e35544b0a2990d": "0.14.0-beta"
35
36
  },
36
37
  "weightedType": "weightedcomb",
37
38
  "wrongLnd": "12 UNIMPLEMENTED: unknown service autopilotrpc.Autopilot"
@@ -18,7 +18,7 @@ export type VerifyAccessResult = {
18
18
  /**
19
19
  * Verify an access token has a given set of permissions
20
20
  *
21
- * Note: this method is not supported in LND versions 0.13.3 and below
21
+ * Note: this method is not supported in LND versions 0.13.4 and below
22
22
  *
23
23
  * Requires `macaroon:read` permission
24
24
  */
@@ -14,7 +14,7 @@ const type = 'default';
14
14
 
15
15
  /** Verify an access token has a given set of permissions
16
16
 
17
- Note: this method is not supported in LND versions 0.13.3 and below
17
+ Note: this method is not supported in LND versions 0.13.4 and below
18
18
 
19
19
  Requires `macaroon:read` permission
20
20
 
@@ -40,8 +40,6 @@ export type GetChannelsResult = {
40
40
  is_partner_initiated: boolean;
41
41
  /** Channel Is Private */
42
42
  is_private: boolean;
43
- /** Remote Key Is Static */
44
- is_static_remote_key: boolean;
45
43
  /** Local Balance Tokens */
46
44
  local_balance: number;
47
45
  /** Local CSV Blocks Delay */
@@ -34,13 +34,10 @@ const type = 'default';
34
34
  [cooperative_close_delay_height]: <Deny Coop Close Until Height Number>
35
35
  id: <Standard Format Channel Id String>
36
36
  is_active: <Channel Active Bool>
37
- is_anchor: <Channel Supports Anchor Outputs Bool>
38
37
  is_closing: <Channel Is Closing Bool>
39
38
  is_opening: <Channel Is Opening Bool>
40
39
  is_partner_initiated: <Channel Partner Opened Channel Bool>
41
40
  is_private: <Channel Is Private Bool>
42
- is_static_remote_key: <Remote Key Is Static Bool>
43
- is_variable_remote_key: <Remote Key Is Variable Bool>
44
41
  local_balance: <Local Balance Tokens Number>
45
42
  [local_csv]: <Local CSV Blocks Delay Number>
46
43
  [local_dust]: <Remote Non-Enforceable Amount Tokens Number>
@@ -27,7 +27,6 @@ const type = 'default';
27
27
  pending_channels: [{
28
28
  [close_transaction_id]: <Channel Closing Transaction Id String>
29
29
  is_active: <Channel Is Active Bool>
30
- is_anchor: <Channel Is Anchor Channel Type Bool>
31
30
  is_closing: <Channel Is Closing Bool>
32
31
  is_opening: <Channel Is Opening Bool>
33
32
  is_partner_initiated: <Channel Partner Initiated Channel Bool>
@@ -21,7 +21,7 @@ export type SendMessageToPeerArgs =
21
21
  * If specified, message type is expected to be between 32768 and 65535
22
22
  * Message data should not be larger than 65533 bytes
23
23
  *
24
- * Note: this method is not supported in LND versions 0.13.3 and below
24
+ * Note: this method is not supported in LND versions 0.13.4 and below
25
25
  *
26
26
  * Requires `offchain:write` permission
27
27
  */
@@ -17,7 +17,7 @@ const type = 'default';
17
17
 
18
18
  Message data should not be larger than 65533 bytes
19
19
 
20
- Note: this method is not supported in LND versions 0.13.3 and below
20
+ Note: this method is not supported in LND versions 0.13.4 and below
21
21
 
22
22
  Requires `offchain:write` permission
23
23
 
@@ -89,8 +89,6 @@ export type SubscribeToChannelsChannelOpenedEvent = {
89
89
  is_partner_initiated: boolean;
90
90
  /** Channel Is Private */
91
91
  is_private: boolean;
92
- /** Remote Key Is Static */
93
- is_static_remote_key: boolean;
94
92
  /** Local Balance Tokens */
95
93
  local_balance: number;
96
94
  /** Local Initially Pushed Tokens */
@@ -83,13 +83,10 @@ const updateOpening = 'pending_open_channel';
83
83
  [cooperative_close_delay_height]: <Prevent Coop Close Until Height Number>
84
84
  id: <Standard Format Channel Id String>
85
85
  is_active: <Channel Active Bool>
86
- is_anchor: <Channel Supports Anchor Outputs Bool>
87
86
  is_closing: <Channel Is Closing Bool>
88
87
  is_opening: <Channel Is Opening Bool>
89
88
  is_partner_initiated: <Channel Partner Opened Channel Bool>
90
89
  is_private: <Channel Is Private Bool>
91
- is_static_remote_key: <Remote Key Is Static Bool>
92
- is_variable_remote_key: <Remote Key Is Variable Bool>
93
90
  local_balance: <Local Balance Tokens Number>
94
91
  local_given: <Local Initially Pushed Tokens Number>
95
92
  local_reserve: <Local Reserved Tokens Number>
@@ -11,8 +11,11 @@ const initialConfirmationCount = 0;
11
11
  const {isArray} = Array;
12
12
  const {isBuffer} = Buffer;
13
13
  const method = 'sendOutputs';
14
+ const minFeeRate = 1;
14
15
  const unconfirmedConfCount = 0;
15
16
  const type = 'wallet';
17
+ const weightPerKWeight = 1e3;
18
+ const weightPerVByte = 4;
16
19
 
17
20
  /** Send on-chain funds to multiple output scripts
18
21
 
@@ -58,6 +61,10 @@ module.exports = (args, cbk) => {
58
61
  },
59
62
 
60
63
  send: ['validate', ({}, cbk) => {
64
+ const feePerVByte = args.fee_tokens_per_vbyte || minFeeRate;
65
+
66
+ const feePerKw = feePerVByte * weightPerKWeight / weightPerVByte;
67
+
61
68
  return args.lnd[type][method]({
62
69
  label: args.description || undefined,
63
70
  min_confs: args.utxo_confirmations || undefined,
@@ -65,7 +72,7 @@ module.exports = (args, cbk) => {
65
72
  pk_script: hexAsBuffer(output.script),
66
73
  value: output.tokens.toString(),
67
74
  })),
68
- sat_per_byte: args.fee_tokens_per_vbyte || undefined,
75
+ sat_per_kw: feePerKw,
69
76
  spend_unconfirmed: args.utxo_confirmations === unconfirmedConfCount,
70
77
  },
71
78
  (err, res) => {
@@ -78,7 +85,7 @@ module.exports = (args, cbk) => {
78
85
  }
79
86
 
80
87
  try {
81
- fromBuffer(res.raw_tx).getId()
88
+ fromBuffer(res.raw_tx).getId();
82
89
  } catch (err) {
83
90
  return cbk([500, 'ExpectedRawTransactionInSendToOutputsResponse']);
84
91
  }
@@ -71,8 +71,6 @@ module.exports = ({lnd}) => {
71
71
 
72
72
  subscription.cancel();
73
73
 
74
- subscription.removeAllListeners();
75
-
76
74
  return;
77
75
  });
78
76
 
@@ -82,7 +82,6 @@ const outpointSeparator = ':';
82
82
  pending_channels: [{
83
83
  [close_transaction_id]: <Channel Closing Transaction Id String>
84
84
  is_active: <Channel Is Active Bool>
85
- is_anchor: <Channel Is Anchor Channel Type Bool>
86
85
  is_closing: <Channel Is Closing Bool>
87
86
  is_opening: <Channel Is Opening Bool>
88
87
  is_partner_initiated: <Channel Partner Initiated Channel Bool>
@@ -288,7 +287,6 @@ module.exports = args => {
288
287
  return {
289
288
  close_transaction_id: endTx || undefined,
290
289
  is_active: false,
291
- is_anchor: channel.commitment_type === anchorChannelType,
292
290
  is_closing: !chanOpen,
293
291
  is_opening: !!chanOpen,
294
292
  is_partner_initiated: channel.initiator === remoteInitiator,
@@ -74,13 +74,10 @@ const outpointDelimiter = ':';
74
74
  [cooperative_close_delay_height]: <Prevent Coop Close Until Height Number>
75
75
  id: <Standard Format Channel Id String>
76
76
  is_active: <Channel Active Bool>
77
- is_anchor: <Channel Supports Anchor Outputs Bool>
78
77
  is_closing: <Channel Is Closing Bool>
79
78
  is_opening: <Channel Is Opening Bool>
80
79
  is_partner_initiated: <Channel Partner Opened Channel Bool>
81
80
  is_private: <Channel Is Private Bool>
82
- is_static_remote_key: <Remote Key Is Static Bool>
83
- is_variable_remote_key: <Remote Key Is Variable Bool>
84
81
  local_balance: <Local Balance Tokens Number>
85
82
  local_csv: <Local CSV Blocks Delay Number>
86
83
  local_dust: <Remote Non-Enforceable Amount Tokens Number>
@@ -224,13 +221,10 @@ module.exports = args => {
224
221
  cooperative_close_delay_height: height,
225
222
  id: chanFormat({number: args.chan_id}).channel,
226
223
  is_active: args.active,
227
- is_anchor: chanType === commitmentTypes.anchor,
228
224
  is_closing: false,
229
225
  is_opening: false,
230
226
  is_partner_initiated: !args.initiator,
231
227
  is_private: args.private,
232
- is_static_remote_key: chanType === commitmentTypes.static_remote_key,
233
- is_variable_remote_key: chanType === commitmentTypes.variable_remote_key,
234
228
  local_balance: Number(args.local_balance),
235
229
  local_csv: own.csv_delay,
236
230
  local_dust: Number(own.dust_limit_sat),
package/package.json CHANGED
@@ -8,9 +8,9 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@grpc/grpc-js": "1.4.4",
11
- "@grpc/proto-loader": "0.6.6",
11
+ "@grpc/proto-loader": "0.6.7",
12
12
  "@types/express": "4.17.13",
13
- "@types/node": "16.11.7",
13
+ "@types/node": "16.11.9",
14
14
  "@types/request": "2.48.7",
15
15
  "@types/ws": "8.2.0",
16
16
  "async": "3.2.2",
@@ -29,8 +29,8 @@
29
29
  "devDependencies": {
30
30
  "@alexbosworth/node-fetch": "2.6.2",
31
31
  "@alexbosworth/tap": "15.0.10",
32
- "tsd": "0.18.0",
33
- "typescript": "4.4.4",
32
+ "tsd": "0.19.0",
33
+ "typescript": "4.5.2",
34
34
  "ws": "8.2.3"
35
35
  },
36
36
  "engines": {
@@ -56,5 +56,5 @@
56
56
  "directory": "test/typescript"
57
57
  },
58
58
  "types": "index.d.ts",
59
- "version": "4.14.4"
59
+ "version": "5.0.0"
60
60
  }
@@ -3,11 +3,6 @@ const {test} = require('@alexbosworth/tap');
3
3
  const {createChainAddress} = require('./../../../');
4
4
 
5
5
  const tests = [
6
- {
7
- args: {},
8
- description: 'An address format is required',
9
- error: [400, 'ExpectedKnownAddressFormat'],
10
- },
11
6
  {
12
7
  args: {format: 'foo'},
13
8
  description: 'A known address format is required',
@@ -11,13 +11,10 @@ const makeExpected = overrides => {
11
11
  cooperative_close_delay_height: undefined,
12
12
  id: '0x0x1',
13
13
  is_active: true,
14
- is_anchor: false,
15
14
  is_closing: false,
16
15
  is_opening: false,
17
16
  is_partner_initiated: false,
18
17
  is_private: true,
19
- is_static_remote_key: false,
20
- is_variable_remote_key: true,
21
18
  local_balance: 1,
22
19
  local_csv: 1,
23
20
  local_dust: 1,
@@ -250,8 +247,6 @@ const tests = [
250
247
  expected: {
251
248
  channel: makeExpected({
252
249
  cooperative_close_delay_height: 1,
253
- is_static_remote_key: true,
254
- is_variable_remote_key: false,
255
250
  }),
256
251
  },
257
252
  },
@@ -261,8 +256,6 @@ const tests = [
261
256
  expected: {
262
257
  channel: makeExpected({
263
258
  cooperative_close_delay_height: 5e5,
264
- is_anchor: true,
265
- is_variable_remote_key: false,
266
259
  }),
267
260
  },
268
261
  },
@@ -244,13 +244,10 @@ const tests = [
244
244
  cooperative_close_delay_height: undefined,
245
245
  id: '0x0x1',
246
246
  is_active: false,
247
- is_anchor: false,
248
247
  is_closing: false,
249
248
  is_opening: false,
250
249
  is_partner_initiated: false,
251
250
  is_private: false,
252
- is_static_remote_key: false,
253
- is_variable_remote_key: true,
254
251
  local_balance: 1,
255
252
  local_csv: 1,
256
253
  local_dust: 1,
@@ -101,7 +101,6 @@ const makeExpectedPending = overrides => {
101
101
  const res = {
102
102
  close_transaction_id: Buffer.alloc(32).toString('hex'),
103
103
  is_active: false,
104
- is_anchor: false,
105
104
  is_closing: true,
106
105
  is_opening: false,
107
106
  is_partner_initiated: true,
@@ -69,13 +69,10 @@ const makeExpected = overrides => {
69
69
  cooperative_close_delay_height: undefined,
70
70
  id: '0x0x1',
71
71
  is_active: true,
72
- is_anchor: false,
73
72
  is_closing: false,
74
73
  is_opening: false,
75
74
  is_partner_initiated: true,
76
75
  is_private: true,
77
- is_static_remote_key: false,
78
- is_variable_remote_key: true,
79
76
  local_balance: 1,
80
77
  local_csv: 1,
81
78
  local_dust: 1,
@@ -236,8 +233,6 @@ const tests = [
236
233
  description: 'Initiated RPC channel is mapped to channel',
237
234
  expected: makeExpected({
238
235
  is_partner_initiated: false,
239
- is_static_remote_key: true,
240
- is_variable_remote_key: false,
241
236
  }),
242
237
  },
243
238
  {
@@ -262,8 +257,6 @@ const tests = [
262
257
  }),
263
258
  description: 'Local constraints RPC channel is mapped to channel',
264
259
  expected: makeExpected({
265
- is_anchor: true,
266
- is_variable_remote_key: false,
267
260
  local_csv: 1,
268
261
  local_dust: 1,
269
262
  local_max_htlcs: 1,