lightning 10.13.2 → 10.14.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
|
@@ -3443,6 +3443,10 @@ message ChanInfoRequest {
|
|
|
3443
3443
|
output index for the channel.
|
|
3444
3444
|
*/
|
|
3445
3445
|
uint64 chan_id = 1 [jstype = JS_STRING];
|
|
3446
|
+
|
|
3447
|
+
// The channel point of the channel in format funding_txid:output_index. If
|
|
3448
|
+
// chan_id is specified, this field is ignored.
|
|
3449
|
+
string chan_point = 2;
|
|
3446
3450
|
}
|
|
3447
3451
|
|
|
3448
3452
|
message NetworkInfoRequest {
|
|
@@ -7,17 +7,28 @@ const {isLnd} = require('./../../lnd_requests');
|
|
|
7
7
|
|
|
8
8
|
const edgeIsZombieErrorMessage = 'edge marked as zombie';
|
|
9
9
|
const edgeNotFoundErrorMessage = 'edge not found';
|
|
10
|
+
const method = 'getChanInfo';
|
|
11
|
+
const type = 'default';
|
|
10
12
|
|
|
11
13
|
/** Get graph information about a channel on the network
|
|
12
14
|
|
|
15
|
+
Either channel `id` or a `transaction_id` and `transaction_vout` is required
|
|
16
|
+
|
|
13
17
|
Requires `info:read` permission
|
|
14
18
|
|
|
15
19
|
`inbound_base_discount_mtokens` is not supported on LND 0.17.5 and below
|
|
20
|
+
|
|
16
21
|
`inbound_rate_discount` is not supported on LND 0.17.5 and below
|
|
17
22
|
|
|
23
|
+
`transaction_id` is not supported on LND 0.18.0 and below
|
|
24
|
+
|
|
25
|
+
`transaction_vout` is not supported on LND 0.18.0 and below
|
|
26
|
+
|
|
18
27
|
{
|
|
19
|
-
id: <Standard Format Channel Id String>
|
|
28
|
+
[id]: <Standard Format Channel Id String>
|
|
20
29
|
lnd: <Authenticated LND API Object>
|
|
30
|
+
[transaction_id]: <Funding Outpoint Transaction Id Hex String>
|
|
31
|
+
[transaction_vout]: <Funding Outpoint Transaction Output Index Number>
|
|
21
32
|
}
|
|
22
33
|
|
|
23
34
|
@returns via cbk or Promise
|
|
@@ -41,30 +52,45 @@ const edgeNotFoundErrorMessage = 'edge not found';
|
|
|
41
52
|
[updated_at]: <Channel Last Updated At ISO 8601 Date String>
|
|
42
53
|
}
|
|
43
54
|
*/
|
|
44
|
-
module.exports = (
|
|
55
|
+
module.exports = (args, cbk) => {
|
|
45
56
|
return new Promise((resolve, reject) => {
|
|
46
57
|
return asyncAuto({
|
|
47
58
|
// Check arguments
|
|
48
59
|
validate: cbk => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
60
|
+
if (!!args.id && !!args.transaction_id) {
|
|
61
|
+
return cbk([400, 'ExpectedEitherChannelIdOrOutpointToGetChannel']);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (!args.id && !args.transaction_id) {
|
|
65
|
+
return cbk([400, 'ExpectedChannelIdOrFundingOutpointToGetChannel']);
|
|
53
66
|
}
|
|
54
67
|
|
|
55
|
-
if (!isLnd({lnd, method: 'getChanInfo', type: 'default'})) {
|
|
68
|
+
if (!isLnd({lnd: args.lnd, method: 'getChanInfo', type: 'default'})) {
|
|
56
69
|
return cbk([400, 'ExpectedLndToGetChannelDetails']);
|
|
57
70
|
}
|
|
58
71
|
|
|
72
|
+
if (!!args.transaction_id && args.transaction_vout === undefined) {
|
|
73
|
+
return cbk([400, 'ExpectedChannelFundingOutputIndexToGetChannel']);
|
|
74
|
+
}
|
|
75
|
+
|
|
59
76
|
return cbk();
|
|
60
77
|
},
|
|
61
78
|
|
|
79
|
+
// Channel arguments
|
|
80
|
+
request: ['validate', ({}, cbk) => {
|
|
81
|
+
// Exit early when a channel id is specified
|
|
82
|
+
if (!!args.id) {
|
|
83
|
+
return cbk(null, {chan_id: chanNumber({channel: args.id}).number});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return cbk(null, {
|
|
87
|
+
chan_point: `${args.transaction_id}:${args.transaction_vout}`,
|
|
88
|
+
});
|
|
89
|
+
}],
|
|
90
|
+
|
|
62
91
|
// Get channel
|
|
63
|
-
getChannel: ['
|
|
64
|
-
return lnd
|
|
65
|
-
chan_id: chanNumber({channel: id}).number,
|
|
66
|
-
},
|
|
67
|
-
(err, response) => {
|
|
92
|
+
getChannel: ['request', ({request}, cbk) => {
|
|
93
|
+
return args.lnd[type][method](request, (err, response) => {
|
|
68
94
|
if (!!err && err.details === edgeIsZombieErrorMessage) {
|
|
69
95
|
return cbk([404, 'FullChannelDetailsNotFound']);
|
|
70
96
|
}
|
package/package.json
CHANGED
|
@@ -8,13 +8,30 @@ const tests = [
|
|
|
8
8
|
{
|
|
9
9
|
args: {},
|
|
10
10
|
description: 'An id for a channel is required',
|
|
11
|
-
error: [400, '
|
|
11
|
+
error: [400, 'ExpectedChannelIdOrFundingOutpointToGetChannel'],
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
args: {id: 'id'},
|
|
15
15
|
description: 'LND is required to get the channel',
|
|
16
16
|
error: [400, 'ExpectedLndToGetChannelDetails'],
|
|
17
17
|
},
|
|
18
|
+
{
|
|
19
|
+
args: {id: 'id', transaction_id: '00'},
|
|
20
|
+
description: 'Only one identifier is required to get channel',
|
|
21
|
+
error: [400, 'ExpectedEitherChannelIdOrOutpointToGetChannel'],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
args: {
|
|
25
|
+
lnd: {
|
|
26
|
+
default: {
|
|
27
|
+
getChanInfo: ({}, cbk) => cbk({details: 'edge marked as zombie'}),
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
transaction_id: '00',
|
|
31
|
+
},
|
|
32
|
+
description: 'A transaction output index is required',
|
|
33
|
+
error: [400, 'ExpectedChannelFundingOutputIndexToGetChannel'],
|
|
34
|
+
},
|
|
18
35
|
{
|
|
19
36
|
args: {
|
|
20
37
|
id: 'id',
|
|
@@ -154,6 +171,77 @@ const tests = [
|
|
|
154
171
|
updated_at: new Date(1000).toISOString(),
|
|
155
172
|
},
|
|
156
173
|
},
|
|
174
|
+
{
|
|
175
|
+
args: {
|
|
176
|
+
lnd: {
|
|
177
|
+
default: {
|
|
178
|
+
getChanInfo: ({}, cbk) => {
|
|
179
|
+
return cbk(null, {
|
|
180
|
+
capacity: '1',
|
|
181
|
+
chan_point: `${Buffer.alloc(32).toString('hex')}:0`,
|
|
182
|
+
channel_id: '000000000',
|
|
183
|
+
node1_policy: {
|
|
184
|
+
disabled: true,
|
|
185
|
+
fee_base_msat: '1',
|
|
186
|
+
fee_rate_milli_msat: '1',
|
|
187
|
+
last_update: 1,
|
|
188
|
+
max_htlc_msat: '1',
|
|
189
|
+
min_htlc: '1',
|
|
190
|
+
time_lock_delta: 1,
|
|
191
|
+
},
|
|
192
|
+
node1_pub: Buffer.alloc(33).toString('hex'),
|
|
193
|
+
node2_policy: {
|
|
194
|
+
disabled: false,
|
|
195
|
+
fee_base_msat: '2',
|
|
196
|
+
fee_rate_milli_msat: '2',
|
|
197
|
+
last_update: 1,
|
|
198
|
+
max_htlc_msat: '2',
|
|
199
|
+
min_htlc: '2',
|
|
200
|
+
time_lock_delta: 2,
|
|
201
|
+
},
|
|
202
|
+
node2_pub: Buffer.alloc(33, 1).toString('hex'),
|
|
203
|
+
});
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
transaction_id: Buffer.alloc(32).toString('hex'),
|
|
208
|
+
transaction_vout: 0,
|
|
209
|
+
},
|
|
210
|
+
description: 'Gets graph channel details',
|
|
211
|
+
expected: {
|
|
212
|
+
capacity: 1,
|
|
213
|
+
id: '0x0x0',
|
|
214
|
+
policies: [
|
|
215
|
+
{
|
|
216
|
+
base_fee_mtokens: '1',
|
|
217
|
+
cltv_delta: 1,
|
|
218
|
+
fee_rate: 1,
|
|
219
|
+
inbound_base_discount_mtokens: '0',
|
|
220
|
+
inbound_rate_discount: 0,
|
|
221
|
+
is_disabled: true,
|
|
222
|
+
max_htlc_mtokens: '1',
|
|
223
|
+
min_htlc_mtokens: '1',
|
|
224
|
+
public_key: Buffer.alloc(33).toString('hex'),
|
|
225
|
+
updated_at: new Date(1000).toISOString(),
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
base_fee_mtokens: '2',
|
|
229
|
+
cltv_delta: 2,
|
|
230
|
+
fee_rate: 2,
|
|
231
|
+
inbound_base_discount_mtokens: '0',
|
|
232
|
+
inbound_rate_discount: 0,
|
|
233
|
+
is_disabled: false,
|
|
234
|
+
max_htlc_mtokens: '2',
|
|
235
|
+
min_htlc_mtokens: '2',
|
|
236
|
+
public_key: Buffer.alloc(33, 1).toString('hex'),
|
|
237
|
+
updated_at: new Date(1000).toISOString(),
|
|
238
|
+
},
|
|
239
|
+
],
|
|
240
|
+
transaction_id: Buffer.alloc(32).toString('hex'),
|
|
241
|
+
transaction_vout: 0,
|
|
242
|
+
updated_at: new Date(1000).toISOString(),
|
|
243
|
+
},
|
|
244
|
+
},
|
|
157
245
|
];
|
|
158
246
|
|
|
159
247
|
tests.forEach(({args, description, error, expected}) => {
|