ln-accounting 10.0.8 → 10.0.9

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.
Files changed (30) hide show
  1. package/CHANGELOG.md +4 -1
  2. package/esplora/get_esplora_vout.js +0 -1
  3. package/package.json +21 -6
  4. package/report/get_accounting_report.js +4 -1
  5. package/.gitattributes +0 -1
  6. package/.tm_properties +0 -1
  7. package/.travis.yml +0 -15
  8. package/blockstream/get_blockstream_tx.js +0 -94
  9. package/blockstream/get_blockstream_vout.js +0 -80
  10. package/blockstream/index.js +0 -4
  11. package/test/blockstream/test_get_blockstream_tx.js +0 -111
  12. package/test/fiat/test_get_coincap_historic_rate.js +0 -86
  13. package/test/fiat/test_get_coindesk_historic_rate.js +0 -80
  14. package/test/fiat/test_get_coingecko_historic_rate.js +0 -152
  15. package/test/fiat/test_get_fiat_values.js +0 -74
  16. package/test/fiat/test_get_historic_rate.js +0 -77
  17. package/test/harmony/test_categorize_records.js +0 -156
  18. package/test/harmony/test_chain_fees_as_records.js +0 -40
  19. package/test/harmony/test_chain_receives_as_records.js +0 -73
  20. package/test/harmony/test_chain_sends_as_records.js +0 -55
  21. package/test/harmony/test_formatted_notes.js +0 -32
  22. package/test/harmony/test_forwards_as_records.js +0 -52
  23. package/test/harmony/test_harmonize.js +0 -24
  24. package/test/harmony/test_invoices_as_records.js +0 -77
  25. package/test/harmony/test_notes_for_chain_transaction.js +0 -43
  26. package/test/harmony/test_payments_as_records.js +0 -159
  27. package/test/harmony/test_records_with_fiat.js +0 -112
  28. package/test/records/test_get_all_invoices.js +0 -105
  29. package/test/records/test_get_all_payments.js +0 -274
  30. package/test/report/test_parse_amount.js +0 -57
