lightning 10.15.1 → 10.16.1

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,14 @@
1
1
  # Versions
2
2
 
3
+ ## 10.16.1
4
+
5
+ - `getFeeRates`: Add support for `inbound_base_discount_mtokens`,
6
+ 'inbound_rate_discount` for inbound fee policy discounts
7
+
8
+ - `getClosedChannels`: Add support for anchor resolution status via new
9
+ attributes `anchor_is_confirmed`, `anchor_is_pending`, `anchor_spent_by`,
10
+ and `anchor_vout`
11
+
3
12
  ## 10.15.1
4
13
 
5
14
  - Add support for LND 0.18.2
@@ -74,6 +74,14 @@ export type GetClosedChannelsResult = {
74
74
  transaction_id: string;
75
75
  /** Channel Funding Output Index */
76
76
  transaction_vout: number;
77
+ /** Anchor CPFP Transaction Id Hex */
78
+ anchor_spent_by?: string,
79
+ /** Our Close Transaction Anchor Output Index */
80
+ anchor_vout?: number,
81
+ /** Is Anchor CPFP Transaction Confirmed */
82
+ anchor_is_confirmed?: boolean,
83
+ /** Is Anchor CPFP Transaction Pending */
84
+ anchor_is_pending?: boolean,
77
85
  }[];
78
86
  };
79
87
 
@@ -31,6 +31,10 @@ const outpointSeparator = ':';
31
31
  @returns via cbk or Promise
