balanceofsatoshis 12.26.0 → 12.26.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,17 @@
1
1
  # Versions
2
2
 
3
+ ## 12.26.3
4
+
5
+ - `open-group-channel`: Fix sufficient balance check coordinating pair group
6
+
7
+ ## 12.26.2
8
+
9
+ - `telegram`: Improve reliability of /commands if lnd connection is interrupted
10
+
11
+ ## 12.26.1
12
+
13
+ - `open-group-channel`: Fix sufficient balance check for 2 party channel groups
14
+
3
15
  ## 12.26.0
4
16
 
5
17
  - `call`: Add support for `sendToChainAddress` to send coins on chain
package/package.json CHANGED
@@ -33,14 +33,14 @@
33
33
  "grammy": "1.10.1",
34
34
  "hot-formula-parser": "4.0.0",
35
35
  "import-lazy": "4.0.0",
36
- "ini": "3.0.0",
36
+ "ini": "3.0.1",
37
37
  "inquirer": "9.1.0",
38
38
  "ln-accounting": "5.0.7",
39
- "ln-service": "53.17.5",
39
+ "ln-service": "53.20.0",
40
40
  "ln-sync": "3.13.1",
41
41
  "ln-telegram": "3.22.3",
42
42
  "moment": "2.29.4",
43
- "paid-services": "3.20.1",
43
+ "paid-services": "3.20.3",
44
44
  "probing": "2.0.6",
45
45
  "psbt": "2.7.1",
46
46
  "qrcode-terminal": "0.12.0",
@@ -54,8 +54,8 @@
54
54
  "devDependencies": {
55
55
  "@alexbosworth/tap": "15.0.11",
56
56
  "invoices": "2.1.0",
57
- "ln-docker-daemons": "2.3.2",
58
- "mock-lnd": "1.4.1",
57
+ "ln-docker-daemons": "2.3.4",
58
+ "mock-lnd": "1.4.4",
59
59
  "tiny-secp256k1": "2.2.1"
60
60
  },
61
61
  "engines": {
@@ -83,5 +83,5 @@
83
83
  "postpublish": "docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t alexbosworth/balanceofsatoshis --push .",
84
84
  "test": "tap --branches=1 --functions=1 --lines=1 --statements=1 -t 60 test/arrays/*.js test/balances/*.js test/chain/*.js test/display/*.js test/encryption/*.js test/lnd/*.js test/network/*.js test/nodes/*.js test/peers/*.js test/responses/*.js test/routing/*.js test/services/*.js test/swaps/*.js test/tags/*.js test/telegram/*.js test/wallets/*.js"
85
85
  },
86
- "version": "12.26.0"
86
+ "version": "12.26.3"
87
87
  }