@@ -1,274 +0,0 @@
1
- const {deepEqual} = require('node:assert').strict;
2
- const {rejects} = require('node:assert').strict;
3
- const test = require('node:test');
4
-
5
- const {getAllPayments} = require('./../../records');
6
-
7
- const tests = [
8
- {
9
- args: {},
10
- description: 'LND is required',
11
- error: [400, 'ExpectedLndToGetAllPayments'],
12
- },
13
- {
14
- args: {lnd: {default: {listPayments: ({}, cbk) => cbk('err')}}},
15
- description: 'Errors from LND are passed back',
16
- error: [503, 'UnexpectedGetPaymentsError', {err: 'err'}],
17
- },
18
- {
19
- args: {
20
- lnd: {
21
- default: {
22
- listPayments: (args, cbk) => {
23
- if (!!args.index_offset) {
24
- return cbk(null, {
25
- first_index_offset: '1',
26
- payments: [],
27
- last_index_offset: '1',
28
- });
29
- }
30
-
31
- return cbk(null, {
32
- first_index_offset: '2',
33
- payments: [{
34
- creation_date: '1',
35
- creation_time_ns: '0',
36
- failure_reason: 'FAILURE_REASON_TIMEOUT',
37
- fee_msat: '1000',
38
- fee_sat: '1',
39
- htlcs: [{
40
- attempt_time_ns: '1000000',
41
- failure: {
42
- channel_update: {
43
- base_fee: '1000',
44
- chain_hash: Buffer.alloc(32),
45
- chan_id: '1',
46
- channel_flags: 1,
47
- extra_opaque_data: Buffer.alloc(1),
48
- fee_rate: 1,
49
- htlc_maximum_msat: '1000',
50
- htlc_minimum_msat: '1000',
51
- message_flags: 1,
52
- signature: Buffer.alloc(71),
53
- time_lock_delta: 1,
54
- timestamp: 1,
55
- },
56
- code: 'UNREADABLE_FAILURE',
57
- failure_source_index1: 1,
58
- height: 1,
59
- htlc_msat: '1000',
60
- },
61
- resolve_time_ns: '1000000',
62
- route: {
63
- hops: [
64
- {
65
- amt_to_forward_msat: '1000',
66
- chan_id: '1',
67
- chan_capacity: 1,
68
- expiry: 1,
69
- fee_msat: '1000',
70
- mpp_record: {
71
- payment_addr: Buffer.alloc(32),
72
- total_amt_msat: '1000',
73
- },
74
- pub_key: Buffer.alloc(33).toString('hex'),
75
- tlv_payload: true,
76
- },
77
- {
78
- amt_to_forward_msat: '1000',
79
- chan_id: '1',
80
- chan_capacity: 1,
81
- expiry: 1,
82
- fee_msat: '1000',
83
- mpp_record: {
84
- payment_addr: Buffer.alloc(32),
85
- total_amt_msat: '1000',
86
- },
87
- pub_key: Buffer.alloc(33).toString('hex'),
88
- tlv_payload: true,
89
- },
90
- ],
91
- total_amt: '1',
92
- total_amt_msat: '1000',
93
- total_fees: '1',
94
- total_fees_msat: '1000',
95
- total_time_lock: 1,
96
- },
97
- status: 'FAILED',
98
- }],
99
- path: [Buffer.alloc(33).toString('hex'), Buffer.alloc(33).toString('hex')],
100
- payment_hash: Buffer.alloc(32).toString('hex'),
101
- payment_index: '1',
102
- payment_preimage: Buffer.alloc(32, 1).toString('hex'),
103
- payment_request: 'lntb1500n1pdn4czkpp5ugdqer05qrrxuchrzkcue94th9w2xzasp9qm7d0yxcgp4uh4kn4qdpa2fjkzep6yprkcmmzv9kzqsmj09c8gmmrw4e8yetwvdujq5n9va6kcct5d9hkucqzysdlghdpua7uvjjkcfj49psxtlqzkp5pdncffdfk2cp3mp76thrl29qhqgzufm503pjj96586n5w6edgw3n66j4rxxs707y4zdjuhyt6qqe5weu4',
104
- status: 'SUCCEEDED',
105
- value: '1',
106
- value_msat: '1000',
107
- value_sat: '1',
108
- }],
109
- last_index_offset: '5',
110
- });
111
- },
112
- },
113
- },
114
- },
115
- description: 'Payments are returned',
116
- expected: {
117
- payments: [{
118
- attempts: [{
119
- confirmed_at: undefined,
120
- created_at: '1970-01-01T00:00:00.001Z',
121
- failed_at: '1970-01-01T00:00:00.001Z',
122
- is_confirmed: false,
123
- is_failed: true,
124
- is_pending: false,
125
- route: {
126
- fee: 1,
127
- fee_mtokens: '1000',
128
- hops: [
129
- {
130
- channel: '0x0x1',
131
- fee: 1,
132
- fee_mtokens: '1000',
133
- forward: 1,
134
- forward_mtokens: '1000',
135
- public_key: Buffer.alloc(33).toString('hex'),
136
- timeout: 1,
137
- },
138
- {
139
- channel: '0x0x1',
140
- fee: 1,
141
- fee_mtokens: '1000',
142
- forward: 1,
143
- forward_mtokens: '1000',
144
- public_key: Buffer.alloc(33).toString('hex'),
145
- timeout: 1,
146
- },
147
- ],
148
- mtokens: '1000',
149
- payment: Buffer.alloc(32).toString('hex'),
150
- timeout: 1,
151
- tokens: 1,
152
- total_mtokens: '1000',
153
- },
154
- }],
155
- confirmed_at: undefined,
156
- created_at: '1970-01-01T00:00:01.000Z',
157
- destination: Buffer.alloc(33).toString('hex'),
158
- fee: 1,
159
- fee_mtokens: '1000',
160
- hops: [Buffer.alloc(33).toString('hex')],
161
- id: Buffer.alloc(32).toString('hex'),
162
- index: 1,
163
- is_confirmed: true,
164
- is_outgoing: true,
165
- mtokens: '1000',
166
- request: 'lntb1500n1pdn4czkpp5ugdqer05qrrxuchrzkcue94th9w2xzasp9qm7d0yxcgp4uh4kn4qdpa2fjkzep6yprkcmmzv9kzqsmj09c8gmmrw4e8yetwvdujq5n9va6kcct5d9hkucqzysdlghdpua7uvjjkcfj49psxtlqzkp5pdncffdfk2cp3mp76thrl29qhqgzufm503pjj96586n5w6edgw3n66j4rxxs707y4zdjuhyt6qqe5weu4',
167
- safe_fee: 1,
168
- safe_tokens: 1,
169
- secret: Buffer.alloc(32, 1).toString('hex'),
170
- tokens: 1,
171
- }],
172
- },
173
- },
174
- {
175
- args: {
176
- after: new Date().toISOString(),
177
- lnd: {
178
- default: {
179
- listPayments: (args, cbk) => {
180
- if (!!args.index_offset) {
181
- return cbk(null, {
182
- first_index_offset: '1',
183
- payments: [],
184
- last_index_offset: '1',
185
- });
186
- }
187
-
188
- return cbk(null, {
189
- first_index_offset: '2',
190
- payments: [{
191
- creation_date: '1',
192
- creation_time_ns: '0',
193
- failure_reason: 'FAILURE_REASON_TIMEOUT',
194
- fee_msat: '1000',
195
- fee_sat: '1',
196
- htlcs: [{
197
- attempt_time_ns: '1000000',
198
- failure: {
199
- channel_update: {
200
- base_fee: '1000',
201
- chain_hash: Buffer.alloc(32),
202
- chan_id: '1',
203
- channel_flags: 1,
204
- extra_opaque_data: Buffer.alloc(1),
205
- fee_rate: 1,
206
- htlc_maximum_msat: '1000',
207
- htlc_minimum_msat: '1000',
208
- message_flags: 1,
209
- signature: Buffer.alloc(71),
210
- time_lock_delta: 1,
211
- timestamp: 1,
212
- },
213
- code: 'UNREADABLE_FAILURE',
214
- failure_source_index1: 1,
215
- height: 1,
216
- htlc_msat: '1000',
217
- },
218
- resolve_time_ns: '1000000',
219
- route: {
220
- hops: [{
221
- amt_to_forward_msat: '1000',
222
- chan_id: '1',
223
- chan_capacity: 1,
224
- expiry: 1,
225
- fee_msat: '1000',
226
- mpp_record: {
227
- payment_addr: Buffer.alloc(32),
228
- total_amt_msat: '1000',
229
- },
230
- pub_key: Buffer.alloc(33).toString('hex'),
231
- tlv_payload: true,
232
- }],
233
- total_amt: '1',
234
- total_amt_msat: '1000',
235
- total_fees: '1',
236
- total_fees_msat: '1000',
237
- total_time_lock: 1,
238
- },
239
- status: 'FAILED',
240
- }],
241
- path: [Buffer.alloc(33).toString('hex'), Buffer.alloc(33).toString('hex')],
242
- payment_hash: Buffer.alloc(32).toString('hex'),
243
- payment_index: '1',
244
- payment_preimage: Buffer.alloc(32).toString('hex'),
245
- payment_request: 'lntb1500n1pdn4czkpp5ugdqer05qrrxuchrzkcue94th9w2xzasp9qm7d0yxcgp4uh4kn4qdpa2fjkzep6yprkcmmzv9kzqsmj09c8gmmrw4e8yetwvdujq5n9va6kcct5d9hkucqzysdlghdpua7uvjjkcfj49psxtlqzkp5pdncffdfk2cp3mp76thrl29qhqgzufm503pjj96586n5w6edgw3n66j4rxxs707y4zdjuhyt6qqe5weu4',
246
- status: 'FAILED',
247
- value: '1',
248
- value_msat: '1000',
249
- value_sat: '1',
250
- }],
251
- last_index_offset: '5',
252
- });
253
- },
254
- },
255
- },
256
- },
257
- description: 'Payments are returned with after condition',
258
- expected: {payments: []},
259
- },
260
- ];
261
-
262
- tests.forEach(({args, description, error, expected}) => {
263
- return test(description, async () => {
264
- if (!!error) {
265
- await rejects(getAllPayments(args), error, 'Got expected error');
266
- } else {
267
- const {payments} = await getAllPayments(args);
268
-
269
- deepEqual(payments, expected.payments, 'Got expected result');
270
- }
271
-
272
- return;
273
- });
274
- });
@@ -1,57 +0,0 @@
1
- const {equal} = require('node:assert').strict;
2
- const test = require('node:test');
3
- const {throws} = require('node:assert').strict;
4
-
5
- const {parseAmount} = require('./../../');
6
-
7
- const tests = [
8
- {
9
- args: {amount: 'amount'},
10
- description: 'A value is required',
11
- error: 'ExpectedAllKnownConstantsInFormulaToEvaluate',
12
- },
13
- {
14
- args: {amount: '1/0'},
15
- description: 'Dividing by zero is not allowed',
16
- error: 'ExpectedNonZeroDivisorForFormulaEvaluation',
17
- },
18
- {
19
- args: {amount: '0.0.0'},
20
- description: 'A generic invalid amount is rejected',
21
- error: 'UnexpectedInvalidDecimalNumberValue',
22
- },
23
- {
24
- args: {amount: 'OCT2DEC()'},
25
- description: 'Invalid functions are rejected',
26
- error: 'UnexpectedFunctionForFormulaEvaluation',
27
- },
28
- {
29
- args: {amount: '"string" + 1'},
30
- description: 'Invalid formulas are rejected',
31
- error: 'ExpectedBoolOrFiniteNumberForNumberConversion',
32
- },
33
- {
34
- args: {amount: '1.20969468*btc', variables: {variable: 'value'}},
35
- description: 'A long precision BTC value is parsed',
36
- expected: {tokens: 120969468},
37
- },
38
- {
39
- args: {amount: '1.20969465*btc'},
40
- description: 'A long precision BTC value that rounds down is parsed',
41
- expected: {tokens: 120969465},
42
- },
43
- ];
44
-
45
- tests.forEach(({args, description, error, expected}) => {
46
- return test(description, (t, end) => {
47
- if (!!error) {
48
- throws(() => parseAmount(args), new Error(error), 'Got expected error');
49
- } else {
50
- const {tokens} = parseAmount(args);
51
-
52
- equal(tokens, expected.tokens, 'Got expected output');
53
- }
54
-
55
- return end();
56
- });
57
- });