lightning 8.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,16 @@
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
+
8
+ ## 9.0.0
9
+
10
+ ### Breaking Changes
11
+
12
+ - node.js version 14 is no longer supported, 16 or higher is required
13
+
3
14
  ## 8.0.0
4
15
 
5
16
  - `openChannel`: Add `is_max_funding` to fund a channel maximally
@@ -863,6 +863,76 @@ enum WitnessType {
863
863
  transaction.
864
864
  */
865
865
  COMMITMENT_ANCHOR = 13;
866
+
867
+ /*
868
+ A witness type that is similar to the COMMITMENT_NO_DELAY type,
869
+ but it omits the tweak that randomizes the key we need to
870
+ spend with a channel peer supplied set of randomness.
871
+ */
872
+ COMMITMENT_NO_DELAY_TWEAKLESS = 14;
873
+
874
+ /*
875
+ A witness type that allows us to spend our output on the counterparty's
876
+ commitment transaction after a confirmation.
877
+ */
878
+ COMMITMENT_TO_REMOTE_CONFIRMED = 15;
879
+
880
+ /*
881
+ A witness type that allows us to sweep an HTLC output that we extended
882
+ to a party, but was never fulfilled. This _is_ the HTLC output directly
883
+ on our commitment transaction, and the input to the second-level HTLC
884
+ timeout transaction. It can only be spent after CLTV expiry, and
885
+ commitment confirmation.
886
+ */
887
+ HTLC_OFFERED_TIMEOUT_SECOND_LEVEL_INPUT_CONFIRMED = 16;
888
+
889
+ /*
890
+ A witness type that allows us to sweep an HTLC output that was offered
891
+ to us, and for which we have a payment preimage. This _is_ the HTLC
892
+ output directly on our commitment transaction, and the input to the
893
+ second-level HTLC success transaction. It can only be spent after the
894
+ commitment has confirmed.
895
+ */
896
+ HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL_INPUT_CONFIRMED = 17;
897
+
898
+ /*
899
+ A witness type that allows us to spend our output on our local
900
+ commitment transaction after a relative and absolute lock-time lockout as
901
+ part of the script enforced lease commitment type.
902
+ */
903
+ LEASE_COMMITMENT_TIME_LOCK = 18;
904
+
905
+ /*
906
+ A witness type that allows us to spend our output on the counterparty's
907
+ commitment transaction after a confirmation and absolute locktime as part
908
+ of the script enforced lease commitment type.
909
+ */
910
+ LEASE_COMMITMENT_TO_REMOTE_CONFIRMED = 19;
911
+
912
+ /*
913
+ A witness type that allows us to sweep an HTLC output that we extended
914
+ to a party, but was never fulfilled. This HTLC output isn't directly on
915
+ the commitment transaction, but is the result of a confirmed second-level
916
+ HTLC transaction. As a result, we can only spend this after a CSV delay
917
+ and CLTV locktime as part of the script enforced lease commitment type.
918
+ */
919
+ LEASE_HTLC_OFFERED_TIMEOUT_SECOND_LEVEL = 20;
920
+
921
+ /*
922
+ A witness type that allows us to sweep an HTLC output that was offered
923
+ to us, and for which we have a payment preimage. This HTLC output isn't
924
+ directly on our commitment transaction, but is the result of confirmed
925
+ second-level HTLC transaction. As a result, we can only spend this after
926
+ a CSV delay and CLTV locktime as part of the script enforced lease
927
+ commitment type.
928
+ */
929
+ LEASE_HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL = 21;
930
+
931
+ /*
932
+ A witness type that allows us to spend a regular p2tr output that's sent
933
+ to an output which is under complete control of the backing wallet.
934
+ */
935
+ TAPROOT_PUB_KEY_SPEND = 22;
866
936
  }
867
937
 
868
938
  message PendingSweep {
@@ -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';
@@ -4,7 +4,7 @@ const {returnResult} = require('asyncjs-util');
4
4
 
5
5
  const {routesFromQueryRoutes} = require('../../lnd_responses');
6
6
 
7
- const defaultFinalCltvDelta = 40;
7
+ const defaultFinalCltvDelta = 144;
8
8
  const defaultMtokens = '1000000';
9
9
  const hexAsBuffer = hex => Buffer.from(hex, 'hex');
10
10
  const {isArray} = Array;
@@ -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]);
@@ -3,7 +3,7 @@ const {randomBytes} = require('crypto');
3
3
  const {isLnd} = require('./../../lnd_requests');
4
4
  const subscribeToPay = require('./subscribe_to_pay');
5
5
 
6
- const defaultCltvDelta = 40;
6
+ const defaultCltvDelta = 144;
7
7
  const isPublicKey = n => !!n && /^[0-9A-F]{66}$/i.test(n);
8
8
  const method = 'sendPaymentV2';
9
9
  const randomId = () => randomBytes(32).toString('hex');
@@ -5,7 +5,7 @@ const {isLnd} = require('./../../lnd_requests');
5
5
  const {rpcFailedPolicyAsFail} = require('./../../lnd_responses');
6
6
 
7
7
  const defaultBaseFee = 1;
8
- const defaultCltvDelta = 40;
8
+ const defaultCltvDelta = 144;
9
9
  const defaultRate = 1;
10
10
  const feeRatio = 1e6;
11
11
  const {floor} = Math;
@@ -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.11",
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": {
@@ -37,7 +37,7 @@
37
37
  "ws": "8.13.0"
38
38
  },
39
39
  "engines": {
40
- "node": ">=14"
40
+ "node": ">=16"
41
41
  },
42
42
  "keywords": [
43
43
  "grpc",
@@ -59,5 +59,5 @@
59
59
  "directory": "test/typescript"
60
60
  },
61
61
  "types": "index.d.ts",
62
- "version": "8.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'}},
@@ -119,7 +119,7 @@ const tests = [
119
119
  fee_rate: 0.000001,
120
120
  global: true,
121
121
  max_htlc_msat: undefined,
122
- time_lock_delta: 40,
122
+ time_lock_delta: 144,
123
123
  },
124
124
  }),
125
125
  description: 'The global channel policy is updated',
@@ -135,7 +135,7 @@ const tests = [
135
135
  fee_rate: 0.000001,
136
136
  global: true,
137
137
  max_htlc_msat: undefined,
138
- time_lock_delta: 40,
138
+ time_lock_delta: 144,
139
139
  },
140
140
  }),
141
141
  description: 'The global channel policy base fee mtokens is updated',
@@ -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
- });