ln-accounting 6.1.0 → 6.1.1

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 6.1.0
3
+ ## Version 6.1.1
4
4
 
5
5
  - `parseAmount`: Add method to parse a human readable amount into tokens
6
6
 
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "goldengate": "11.4.0",
14
14
  "hot-formula-parser": "4.0.0",
15
15
  "json2csv": "5.0.7",
16
- "ln-service": "54.2.3"
16
+ "ln-service": "54.2.6"
17
17
  },
18
18
  "description": "lnd accounting reports",
19
19
  "devDependencies": {
@@ -36,5 +36,5 @@
36
36
  "scripts": {
37
37
  "test": "tap --branches=1 --functions=1 --lines=1 --statements=1 test/blockstream/*.js test/fiat/*.js test/harmony/*.js test/records/*.js test/report/*.js"
38
38
  },
39
- "version": "6.1.0"
39
+ "version": "6.1.1"
40
40
  }
@@ -3,10 +3,14 @@ const asyncUntil = require('async/until');
3
3
  const {getInvoices} = require('ln-service');
4
4
  const {returnResult} = require('asyncjs-util');
5
5
 
6
- /** Get all invoices
6
+ const limit = 1000;
7
+
8
+ /** Get all confirmed invoices
7
9
 
8
10
  {
9
- lnd: <Authenticated LND gRPC API Object>
11
+ [after]: <Invoices Confirmed After ISO 8601 Date String>
12
+ [before]: <Invoices Confirmed Before ISO 8601 Date String>
13
+ lnd: <Authenticated LND API Object>
10
14
  }
11
15
 
12
16
  @returns via cbk or Promise
@@ -39,7 +43,7 @@ const {returnResult} = require('asyncjs-util');
39
43
  }]
40
44
  }
41
45
  */
42
- module.exports = ({lnd}, cbk) => {
46
+ module.exports = ({after, before, lnd}, cbk) => {
43
47
  return new Promise((resolve, reject) => {
44
48
  return asyncAuto({
45
49
  // Check arguments
@@ -60,14 +64,32 @@ module.exports = ({lnd}, cbk) => {
60
64
  return asyncUntil(
61
65
  cbk => cbk(null, token === false),
62
66
  cbk => {
63
- return getInvoices({lnd, token}, (err, res) => {
67
+ return getInvoices({
68
+ lnd,
69
+ token,
70
+ limit: !token ? limit : undefined,
71
+ },
72
+ (err, res) => {
64
73
  if (!!err) {
65
74
  return cbk(err);
66
75
  }
67
76
 
68
77
  token = res.next || false;
69
78
 
70
- res.invoices.forEach(invoice => invoices.push(invoice));
79
+ res.invoices
80
+ .filter(n => !!n.confirmed_at && !!n.is_confirmed)
81
+ .filter(invoice => {
82
+ if (!!after && invoice.confirmed_at <= after) {
83
+ return false;
84
+ }
85
+
86
+ if (!!before && invoice.confirmed_at > before) {
87
+ return false;
88
+ }
89
+
90
+ return true;
91
+ })
92
+ .forEach(invoice => invoices.push(invoice));
71
93
 
72
94
  return cbk(null, invoices);
73
95
  });
@@ -34,8 +34,8 @@ const times = 10;
34
34
  Note: Chain fees does not include chain fees paid to close channels
35
35
 
36
36
  {
37
- [after]: <Records Created After ISO 8601 Date>
38
- [before]: <Records Created Before ISO 8601 Date>
37
+ [after]: <Records Created After ISO 8601 Date String>
38
+ [before]: <Records Created Before ISO 8601 Date String>
39
39
  [category]: <Category Filter String>
40
40
  currency: <Base Currency Type String>
41
41
  [fiat]: <Fiat Currency Type String>
@@ -191,7 +191,12 @@ module.exports = (args, cbk) => {
191
191
  }
192
192
 
193
193
  // Since there is no way to page by settle date, get all the invoices
194
- return getAllInvoices({lnd: args.lnd}, cbk);
194
+ return getAllInvoices({
195
+ after: args.after,
196
+ before: args.before,
197
+ lnd: args.lnd,
198
+ },
199
+ cbk);
195
200
  }],
196
201
 
197
202
  // Get payments