paid-services 4.0.0 → 4.0.2

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,10 @@
1
1
  # Versions
2
2
 
3
- ## Version 4.0.0
3
+ ## Version 4.0.2
4
+
5
+ - `manageTrades`: Fix connection to seller failing
6
+
7
+ ## Version 4.0.1
4
8
 
5
9
  - `createGroupChannel`: Add method to coordinate a channel group
6
10
  - `joinGroupChannel`: Add method to join a channel group
@@ -138,27 +138,31 @@ module.exports = ({capacity, count, ecp, identity, lnd, rate}) => {
138
138
 
139
139
  const basePsbt = decodePsbt({ecp, psbt: coordinator.unsigned()});
140
140
 
141
- // Sign the unsigned funding transaction
142
- const signed = await signAndFundGroupChannel({
143
- lnd,
144
- id: pending.id,
145
- psbt: coordinator.unsigned(),
146
- utxos: pending.utxos,
147
- });
148
-
149
- // Make sure there is an incoming channel
150
- await asyncRetry({interval, times}, async () => {
151
- return await confirmIncomingChannel({
152
- capacity,
141
+ try {
142
+ // Sign the unsigned funding transaction
143
+ const signed = await signAndFundGroupChannel({
153
144
  lnd,
154
- from: coordinator.partners(identity).inbound,
155
- id: fromHex(basePsbt.unsigned_transaction).getId(),
156
- to: coordinator.partners(identity).outbound || undefined,
145
+ id: pending.id,
146
+ psbt: coordinator.unsigned(),
147
+ utxos: pending.utxos,
148
+ });
149
+
150
+ // Make sure there is an incoming channel
151
+ await asyncRetry({interval, times}, async () => {
152
+ return await confirmIncomingChannel({
153
+ capacity,
154
+ lnd,
155
+ from: coordinator.partners(identity).inbound,
156
+ id: fromHex(basePsbt.unsigned_transaction).getId(),
157
+ to: coordinator.partners(identity).outbound || undefined,
158
+ });
157
159
  });
158
- });
159
160
 
160
- // Register the signature with the coordinator
161
- return coordinator.sign({id: identity, signed: signed.psbt});
161
+ // Register the signature with the coordinator
162
+ return coordinator.sign({id: identity, signed: signed.psbt});
163
+ } catch (err) {
164
+ return errored(err);
165
+ }
162
166
  });
163
167
 
164
168
  // Group members have submitted their partial signatures
package/package.json CHANGED
@@ -16,8 +16,8 @@
16
16
  "ecpair": "2.1.0",
17
17
  "goldengate": "11.4.0",
18
18
  "invoices": "2.2.0",
19
- "ln-service": "54.2.0",
20
- "ln-sync": "3.14.0",
19
+ "ln-service": "54.2.3",
20
+ "ln-sync": "4.0.4",
21
21
  "psbt": "2.7.1",
22
22
  "p2tr": "1.3.2",
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.11",
28
- "ln-docker-daemons": "3.1.0",
28
+ "ln-docker-daemons": "3.1.2",
29
29
  "mock-lnd": "1.4.4",
30
30
  "secp256k1": "4.0.3"
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": "4.0.0"
50
+ "version": "4.0.2"
51
51
  }
@@ -15,7 +15,7 @@ const {returnResult} = require('asyncjs-util');
15
15
 
16
16
  const interval = 1000;
17
17
  const {isArray} = Array;
18
- const times = 10;
18
+ const times = 20;
19
19
  const uniq = arr => Array.from(new Set(arr));
20
20
 
21
21
  /** Connect to a seller
@@ -213,7 +213,7 @@ module.exports = ({lnd, logger, nodes}, cbk) => {
213
213
 
214
214
  // Try and connect to a referenced node
215
215
  return asyncDetect(getNodes.filter(n => !!n), (node, cbk) => {
216
- logger.info({connecting_to: node.id});
216
+ logger.info({finalizing_connection_to: node.id});
217
217
 
218
218
  // Attempt referenced sockets to establish p2p connection
219
219
  return asyncDetectSeries(node.sockets, (socket, cbk) => {
@@ -244,6 +244,8 @@ module.exports = ({lnd, logger, nodes}, cbk) => {
244
244
 
245
245
  const peer = res.peers.find(n => n.public_key === connect.id);
246
246
 
247
+ logger.info({peer_connection_pending: connect.id});
248
+
247
249
  if (!peer) {
248
250
  return cbk([503, 'FailedToConnectToPeer']);
249
251
  }
@@ -2,6 +2,7 @@ const {randomBytes} = require('crypto');
2
2
 
3
3
  const asyncAuto = require('async/auto');
4
4
  const asyncReflect = require('async/reflect');
5
+ const asyncRetry = require('async/retry');
5
6
  const {returnResult} = require('asyncjs-util');
6
7
 
7
8
  const connectToSeller = require('./connect_to_seller');
@@ -16,7 +17,7 @@ const findBasicRecord = records => records.find(n => n.type === '1');
16
17
  const findIdRecord = records => records.find(n => n.type === '0');
17
18
  const {isArray} = Array;
18
19
  const makeRequestId = () => randomBytes(32).toString('hex');
19
- const requestTradesTimeoutMs = 1000 * 30;
20
+ const requestTradesTimeoutMs = 1000 * 45;
20
21
  const tradesRequestIdType = '1';
21
22
  const uniqBy = (a,b) => a.filter((e,i) => a.findIndex(n => n[b] == e[b]) == i);
22
23
  const waitForTradesMs = 1000 * 5;
@@ -72,7 +73,10 @@ module.exports = ({ask, id, lnd, logger, nodes}, cbk) => {
72
73
 
73
74
  // Connect to the seller
74
75
  connect: ['validate', ({}, cbk) => {
75
- return connectToSeller({lnd, logger, nodes}, cbk);
76
+ return asyncRetry({}, cbk => {
77
+ return connectToSeller({lnd, logger, nodes}, cbk);
78
+ },
79
+ cbk);
76
80
  }],
77
81
 
78
82
  // Send request to node with public key identity