lightning 9.0.0 → 9.1.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,10 @@
1
1
  # Versions
2
2
 
3
+ ## 9.1.0
4
+
5
+ - `getWalletInfo`: Add support for LND 0.16.1
6
+ - `subscribeToOpenRequests`: Add `type` for channel request commitment type
7
+
3
8
  ## 9.0.0
4
9
 
5
10
  ### Breaking Changes
@@ -44,6 +44,7 @@
44
44
  "d62c575f8499a314eb27f12462d20500b6bda2c7": "0.10.3-beta",
45
45
  "df0b82f0165f19bde8832bacd1e35544b0a2990d": "0.14.0-beta",
46
46
  "eecbe99d68384c734b2c91fd0800484e69c5cab2": "0.14.4-beta",
47
+ "fb765fdb1daf1c1db08ab9b6aa0c442af431bc82": "0.16.1-beta",
47
48
  "fd1a95bf322cdd1c743a1554f8e470fbf9a5e564": "0.15.1-beta"
48
49
  },
49
50
  "weightedType": "weightedcomb",
@@ -4,7 +4,6 @@ const {returnResult} = require('asyncjs-util');
4
4
 
5
5
  const {isLnd} = require('./../../lnd_requests');
6
6
  const {pendingAsPendingChannels} = require('./../../lnd_responses');
7
- const {rpcChannelAsOldRpcChannel} = require('./../../lnd_responses');
8
7
 
9
8
  const {isArray} = Array;
10
9
  const method = 'pendingChannels';
@@ -53,6 +53,8 @@ export type SubscribeToOpenRequestsChannelRequestEvent = {
53
53
  /** 500 Character Limited Rejection Reason */
54
54
  reason?: string;
55
55
  }) => void;
56
+ /** Channel Commitment Transaction Type */
57
+ type?: string;
56
58
  };
57
59
 
58
60
  /**
@@ -60,6 +60,7 @@ const type = 'default';
60
60
  reject: <Reject Request Function> ({
61
61
  [reason]: <500 Character Limited Rejection Reason String>
62
62
  }) -> {}
63
+ [type]: <Channel Commitment Transaction Type String>
63
64
  }
64
65
 
65
66
  @event 'error'
@@ -132,6 +133,7 @@ module.exports = ({lnd}) => {
132
133
  pending_chan_id: id,
133
134
  });
134
135
  },
136
+ type: request.type,
135
137
  }));
136
138
  } catch (err) {
137
139
  return emitError([503, err.message]);
@@ -1,3 +1,5 @@
1
+ const {channelTypes} = require('./constants');
2
+
1
3
  const bufferAsHex = buffer => buffer.toString('hex');
2
4
  const compressedPublicKeyLength = 33;
3
5
  const hashAsId = hash => hash.reverse().toString('hex');
@@ -13,6 +15,7 @@ const weightPerVByte = 4;
13
15
  chain_hash: <Blockchain Genesis Block Hash Bytes Buffer Object>
14
16
  channel_flags: <Bit-field Channel Type Flags Number>
15
17
  channel_reserve: <Reserve Tokens Requirement String>
18
+ commitment_type: <Channel Commitment Transaction Type String>
16
19
  csv_delay: <Relative Time Lock Blocks Count Number>
17
20
  dust_limit: <Dust Limit Tokens of Peer's Commitment Transaction String>
18
21
  fee_per_kw: <Commitment Transaction Fee Rate String>
@@ -45,6 +48,7 @@ const weightPerVByte = 4;
45
48
  min_chain_output: <Minimum Chain Output Tokens Number>
46
49
  min_htlc_mtokens: <Minimum HTLC Millitokens String>
47
50
  partner_public_key: <Peer Public Key Hex String>
51
+ [type]: <Channel Commitment Transaction Type String>
48
52
  }
49
53
  */
50
54
  module.exports = data => {
@@ -64,6 +68,10 @@ module.exports = data => {
64
68
  throw new Error('ExpectedChannelReserveForChannelRequest');
65
69
  }
66
70
 
71
+ if (!data.commitment_type) {
72
+ throw new Error('ExpectedCommitmentTypeForChannelRequest');
73
+ }
74
+
67
75
  if (data.csv_delay === undefined) {
68
76
  throw new Error('ExpectedCsvDelayInChannelOpenRequest');
69
77
  }
@@ -125,5 +133,6 @@ module.exports = data => {
125
133
  min_chain_output: Number(data.dust_limit),
126
134
  min_htlc_mtokens: data.min_htlc,
127
135
  partner_public_key: bufferAsHex(data.node_pubkey),
136
+ type: channelTypes[data.commitment_type],
128
137
  };
129
138
  };
@@ -14,6 +14,12 @@
14
14
  "failed": "FAILED",
15
15
  "pending": "IN_FLIGHT"
16
16
  },