@@ -0,0 +1,77 @@
1
+ const asyncAuto = require('async/auto');
2
+ const asyncMap = require('async/map');
3
+ const {returnResult} = require('asyncjs-util');
4
+ const {getWalletInfo} = require('ln-service');
5
+
6
+ const {getLnds} = require('./../lnd');
7
+
8
+ const fromName = node => `${node.alias} ${node.public_key.substring(0, 8)}`;
9
+ const {isArray} = Array;
10
+ const sanitize = n => (n || '').replace(/_/g, '\\_').replace(/[*~`]/g, '');
11
+
12
+ /** Get node details for telegram commands
13
+
14
+ {
15
+ logger: <Winston Logger Object>
16
+ nodes: [<Saved Node Name String>]
17
+ }
18
+
19
+ @returns via cbk or Promise
20
+ {
21
+ nodes: [{
22
+ lnd: <Authenticated LND API Object>
23
+ alias: <Node Alias String>
24
+ from: <Node Name String>
25
+ public_key: <Node Identity Public Key Hex String>
26
+ }]
27
+ }
28
+ */
29
+ module.exports = ({logger, nodes}, cbk) => {
30
+ return new Promise((resolve, reject) => {
31
+ return asyncAuto({
32
+ // Check arguments
33
+ validate: cbk => {
34
+ if (!logger) {
35
+ return cbk([400, 'ExpectedWinstonLoggerGetGetTelegramNodeDetails']);
36
+ }
37
+
38
+ if (!isArray(nodes)) {
39
+ return cbk([400, 'ExpectedArrayOfSavedNodesToGetNodeDetailsFor']);
40
+ }
41
+
42
+ return cbk();
43
+ },
44
+
45
+ // Get associated LNDs
46
+ getLnds: ['validate', ({}, cbk) => getLnds({logger, nodes}, cbk)],
47
+
48
+ // Get node info for the nodes
49
+ getNodes: ['getLnds', ({getLnds}, cbk) => {
50
+ return asyncMap(getLnds.lnds, (lnd, cbk) => {
51
+ return getWalletInfo({lnd}, (err, res) => {
52
+ if (!!err) {
53
+ return cbk([503, 'FailedToGetNodeInfoForTelegramNode', {err}]);
54
+ }
55
+
56
+ const named = fromName({
57
+ alias: res.alias,
58
+ public_key: res.public_key,
59
+ });
60
+
61
+ return cbk(null, {
62
+ lnd,
63
+ alias: res.alias,
64
+ from: sanitize(named),
65
+ public_key: res.public_key,
66
+ });
67
+ });
68
+ },
69
+ cbk);
70
+ }],
71
+
72
+ // List of nodes with details
73
+ nodes: ['getNodes', ({getNodes}, cbk) => cbk(null, {nodes: getNodes})],
74
+ },
75
+ returnResult({reject, resolve, of: 'nodes'}, cbk));
76
+ });
77
+ };
@@ -98,6 +98,7 @@ module.exports = (args, cbk) => {
98
98
  min_forward_tokens: args.min_forward_tokens,
99
99
  lnds: getLnds.lnds,
100
100
  logger: args.logger,
101
+ nodes: args.nodes,
101
102
  payments_limit: args.payments_limit,
102
103
  proxy: args.proxy,
103
104
  request: args.request,
@@ -49,12 +49,14 @@ const {subscribeToPastPayments} = require('ln-service');
49
49
  const {subscribeToPendingChannels} = require('ln-sync');
50
50
  const {subscribeToTransactions} = require('ln-service');
51
51
 
52
+ const getNodeDetails = require('./get_node_details');
52
53
  const interaction = require('./interaction');
53
54
  const named = require('./../package').name;
54
55
  const {version} = require('./../package');
55
56
 
56
57
  const fileAsDoc = file => new InputFile(file.source, file.filename);
57
58
  const fromName = node => `${node.alias} ${node.public_key.substring(0, 8)}`;
59
+ const getNodes = (logger, nodes) => getNodeDetails({logger, nodes});
58
60
  const {isArray} = Array;
59
61
  const isHash = n => /^[0-9A-F]{64}$/i.test(n);
60
62
  let isBotInit = false;
@@ -74,6 +76,7 @@ const sanitize = n => (n || '').replace(/_/g, '\\_').replace(/[*~`]/g, '');
74
76
  key: <Telegram API Key String>
75
77
  [min_forward_tokens]: <Minimum Forward Tokens To Notify Number>
76
78
  lnds: [<Authenticated LND API Object>]
79
+ nodes: [<Saved Nodes String>]
77
80
  logger: <Winston Logger Object>
78
81
  payments_limit: <Total Spendable Budget Tokens Limit Number>
79
82
  request: <Request Function>
@@ -115,6 +118,10 @@ module.exports = (args, cbk) => {
115
118
  return cbk([400, 'ExpectedLoggerToStartTelegramBot']);
116
119
  }
117
120
 
121
+ if (!isArray(args.nodes)) {
122
+ return cbk([400, 'ExpectedArrayOfSavedNodesToStartTelegramBot']);
123
+ }
124
+
118
125
  if (!isNumber(args.payments_limit)) {
119
126
  return cbk([400, 'ExpectedPaymentsLimitTokensNumberToStartBot']);
120
127
  }
@@ -150,29 +157,8 @@ module.exports = (args, cbk) => {
150
157
  cbk);
151
158
  }],
152
159
 
