balanceofsatoshis 19.0.2 → 19.0.4

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
- ## 19.0.2
3
+ ## 19.0.4
4
4
 
5
5
  - `offer-channel-open`: Correct PPM fee pricing for custom lifetime lengths
6
6
 
package/README.md CHANGED
@@ -7,7 +7,7 @@ Commands for working with LND balances.
7
7
 
8
8
  Supported LND versions:
9
9
 
10
- - v0.18.0-beta to v0.18.1-beta
10
+ - v0.18.0-beta to v0.18.2-beta
11
11
  - v0.17.0-beta to v0.17.5-beta
12
12
  - v0.16.0-beta to v0.16.4-beta
13
13
  - v0.15.2-beta to v0.15.5-beta
@@ -112,11 +112,12 @@ module.exports = ({lnd, query}, cbk) => {
112
112
  channels: res.channels,
113
113
  nodes: [{
114
114
  alias: res.alias,
115
+ capacity: res.capacity,
115
116
  color: res.color,
116
117
  features: res.features,
117
118
  public_key: getKey.value.public_key,
118
119
  sockets: res.sockets.map(n => n.socket),
119
- updated_at: res.last_updated,
120
+ updated_at: res.updated_at,
120
121
  }],
121
122
  });
122
123
  });
@@ -192,7 +193,7 @@ module.exports = ({lnd, query}, cbk) => {
192
193
 
193
194
  return {
194
195
  alias: node.alias,
195
- capacity: asBigUnit(getGraph.channels.reduce(
196
+ capacity: asBigUnit(node.capacity || getGraph.channels.reduce(
196
197
  (sum, {capacity, policies}) => {
197
198
  if (!policies.find(n => n.public_key === node.public_key)) {
198
199
  return sum;
@@ -145,6 +145,10 @@ module.exports = (args, cbk) => {
145
145
  return cbk([404, 'NoServicesOfferingChannelsFound']);
146
146
  }
147
147
 
148
+ args.logger.info({
149
+ services: services.map(n => `${n.alias} ${n.public_key}`.trim()),
150
+ });
151
+
148
152
  return args.ask({
149
153
  choices: services.map(node => ({
150
154
  name: `${node.alias} ${node.public_key}`,
package/package.json CHANGED
@@ -31,19 +31,19 @@
31
31
  "csv-parse": "5.5.6",
32
32
  "ecpair": "2.1.0",
33
33
  "goldengate": "14.0.7",
34
- "grammy": "1.26.1",
34
+ "grammy": "1.27.0",
35
35
  "hot-formula-parser": "4.0.0",
36
36
  "import-lazy": "4.0.0",
37
37
  "ini": "4.1.3",
38
- "inquirer": "9.3.4",
38
+ "inquirer": "10.0.1",
39
39
  "ln-accounting": "8.0.3",
40
- "ln-service": "57.14.4",
40
+ "ln-service": "57.15.0",
41
41
  "ln-sync": "6.0.4",
42
42
  "ln-telegram": "6.1.6",
43
43
  "minimist": "1.2.8",
44
44
  "moment": "2.30.1",
45
45
  "paid-services": "6.1.4",
46
- "probing": "5.0.2",
46
+ "probing": "5.0.3",
47
47
  "psbt": "3.0.0",
48
48
  "qrcode-terminal": "0.12.0",
49
49
  "sanitize-filename": "1.6.3",
@@ -56,7 +56,7 @@
56
56
  "description": "Lightning balance CLI",
57
57
  "devDependencies": {
58
58
  "invoices": "3.0.0",
59
- "ln-docker-daemons": "6.0.20",
59
+ "ln-docker-daemons": "6.0.21",
60
60
  "mock-lnd": "1.4.4"
61
61
  },
62
62
  "engines": {
@@ -84,5 +84,5 @@
84
84
  "postpublish": "docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t alexbosworth/balanceofsatoshis -t alexbosworth/balanceofsatoshis:$npm_package_version --push .",
85
85
  "test": "npx nyc@15.1.0 node --experimental-test-coverage --test 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"
86
86
  },
87
- "version": "19.0.2"
87
+ "version": "19.0.4"
88
88
  }
@@ -61,6 +61,8 @@ module.exports = (args, cbk) => {
61
61
 
62
62
  // Run the rebalance
63
63
  rebalance: ['validate', ({}, cbk) => {
64
+ const start = new Date().toISOString();
65
+
64
66
  return asyncRetry({
65
67
  errorFilter: err => {
66
68
  // Do not retry on invalid errors
@@ -87,6 +89,7 @@ module.exports = (args, cbk) => {
87
89
  },
88
90
  cbk => {
89
91
  return rebalance({
92
+ start,
90
93
  avoid: args.avoid,
91
94
  fs: args.fs,
92
95
  in_filters: args.in_filters,
@@ -11,6 +11,7 @@ const {getIdentity} = require('ln-service');
11
11
  const {getNode} = require('ln-service');
12
12
  const {getPeerLiquidity} = require('ln-sync');
13
13
  const {getWalletVersion} = require('ln-service');
14
+ const moment = require('moment');
14
15
  const {parseAmount} = require('ln-accounting');
15
16
  const {payViaRoutes} = require('ln-service');
16
17
  const {returnResult} = require('asyncjs-util');
@@ -84,6 +85,7 @@ const uniq = arr => Array.from(new Set(arr));
84
85
  [out_filters]: [<Outbound Filter Formula String>]
85
86
  [out_inbound]: <Outbound Target Inbound Liquidity Tokens Number>
86
87
  [out_through]: <Pay Out Through Peer String>
88
+ [start]: <ISO 8601 Start Date String>
87
89
  [timeout_minutes]: <Deadline To Stop Rebalance Minutes Number>
88
90
  }
89
91
 
@@ -808,13 +810,21 @@ module.exports = (args, cbk) => {
808
810
 
809
811
  const dif = BigInt(route.fee_mtokens) - BigInt(discounted.fee_mtokens);
810
812
 
813
+ // Exit early when the inbound incluive fee rate is actually higher
814
+ if (BigInt(discounted.fee_mtokens) > BigInt(route.fee_mtokens)) {
815
+ return cbk(null, {route});
816
+ }
817
+
811
818
  return cbk(null, {
812
819
  lowered: tokAsBigTok(Number(dif / mtokensPerToken)),
820
+ route: discounted,
813
821
  });
814
822
  }],
815
823
 
816
824
  // Execute the rebalance
817
- pay: ['invoice', 'lnd', 'routes', ({invoice, lnd, routes}, cbk) => {
825
+ pay: ['discount', 'invoice', 'lnd', ({discount, invoice, lnd}, cbk) => {
826
+ const routes = [discount.route];
827
+
818
828
  return payViaRoutes({lnd, routes, id: invoice.id}, (err, res) => {
819
829
  if (!!err) {
820
830
  return cbk([503, 'UnexpectedErrExecutingRebalance', {err}]);
@@ -828,6 +838,19 @@ module.exports = (args, cbk) => {
828
838
  });
829
839
  }],
830
840
 
841
+ // Calculate rebalance time
842
+ time: ['pay', ({}, cbk) => {
843
+ // Exit early when no start time was specified
844
+ if (!args.start) {
845
+ return cbk();
846
+ }
847
+
848
+ const end = new moment();
849
+ const start = new moment(new Date(args.start));
850
+
851
+ return cbk(null, moment.duration(end.diff(start)).humanize());
852
+ }],
853
+
831
854
  // Get adjusted inbound liquidity after rebalance
832
855
  getAdjustedInbound: ['getInbound', 'pay', ({getInbound, pay}, cbk) => {
833
856
  return getPeerLiquidity({
@@ -856,6 +879,7 @@ module.exports = (args, cbk) => {
856
879
  'getInbound',
857
880
  'getOutbound',
858
881
  'pay',
882
+ 'time',
859
883
  ({
860
884
  discount,
861
885
  getAdjustedInbound,
@@ -863,6 +887,7 @@ module.exports = (args, cbk) => {
863
887
  getInbound,
864
888
  getOutbound,
865
889
  pay,
890
+ time,
866
891
  },
867
892
  cbk) =>
868
893
  {
@@ -880,6 +905,7 @@ module.exports = (args, cbk) => {
880
905
 
881
906
  return cbk(null, {
882
907
  got_inbound_fee_discount: discount.lowered,
908
+ total_execution_time: time,
883
909
  rebalance: [
884
910
  {
885
911
  increased_inbound_on: inOn,