17
+ "channelTypes": {
18
+ "ANCHORS": "anchor",
19
+ "LEGACY": "original",
20
+ "SCRIPT_ENFORCED_LEASE": "anchor_with_lease_constraint",
21
+ "STATIC_REMOTE_KEY": "original_with_static_to_remote"
22
+ },
17
23
  "commitmentTypes": {
18
24
  "anchor": "ANCHORS",
19
25
  "static_remote_key": "STATIC_REMOTE_KEY",
@@ -18,7 +18,6 @@ const routingFailureFromHtlc = require('./routing_failure_from_htlc');
18
18
  const rpcAddressesAsAddresses = require('./rpc_addresses_as_addresses');
19
19
  const rpcAttemptHtlcAsAttempt = require('./rpc_attempt_htlc_as_attempt');
20
20
  const rpcChannelAsChannel = require('./rpc_channel_as_channel');
21
- const rpcChannelAsOldRpcChannel = require('./rpc_channel_as_old_rpc_channel');
22
21
  const rpcChannelClosedAsClosed = require('./rpc_channel_closed_as_closed');
23
22
  const rpcChannelUpdateAsUpdate = require('./rpc_channel_update_as_update');
24
23
  const rpcClosedChannelAsClosed = require('./rpc_closed_channel_as_closed');
@@ -64,7 +63,6 @@ module.exports = {
64
63
  rpcAddressesAsAddresses,
65
64
  rpcAttemptHtlcAsAttempt,
66
65
  rpcChannelAsChannel,
67
- rpcChannelAsOldRpcChannel,
68
66
  rpcChannelClosedAsClosed,
69
67
  rpcChannelUpdateAsUpdate,
70
68
  rpcClosedChannelAsClosed,
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "@grpc/grpc-js": "1.8.14",
11
11
  "@grpc/proto-loader": "0.7.6",
12
12
  "@types/express": "4.17.17",
13
- "@types/node": "18.15.13",
13
+ "@types/node": "18.16.1",
14
14
  "@types/request": "2.48.8",
15
15
  "@types/ws": "8.5.4",
16
16
  "async": "3.2.4",
@@ -26,7 +26,7 @@
26
26
  "invoices": "2.2.3",
27
27
  "psbt": "2.7.2",
28
28
  "tiny-secp256k1": "2.2.1",
29
- "type-fest": "3.8.0"
29
+ "type-fest": "3.9.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.0.0"
62
+ "version": "9.1.0"
63
63
  }
@@ -21,6 +21,7 @@ const makeLnd = ({data, err}) => {
21
21
  chain_hash: Buffer.alloc(32),
22
22
  channel_flags: 34,
23
23
  channel_reserve: '1',
24
+ commitment_type: 'LEGACY',
24
25
  csv_delay: 1,
25
26
  dust_limit: '1',
26
27
  fee_per_kw: '1000',
@@ -90,6 +91,7 @@ const tests = [
90
91
  min_chain_output: 1,
91
92
  min_htlc_mtokens: '1000',
92
93
  partner_public_key: '030303030303030303030303030303030303030303030303030303030303030303',
94
+ type: 'original',
93
95
  }
94
96
  },
95
97
  {event: 'error', data: {details: 'Cancelled on client'}},
@@ -7,6 +7,7 @@ const makeArgs = overrides => {
7
7
  chain_hash: Buffer.alloc(32),
8
8
  channel_flags: 34,
9
9
  channel_reserve: '1',
10
+ commitment_type: 'LEGACY',
10
11
  csv_delay: 1,
11
12
  dust_limit: '1',
12
13
  fee_per_kw: '1000',
@@ -43,6 +44,7 @@ const tests = [
43
44
  min_chain_output: 1,
44
45
  min_htlc_mtokens: '1000',
45
46
  partner_public_key: Buffer.alloc(33, 3).toString('hex'),
47
+ type: 'original',
46
48
  },
47
49
  },
48
50
  {
@@ -1,64 +0,0 @@
1
- const {test} = require('@alexbosworth/tap');
2
-
3
- const {rpcChannelAsOldRpcChannel} = require('./../../lnd_responses');
4
-
5
- const makeArgs = overrides => {
6
- const args = {
7
- channel: {
8
- commitment_type: undefined,
9
- uptime: 1,
10
- },
11
- version: undefined,
12
- };
13
-
14
- Object.keys(overrides).forEach(k => args[k] = overrides[k]);
15
-
16
- return args;
17
- };
18
-
19
- const makeExpected = overrides => {
20
- const expected = {
21
- };
22
-
23
- Object.keys(overrides).forEach(k => expected[k] = overrides[k]);
24
-
25
- return expected;
26
- };
27
-
28
- const tests = [
29
- {
30
- args: makeArgs({}),
31
- description: 'Initiated RPC channel is mapped to channel',
32
- expected: {commitment_type: undefined, uptime: 1},
33
- },
34
- {
35
- args: makeArgs({
36
- channel: {commitment_type: undefined, uptime: 1},
37
- version: '0.11.1-beta',
38
- }),
39
- description: 'Old RPC channel is mapped to channel',
40
- expected: {commitment_type: 'UNKNOWN_COMMITMENT_TYPE', uptime: 1},
41
- },
42
- {
43
- args: makeArgs({
44
- channel: {commitment_type: 'LEGACY', uptime: 1},
45
- version: '0.11.1-beta',
46
- }),
47
- description: 'Legacy was 0 but it is updated to 1, so 1 means 2',
48
- expected: {commitment_type: 'STATIC_REMOTE_KEY', uptime: 1},
49
- },
50
- ];
51
-
52
- tests.forEach(({args, description, error, expected}) => {
53
- return test(description, ({end, strictSame, throws}) => {
54
- if (!!error) {
55
- throws(() => rpcChannelAsOldRpcChannel(args), new Error(error), 'Error');
56
- } else {
57
- const channel = rpcChannelAsOldRpcChannel(args);
58
-
59
- strictSame(channel, expected, 'Channel cast as old channel');
60
- }
61
-
62
- return end();
63
- });
64
- });