paid-services 4.3.4 → 5.0.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 +9 -1
- package/LICENSE +1 -1
- package/groups/assemble_channel_group.js +0 -1
- package/groups/coordinate_channel_group.js +11 -5
- package/groups/create_group_channel.js +17 -1
- package/groups/join_group_channel.js +5 -1
- package/package.json +6 -6
- package/swaps/complete_on_to_off_swap.js +1 -0
- package/test/integration/test_group_noninteractive.js +14 -16
- package/test/integration/test_request_swap_out.js +19 -0
- package/test/integration/test_sign_capacity_replacement.js +3 -1
- package/test/integration/test_swap_with_claim_path.js +21 -0
- package/test/integration/test_swap_with_refund_path.js +12 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
-
## Version
|
|
3
|
+
## Version 5.0.0
|
|
4
|
+
|
|
5
|
+
- 'createGroupChannel': Repeatedly broadcast chain transaction
|
|
6
|
+
|
|
7
|
+
### Breaking Changes
|
|
8
|
+
|
|
9
|
+
- node.js 14 is no longer supported, node.js 16+ required
|
|
10
|
+
|
|
11
|
+
## Version 4.3.5
|
|
4
12
|
|
|
5
13
|
- `createGroupChannel`: Show members that are present
|
|
6
14
|
|
package/LICENSE
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const asyncAuto = require('async/auto');
|
|
2
2
|
const asyncMap = require('async/map');
|
|
3
|
+
const {broadcastTransaction} = require('ln-sync');
|
|
3
4
|
const {getIdentity} = require('ln-service');
|
|
4
5
|
const {getNodeAlias} = require('ln-sync');
|
|
5
6
|
const {returnResult} = require('asyncjs-util');
|
|
@@ -8,6 +9,7 @@ const tinysecp = require('tiny-secp256k1');
|
|
|
8
9
|
const askForGroupDetails = require('./ask_for_group_details');
|
|
9
10
|
const assembleChannelGroup = require('./assemble_channel_group');
|
|
10
11
|
|
|
12
|
+
const descriptionForGroup = 'group channel open';
|
|
11
13
|
const join = arr => arr.join(', ');
|
|
12
14
|
const niceName = ({alias, id}) => `${alias} ${id}`.trim();
|
|
13
15
|
|
|
@@ -20,10 +22,6 @@ const niceName = ({alias, id}) => `${alias} ${id}`.trim();
|
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
@returns via cbk or Promise
|
|
23
|
-
{
|
|
24
|
-
id: <Transaction Id Hex String>
|
|
25
|
-
transaction: <Raw Transaction Hex String>
|
|
26
|
-
}
|
|
27
25
|
*/
|
|
28
26
|
module.exports = ({ask, lnd, logger}, cbk) => {
|
|
29
27
|
return new Promise((resolve, reject) => {
|
|
@@ -107,7 +105,15 @@ module.exports = ({ask, lnd, logger}, cbk) => {
|
|
|
107
105
|
coordinate.events.once('broadcast', broadcast => {
|
|
108
106
|
coordinate.events.removeAllListeners();
|
|
109
107
|
|
|
110
|
-
|
|
108
|
+
logger.info({transaction_id: broadcast.id});
|
|
109
|
+
|
|
110
|
+
return broadcastTransaction({
|
|
111
|
+
lnd,
|
|
112
|
+
logger,
|
|
113
|
+
description: descriptionForGroup,
|
|
114
|
+
transaction: broadcast.transaction,
|
|
115
|
+
},
|
|
116
|
+
cbk);
|
|
111
117
|
});
|
|
112
118
|
|
|
113
119
|
coordinate.events.once('error', err => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const asyncAuto = require('async/auto');
|
|
2
2
|
const asyncMap = require('async/map');
|
|
3
|
+
const {broadcastTransaction} = require('ln-sync');
|
|
3
4
|
const {getChainBalance} = require('ln-service');
|
|
4
5
|
const {getIdentity} = require('ln-service');
|
|
5
6
|
const {getMethods} = require('ln-service');
|
|
@@ -9,6 +10,7 @@ const tinysecp = require('tiny-secp256k1');
|
|
|
9
10
|
|
|
10
11
|
const assembleChannelGroup = require('./assemble_channel_group');
|
|
11
12
|
|
|
13
|
+
const descriptionForGroup = 'group channel open';
|
|
12
14
|
const halfOf = n => n / 2;
|
|
13
15
|
const {isArray} = Array;
|
|
14
16
|
const isPublicKey = n => !!n && /^0[2-3][0-9A-F]{64}$/i.test(n);
|
|
@@ -214,7 +216,21 @@ module.exports = (args, cbk) => {
|
|
|
214
216
|
coordinate.events.once('broadcast', broadcast => {
|
|
215
217
|
coordinate.events.removeAllListeners();
|
|
216
218
|
|
|
217
|
-
|
|
219
|
+
args.logger.info({transaction_id: broadcast.id});
|
|
220
|
+
|
|
221
|
+
return broadcastTransaction({
|
|
222
|
+
description: descriptionForGroup,
|
|
223
|
+
lnd: args.lnd,
|
|
224
|
+
logger: args.logger,
|
|
225
|
+
transaction: broadcast.transaction,
|
|
226
|
+
},
|
|
227
|
+
err => {
|
|
228
|
+
if (!!err) {
|
|
229
|
+
return cbk(err);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return cbk(null, {transaction_id: broadcast.id});
|
|
233
|
+
});
|
|
218
234
|
});
|
|
219
235
|
|
|
220
236
|
coordinate.events.once('error', err => {
|
|
@@ -80,7 +80,11 @@ module.exports = (args, cbk) => {
|
|
|
80
80
|
({getJoinDetails}, cbk) =>
|
|
81
81
|
{
|
|
82
82
|
if (getJoinDetails.rate > args.max_rate) {
|
|
83
|
-
return cbk([
|
|
83
|
+
return cbk([
|
|
84
|
+
400,
|
|
85
|
+
'ExpectedHigherMaxFeeRateToJoinGroup',
|
|
86
|
+
{needed_max_fee_rate: getJoinDetails.rate},
|
|
87
|
+
]);
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
args.logger.info({waiting_for_other_members: true});
|
package/package.json
CHANGED
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"bolt01": "1.2.6",
|
|
15
15
|
"bolt07": "1.8.3",
|
|
16
16
|
"ecpair": "2.1.0",
|
|
17
|
-
"goldengate": "12.0.
|
|
17
|
+
"goldengate": "12.0.5",
|
|
18
18
|
"invoices": "2.2.3",
|
|
19
|
-
"ln-service": "
|
|
20
|
-
"ln-sync": "4.3.
|
|
19
|
+
"ln-service": "56.1.0",
|
|
20
|
+
"ln-sync": "4.3.2",
|
|
21
21
|
"psbt": "2.7.2",
|
|
22
22
|
"p2tr": "1.3.3",
|
|
23
23
|
"tiny-secp256k1": "2.2.1"
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
"description": "Lightning Paid Services library",
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@alexbosworth/tap": "15.0.12",
|
|
28
|
-
"ln-docker-daemons": "
|
|
28
|
+
"ln-docker-daemons": "5.0.1",
|
|
29
29
|
"mock-lnd": "1.4.4",
|
|
30
30
|
"secp256k1": "5.0.0"
|
|
31
31
|
},
|
|
32
32
|
"engines": {
|
|
33
|
-
"node": ">=
|
|
33
|
+
"node": ">=16"
|
|
34
34
|
},
|
|
35
35
|
"keywords": [
|
|
36
36
|
"lightning",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"integration-tests": "tap -j 2 --branches=1 --functions=1 --lines=1 --statements=1 -t 180 test/integration/*.js",
|
|
48
48
|
"test": "tap --branches=1 --functions=1 --lines=1 --statements=1 -t 60 test/actions/*.js test/balanced/*.js test/capacity/*.js test/client/*.js test/config/*.js test/p2p/*.js test/records/*.js test/respond/*.js test/server/*.js test/swaps/*.js test/services/*.js test/trades/*.js"
|
|
49
49
|
},
|
|
50
|
-
"version": "
|
|
50
|
+
"version": "5.0.0"
|
|
51
51
|
}
|
|
@@ -584,6 +584,7 @@ module.exports = (args, cbk) => {
|
|
|
584
584
|
const vout = tx.outs.findIndex(n => n.script.equals(script));
|
|
585
585
|
|
|
586
586
|
args.emitter.emit('update', {
|
|
587
|
+
funding_transaction: signFunding.transaction,
|
|
587
588
|
funding_transaction_id: id,
|
|
588
589
|
funding_transaction_vout: vout,
|
|
589
590
|
});
|
|
@@ -81,12 +81,25 @@ test(`Setup joint channel group`, async ({end, equal, strictSame}) => {
|
|
|
81
81
|
capacity,
|
|
82
82
|
count: nodes.length,
|
|
83
83
|
lnd: control.lnd,
|
|
84
|
-
logger: {info: line => createLog.push(line)},
|
|
84
|
+
logger: {info: line => {createLog.push(line)}},
|
|
85
85
|
members: [],
|
|
86
86
|
rate: feeRate,
|
|
87
87
|
});
|
|
88
88
|
},
|
|
89
89
|
|
|
90
|
+
// Make blocks to activate the channel
|
|
91
|
+
generate: async () => {
|
|
92
|
+
await asyncRetry({interval, times}, async () => {
|
|
93
|
+
await generate({});
|
|
94
|
+
|
|
95
|
+
const {channels} = await getChannels({lnd, is_active: true});
|
|
96
|
+
|
|
97
|
+
if (!channels.length) {
|
|
98
|
+
throw new Error('ExpectedChannelActivation');
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
|
|
90
103
|
// Join the group
|
|
91
104
|
join: async () => {
|
|
92
105
|
return await asyncRetry({interval, times}, async () => {
|
|
@@ -108,21 +121,6 @@ test(`Setup joint channel group`, async ({end, equal, strictSame}) => {
|
|
|
108
121
|
|
|
109
122
|
const ids = [group.join.transaction_id, group.create.transaction_id];
|
|
110
123
|
|
|
111
|
-
// Finished, wait for the channels to activate
|
|
112
|
-
await generate({count});
|
|
113
|
-
|
|
114
|
-
const {getPendingChannels} = require('ln-service');
|
|
115
|
-
|
|
116
|
-
await asyncRetry({interval, times}, async () => {
|
|
117
|
-
await generate({});
|
|
118
|
-
|
|
119
|
-
const {channels} = await getChannels({lnd, is_active: true});
|
|
120
|
-
|
|
121
|
-
if (!channels.length) {
|
|
122
|
-
throw new Error('ExpectedChannelActivation');
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
|
|
126
124
|
strictSame(ids.length, nodes.length, 'Got tx ids');
|
|
127
125
|
} catch (err) {
|
|
128
126
|
strictSame(err, null, 'Expected no failure');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const asyncRetry = require('async/retry');
|
|
2
|
+
const {broadcastChainTransaction} = require('ln-service');
|
|
2
3
|
const {createChainAddress} = require('ln-service');
|
|
3
4
|
const {createInvoice} = require('ln-service');
|
|
4
5
|
const {getChannelBalance} = require('ln-service');
|
|
@@ -79,6 +80,16 @@ test(`Start offchain swap`, async ({end, equal, strictSame}) => {
|
|
|
79
80
|
await target.generate({count: maturity});
|
|
80
81
|
}
|
|
81
82
|
|
|
83
|
+
// Make sure control can pay off chain to target
|
|
84
|
+
{
|
|
85
|
+
await asyncRetry({interval, times}, async () => {
|
|
86
|
+
return await pay({
|
|
87
|
+
lnd,
|
|
88
|
+
request: (await createInvoice({tokens, lnd: target.lnd})).request,
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
82
93
|
// Collect request messages
|
|
83
94
|
const messages = [];
|
|
84
95
|
|
|
@@ -116,6 +127,14 @@ test(`Start offchain swap`, async ({end, equal, strictSame}) => {
|
|
|
116
127
|
lnd: target.lnd,
|
|
117
128
|
logger: {
|
|
118
129
|
info: async message => {
|
|
130
|
+
// Make sure that target gets the funding transaction
|
|
131
|
+
if (message.funding_transaction) {
|
|
132
|
+
await broadcastChainTransaction({
|
|
133
|
+
lnd: target.lnd,
|
|
134
|
+
transaction: message.funding_transaction,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
119
138
|
if (!!message.response) {
|
|
120
139
|
return cbk({response: message.response});
|
|
121
140
|
}
|
|
@@ -71,8 +71,9 @@ test(`Sign capacity replacement`, async ({end, equal, strictSame}) => {
|
|
|
71
71
|
// Close the channel
|
|
72
72
|
const channelClose = await closeChannel({
|
|
73
73
|
lnd,
|
|
74
|
-
id: channel.id,
|
|
75
74
|
is_force_close: true,
|
|
75
|
+
transaction_id: channel.transaction_id,
|
|
76
|
+
transaction_vout: channel.transaction_vout,
|
|
76
77
|
});
|
|
77
78
|
|
|
78
79
|
// Find the open tx
|
|
@@ -124,6 +125,7 @@ test(`Sign capacity replacement`, async ({end, equal, strictSame}) => {
|
|
|
124
125
|
});
|
|
125
126
|
|
|
126
127
|
await broadcastChainTransaction({transaction, lnd});
|
|
128
|
+
await broadcastChainTransaction({transaction, lnd: target.lnd});
|
|
127
129
|
|
|
128
130
|
await generate({count: maturity});
|
|
129
131
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const asyncRetry = require('async/retry');
|
|
2
|
+
const {broadcastChainTransaction} = require('ln-service');
|
|
2
3
|
const {createChainAddress} = require('ln-service');
|
|
3
4
|
const {createInvoice} = require('ln-service');
|
|
4
5
|
const {getChannelBalance} = require('ln-service');
|
|
@@ -52,6 +53,18 @@ test(`Swap with claim path`, async ({end, equal, strictSame}) => {
|
|
|
52
53
|
});
|
|
53
54
|
});
|
|
54
55
|
|
|
56
|
+
// Make sure control can pay off chain to target
|
|
57
|
+
{
|
|
58
|
+
await asyncRetry({interval, times}, async () => {
|
|
59
|
+
await generate({});
|
|
60
|
+
|
|
61
|
+
return await pay({
|
|
62
|
+
lnd,
|
|
63
|
+
request: (await createInvoice({tokens, lnd: target.lnd})).request,
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
55
68
|
await asyncRetry({interval, times}, async () => {
|
|
56
69
|
const {channels} = await getChannels({lnd, is_active: true});
|
|
57
70
|
|
|
@@ -116,6 +129,14 @@ test(`Swap with claim path`, async ({end, equal, strictSame}) => {
|
|
|
116
129
|
lnd: target.lnd,
|
|
117
130
|
logger: {
|
|
118
131
|
info: async message => {
|
|
132
|
+
// Make sure that target gets the funding transaction
|
|
133
|
+
if (message.funding_transaction) {
|
|
134
|
+
await broadcastChainTransaction({
|
|
135
|
+
lnd: target.lnd,
|
|
136
|
+
transaction: message.funding_transaction,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
119
140
|
if (!!message.response) {
|
|
120
141
|
return cbk({response: message.response});
|
|
121
142
|
}
|
|
@@ -84,6 +84,18 @@ test(`Timeout a swap`, async ({end, equal, strictSame}) => {
|
|
|
84
84
|
await target.generate({count: maturity});
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
// Make sure control can pay off chain to target
|
|
88
|
+
{
|
|
89
|
+
await asyncRetry({interval, times}, async () => {
|
|
90
|
+
await generate({});
|
|
91
|
+
|
|
92
|
+
return await pay({
|
|
93
|
+
lnd,
|
|
94
|
+
request: (await createInvoice({tokens, lnd: target.lnd})).request,
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
87
99
|
// Collect request messages
|
|
88
100
|
const messages = [];
|
|
89
101
|
|