lightning 10.15.1 → 10.16.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 +6 -0
- package/lnd_methods/offchain/get_closed_channels.d.ts +8 -0
- package/lnd_methods/offchain/get_closed_channels.js +9 -0
- package/lnd_responses/constants.json +2 -1
- package/lnd_responses/rpc_resolution_as_resolution.js +16 -0
- package/package.json +3 -3
- package/test/lnd_methods/offchain/test_get_closed_channels.js +33 -0
- package/test/lnd_responses/test_rpc_resolution_as_resolution.js +24 -0
package/CHANGELOG.md
CHANGED
|
@@ -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,
|
|
@@ -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
|
+
"@grpc/grpc-js": "1.11.0",
|
|
11
11
|
"@grpc/proto-loader": "0.7.13",
|
|
12
12
|
"@types/node": "20.14.10",
|
|
13
13
|
"@types/request": "2.48.12",
|
|
14
|
-
"@types/ws": "8.5.
|
|
14
|
+
"@types/ws": "8.5.11",
|
|
15
15
|
"async": "3.2.5",
|
|
16
16
|
"asyncjs-util": "1.2.12",
|
|
17
17
|
"bitcoinjs-lib": "6.1.6",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"directory": "test/typescript"
|
|
54
54
|
},
|
|
55
55
|
"types": "index.d.ts",
|
|
56
|
-
"version": "10.
|
|
56
|
+
"version": "10.16.0"
|
|
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',
|
|
@@ -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}) => {
|