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,52 +0,0 @@
1
- const {deepEqual} = require('node:assert').strict;
2
- const test = require('node:test');
3
- const {throws} = require('node:assert').strict;
4
-
5
- const {forwardsAsRecords} = require('./../../harmony');
6
-
7
- const date = new Date().toISOString();
8
-
9
- const tests = [
10
- {
11
- args: {
12
- forwards: [{
13
- created_at: date,
14
- fee: 1,
15
- incoming_channel: 'incoming',
16
- outgoing_channel: 'outgoing',
17
- tokens: 2,
18
- }]
19
- },
20
- description: 'Forwards as records',
21
- expected: {
22
- records: [{
23
- amount: 1,
24
- category: 'forwards',
25
- created_at: date,
26
- from_id: 'incoming',
27
- notes: '2',
28
- to_id: 'outgoing',
29
- type: 'income',
30
- }],
31
- },
32
- },
33
- {
34
- args: {},
35
- description: 'Array of forwards required',
36
- error: 'ExpectedArrayOfForwardsToFormatAsAccountingRecords',
37
- },
38
- ];
39
-
40
- tests.forEach(({args, description, error, expected}) => {
41
- return test(description, (t, end) => {
42
- if (!!error) {
43
- throws(() => forwardsAsRecords(args), new Error(error), 'Got error');
44
- } else {
45
- const {records} = forwardsAsRecords(args);
46
-
47
- deepEqual(records, expected.records, 'Forwards formatted as records');
48
- }
49
-
50
- return end();
51
- });
52
- });
@@ -1,24 +0,0 @@
1
- const test = require('node:test');
2
- const {throws} = require('node:assert').strict;
3
-
4
- const {harmonize} = require('./../../harmony');
5
-
6
- const tests = [
7
- {
8
- args: {},
9
- description: 'Records are required',
10
- error: 'ExpectedRecordsToConvertToHarmonyFormat',
11
- },
12
- ];
13
-
14
- tests.forEach(({args, description, error}) => {
15
- return test(description, (t, end) => {
16
- if (!!error) {
17
- throws(() => harmonize(args), new Error(error), 'Got error');
18
- } else {
19
- harmonize(args);
20
- }
21
-
22
- return end();
23
- });
24
- });
@@ -1,77 +0,0 @@
1
- const {deepEqual} = require('node:assert').strict;
2
- const test = require('node:test');
3
- const {throws} = require('node:assert').strict;
4
-
5
- const {invoicesAsRecords} = require('./../../harmony');
6
-
7
- const date = new Date().toISOString();
8
-
9
- const tests = [
10
- {
11
- args: {
12
- invoices: [{
13
- confirmed_at: date,
14
- created_at: date,
15
- description: 'description',
16
- id: 'id',
17
- is_confirmed: true,
18
- payments: [],
19
- received: 1,
20
- }],
21
- },
22
- description: 'Invoices as records',
23
- expected: {
24
- records: [{
25
- amount: 1,
26
- category: 'invoices',
27
- created_at: date,
28
- id: 'id',
29
- notes: 'description',
30
- type: 'income',
31
- }],
32
- },
33
- },
34
- {
35
- args: {
36
- invoices: [{
37
- confirmed_at: date,
38
- created_at: date,
39
- description: '',
40
- id: 'id',
41
- is_confirmed: true,
42
- payments: [{messages: [{type: '5482373484'}]}],
43
- received: 1,
44
- }],
45
- },
46
- description: 'Push payment is represented',
47
- expected: {
48
- records: [{
49
- amount: 1,
50
- category: 'invoices',
51
- created_at: date,
52
- id: 'id',
53
- notes: '[Push Payment]',
54
- type: 'income',
55
- }],
56
- },
57
- },
58
- {
59
- args: {},
60
- description: 'Expects array of invoices',
61
- error: 'ExpectedArrayOfInvoicesToMapToAccountingRecords',
62
- }
63
- ];
64
-
65
- tests.forEach(({args, description, error, expected}) => {
66
- return test(description, (t, end) => {
67
- if (!!error) {
68
- throws(() => invoicesAsRecords(args), new Error(error), 'Got error');
69
- } else {
70
- const {records} = invoicesAsRecords(args);
71
-
72
- deepEqual(records, expected.records, 'Forwards formatted as records');
73
- }
74
-
75
- return end();
76
- });
77
- });
@@ -1,43 +0,0 @@
1
- const {equal} = require('node:assert').strict;
2
- const test = require('node:test');
3
-
4
- const notesForChainTx = require('./../../harmony/notes_for_chain_transaction');
5
-
6
- const tests = [
7
- {
8
- args: {
9
- output_addresses: ['a', 'b'],
10
- transaction: '010000000001010cb9318f1cbe8688e71ca9e61a9b2e361d1fb47adf92ee4152d274f15cca2ebd00000000232200206f569f1dcbb18b78883398b66a52c7c50938119ed4567cc3c2e5bb6d7b36c65000000000016d26000000000000160014362a2872a1c9988ef71c31bb332dfff68d895f0d0347304402207651e5bfabb17ec044f7e3cafc4817df07c3d81a72cdcdc4706f20bf0a1ff01302206b08d9f5ac317279b30b597dd91ddddc07d9f6c82b42a47e4453ff2ae9d6eafa01006a8201208763a914d1a70126ff7a149ca6f9b638db084480440ff8428821000000000000000000000000000000000000000000000000000000000000000000677503fbfa17b175210280a5a994052abe443adb74851387b389386306c690a94ddf3bfd71234cd2a72b68acfbfa1700',
11
- },
12
- description: 'Notes for timeout sweep are returned',
13
- expected: {notes: 'Submarine swap failure, swept out to a b'},
14
- },
15
- {
16
- args: {
17
- output_addresses: ['a', 'b'],
18
- transaction: '020000000001010cb9318f1cbe8688e71ca9e61a9b2e361d1fb47adf92ee4152d274f15cca2ebd000000000000000000018826000000000000160014362a2872a1c9988ef71c31bb332dfff68d895f0d0347304402203f4e9e57ac637980d380ecd634db6ff42a7def7086f0e08391c51a595bbd67cb022036010e360ef844381a6d271505d809e4cc9ca783dc6859aeae02f1de04df2c78012000000000000000000000000000000000000000000000000000000000000000006a8201208763a914b8bcb07f6344b42ab04250c86a6e8b75d3fdbbc68821020ffb4c13e0f3547a1c9b98fe8b0430643b6a4c5f49985f3dbe11564898f7040e67750327fc17b1752102e8442ed17709432b996d70838a686cbd990f19c559ea0d04e319d27ceb135b9568acfbfa1700',
19
- },
20
- description: 'Notes for successful sweep are returned',
21
- expected: {notes: 'Submarine swap success, swept out to a b'},
22
- },
23
- {
24
- args: {output_addresses: ['a', 'b']},
25
- description: 'Notes are returned',
26
- expected: {notes: 'Outputs to a b'},
27
- },
28
- {
29
- args: {description: 'description', output_addresses: ['a', 'b']},
30
- description: 'Notes with description are returned',
31
- expected: {notes: 'description - Outputs to a b'},
32
- },
33
- ];
34
-
35
- tests.forEach(({args, description, expected}) => {
36
- return test(description, (t, end) => {
37
- const {notes} = notesForChainTx(args);
38
-
39
- equal(notes, expected.notes, 'Notes for chain transaction');
40
-
41
- return end();
42
- });
43
- });
@@ -1,159 +0,0 @@
1
- const {deepEqual} = require('node:assert').strict;
2
- const test = require('node:test');
3
-
4
- const {paymentsAsRecords} = require('./../../harmony');
5
-
6
- const date = new Date().toISOString();
7
-
8
- const tests = [
9
- {
10
- args: {
11
- payments: [{
12
- created_at: date,
13
- destination: 'destination',
14
- fee: 1,
15
- id: 'id',
16
- secret: 'secret',
17
- tokens: 2,
18
- }],
19
- },
20
- description: 'Payments as records',
21
- expected: {
22
- records: [
23
- {
24
- amount: -2,
25
- category: 'payments',
26
- created_at: date,
27
- id: 'id',
28
- notes: 'secret',
29
- to_id: 'destination',
30
- type: 'spend',
31
- },
32
- {
33
- amount: -1,
34
- category: 'payments',
35
- created_at: date,
36
- id: 'id:fee',
37
- notes: 'Routing fee',
38
- type: 'fee:network',
39
- },
40
- ],
41
- },
42
- },
43
- {
44
- args: {
45
- payments: [{
46
- created_at: date,
47
- destination: 'destination',
48
- fee: 1,
49
- id: 'id',
50
- request: 'lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq8rkx3yf5tcsyz3d73gafnh3cax9rn449d9p5uxz9ezhhypd0elx87sjle52x86fux2ypatgddc6k63n7erqz25le42c4u4ecky03ylcqca784w',
51
- secret: 'secret',
52
- tokens: 2,
53
- }],
54
- },
55
- description: 'Payments as records',
56
- expected: {
57
- records: [
58
- {
59
- amount: -2,
60
- category: 'payments',
61
- created_at: date,
62
- id: 'id',
63
- notes: 'Please consider supporting this project',
64
- to_id: 'destination',
65
- type: 'spend',
66
- },
67
- {
68
- amount: -1,
69
- category: 'payments',
70
- created_at: date,
71
- id: 'id:fee',
72
- notes: 'Routing fee',
73
- type: 'fee:network',
74
- },
75
- ],
76
- },
77
- },
78
- {
79
- args: {
80
- payments: [{
81
- created_at: date,
82
- destination: 'destination',
83
- fee: 1,
84
- id: 'id',
85
- request: 'request',
86
- secret: 'secret',
87
- tokens: 2,
88
- }],
89
- },
90
- description: 'Payments as records when the request is weird',
91
- expected: {
92
- records: [
93
- {
94
- amount: -2,
95
- category: 'payments',
96
- created_at: date,
97
- id: 'id',
98
- notes: 'secret',
99
- to_id: 'destination',
100
- type: 'spend',
101
- },
102
- {
103
- amount: -1,
104
- category: 'payments',
105
- created_at: date,
106
- id: 'id:fee',
107
- notes: 'Routing fee',
108
- type: 'fee:network',
109
- },
110
- ],
111
- },
112
- },
113
- {
114
- args: {
115
- payments: [{
116
- created_at: date,
117
- destination: 'destination',
118
- fee: 1,
119
- id: 'id',
120
- request: 'request',
121
- secret: 'secret',
122
- tokens: 2,
123
- }],
124
- public_key: 'destination'
125
- },
126
- description: 'Circular payments are represented',
127
- expected: {
128
- records: [
129
- {
130
- amount: -2,
131
- category: 'payments',
132
- created_at: date,
133
- id: 'id',
134
- notes: '[To Self] secret',
135
- to_id: 'destination',
136
- type: 'spend',
137
- },
138
- {
139
- amount: -1,
140
- category: 'payments',
141
- created_at: date,
142
- id: 'id:fee',
143
- notes: 'Circular payment routing fee',
144
- type: 'fee:network',
145
- },
146
- ],
147
- },
148
- },
149
- ];
150
-
151
- tests.forEach(({args, description, expected}) => {
152
- return test(description, (t, end) => {
153
- const {records} = paymentsAsRecords(args);
154
-
155
- deepEqual(records, expected.records, 'Forwards formatted as records');
156
-
157
- return end();
158
- });
159
- });
@@ -1,112 +0,0 @@
1
- const {deepEqual} = require('node:assert').strict;
2
- const test = require('node:test');
3
- const {throws} = require('node:assert').strict;
4
-
5
- const {recordsWithFiat} = require('./../../harmony');
6
-
7
- const date = new Date().toISOString();
8
-
9
- const tests = [
10
- {
11
- args: {
12
- currency: 'BTC',
13
- fiat: [{date, cents: 123456}],
14
- records: [{
15
- amount: 1e8,
16
- category: 'category',
17
- created_at: date,
18
- id: 'id',
19
- type: 'type',
20
- }],
21
- },
22
- description: 'Add fiat values to records',
23
- expected: {
24
- records: [{
25
- amount: 1e8,
26
- asset: 'BTC',
27
- category: 'category',
28
- created_at: date,
29
- external_id: '',
30
- fiat_amount: 1234.56,
31
- from_id: '',
32
- id: 'id',
33
- notes: '',
34
- to_id: '',
35
- type: 'type',
36
- }],
37
- },
38
- },
39
- {
40
- args: {
41
- currency: 'BTC',
42
- fiat: [{date, cents: 123456}],
43
- records: [{
44
- category: 'category',
45
- created_at: date,
46
- type: 'type',
47
- }],
48
- },
49
- description: 'Add fiat values to records',
50
- expected: {
51
- records: [{
52
- amount: 0,
53
- asset: 'BTC',
54
- category: 'category',
55
- created_at: date,
56
- external_id: '',
57
- fiat_amount: 0,
58
- from_id: '',
59
- id: '',
60
- notes: '',
61
- to_id: '',
62
- type: 'type',
63
- }],
64
- },
65
- },
66
- {
67
- args: {
68
- currency: 'BTC',
69
- fiat: [],
70
- records: [{
71
- category: 'category',
72
- created_at: date,
73
- type: 'type',
74
- }],
75
- },
76
- description: 'No fiat is known',
77
- expected: {
78
- records: [{
79
- amount: 0,
80
- asset: 'BTC',
81
- category: 'category',
82
- created_at: date,
83
- external_id: '',
84
- fiat_amount: undefined,
85
- from_id: '',
86
- id: '',
87
- notes: '',
88
- to_id: '',
89
- type: 'type',
90
- }],
91
- },
92
- },
93
- {
94
- args: {},
95
- description: 'Records are required',
96
- error: 'ExpectedArrayOfRecordsToMapToFiatRecords',
97
- },
98
- ];
99
-
100
- tests.forEach(({args, description, error, expected}) => {
101
- return test(description, (t, end) => {
102
- if (!!error) {
103
- throws(() => recordsWithFiat(args), new Error(error), 'Got error');
104
- } else {
105
- const {records} = recordsWithFiat(args);
106
-
107
- deepEqual(records, expected.records, 'Fiat added to records');
108
- }
109
-
110
- return end();
111
- });
112
- });
@@ -1,105 +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 {getAllInvoices} = require('./../../records');
6
-
7
- const tests = [
8
- {
9
- args: {},
10
- description: 'LND is required',
11
- error: [400, 'ExpectedLndToGetAllInvoices'],
12
- },
13
- {
14
- args: {lnd: {default: {listInvoices: ({}, cbk) => cbk('err')}}},
15
- description: 'Errors from LND are passed back',
16
- error: [503, 'UnexpectedGetInvoicesError', {err: 'err'}],
17
- },
18
- {
19
- args: {
20
- lnd: {
21
- default: {
22
- listInvoices: (args, cbk) => {
23
- if (!!args.index_offset) {
24
- return cbk(null, {
25
- first_index_offset: '1',
26
- invoices: [],
27
- last_index_offset: '1',
28
- });
29
- }
30
-
31
- return cbk(null, {
32
- first_index_offset: '2',
33
- invoices: [{
34
- add_index: '0',
35
- amt_paid_msat: '1000',
36
- amt_paid_sat: '1',
37
- cltv_expiry: 1,
38
- creation_date: 1,
39
- description_hash: Buffer.alloc(32),
40
- expiry: 1,
41
- features: {},
42
- htlcs: [],
43
- memo: '',
44
- payment_addr: Buffer.alloc(32),
45
- payment_request: 'request',
46
- private: false,
47
- r_hash: Buffer.alloc(32),
48
- r_preimage: Buffer.alloc(32),
49
- settle_date: 1,
50
- settled: true,
51
- state: 'SETTLED',
52
- value: '1',
53
- value_msat: '1000',
54
- }],
55
- last_index_offset: '5',
56
- });
57
- },
58
- },
59
- },
60
- },
61
- description: 'Invoices are returned',
62
- expected: {
63
- invoices: [{
64
- chain_address: undefined,
65
- cltv_delta: 1,
66
- confirmed_at: '1970-01-01T00:00:01.000Z',
67
- confirmed_index: undefined,
68
- created_at: '1970-01-01T00:00:01.000Z',
69
- description: '',
70
- description_hash: '0000000000000000000000000000000000000000000000000000000000000000',
71
- expires_at: '1970-01-01T00:00:02.000Z',
72
- features: [],
73
- id: '0000000000000000000000000000000000000000000000000000000000000000',
74
- index: 0,
75
- is_canceled: undefined,
76
- is_confirmed: true,
77
- is_held: undefined,
78
- is_private: false,
79
- is_push: undefined,
80
- mtokens: '1000',
81
- payment: undefined,
82
- payments: [],
83
- received: 1,
84
- received_mtokens: '1000',
85
- request: 'request',
86
- secret: '0000000000000000000000000000000000000000000000000000000000000000',
87
- tokens: 1,
88
- }],
89
- },
90
- },
91
- ];
92
-
93
- tests.forEach(({args, description, error, expected}) => {
94
- return test(description, async () => {
95
- if (!!error) {
96
- await rejects(getAllInvoices(args), error, 'Got expected error');
97
- } else {
98
- const {invoices} = await getAllInvoices(args);
99
-
100
- deepEqual(invoices, expected.invoices, 'Got expected result');
101
- }
102
-
103
- return;
104
- });
105
- });