153
- // Setup the bot commands
154
- setCommands: ['validate', async ({}) => {
155
- return await args.bot.api.setMyCommands([
156
- {command: 'backup', description: 'Get node backup file'},
157
- {command: 'blocknotify', description: 'Get notified on next block'},
158
- {command: 'connect', description: 'Get connect code for the bot'},
159
- {command: 'costs', description: 'Show costs over the week'},
160
- {command: 'earnings', description: 'Show earnings over the week'},
161
- {command: 'graph', description: 'Show info about a node'},
162
- {command: 'help', description: 'Show the list of commands'},
163
- {command: 'info', description: 'Show wallet info'},
164
- {command: 'invoice', description: 'Create an invoice [amt] [memo]'},
165
- {command: 'liquidity', description: 'Get liquidity [with-peer]'},
166
- {command: 'mempool', description: 'Get info about the mempool'},
167
- {command: 'pay', description: 'Pay a payment request'},
168
- {command: 'pending', description: 'Get pending forwards, channels'},
169
- {command: 'stop', description: 'Stop the bot'},
170
- {command: 'version', description: 'View current bot version'},
171
- ]);
172
- }],
173
-
174
160
  // Setup the bot start action
175
- initBot: ['getNodes', ({getNodes}, cbk) => {
161
+ initBot: ['validate', ({}, cbk) => {
176
162
  // Exit early when the bot was already setup
177
163
  if (!!isBotInit) {
178
164
  return cbk();
@@ -197,7 +183,7 @@ module.exports = (args, cbk) => {
197
183
  await handleBackupCommand({
198
184
  from: ctx.message.from.id,
199
185
  id: connectedId,
200
- nodes: getNodes,
186
+ nodes: (await getNodes(args.logger, args.nodes)).nodes,
201
187
  reply: ctx.reply,
202
188
  send: (n, opts) => ctx.replyWithDocument(fileAsDoc(n), opts),
203
189
  });
@@ -232,7 +218,7 @@ module.exports = (args, cbk) => {
232
218
  await handleCostsCommand({
233
219
  from: ctx.message.from.id,
234
220
  id: connectedId,
235
- nodes: getNodes,
221
+ nodes: (await getNodes(args.logger, args.nodes)).nodes,
236
222
  reply: n => ctx.reply(n, markdown),
237
223
  request: args.request,
238
224
  working: () => ctx.replyWithChatAction('typing'),
@@ -248,7 +234,7 @@ module.exports = (args, cbk) => {
248
234
  await handleEarningsCommand({
249
235
  from: ctx.message.from.id,
250
236
  id: connectedId,
251
- nodes: getNodes,
237
+ nodes: (await getNodes(args.logger, args.nodes)).nodes,
252
238
  reply: n => ctx.reply(n, markdown),
253
239
  working: () => ctx.replyWithChatAction('typing'),
254
240
  });
@@ -263,7 +249,7 @@ module.exports = (args, cbk) => {
263
249
  await handleGraphCommand({
264
250
  from: ctx.message.from.id,
265
251
  id: connectedId,
266
- nodes: getNodes,
252
+ nodes: (await getNodes(args.logger, args.nodes)).nodes,
267
253
  remove: () => ctx.deleteMessage(),
268
254
  reply: (message, options) => ctx.reply(message, options),
269
255
  text: ctx.message.text,
@@ -280,7 +266,7 @@ module.exports = (args, cbk) => {
280
266
  await handleInfoCommand({
281
267
  from: ctx.message.from.id,
282
268
  id: connectedId,
283
- nodes: getNodes,
269
+ nodes: (await getNodes(args.logger, args.nodes)).nodes,
284
270
  remove: () => ctx.deleteMessage(),
285
271
  reply: (message, options) => ctx.reply(message, options),
286
272
  });
@@ -295,7 +281,7 @@ module.exports = (args, cbk) => {
295
281
  await handleInvoiceCommand({
296
282
  ctx,
297
283
  id: connectedId,
298
- nodes: getNodes,
284
+ nodes: (await getNodes(args.logger, args.nodes)).nodes,
299
285
  });
300
286
  } catch (err) {
301
287
  args.logger.error({err});
@@ -331,7 +317,7 @@ module.exports = (args, cbk) => {
331
317
  await handleLiquidityCommand({
332
318
  from: ctx.message.from.id,
333
319
  id: connectedId,
334
- nodes: getNodes,
320
+ nodes: (await getNodes(args.logger, args.nodes)).nodes,
335
321
  reply: (n, opt) => ctx.reply(n, opt),
336
322
  text: ctx.message.text,
337
323
  working: () => ctx.replyWithChatAction('typing'),
@@ -360,7 +346,7 @@ module.exports = (args, cbk) => {
360
346
  budget,
361
347
  from: ctx.message.from.id,
362
348
  id: connectedId,
363
- nodes: getNodes,
349
+ nodes: (await getNodes(args.logger, args.nodes)).nodes,
364
350
  reply: message => ctx.reply(message, markdown),
365
351
  request: args.request,
366
352
  text: ctx.message.text,
@@ -379,7 +365,7 @@ module.exports = (args, cbk) => {
379
365
  await handlePendingCommand({
380
366
  from: ctx.message.from.id,
381
367
  id: connectedId,
382
- nodes: getNodes,
368
+ nodes: (await getNodes(args.logger, args.nodes)).nodes,
383
369
  reply: (message, options) => ctx.reply(message, options),
384
370
  working: () => ctx.replyWithChatAction('typing'),
385
371
  });
@@ -530,6 +516,27 @@ module.exports = (args, cbk) => {
530
516
  });
531
517
  }],
532
518
 
519
+ // Setup the bot commands
520
+ setCommands: ['validate', async ({}) => {
521
+ return await args.bot.api.setMyCommands([
522
+ {command: 'backup', description: 'Get node backup file'},
523
+ {command: 'blocknotify', description: 'Get notified on next block'},
524
+ {command: 'connect', description: 'Get connect code for the bot'},
525
+ {command: 'costs', description: 'Show costs over the week'},
526
+ {command: 'earnings', description: 'Show earnings over the week'},
527
+ {command: 'graph', description: 'Show info about a node'},
528
+ {command: 'help', description: 'Show the list of commands'},
529
+ {command: 'info', description: 'Show wallet info'},
530
+ {command: 'invoice', description: 'Create an invoice [amt] [memo]'},
531
+ {command: 'liquidity', description: 'Get liquidity [with-peer]'},
532
+ {command: 'mempool', description: 'Get info about the mempool'},
533
+ {command: 'pay', description: 'Pay a payment request'},
534
+ {command: 'pending', description: 'Get pending forwards, channels'},
535
+ {command: 'stop', description: 'Stop the bot'},
536
+ {command: 'version', description: 'View current bot version'},
537
+ ]);
538
+ }],
539
+
533
540
  // Subscribe to backups
534
541
  backups: ['getNodes', 'userId', ({getNodes}, cbk) => {
535
542
  return asyncEach(getNodes, (node, cbk) => {
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "channels": [{
3
3
  "active": true,
4
+ "alias_scids": [],
4
5
  "capacity": "1",
5
6
  "chan_id": "1",
6
7
  "chan_status_flags": "1",
@@ -123,6 +123,7 @@ const tests = [
123
123
  pendingChannels: ({}, cbk) => cbk(null, pendingChannelsResponse),
124
124
  listChannels: ({}, cbk) => cbk(null, {channels: [{
125
125
  active: true,
126
+ alias_scids: [],
126
127
  capacity: '1',
127
128
  chan_id: '1',
128
129
  channel_point: '00:1',
@@ -222,6 +223,7 @@ const tests = [
222
223
  }),
223
224
  listChannels: ({}, cbk) => cbk(null, {channels: [{
224
225
  active: true,
226
+ alias_scids: [],
225
227
  capacity: '1',
226
228
  chan_id: '1',
227
229
  channel_point: '00:1',
@@ -34,6 +34,7 @@ const tests = [
34
34
  channels: {
35
35
  "channels": [{
36
36
  "active": true,
37
+ "alias_scids": [],
37
38
  "capacity": "1",
38
39
  "chan_id": "1",
39
40
  "chan_status_flags": "1",
@@ -199,7 +199,7 @@ const makeArgs = overrides => {
199
199
  settle_date: '1',
200
200
  settle_index: '1',
201
201
  settled: true,
202
- state: '',
202
+ state: 'SETTLED',
203
203
  value: '1',
204
204
  value_msat: '1000',
205
205
  });