ln-service 56.11.1 → 56.12.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 +4 -0
- package/README.md +37 -0
- package/package.json +3 -3
- package/test/integration/test_open_simplified_taproot.js +111 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -99,6 +99,39 @@ const nodePublicKey = (await lnService.getWalletInfo({lnd})).public_key;
|
|
|
99
99
|
An [unauthenticatedLndGrpc](#unauthenticatedLndGrpc) function is also available
|
|
100
100
|
for `unlocker` methods.
|
|
101
101
|
|
|
102
|
+
## Subscriptions
|
|
103
|
+
|
|
104
|
+
- Besides the events listed in this documentation, all `EventEmitter` objects
|
|
105
|
+
returned by any of the `subscribeTo...` methods also offer an `error`
|
|
106
|
+
event. This event is triggered e.g. when LND is shut down. So, in order to
|
|
107
|
+
detect and correctly handle such a situation, robust client code should
|
|
108
|
+
generally also add a listener for the `error` event. For example, a
|
|
109
|
+
function that will wait for and return the next forward but throw an
|
|
110
|
+
exception when LND is either not reachable or shuts down while waiting for
|
|
111
|
+
the forward would look something like this:
|
|
112
|
+
|
|
113
|
+
``` node
|
|
114
|
+
const getNextForward = async (lnd) => {
|
|
115
|
+
const emitter = subscribeToForwards({ lnd });
|
|
116
|
+
|
|
117
|
+
try {
|
|
118
|
+
return await new Promise((resolve, reject) => {
|
|
119
|
+
emitter.on("forward", resolve);
|
|
120
|
+
// Without the following line, the function will never throw
|
|
121
|
+
// when the connection is lost after calling subscribeToForwards
|
|
122
|
+
emitter.on("error", reject);
|
|
123
|
+
});
|
|
124
|
+
} finally {
|
|
125
|
+
emitter.removeAllListeners();
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
- After the last listener has been removed from an `EventEmitter` object, the
|
|
131
|
+
subscription is released and subsequent attempts to add a listener will
|
|
132
|
+
result in an error. Call `subscribeTo...` again and add new listeners to the
|
|
133
|
+
new `EventEmitter` object.
|
|
134
|
+
|
|
102
135
|
## All Methods
|
|
103
136
|
|
|
104
137
|
- [addExternalSocket](#addexternalsocket) - Advertise a new p2p host:ip address
|
|
@@ -3731,6 +3764,9 @@ Requires `offchain:write`, `onchain:write`, `peers:write` permissions
|
|
|
3731
3764
|
|
|
3732
3765
|
`inputs` is not supported on LND 0.16.4 and below
|
|
3733
3766
|
|
|
3767
|
+
`is_simplified_taproot` is not supported on LND 0.16.4 and below and requires
|
|
3768
|
+
`--protocol.simple-taproot-chans` set on both sides.
|
|
3769
|
+
|
|
3734
3770
|
{
|
|
3735
3771
|
[base_fee_mtokens]: <Routing Base Fee Millitokens Charged String>
|
|
3736
3772
|
[chain_fee_tokens_per_vbyte]: <Chain Fee Tokens Per VByte Number>
|
|
@@ -3744,6 +3780,7 @@ Requires `offchain:write`, `onchain:write`, `peers:write` permissions
|
|
|
3744
3780
|
}]
|
|
3745
3781
|
[is_max_funding]: <Use Maximal Chain Funds For Local Funding Bool>
|
|
3746
3782
|
[is_private]: <Channel is Private Bool> // Defaults to false
|
|
3783
|
+
[is_simplified_taproot]: <Channel is Simplified Taproot Type Bool>
|
|
3747
3784
|
[is_trusted_funding]: <Accept Funding as Trusted Bool>
|
|
3748
3785
|
lnd: <Authenticated LND API Object>
|
|
3749
3786
|
local_tokens: <Total Channel Capacity Tokens Number>
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"cors": "2.8.5",
|
|
12
12
|
"express": "4.18.2",
|
|
13
13
|
"invoices": "3.0.0",
|
|
14
|
-
"lightning": "9.
|
|
14
|
+
"lightning": "9.12.0",
|
|
15
15
|
"macaroon": "3.0.4",
|
|
16
16
|
"morgan": "1.10.0",
|
|
17
17
|
"ws": "8.13.0"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"bn.js": "5.2.1",
|
|
29
29
|
"bs58check": "3.0.1",
|
|
30
30
|
"ecpair": "2.1.0",
|
|
31
|
-
"ln-docker-daemons": "5.1.
|
|
31
|
+
"ln-docker-daemons": "5.1.3",
|
|
32
32
|
"p2tr": "2.0.0",
|
|
33
33
|
"portfinder": "1.0.32",
|
|
34
34
|
"psbt": "3.0.0",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"integration-test-0.14.4": "DOCKER_LND_VERSION=v0.14.4-beta npm run test",
|
|
70
70
|
"test": "echo $DOCKER_LND_VERSION && node test/runner"
|
|
71
71
|
},
|
|
72
|
-
"version": "56.
|
|
72
|
+
"version": "56.12.0"
|
|
73
73
|
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
const {equal} = require('node:assert').strict;
|
|
2
|
+
const test = require('node:test');
|
|
3
|
+
|
|
4
|
+
const asyncRetry = require('async/retry');
|
|
5
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
6
|
+
|
|
7
|
+
const {addPeer} = require('./../../');
|
|
8
|
+
const {getChannels} = require('./../../');
|
|
9
|
+
const {openChannel} = require('./../../');
|
|
10
|
+
|
|
11
|
+
const channelCapacityTokens = 1e6;
|
|
12
|
+
const count = 100;
|
|
13
|
+
const defaultFee = 1e3;
|
|
14
|
+
const description = 'description';
|
|
15
|
+
const interval = 250;
|
|
16
|
+
const size = 2;
|
|
17
|
+
const times = 1000;
|
|
18
|
+
|
|
19
|
+
// Opening a simplified taproot channel should open a simple taproot channel
|
|
20
|
+
test(`Open simplified taproot channel`, async () => {
|
|
21
|
+
// Test for LND 0.16.4 or below to exit early and avoid test
|
|
22
|
+
{
|
|
23
|
+
const {kill, nodes} = await spawnLightningCluster({size});
|
|
24
|
+
|
|
25
|
+
const [{generate, id, lnd}, target] = nodes;
|
|
26
|
+
|
|
27
|
+
await generate({count});
|
|
28
|
+
|
|
29
|
+
const channelOpen = await asyncRetry({interval, times}, async () => {
|
|
30
|
+
await addPeer({lnd, public_key: target.id, socket: target.socket});
|
|
31
|
+
|
|
32
|
+
return await openChannel({
|
|
33
|
+
description,
|
|
34
|
+
lnd,
|
|
35
|
+
chain_fee_tokens_per_vbyte: defaultFee,
|
|
36
|
+
local_tokens: channelCapacityTokens,
|
|
37
|
+
partner_public_key: target.id,
|
|
38
|
+
socket: target.socket,
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const channel = await asyncRetry({interval, times}, async () => {
|
|
43
|
+
await generate({});
|
|
44
|
+
|
|
45
|
+
const {channels} = await getChannels({lnd});
|
|
46
|
+
|
|
47
|
+
const [channel] = channels;
|
|
48
|
+
|
|
49
|
+
if (!channel) {
|
|
50
|
+
throw new Error('ExpectedChannelOpened');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return channel;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
await kill({});
|
|
57
|
+
|
|
58
|
+
// Exit early when on LND 0.16.4 that do not support simplified taproot
|
|
59
|
+
if (channel.description !== description) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Try opening a simplified taproot channel
|
|
65
|
+
{
|
|
66
|
+
const {kill, nodes} = await spawnLightningCluster({
|
|
67
|
+
size,
|
|
68
|
+
lnd_configuration: ['--protocol.simple-taproot-chans'],
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const [{generate, id, lnd}, target] = nodes;
|
|
72
|
+
|
|
73
|
+
await generate({count});
|
|
74
|
+
|
|
75
|
+
await addPeer({lnd, public_key: target.id, socket: target.socket});
|
|
76
|
+
|
|
77
|
+
const channelOpen = await asyncRetry({interval, times}, async () => {
|
|
78
|
+
await addPeer({lnd, public_key: target.id, socket: target.socket});
|
|
79
|
+
|
|
80
|
+
return await openChannel({
|
|
81
|
+
lnd,
|
|
82
|
+
chain_fee_tokens_per_vbyte: defaultFee,
|
|
83
|
+
is_private: true,
|
|
84
|
+
is_simplified_taproot: true,
|
|
85
|
+
local_tokens: channelCapacityTokens,
|
|
86
|
+
partner_public_key: target.id,
|
|
87
|
+
socket: target.socket,
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const channel = await asyncRetry({interval, times}, async () => {
|
|
92
|
+
await generate({});
|
|
93
|
+
|
|
94
|
+
const {channels} = await getChannels({lnd});
|
|
95
|
+
|
|
96
|
+
const [channel] = channels;
|
|
97
|
+
|
|
98
|
+
if (!channel) {
|
|
99
|
+
throw new Error('ExpectedChannelOpened');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return channel;
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
equal(channel.type, 'simplified_taproot', 'Opened simplified taproot');
|
|
106
|
+
|
|
107
|
+
await kill({});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return;
|
|
111
|
+
});
|