paid-services 5.0.1 → 5.0.3

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
@@ -1,6 +1,6 @@
1
1
  # Versions
2
2
 
3
- ## Version 5.0.1
3
+ ## Version 5.0.3
4
4
 
5
5
  - `createGroupChannel`, `joinGroupChannel`, `manageGroupJoin`: Double check
6
6
  open channel acceptance when peering
@@ -1,5 +1,6 @@
1
1
  const asyncAuto = require('async/auto');
2
2
  const asyncRetry = require('async/retry');
3
+ const asyncTimeout = require('async/timeout');
3
4
  const {connectPeer} = require('ln-sync');
4
5
  const {getChainBalance} = require('ln-service');
5
6
  const {getNodeAlias} = require('ln-sync');
@@ -8,6 +9,7 @@ const {returnResult} = require('asyncjs-util');
8
9
  const {getGroupDetails} = require('./p2p');
9
10
 
10
11
  const coordinatorFromJoinCode = n => n.slice(0, 66);
12
+ const defaultConnectRetryMs = 1000 * 60;
11
13
  const groupIdFromJoinCode = n => n.slice(66);
12
14
  const interval = 500;
13
15
  const isCode = n => !!n && n.length === 98;
@@ -77,7 +79,11 @@ module.exports = ({ask, lnd}, cbk) => {
77
79
  // Connect to the coordinator
78
80
  connect: ['group', ({group}, cbk) => {
79
81
  return asyncRetry({interval, times}, cbk => {
80
- return connectPeer({lnd, id: group.coordinator}, cbk);
82
+ return asyncTimeout(connectPeer, defaultConnectRetryMs)({
83
+ lnd,
84
+ id: group.coordinator,
85
+ },
86
+ cbk);
81
87
  },
82
88
  cbk);
83
89
  }],
@@ -88,11 +94,14 @@ module.exports = ({ask, lnd}, cbk) => {
88
94
  }],
89
95
 
90
96
  // Get the group details from the coordinator
91
- getDetails: ['group', ({group}, cbk) => {
92
- return getGroupDetails({
93
- lnd,
94
- coordinator: group.coordinator,
95
- id: group.id,
97
+ getDetails: ['connect', 'group', ({group}, cbk) => {
98
+ return asyncRetry({interval, times}, cbk => {
99
+ return asyncTimeout(getGroupDetails, defaultConnectRetryMs)({
100
+ lnd,
101
+ coordinator: group.coordinator,
102
+ id: group.id,
103
+ },
104
+ cbk);
96
105
  },
97
106
  cbk);
98
107
  }],
@@ -1,5 +1,6 @@
1
1
  const asyncAuto = require('async/auto');
2
2
  const asyncRetry = require('async/retry');
3
+ const asyncTimeout = require('async/timeout');
3
4
  const {connectPeer} = require('ln-sync');
4
5
  const {getChainBalance} = require('ln-service');
5
6
  const {getNodeAlias} = require('ln-sync');
@@ -8,6 +9,7 @@ const {returnResult} = require('asyncjs-util');
8
9
  const {getGroupDetails} = require('./p2p');
9
10
 
10
11
  const coordinatorFromJoinCode = n => n.slice(0, 66);
12
+ const defaultTimeoutMs = 1000 * 60;
11
13
  const groupIdFromJoinCode = n => n.slice(66);
12
14
  const interval = 500;
13
15
  const isCode = n => !!n && n.length === 98;
@@ -73,7 +75,13 @@ module.exports = ({code, lnd, logger}, cbk) => {
73
75
  // Connect to the coordinator
74
76
  connect: ['group', ({group}, cbk) => {
75
77
  return asyncRetry({interval, times}, cbk => {
76
- return connectPeer({lnd, id: group.coordinator}, cbk);
78
+ logger.info({connecting_to: group.coordinator});
79
+
80
+ return asyncTimeout(connectPeer, defaultTimeoutMs)({
81
+ lnd,
82
+ id: group.coordinator,
83
+ },
84
+ cbk);
77
85
  },
78
86
  cbk);
79
87
  }],
@@ -84,11 +92,16 @@ module.exports = ({code, lnd, logger}, cbk) => {
84
92
  }],
85
93
 
86
94
  // Get the group details from the coordinator
87
- getDetails: ['group', ({group}, cbk) => {
88
- return getGroupDetails({
89
- lnd,
90
- coordinator: group.coordinator,
91
- id: group.id,
95
+ getDetails: ['connect', 'group', ({group}, cbk) => {
96
+ return asyncRetry({interval, times}, cbk => {
97
+ logger.info({requesting_group_details_from: group.coordinator});
98
+
99
+ return getGroupDetails({
100
+ lnd,
101
+ coordinator: group.coordinator,
102
+ id: group.id,
103
+ },
104
+ cbk);
92
105
  },
93
106
  cbk);
94
107
  }],
package/package.json CHANGED
@@ -16,8 +16,8 @@
16
16
  "ecpair": "2.1.0",
17
17
  "goldengate": "12.0.5",
18
18
  "invoices": "2.2.3",
19
- "ln-service": "56.1.0",
20
- "ln-sync": "4.3.2",
19
+ "ln-service": "56.3.0",
20
+ "ln-sync": "5.1.0",
21
21
  "psbt": "2.7.2",
22
22
  "p2tr": "1.3.3",
23
23
  "tiny-secp256k1": "2.2.1"
@@ -25,7 +25,7 @@
25
25
  "description": "Lightning Paid Services library",
26
26
  "devDependencies": {
27
27
  "@alexbosworth/tap": "15.0.12",
28
- "ln-docker-daemons": "5.0.1",
28
+ "ln-docker-daemons": "5.0.2",
29
29
  "mock-lnd": "1.4.4",
30
30
  "secp256k1": "5.0.0"
31
31
  },
@@ -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": "5.0.1"
50
+ "version": "5.0.3"
51
51
  }
@@ -150,6 +150,10 @@ module.exports = ({lnd, logger, nodes}, cbk) => {
150
150
  'getPeered',
151
151
  ({getChannels, getNodes, getPeered}, cbk) =>
152
152
  {
153
+ if (!getNodes.filter(n => !!n).length) {
154
+ return cbk([404, 'FailedToFindSellerNodeDetails']);
155
+ }
156
+
153
157
  const ids = getChannels.channels.map(n => n.partner_public_key);
154
158
 
155
159
  return asyncEach(getNodes, (node, cbk) => {