lightning 5.0.1 → 5.2.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 +13 -0
- package/README.md +0 -4
- package/lnd_methods/info/constants.json +1 -0
- package/lnd_methods/offchain/get_pending_channels.d.ts +2 -0
- package/lnd_methods/offchain/get_pending_channels.js +2 -0
- package/lnd_methods/onchain/fund_pending_channels.js +13 -13
- package/lnd_methods/onchain/open_channel.js +2 -2
- package/lnd_methods/onchain/open_channels.d.ts +2 -0
- package/lnd_methods/onchain/open_channels.js +17 -11
- package/lnd_responses/pending_as_pending_channels.js +2 -0
- package/package.json +7 -7
- package/test/lnd_responses/test_pending_as_pending_channels.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
+
## 5.2.1
|
|
4
|
+
|
|
5
|
+
- `getPendingChannels`: Add support for channel `capacity`
|
|
6
|
+
|
|
7
|
+
## 5.1.1
|
|
8
|
+
|
|
9
|
+
- `openChannels`: Fix `cooperative_close_address` not being set on channels
|
|
10
|
+
|
|
11
|
+
## 5.1.0
|
|
12
|
+
|
|
13
|
+
- Add support for LND 0.14.1
|
|
14
|
+
- `openChannels`: Add `is_avoiding_broadcast` to avoid all funding broadcast
|
|
15
|
+
|
|
3
16
|
## 5.0.1
|
|
4
17
|
|
|
5
18
|
- `createChainAddress`: Fix type hints to reflect optionality of `format`
|
package/README.md
CHANGED
|
@@ -52,10 +52,6 @@ To access unauthenticated methods like the wallet unlocker, use
|
|
|
52
52
|
|
|
53
53
|
## Methods
|
|
54
54
|
|
|
55
|
-
There are two libraries, [ln-service](https://github.com/alexbosworth/ln-service) and this library.
|
|
56
|
-
|
|
57
|
-
Methods exported by this library support typescript, but ln-service includes additional metthods.
|
|
58
|
-
|
|
59
55
|
- [addPeer](https://github.com/alexbosworth/ln-service#addpeer): Connect to a new peer
|
|
60
56
|
- [authenticatedLndGrpc](https://github.com/alexbosworth/ln-service#authenticatedlndgrpc):
|
|
61
57
|
Instantiate connection to authenticated lnd methods.
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"4f567577db9d85b6f392f960b3aabddcad3cd02c": "0.13.3-beta",
|
|
25
25
|
"52bb3f33707b81972c67937c7a89addcdf00991c": "0.10.1-beta",
|
|
26
26
|
"596fd90ef310cd7abbf2251edaae9ba4d5f8a689": "0.13.1-beta",
|
|
27
|
+
"6042004edaaa5b3cad0a0808ff23dba4716f7178": "0.14.1-beta",
|
|
27
28
|
"61c34683058f2cc8dc10f49392a0057440d831c4": "0.13.4-beta",
|
|
28
29
|
"725ff104808f49f0a5247bfdb4b6b5da7f488d38": "0.13.0-beta",
|
|
29
30
|
"7f34774529fa0964d47fc418d4d2965435cbfdc0": "0.11.1-beta",
|
|
@@ -3,6 +3,8 @@ import {AuthenticatedLnd} from '../../lnd_grpc';
|
|
|
3
3
|
|
|
4
4
|
export type GetPendingChannelsResult = {
|
|
5
5
|
pending_channels: {
|
|
6
|
+
/** Channel Capacity Tokens */
|
|
7
|
+
capacity: number;
|
|
6
8
|
/** Channel Closing Transaction Id */
|
|
7
9
|
close_transaction_id?: string;
|
|
8
10
|
/** Channel Is Active */
|
|
@@ -25,6 +25,7 @@ const type = 'default';
|
|
|
25
25
|
@returns via cbk or Promise
|
|
26
26
|
{
|
|
27
27
|
pending_channels: [{
|
|
28
|
+
capacity: <Channel Capacity Tokens Number>
|
|
28
29
|
[close_transaction_id]: <Channel Closing Transaction Id String>
|
|
29
30
|
is_active: <Channel Is Active Bool>
|
|
30
31
|
is_closing: <Channel Is Closing Bool>
|
|
@@ -68,6 +69,7 @@ module.exports = ({lnd}, cbk) => {
|
|
|
68
69
|
return cbk();
|
|
69
70
|
},
|
|
70
71
|
|
|
72
|
+
// Get pending channels
|
|
71
73
|
getPending: ['validate', ({}, cbk) => {
|
|
72
74
|
return lnd[type][method]({}, (err, res) => {
|
|
73
75
|
if (!!err) {
|
|
@@ -24,32 +24,32 @@ const type = 'default';
|
|
|
24
24
|
|
|
25
25
|
@returns via cbk or Promise
|
|
26
26
|
*/
|
|
27
|
-
module.exports = (
|
|
27
|
+
module.exports = (args, cbk) => {
|
|
28
28
|
return new Promise((resolve, reject) => {
|
|
29
29
|
return asyncAuto({
|
|
30
30
|
// Check arguments
|
|
31
31
|
validate: cbk => {
|
|
32
|
-
if (!isArray(channels)) {
|
|
32
|
+
if (!isArray(args.channels)) {
|
|
33
33
|
return cbk([400, 'ExpectedPendingChannelIdsToFundChannels']);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
if (!channels.length) {
|
|
36
|
+
if (!args.channels.length) {
|
|
37
37
|
return cbk([400, 'ExpectedPendingChannelIdsToFund']);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
if (channels.filter(n => !n).length) {
|
|
40
|
+
if (args.channels.filter(n => !n).length) {
|
|
41
41
|
return cbk([400, 'ExpectedNonEmptyPendingChannelIdsToFund']);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
if (!!channels.find(n => !isHash(n))) {
|
|
44
|
+
if (!!args.channels.find(n => !isHash(n))) {
|
|
45
45
|
return cbk([400, 'ExpectedPendingChannelIdOfChannelToFund']);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
if (!isHex(funding)) {
|
|
48
|
+
if (!isHex(args.funding)) {
|
|
49
49
|
return cbk([400, 'ExpectedFundingPsbtToFundChannel']);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
if (!isLnd({
|
|
52
|
+
if (!isLnd({method, type, lnd: args.lnd})) {
|
|
53
53
|
return cbk([400, 'ExpectedAuthenticatedLndToFundChannels']);
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -57,12 +57,12 @@ module.exports = ({channels, funding, lnd}, cbk) => {
|
|
|
57
57
|
},
|
|
58
58
|
|
|
59
59
|
// Funded and signed PSBT
|
|
60
|
-
psbt: ['validate', ({}, cbk) => cbk(null, bufferFromHex(funding))],
|
|
60
|
+
psbt: ['validate', ({}, cbk) => cbk(null, bufferFromHex(args.funding))],
|
|
61
61
|
|
|
62
62
|
// Verify the funding for each pending channel
|
|
63
63
|
verify: ['psbt', 'validate', ({psbt}, cbk) => {
|
|
64
|
-
return asyncEach(channels, (id, cbk) => {
|
|
65
|
-
return lnd[type][method]({
|
|
64
|
+
return asyncEach(args.channels, (id, cbk) => {
|
|
65
|
+
return args.lnd[type][method]({
|
|
66
66
|
psbt_verify: {
|
|
67
67
|
funded_psbt: psbt,
|
|
68
68
|
pending_chan_id: bufferFromHex(id),
|
|
@@ -81,10 +81,10 @@ module.exports = ({channels, funding, lnd}, cbk) => {
|
|
|
81
81
|
|
|
82
82
|
// Finalize the psbts
|
|
83
83
|
finalize: ['psbt', 'verify', ({psbt}, cbk) => {
|
|
84
|
-
const [lastChannel] = channels.slice().reverse();
|
|
84
|
+
const [lastChannel] = args.channels.slice().reverse();
|
|
85
85
|
|
|
86
|
-
return asyncEachSeries(channels, (id, cbk) => {
|
|
87
|
-
return lnd[type][method]({
|
|
86
|
+
return asyncEachSeries(args.channels, (id, cbk) => {
|
|
87
|
+
return args.lnd[type][method]({
|
|
88
88
|
psbt_finalize: {
|
|
89
89
|
no_publish: id !== lastChannel,
|
|
90
90
|
pending_chan_id: bufferFromHex(id),
|
|
@@ -26,11 +26,11 @@ const type = 'default';
|
|
|
26
26
|
[give_tokens]: <Tokens to Gift To Partner Number> // Defaults to zero
|
|
27
27
|
[is_private]: <Channel is Private Bool> // Defaults to false
|
|
28
28
|
lnd: <Authenticated LND API Object>
|
|
29
|
-
local_tokens: <
|
|
29
|
+
local_tokens: <Total Channel Capacity Tokens Number>
|
|
30
30
|
[min_confirmations]: <Spend UTXOs With Minimum Confirmations Number>
|
|
31
31
|
[min_htlc_mtokens]: <Minimum HTLC Millitokens String>
|
|
32
|
-
partner_public_key: <Public Key Hex String>
|
|
33
32
|
[partner_csv_delay]: <Peer Output CSV Delay Number>
|
|
33
|
+
partner_public_key: <Public Key Hex String>
|
|
34
34
|
[partner_socket]: <Peer Connection Host:Port String>
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -22,6 +22,8 @@ export type OpenChannelsArgs = AuthenticatedLightningArgs<{
|
|
|
22
22
|
/** Peer Connection Host:Port */
|
|
23
23
|
partner_socket?: string;
|
|
24
24
|
}[];
|
|
25
|
+
/** Do not broadcast any channel funding transactions */
|
|
26
|
+
is_avoiding_broadcast?: boolean;
|
|
25
27
|
}>;
|
|
26
28
|
|
|
27
29
|
export type OpenChannelsResult = {
|
|
@@ -29,6 +29,9 @@ const type = 'default';
|
|
|
29
29
|
If you do not fund the channels, be sure to `cancelPendingChannel` on each
|
|
30
30
|
channel that was not funded.
|
|
31
31
|
|
|
32
|
+
Use `is_avoiding_broadcast` only when self-publishing the raw transaction
|
|
33
|
+
after the funding step.
|
|
34
|
+
|
|
32
35
|
{
|
|
33
36
|
channels: [{
|
|
34
37
|
capacity: <Channel Capacity Tokens Number>
|
|
@@ -36,10 +39,11 @@ const type = 'default';
|
|
|
36
39
|
[give_tokens]: <Tokens to Gift To Partner Number> // Defaults to zero
|
|
37
40
|
[is_private]: <Channel is Private Bool> // Defaults to false
|
|
38
41
|
[min_htlc_mtokens]: <Minimum HTLC Millitokens String>
|
|
39
|
-
partner_public_key: <Public Key Hex String>
|
|
40
42
|
[partner_csv_delay]: <Peer Output CSV Delay Number>
|
|
43
|
+
partner_public_key: <Public Key Hex String>
|
|
41
44
|
[partner_socket]: <Peer Connection Host:Port String>
|
|
42
45
|
}]
|
|
46
|
+
[is_avoiding_broadcast]: <Avoid Broadcast of All Channels Bool>
|
|
43
47
|
lnd: <Authenticated LND API Object>
|
|
44
48
|
}
|
|
45
49
|
|
|
@@ -52,28 +56,28 @@ const type = 'default';
|
|
|
52
56
|
}]
|
|
53
57
|
}
|
|
54
58
|
*/
|
|
55
|
-
module.exports = (
|
|
59
|
+
module.exports = (args, cbk) => {
|
|
56
60
|
return new Promise((resolve, reject) => {
|
|
57
61
|
return asyncAuto({
|
|
58
62
|
// Check arguments
|
|
59
63
|
validate: cbk => {
|
|
60
|
-
if (!isArray(channels)) {
|
|
64
|
+
if (!isArray(args.channels)) {
|
|
61
65
|
return cbk([400, 'ExpectedChannelsToOpenChannels']);
|
|
62
66
|
}
|
|
63
67
|
|
|
64
|
-
if (channels.filter(n => !!n).length !== channels.length) {
|
|
68
|
+
if (args.channels.filter(n => !!n).length !== args.channels.length) {
|
|
65
69
|
return cbk([400, 'ExpectedChannelDetailsToOpenChannels']);
|
|
66
70
|
}
|
|
67
71
|
|
|
68
|
-
if (!!channels.find(n => !n.capacity)) {
|
|
72
|
+
if (!!args.channels.find(n => !n.capacity)) {
|
|
69
73
|
return cbk([400, 'ExpectedCapacityOfChannelsToOpenChannels']);
|
|
70
74
|
}
|
|
71
75
|
|
|
72
|
-
if (!!channels.find(n => !isPublicKey(n.partner_public_key))) {
|
|
76
|
+
if (!!args.channels.find(n => !isPublicKey(n.partner_public_key))) {
|
|
73
77
|
return cbk([400, 'ExpectedPeerPublicKeyToOpenChannels']);
|
|
74
78
|
}
|
|
75
79
|
|
|
76
|
-
if (!isLnd({
|
|
80
|
+
if (!isLnd({method, type, lnd: args.lnd})) {
|
|
77
81
|
return cbk([400, 'ExpectedAuthenticatedLndToOpenChannels']);
|
|
78
82
|
}
|
|
79
83
|
|
|
@@ -82,7 +86,7 @@ module.exports = ({channels, lnd}, cbk) => {
|
|
|
82
86
|
|
|
83
87
|
// Channels to open
|
|
84
88
|
toOpen: ['validate', ({}, cbk) => {
|
|
85
|
-
return cbk(null, channels.map(channel => ({
|
|
89
|
+
return cbk(null, args.channels.map(channel => ({
|
|
86
90
|
capacity: channel.capacity,
|
|
87
91
|
id: makeId(),
|
|
88
92
|
cooperative_close_address: channel.cooperative_close_address,
|
|
@@ -101,11 +105,13 @@ module.exports = ({channels, lnd}, cbk) => {
|
|
|
101
105
|
|
|
102
106
|
return asyncMap(toOpen, (channel, cbk) => {
|
|
103
107
|
let isDone = false;
|
|
108
|
+
const isSelfPublish = !!args.is_avoiding_broadcast;
|
|
104
109
|
|
|
105
|
-
const channelOpen = lnd[type][method]({
|
|
110
|
+
const channelOpen = args.lnd[type][method]({
|
|
111
|
+
close_address: channel.cooperative_close_address || undefined,
|
|
106
112
|
funding_shim: {
|
|
107
113
|
psbt_shim: {
|
|
108
|
-
no_publish: !channel.id.equals(lastChannel),
|
|
114
|
+
no_publish: !!isSelfPublish || !channel.id.equals(lastChannel),
|
|
109
115
|
pending_chan_id: channel.id,
|
|
110
116
|
},
|
|
111
117
|
},
|
|
@@ -183,7 +189,7 @@ module.exports = ({channels, lnd}, cbk) => {
|
|
|
183
189
|
return asyncEach(toOpen, (channel, cbk) => {
|
|
184
190
|
const id = hexFromBuffer(channel.id);
|
|
185
191
|
|
|
186
|
-
return cancelPendingChannel({id, lnd}, () => cbk());
|
|
192
|
+
return cancelPendingChannel({id, lnd: args.lnd}, () => cbk());
|
|
187
193
|
},
|
|
188
194
|
() => {
|
|
189
195
|
return cbk([503, 'UnexpectedErrorOpeningChannels', {err}]);
|
|
@@ -80,6 +80,7 @@ const outpointSeparator = ':';
|
|
|
80
80
|
@returns
|
|
81
81
|
{
|
|
82
82
|
pending_channels: [{
|
|
83
|
+
capacity: <Channel Capacity Tokens Number>
|
|
83
84
|
[close_transaction_id]: <Channel Closing Transaction Id String>
|
|
84
85
|
is_active: <Channel Is Active Bool>
|
|
85
86
|
is_closing: <Channel Is Closing Bool>
|
|
@@ -285,6 +286,7 @@ module.exports = args => {
|
|
|
285
286
|
const pendingTokens = wait.pending_balance || forced.pending_balance;
|
|
286
287
|
|
|
287
288
|
return {
|
|
289
|
+
capacity: Number(channel.capacity),
|
|
288
290
|
close_transaction_id: endTx || undefined,
|
|
289
291
|
is_active: false,
|
|
290
292
|
is_closing: !chanOpen,
|
package/package.json
CHANGED
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
"@grpc/grpc-js": "1.4.4",
|
|
11
11
|
"@grpc/proto-loader": "0.6.7",
|
|
12
12
|
"@types/express": "4.17.13",
|
|
13
|
-
"@types/node": "16.11.
|
|
13
|
+
"@types/node": "16.11.12",
|
|
14
14
|
"@types/request": "2.48.7",
|
|
15
|
-
"@types/ws": "8.2.
|
|
15
|
+
"@types/ws": "8.2.2",
|
|
16
16
|
"async": "3.2.2",
|
|
17
17
|
"asyncjs-util": "1.2.7",
|
|
18
|
-
"bitcoinjs-lib": "6.0.
|
|
18
|
+
"bitcoinjs-lib": "6.0.1",
|
|
19
19
|
"bn.js": "5.2.0",
|
|
20
20
|
"body-parser": "1.19.0",
|
|
21
21
|
"bolt07": "1.7.4",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"express": "4.17.1",
|
|
25
25
|
"invoices": "2.0.2",
|
|
26
26
|
"psbt": "1.1.10",
|
|
27
|
-
"type-fest": "2.
|
|
27
|
+
"type-fest": "2.8.0"
|
|
28
28
|
},
|
|
29
29
|
"description": "Lightning Network client library",
|
|
30
30
|
"devDependencies": {
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"@alexbosworth/tap": "15.0.10",
|
|
33
33
|
"tsd": "0.19.0",
|
|
34
34
|
"typescript": "4.5.2",
|
|
35
|
-
"ws": "8.
|
|
35
|
+
"ws": "8.3.0"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
|
-
"node": ">=12"
|
|
38
|
+
"node": ">=12.20"
|
|
39
39
|
},
|
|
40
40
|
"keywords": [
|
|
41
41
|
"grpc",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"directory": "test/typescript"
|
|
58
58
|
},
|
|
59
59
|
"types": "index.d.ts",
|
|
60
|
-
"version": "5.
|
|
60
|
+
"version": "5.2.1"
|
|
61
61
|
}
|