lightning 7.1.9 → 9.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,22 @@
1
1
  # Versions
2
2
 
3
+ ## 9.0.0
4
+
5
+ ### Breaking Changes
6
+
7
+ - node.js version 14 is no longer supported, 16 or higher is required
8
+
9
+ ## 8.0.0
10
+
11
+ - `openChannel`: Add `is_max_funding` to fund a channel maximally
12
+ - `subscribeToRpcRequests`: Add support for returning `is_max_funding` in
13
+ `open_channel_request`
14
+
15
+ ### Breaking Changes
16
+
17
+ - `subscribeToRpcRequests`: `open_channel_request`: `local_tokens` is now an
18
+ optional value
19
+
3
20
  ## 7.1.9
4
21
 
5
22
  - `getPeers`: Correct feature bit returned as string and not number
@@ -2265,6 +2265,13 @@ message OpenChannelRequest {
2265
2265
  capacity.
2266
2266
  */
2267
2267
  uint64 remote_chan_reserve_sat = 25;
2268
+
2269
+ /*
2270
+ If set, then lnd will attempt to commit all the coins under control of the
2271
+ internal wallet to open the channel, and the LocalFundingAmount field must
2272
+ be zero and is ignored.
2273
+ */
2274
+ bool fund_max = 26;
2268
2275
  }