32
32
  {
33
33
  channels: [{
34
+ [anchor_is_confirmed]: <Anchor Sweep Confirmed Bool>
35
+ [anchor_is_pending]: <Anchor Sweep Pending Confirmation Bool>
36
+ [anchor_spent_by]: <Anchor Sweep Transaction Id Hex String>
37
+ [anchor_vout]: <Anchor Output Index Number>
34
38
  capacity: <Closed Channel Capacity Tokens Number>
35
39
  [close_balance_spent_by]: <Channel Balance Output Spent By Tx Id String>
36
40
  [close_balance_vout]: <Channel Balance Close Tx Output Index Number>
@@ -191,10 +195,15 @@ module.exports = (args, cbk) => {
191
195
 
192
196
  const resolutions = chanResolutions.map(rpcResolutionAsResolution);
193
197
 
198
+ const {anchor} = resolutions.find(n => n.anchor) || {anchor: {}};
194
199
  const {balance} = resolutions.find(n => n.balance) || {balance: {}};
195
200
  const payments = resolutions.map(n => n.payment).filter(n => !!n);
196
201
 
197
202
  return cbk(null, {
203
+ anchor_is_confirmed: anchor.is_confirmed,
204
+ anchor_is_pending: anchor.is_pending,
205
+ anchor_spent_by: anchor.spent_by,
206
+ anchor_vout: anchor.transaction_vout,
198
207
  capacity: Number(chan.capacity),
199
208
  close_balance_spent_by: balance.spent_by,
200
209
  close_balance_vout: balance.transaction_vout,
@@ -11,6 +11,18 @@ export type GetFeeRatesResult = {
11
11
  fee_rate: number;
12
12
  /** Standard Format Channel Id */
13
13
  id: string;
14
+ /**
15
+ * Source Based Base Fee Reduction String
16
+ *
17
+ * Not supported on LND 0.17.5 and below
18
+ */
19
+ inbound_base_discount_mtokens: string;
20
+ /**
21
+ * Source Based Per Million Rate Reduction Number
22
+ *
23
+ * Not supported on LND 0.17.5 and below
24
+ */
25
+ inbound_rate_discount: number;
14
26
  /** Channel Funding Transaction Id Hex */
15
27
  transaction_id: string;
16
28
  /** Funding Outpoint Output Index */
@@ -23,6 +23,8 @@ const type = 'default';
23
23
  base_fee_mtokens: <Base Flat Fee Millitokens String>
24
24
  fee_rate: <Fee Rate in Millitokens Per Million Number>
25
25
  id: <Standard Format Channel Id String>
26
+ inbound_base_discount_mtokens: <Source Based Base Fee Reduction String>
27
+ inbound_rate_discount: <Source Based Per Million Rate Reduction Number>
26
28
  transaction_id: <Channel Funding Transaction Id Hex String>
27
29
  transaction_vout: <Funding Outpoint Output Index Number>
28
30
  }]
@@ -43,6 +43,8 @@ const separatorChar = ':';
43
43
  [base_fee_mtokens]: <Base Fee Millitokens String>
44
44
  [cltv_delta]: <Locktime Delta Number>
45
45
  [fee_rate]: <Fees Charged in Millitokens Per Million Number>
46
+ [inbound_base_discount_mtokens]: <Source Based Base Fee Reduction String>
47
+ [inbound_rate_discount]: <Source Based Per Million Rate Reduction Number>
46
48
  [is_disabled]: <Channel Is Disabled Bool>
47
49
  [max_htlc_mtokens]: <Maximum HTLC Millitokens Value String>
48
50
  [min_htlc_mtokens]: <Minimum HTLC Millitokens Value String>
@@ -78,7 +78,8 @@
78
78
  "resolutionTypes": {
79
79
  "balance": "COMMIT",
80
80
  "incoming_payment": "INCOMING_HTLC",
81
- "outgoing_payment": "OUTGOING_HTLC"
81
+ "outgoing_payment": "OUTGOING_HTLC",
82
+ "anchor": "ANCHOR"
82
83
  },
83
84
  "syncTypes": {
84
85
  "active": "ACTIVE_SYNC",
@@ -2,6 +2,8 @@ const {chanFormat} = require('bolt07');
2
2
 
3
3
  const {safeTokens} = require('./../bolt00');
4
4
 
5
+ const discount = fee => (!fee ? 0 : -fee).toString();
6
+ const inverse = rate => !rate ? 0 : -rate;
5
7
  const isHash = n => /^[0-9A-F]{64}$/i.test(n);
6
8
  const notFound = -1;
7
9
  const outpointDivider = ':';
@@ -21,6 +23,8 @@ const outpointDivider = ':';
21
23
  base_fee_mtokens: <Base Flat Fee Millitokens String>
22
24
  fee_rate: <Fee Rate in Millitokens Per Million Number>
23
25
  id: <Standard Format Channel Id String>
26
+ inbound_base_discount_mtokens: <Source Based Base Fee Reduction String>
27
+ inbound_rate_discount: <Source Based Per Million Rate Reduction Number>
24
28
  transaction_id: <Channel Funding Transaction Id Hex String>
25
29
  transaction_vout: <Funding Outpoint Output Index Number>
26
30
  }
@@ -61,6 +65,8 @@ module.exports = channel => {
61
65
  base_fee_mtokens: channel.base_fee_msat,
62
66
  fee_rate: Number(channel.fee_per_mil),
63
67
  id: chanFormat({number: channel.chan_id}).channel,
68
+ inbound_base_discount_mtokens: discount(channel.inbound_base_fee_msat),
69
+ inbound_rate_discount: inverse(channel.inbound_fee_per_mil),
64
70
  transaction_id: txId,
65
71
  transaction_vout: Number(index),
66
72
  };
@@ -22,6 +22,12 @@ const outpointSeparator = ':';
22
22
 
23
23
  @returns
24
24
  {
25
+ [anchor]: {
26
+ is_confirmed: <Anchor Output Spend Is Confirmed Bool>
27
+ is_pending: <Anchor Output Spend Is Pending Confirmation Bool>
28
+ [spent_by]: <Sweep Transaction Id Hex String>
29
+ transaction_vout: <Anchor Output Index Number>
30
+ }
25
31
  [balance]: {
26
32
  spent_by: <Close Transaction Spent By Transaction Id Hex String>
27
33
  transaction_vout: <Balance Spent By Transaction Output Index Number>
@@ -72,6 +78,16 @@ module.exports = args => {
72
78
  }
73
79
 
74
80
  switch (args.resolution_type) {
81
+ case resolutionTypes.anchor:
82
+ return {
83
+ anchor: {
84
+ is_confirmed: args.outcome === resolutionOutcomes.confirmed,
85
+ is_pending: args.outcome === resolutionOutcomes.pending,
86
+ spent_by: args.sweep_txid || undefined,
87
+ transaction_vout: args.outpoint.output_index,
88
+ },
89
+ };
90
+
75
91
  case resolutionTypes.balance:
76
92
  // Exit early when the outcome is indeterminate
77
93
  if (!args.sweep_txid || args.outcome !== resolutionOutcomes.confirmed) {
package/package.json CHANGED
@@ -7,11 +7,11 @@
7
7
  "url": "https://github.com/alexbosworth/lightning/issues"
8
8
  },
9
9
  "dependencies": {
10
- "@grpc/grpc-js": "1.10.11",
10
+ "@grpc/grpc-js": "1.11.1",
11
11
  "@grpc/proto-loader": "0.7.13",
12
- "@types/node": "20.14.10",
12
+ "@types/node": "22.1.0",
13
13
  "@types/request": "2.48.12",
14
- "@types/ws": "8.5.10",
14
+ "@types/ws": "8.5.12",
15
15
  "async": "3.2.5",
16
16
  "asyncjs-util": "1.2.12",
17
17
  "bitcoinjs-lib": "6.1.6",
@@ -22,12 +22,12 @@
22
22
  "invoices": "3.0.0",
23
23
  "psbt": "3.0.0",
24
24
  "tiny-secp256k1": "2.2.3",
25
- "type-fest": "4.21.0"
25
+ "type-fest": "4.23.0"
26
26
  },
27
27
  "description": "Lightning Network client library",
28
28
  "devDependencies": {
29
29
  "tsd": "0.31.1",
30
- "typescript": "5.5.3"
30
+ "typescript": "5.5.4"
31
31
  },
32
32
  "engines": {
33
33
  "node": ">=18"
@@ -53,5 +53,5 @@
53
53
  "directory": "test/typescript"
54
54
  },
55
55
  "types": "index.d.ts",
56
- "version": "10.15.1"
56
+ "version": "10.16.1"
57
57
  }
@@ -43,6 +43,10 @@ const makeArgs = ({override}) => {
43
43
 
44
44
  const makeExpectedChannel = ({override}) => {
45
45
  const expected = {
46
+ anchor_is_confirmed: undefined,
47
+ anchor_is_pending: undefined,
48
+ anchor_spent_by: undefined,
49
+ anchor_vout: undefined,
46
50
  capacity: 1,
47
51
  close_balance_vout: undefined,
48
52
  close_balance_spent_by: undefined,
@@ -270,6 +274,35 @@ const tests = [
270
274
  description: 'Empty chan id is returned as undefined',
271
275
  expected: {channels: [makeExpectedChannel({override: {id: undefined}})]},
272
276
  },
277
+ {
278
+ args: makeArgs({
279
+ override: {
280
+ lnd: makeLnd(null, {
281
+ resolutions: [{
282
+ amount_sat: '1',
283
+ outcome: 'CLAIMED',
284
+ outpoint: {
285
+ output_index: 0,
286
+ txid_str: Buffer.alloc(32).toString('hex'),
287
+ },
288
+ resolution_type: 'ANCHOR',
289
+ sweep_txid: Buffer.alloc(32, 1).toString('hex'),
290
+ }],
291
+ }),
292
+ },
293
+ }),
294
+ description: 'Anchor resolution maps to anchor status',
295
+ expected: {
296
+ channels: [
297
+ makeExpectedChannel({override: {
298
+ anchor_is_confirmed: true,
299
+ anchor_is_pending: false,
300
+ anchor_spent_by: Buffer.alloc(32, 1).toString('hex'),
301
+ anchor_vout: 0,
302
+ }}),
303
+ ],
304
+ },
305
+ },
273
306
  {
274
307
  args: makeArgs({override: {lnd: makeLnd(null, {resolutions: [null]})}}),
275
308
  description: 'Valid resolutions are expected',
@@ -56,6 +56,8 @@ const tests = [
56
56
  base_fee_mtokens: '0',
57
57
  fee_rate: 0,
58
58
  id: '0x0x1',
59
+ inbound_base_discount_mtokens: '0',
60
+ inbound_rate_discount: 0,
59
61
  transaction_id: Buffer.alloc(32).toString('hex'),
60
62
  transaction_vout: 0,
61
63
  }],
@@ -66,6 +66,8 @@ const tests = [
66
66
  base_fee_mtokens: '1',
67
67
  fee_rate: 0,
68
68
  id: '0x0x1',
69
+ inbound_base_discount_mtokens: '0',
70
+ inbound_rate_discount: 0,
69
71
  transaction_id: Buffer.alloc(32).toString('hex'),
70
72
  transaction_vout: 0,
71
73
  },
@@ -113,6 +113,30 @@ const tests = [
113
113
  },
114
114
  },
115
115
  },
116
+ {
117
+ args: makeArgs({resolution_type: 'ANCHOR'}),
118
+ description: 'RPC anchor resolution is mapped to anchor',
119
+ expected: {
120
+ anchor: {
121
+ is_confirmed: true,
122
+ is_pending: false,
123
+ spent_by: Buffer.alloc(32, 1).toString('hex'),
124
+ transaction_vout: 0,
125
+ },
126
+ },
127
+ },
128
+ {
129
+ args: makeArgs({resolution_type: 'ANCHOR', sweep_txid: ''}),
130
+ description: 'RPC pending anchor resolution is mapped to anchor',
131
+ expected: {
132
+ anchor: {
133
+ is_confirmed: true,
134
+ is_pending: false,
135
+ spent_by: undefined,
136
+ transaction_vout: 0,
137
+ },
138
+ },
139
+ },
116
140
  ];
117
141
 
118
142
  tests.forEach(({args, description, error, expected}) => {