paid-services 4.0.1 → 4.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,5 +1,9 @@
1
1
  # Versions
2
2
 
3
+ ## Version 4.0.3
4
+
5
+ - `manageTrades`: Fix connection to seller failing
6
+
3
7
  ## Version 4.0.1
4
8
 
5
9
  - `createGroupChannel`: Add method to coordinate a channel group
@@ -134,11 +134,11 @@ module.exports = ({capacity, count, ecp, identity, lnd, rate}) => {
134
134
 
135
135
  // Group members have proposed channels to each other
136
136
  coordinator.events.once('funded', async () => {
137
- emitter.emit('proposed', {});
138
-
139
- const basePsbt = decodePsbt({ecp, psbt: coordinator.unsigned()});
137
+ emitter.emit('proposed', {unsigned: coordinator.unsigned()});
140
138
 
141
139
  try {
140
+ const basePsbt = decodePsbt({ecp, psbt: coordinator.unsigned()});
141
+
142
142
  // Sign the unsigned funding transaction
143
143
  const signed = await signAndFundGroupChannel({
144
144
  lnd,
@@ -167,21 +167,21 @@ module.exports = ({capacity, count, ecp, identity, lnd, rate}) => {
167
167
 
168
168
  // Group members have submitted their partial signatures
169
169
  coordinator.events.once('signed', async () => {
170
- emitter.emit('signed', {});
171
-
172
170
  // Collect all the partially signed PSBTs
173
171
  const psbts = coordinator.signed().map(n => n.signed);
174
172
 
175
- // Merge partial PSBTs into a single PSBT
176
- const combined = combinePsbts({ecp, psbts});
173
+ emitter.emit('signed', {psbts});
177
174
 
178
- // Finalize the PSBT to convert partial signatures to full final signatures
179
- const finalized = finalizePsbt({ecp, psbt: combined.psbt});
175
+ try {
176
+ // Merge partial PSBTs into a single PSBT
177
+ const combined = combinePsbts({ecp, psbts});
180
178
 
181
- // Pull out the raw transaction from the PSBT
182
- const {transaction} = extractTransaction({ecp, psbt: finalized.psbt});
179
+ // Finalize the PSBT to convert partial signatures to final signatures
180
+ const finalized = finalizePsbt({ecp, psbt: combined.psbt});
181
+
182
+ // Pull out the raw transaction from the PSBT
183
+ const {transaction} = extractTransaction({ecp, psbt: finalized.psbt});
183
184
 
184
- try {
185
185
  emitter.emit('broadcasting', ({transaction}));
186
186
 
187
187
  const {id} = await broadcastChainTransaction({lnd, transaction});
@@ -91,12 +91,12 @@ module.exports = ({ask, lnd, logger}, cbk) => {
91
91
  coordinate.events.once('connected', () => logger.info({peered: true}));
92
92
 
93
93
  // Members will propose pending channels to each other
94
- coordinate.events.once('proposed', () => {
95
- return logger.info({proposed: true});
94
+ coordinate.events.once('proposed', ({unsigned}) => {
95
+ return logger.info({proposed: unsigned});
96
96
  });
97
97
 
98
98
  // Once all pending channels are in place, signatures will be received
99
- coordinate.events.once('signed', () => logger.info({signed: true}));
99
+ coordinate.events.once('signed', signed => logger.info({signed}));
100
100
 
101
101
  // Finally the open channel tx will be broadcast
102
102
  coordinate.events.once('broadcasting', broadcast => {
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "ecpair": "2.1.0",
17
17
  "goldengate": "11.4.0",
18
18
  "invoices": "2.2.0",
19
- "ln-service": "54.2.3",
19
+ "ln-service": "54.2.5",
20
20
  "ln-sync": "4.0.4",
21
21
  "psbt": "2.7.1",
22
22
  "p2tr": "1.3.2",
@@ -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.2",
28
+ "ln-docker-daemons": "3.1.4",
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.1"
50
+ "version": "4.0.3"
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