2269
2276
  message OpenStatusUpdate {
2270
2277
  oneof update {
@@ -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 {
@@ -7,6 +7,7 @@ const minConfs = (isZero, confs) => isZero ? Number() : (confs || undefined);
7
7
  base_fee: <Set Channel Base Fee Millitokens String>
8
8
  close_address: <Cooperative Close Address String>
9
9
  fee_rate: <Set Channel Routing Fee Rate Millitoken Per Millitokens String>
10
+ fund_max: <Use Maximal Funding Bool>
10
11
  local_funding_amount: <Channel Capacity Tokens String>
11
12
  min_htlc_msat: <Minimum HTLC Millitokens String>
12
13
  node_pubkey: <Node Public Key Buffer Object>
@@ -29,8 +30,9 @@ const minConfs = (isZero, confs) => isZero ? Number() : (confs || undefined);
29
30
  [cooperative_close_address]: <Restrict Cooperative Close To Address String>
30
31
  [fee_rate]: <Routing Fee Rate In Millitokens Per Million Number>
31
32
  [give_tokens]: <Tokens to Gift To Partner Number>
33
+ [is_max_funding]: <Use Maximal Chain Funds For Local Funding Bool>
32
34
  [is_private]: <Channel is Private Bool>
33
- local_tokens: <Local Tokens Number>
35
+ [local_tokens]: <Local Tokens Number>
34
36
  [min_confirmations]: <Spend UTXOs With Minimum Confirmations Number>
35
37
  [min_htlc_mtokens]: <Minimum HTLC Millitokens String>
36
38
  partner_public_key: <Public Key Hex String>
@@ -40,6 +42,7 @@ const minConfs = (isZero, confs) => isZero ? Number() : (confs || undefined);
40
42
  module.exports = args => {
41
43
  const chainFeeRate = Number(args.sat_per_vbyte) || Number(args.sat_per_byte);
42
44
  const hasMinHtlc = args.min_htlc_msat !== Number().toString();
45
+ const normalFunded = !args.fund_max;
43
46
  const publicKey = bufferAsHex(args.node_pubkey) || args.node_pubkey_string;
44
47
  const utxoConfs = minConfs(args.spend_unconfirmed, args.min_confirmations);
45
48
 
@@ -49,8 +52,9 @@ module.exports = args => {
49
52
  cooperative_close_address: args.close_address || undefined,
50
53
  fee_rate: !!args.use_fee_rate ? Number(args.fee_rate) : undefined,
51
54
  give_tokens: Number(args.push_sat) || undefined,
55
+ is_max_funding: !!args.fund_max || undefined,
52
56
  is_private: args.private || undefined,
53
- local_tokens: Number(args.local_funding_amount),
57
+ local_tokens: normalFunded ? Number(args.local_funding_amount) : undefined,
54
58
  min_confirmations: utxoConfs,
55
59
  min_htlc_mtokens: hasMinHtlc ? args.min_htlc_msat : undefined,
56
60
  partner_public_key: publicKey,
@@ -69,8 +69,9 @@ const type = 'default';
69
69
  [cooperative_close_address]: <Prefer Cooperative Close To Address String>
70
70
  [fee_rate]: <Routing Fee Rate In Millitokens Per Million Number>
71
71
  [give_tokens]: <Tokens to Gift To Partner Number>
72
+ [is_max_funding]: <Use Maximal Chain Funds For Local Funding Bool>
72
73
  [is_private]: <Channel is Private Bool>
73
- local_tokens: <Local Tokens Number>
74
+ [local_tokens]: <Local Tokens Number>
74
75
  [min_confirmations]: <Spend UTXOs With Minimum Confirmations Number>
75
76
  [min_htlc_mtokens]: <Minimum HTLC Millitokens String>
76
77
  partner_public_key: <Public Key Hex String>
@@ -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;
@@ -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;
@@ -23,15 +23,18 @@ const type = 'default';
23
23
  `base_fee_mtokens` is not supported on LND 0.15.5 and below
24
24
  `fee_rate` is not supported on LND 0.15.5 and below
25
25
 
26
+ `is_max_funding` is not supported on LND 0.16.0 and below
27
+
26
28
  {
27
29
  [base_fee_mtokens]: <Routing Base Fee Millitokens Charged String>
28
30
  [chain_fee_tokens_per_vbyte]: <Chain Fee Tokens Per VByte Number>
29
31
  [cooperative_close_address]: <Restrict Cooperative Close To Address String>
30
32
  [fee_rate]: <Routing Fee Rate In Millitokens Per Million Number>
31
33
  [give_tokens]: <Tokens to Gift To Partner Number> // Defaults to zero
34
+ [is_max_funding]: <Use Maximal Chain Funds For Local Funding Bool>
32
35
  [is_private]: <Channel is Private Bool> // Defaults to false
33
36
  lnd: <Authenticated LND API Object>
34
- local_tokens: <Total Channel Capacity Tokens Number>
37
+ [local_tokens]: <Total Channel Capacity Tokens Number>
35
38
  [min_confirmations]: <Spend UTXOs With Minimum Confirmations Number>
36
39
  [min_htlc_mtokens]: <Minimum HTLC Millitokens String>
37
40
  [partner_csv_delay]: <Peer Output CSV Delay Number>
@@ -54,11 +57,11 @@ module.exports = (args, cbk) => {
54
57
  return cbk([400, 'ExpectedLndForChannelOpen']);
55
58
  }
56
59
 
57
- if (!args.local_tokens) {
60
+ if (!args.local_tokens && !args.is_max_funding) {
58
61
  return cbk([400, 'ExpectedLocalTokensNumberToOpenChannelWith']);
59
62
  }
60
63
 
61
- if (args.local_tokens < minChannelTokens) {
64
+ if (!args.is_max_funding && args.local_tokens < minChannelTokens) {
62
65
  return cbk([400, 'ExpectedLargerChannelSizeForChannelOpen']);
63
66
  }
64
67
 
@@ -99,6 +102,7 @@ module.exports = (args, cbk) => {
99
102
  const options = {
100
103
  base_fee: args.base_fee_mtokens || undefined,
101
104
  fee_rate: args.fee_rate,
105
+ fund_max: args.is_max_funding || undefined,
102
106
  local_funding_amount: args.local_tokens,
103
107
  min_confs: minConfs,
104
108
  min_htlc_msat: args.min_htlc_mtokens || defaultMinHtlcMtokens,
package/package.json CHANGED
@@ -7,10 +7,10 @@
7
7
  "url": "https://github.com/alexbosworth/lightning/issues"
8
8
  },
9
9
  "dependencies": {
10
- "@grpc/grpc-js": "1.8.13",
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.15.13",
14
14
  "@types/request": "2.48.8",
15
15
  "@types/ws": "8.5.4",
16
16
  "async": "3.2.4",
@@ -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": "7.1.9"
62
+ "version": "9.0.0"
63
63
  }
@@ -30,6 +30,7 @@ const makeExpected = overrides => {
30
30
  cooperative_close_address: 'close_address',
31
31
  fee_rate: undefined,
32
32
  give_tokens: 1,
33
+ is_max_funding: undefined,
33
34
  is_private: undefined,
34
35
  local_tokens: 1,
35
36
  min_confirmations: 0,
@@ -105,6 +105,7 @@ const tests = [
105
105
  cooperative_close_address: 'close_address',
106
106
  fee_rate: undefined,
107
107
  give_tokens: 1,
108
+ is_max_funding: undefined,
108
109
  is_private: undefined,
109
110
  local_tokens: 1,
110
111
  min_confirmations: 0,
@@ -196,6 +196,7 @@ const tests = [
196
196
  cooperative_close_address: 'close_address',
197
197
  fee_rate: undefined,
198
198
  give_tokens: 1,
199
+ is_max_funding: undefined,
199
200
  is_private: undefined,
200
201
  local_tokens: 1,
201
202
  min_confirmations: 0,
@@ -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',