aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/finance.scm
blob: 371dafddbf3d5324b4eb216547acf4034f5e0e8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015, 2016, 2023 Andreas Enge <andreas@enge.fr>
;;; Copyright © 2016-2018, 2023 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2016 Alex Griffin <a@ajgrf.com>
;;; Copyright © 2016, 2020 Hartmut Goebel <h.goebel@crazy-compilers.com>
;;; Copyright © 2017 Carlo Zancanaro <carlo@zancanaro.id.au>
;;; Copyright © 2017 Theodoros Foradis <theodoros@foradis.org>
;;; Copyright © 2017 Vasile Dumitrascu <va511e@yahoo.com>
;;; Copyright © 2017–2021 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2018 Eric Bavier <bavier@member.fsf.org>
;;; Copyright © 2018 Adriano Peluso <catonano@gmail.com>
;;; Copyright © 2018-2022, 2024 Nicolas Goaziou <mail@nicolasgoaziou.fr>
;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
;;; Copyright © 2019-2024 Guillaume Le Vaillant <glv@posteo.net>
;;; Copyright © 2019 Tanguy Le Carrour <tanguy@bioneland.org>
;;; Copyright © 2019, 2020 Martin Becze <mjbecze@riseup.net>
;;; Copyright © 2019 Sebastian Schott <sschott@mailbox.org>
;;; Copyright © 2020 Kei Kebreau <kkebreau@posteo.net>
;;; Copyright © 2020 Christine Lemmer-Webber <cwebber@dustycloud.org>
;;; Copyright © 2020 Tom Zander <tomz@freedommail.ch>
;;; Copyright © 2020, 2023 Marius Bakke <marius@gnu.org>
;;; Copyright © 2020, 2021, 2022, 2024 Vinicius Monego <monego@posteo.net>
;;; Copyright © 2020 Carlo Holl <carloholl@gmail.com>
;;; Copyright © 2020 Giacomo Leidi <goodoldpaul@autistici.org>
;;; Copyright © 2021 ZmnSCPxj jxPCSnmZ <ZmnSCPxj@protonmail.com>
;;; Copyright © 2021 François J <francois-oss@avalenn.eu>
;;; Copyright © 2021 Foo Chuan Wei <chuanwei.foo@hotmail.com>
;;; Copyright © 2021 John Kehayias <john.kehayias@protonmail.com>
;;; Copyright © 2022 Kyle Meyer <kyle@kyleam.com>
;;; Copyright © 2022 Aleksandr Vityazev <avityazev@posteo.org>
;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2022 Philip McGrath <philip@philipmcgrath.com>
;;; Copyright © 2022 Collin J. Doering <collin@rekahsoft.ca>
;;; Copyright © 2023 dan <i@dan.games>
;;; Copyright © 2022 Justin Veilleux <terramorpha@cock.li>
;;; Copyright © 2023 Frank Pursel <frank.pursel@gmail.com>
;;; Copyright © 2023 Skylar Hill <stellarskylark@posteo.net>
;;; Copyright © 2023 Foundation Devices, Inc. <hello@foundationdevices.com>
;;; Copyright © 2023 Attila Lendvai <attila@lendvai.name>
;;; Copyright © 2024 Saku Laesvuori <saku@laesvuori.fi>
;;; Copyright © 2024 Sharlatan Hellseher <sharlatanus@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu packages finance)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system cmake)
  #:use-module (guix build-system copy)
  #:use-module (guix build-system emacs)
  #:use-module (guix build-system haskell)
  #:use-module (guix build-system python)
  #:use-module (guix build-system pyproject)
  #:use-module (guix build-system glib-or-gtk)
  #:use-module (guix build-system go)
  #:use-module (guix build-system qt)
  #:use-module (guix deprecation)
  #:use-module (guix gexp)
  #:use-module (guix utils)
  #:use-module (srfi srfi-26)
  #:use-module (gnu packages)
  #:use-module (gnu packages aidc)
  #:use-module (gnu packages autotools)
  #:use-module (gnu packages base)
  #:use-module (gnu packages boost)
  #:use-module (gnu packages check)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages cpp)
  #:use-module (gnu packages crypto)
  #:use-module (gnu packages curl)
  #:use-module (gnu packages databases)
  #:use-module (gnu packages docbook)
  #:use-module (gnu packages documentation)
  #:use-module (gnu packages dns)
  #:use-module (gnu packages emacs)
  #:use-module (gnu packages emacs-xyz)
  #:use-module (gnu packages dbm)
  #:use-module (gnu packages gettext)
  #:use-module (gnu packages glib)
  #:use-module (gnu packages gnome)
  #:use-module (gnu packages gnupg)
  #:use-module (gnu packages golang)
  #:use-module (gnu packages golang-web)
  #:use-module (gnu packages golang-xyz)
  #:use-module (gnu packages graphviz)
  #:use-module (gnu packages groff)
  #:use-module (gnu packages gsasl)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages haskell-check)
  #:use-module (gnu packages haskell-web)
  #:use-module (gnu packages haskell-xyz)
  #:use-module (gnu packages jemalloc)
  #:use-module (gnu packages libedit)
  #:use-module (gnu packages libevent)
  #:use-module (gnu packages libunwind)
  #:use-module (gnu packages libusb)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages man)
  #:use-module (gnu packages maths)
  #:use-module (gnu packages mpi)
  #:use-module (gnu packages multiprecision)
  #:use-module (gnu packages ncurses)
  #:use-module (gnu packages networking)
  #:use-module (gnu packages pdf)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages popt)
  #:use-module (gnu packages protobuf)
  #:use-module (gnu packages python)
  #:use-module (gnu packages python-build)
  #:use-module (gnu packages python-crypto)
  #:use-module (gnu packages python-science)
  #:use-module (gnu packages python-web)
  #:use-module (gnu packages python-xyz)
  #:use-module (gnu packages qt)
  #:use-module (gnu packages readline)
  #:use-module (gnu packages security-token)
  #:use-module (gnu packages sphinx)
  #:use-module (gnu packages sqlite)
  #:use-module (gnu packages tex)
  #:use-module (gnu packages texinfo)
  #:use-module (gnu packages textutils)
  #:use-module (gnu packages time)
  #:use-module (gnu packages tls)
  #:use-module (gnu packages upnp)
  #:use-module (gnu packages web)
  #:use-module (gnu packages xml)
  #:use-module (gnu packages gnuzilla))

(define-public bitcoin-core
  ;; The support lifetimes for bitcoin-core versions can be found in
  ;; <https://bitcoincore.org/en/lifecycle/#schedule>.
  (package
    (name "bitcoin-core")
    (version "27.1")
    (source (origin
              (method url-fetch)
              (uri
               (string-append "https://bitcoincore.org/bin/bitcoin-core-"
                              version "/bitcoin-" version ".tar.gz"))
              (sha256
               (base32
                "1npk30c4s2xihm2vxmswl2x4baw5n23gsbaw5y8sx3qvjbym240c"))))
    (build-system gnu-build-system)
    (native-inputs
     (list autoconf
           automake
           libtool
           pkg-config
           python ; for the tests
           util-linux ; provides the hexdump command for tests
           qttools-5))
    (inputs
     (list bdb-4.8 ; 4.8 required for compatibility
           boost
           libevent
           miniupnpc
           openssl
           qtbase-5
           sqlite))
    (arguments
     `(#:configure-flags
       (list
        ;; Boost is not found unless specified manually.
        (string-append "--with-boost="
                       (assoc-ref %build-inputs "boost"))
        ;; XXX: The configure script looks up Qt paths by
        ;; `pkg-config --variable=host_bins Qt5Core`, which fails to pick
        ;; up executables residing in 'qttools-5', so we specify them here.
        (string-append "ac_cv_path_LRELEASE="
                       (assoc-ref %build-inputs "qttools")
                       "/bin/lrelease")
        (string-append "ac_cv_path_LUPDATE="
                       (assoc-ref %build-inputs "qttools")
                       "/bin/lupdate"))
       #:phases
       (modify-phases %standard-phases
         (add-before 'configure 'make-qt-deterministic
           (lambda _
             ;; Make Qt deterministic.
             (setenv "QT_RCC_SOURCE_DATE_OVERRIDE" "1")
             #t))
         (add-before 'build 'set-no-git-flag
           (lambda _
             ;; Make it clear we are not building from within a git repository
             ;; (and thus no information regarding this build is available
             ;; from git).
             (setenv "BITCOIN_GENBUILD_NO_GIT" "1")
             #t))
         (add-before 'check 'set-home
           (lambda _
             (setenv "HOME" (getenv "TMPDIR")) ; tests write to $HOME
             #t))
         (add-after 'check 'check-functional
           (lambda _
             (invoke
              "python3" "./test/functional/test_runner.py"
              (string-append "--jobs=" (number->string (parallel-job-count))))
             #t)))))
    (home-page "https://bitcoin.org/")
    (synopsis "Bitcoin peer-to-peer client")
    (description
     "Bitcoin is a digital currency that enables instant payments to anyone
anywhere in the world.  It uses peer-to-peer technology to operate without
central authority: managing transactions and issuing money are carried out
collectively by the network.  Bitcoin Core is the reference implementation
of the bitcoin protocol.  This package provides the Bitcoin Core command
line client and a client based on Qt.")
    (license license:expat)))

(define-public ghc-hledger
  (package
    (name "ghc-hledger")
    (version "1.27.1")
    (source (origin
              (method url-fetch)
              (uri (hackage-uri "hledger" version))
              (sha256
               (base32
                "0qdg87m7ys2ykqqq32p7h7aw827w4f5bcqx4dspxxq6zqlvzddqb"))))
    (build-system haskell-build-system)
    (properties '((upstream-name . "hledger")))
    (inputs (list ghc-decimal
                  ghc-diff
                  ghc-aeson
                  ghc-ansi-terminal
                  ghc-breakpoint
                  ghc-cmdargs
                  ghc-data-default
                  ghc-extra
                  ghc-githash
                  ghc-hashable
                  ghc-hledger-lib
                  ghc-lucid
                  ghc-math-functions
                  ghc-megaparsec
                  ghc-microlens
                  ghc-regex-tdfa
                  ghc-safe
                  ghc-shakespeare
                  ghc-split
                  ghc-tabular
                  ghc-tasty
                  ghc-temporary
                  ghc-timeit
                  ghc-unordered-containers
                  ghc-utf8-string
                  ghc-utility-ht
                  ghc-wizards))
    (home-page "http://hledger.org")
    (synopsis "Command-line interface for the hledger accounting system")
    (description
     "The command-line interface for the hledger accounting system.  Its basic
function is to read a plain text file describing financial transactions and
produce useful reports.

hledger is a robust, cross-platform set of tools for tracking money, time, or
any other commodity, using double-entry accounting and a simple, editable file
format, with command-line, terminal and web interfaces.  It is a Haskell
rewrite of Ledger, and one of the leading implementations of Plain Text
Accounting.")
    (license license:gpl3)))

(define-public hledger
  (package
    (inherit ghc-hledger)
    (name "hledger")
    (arguments
     (list
      #:haddock? #f
      #:phases
      #~(modify-phases %standard-phases
          (add-after 'install 'install-doc
            (lambda _
              (install-file "hledger.info" (string-append #$output "/share/info"))
              (install-file "hledger.1" (string-append #$output "/man/man1"))))
           (add-after 'register 'remove-libraries
             (lambda* (#:key outputs #:allow-other-keys)
               (delete-file-recursively (string-append (assoc-ref outputs "out") "/lib")))))))))

(define-public homebank
  (package
    (name "homebank")
    (version "5.8.1")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://www.gethomebank.org/public/sources"
                                  "/homebank-" version ".tar.gz"))
              (sha256
               (base32
                "00fwadn6q2hryx7q1xf5fhb5q3ywfnlb1r4xxn7yq6ilzvm5zhv0"))))
    (build-system glib-or-gtk-build-system)
    (native-inputs
     (list pkg-config intltool))
    (inputs
     (list gtk+ libofx libsoup-minimal))
    (home-page "https://gethomebank.org/en/index.php")
    (synopsis "Graphical personal accounting application")
    (description "HomeBank allows you to manage your personal accounts at
home.  The seeks to be lightweight, simple and easy to use.  It brings
features that allow you to analyze your finances in a detailed way instantly
and dynamically with report tools based on filtering and graphical charts.")
    (license license:gpl2+)))

(define-public ledger
  (package
    (name "ledger")
    (version "3.3.2")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/ledger/ledger")
             (commit (string-append "v" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32 "0vchc97952w3fkkdn3v0nzjlgzg83cblwsi647jp3k9jq6rvhaak"))))
    (build-system cmake-build-system)
    (arguments
     `(#:modules (,@%cmake-build-system-modules
                  ((guix build python-build-system) #:select (python-version)))
       #:imported-modules (,@%cmake-build-system-modules
                           (guix build python-build-system))
       #:configure-flags
       `("-DBUILD_DOCS:BOOL=ON"
         "-DBUILD_WEB_DOCS:BOOL=ON"
         "-DUSE_PYTHON:BOOL=ON"
         "-DCMAKE_INSTALL_LIBDIR:PATH=lib")
       #:phases
       (modify-phases (@ (guix build cmake-build-system) %standard-phases)
         (add-after 'unpack 'fix-python-installation-directory
           (lambda* (#:key inputs outputs #:allow-other-keys)
             ;; By default the package attempts to install its Python bindings
             ;; to the Python store directory, which obviously does not work.
             ;; Passing -DPython_SITEARCH in #:configure-flags has no effect.
             (let ((python-version (python-version (assoc-ref inputs "python")))
                   (out (assoc-ref outputs "out")))
               (substitute* "src/CMakeLists.txt"
                 (("DESTINATION \\$\\{Python_SITEARCH\\}")
                  (string-append "DESTINATION " out "/lib/python"
                                 python-version "/site-packages")))
               #t)))
         (add-before 'configure 'install-examples
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((examples (string-append (assoc-ref outputs "out")
                                            "/share/doc/ledger/examples")))
               (install-file "test/input/sample.dat" examples)
               (install-file "test/input/demo.ledger" examples)
               (install-file "contrib/report" examples))
             #t))
         (add-after 'build 'build-doc
           (lambda _ (invoke "make" "doc")))
         (add-before 'check 'check-setup
           ;; One test fails if it can't set the timezone.
           (lambda* (#:key inputs #:allow-other-keys)
             (setenv "TZDIR"
                     (search-input-directory inputs
                                             "share/zoneinfo"))
             #t)))))
    (inputs
     (list boost
           gmp
           libedit
           mpfr
           python
           utfcpp))
    (native-inputs
     (list groff texinfo tzdata-for-tests))
    (home-page "https://ledger-cli.org/")
    (synopsis "Command-line double-entry accounting program")
    (description
     "Ledger is a powerful, double-entry accounting system that is
accessed from the UNIX command-line.  This may put off some users, since
there is no flashy UI, but for those who want unparalleled reporting
access to their data there are few alternatives.

Ledger uses text files for input.  It reads the files and generates
reports; there is no other database or stored state.  To use Ledger,
you create a file of your account names and transactions, run from the
command line with some options to specify input and requested reports, and
get output.  The output is generally plain text, though you could generate
a graph or html instead.  Ledger is simple in concept, surprisingly rich
in ability, and easy to use.")
    ;; There are some extra licenses in files which do not presently get
    ;; installed when you build this package.  Different versions of the GPL
    ;; are used in the contrib and python subdirectories.  The bundled version
    ;; of utfcpp is under the Boost 1.0 license. Also the file
    ;; `tools/update_copyright_year` has an Expat license.
    (license (list license:bsd-3
                   license:asl2.0     ; src/strptime.cc
                   (license:non-copyleft
                    "file://src/wcwidth.cc"
                    "See src/wcwidth.cc in the distribution.")))))

(define-public emacs-ledger-mode
  ;; The last release was on Nov 8, 2019 and doesn't build with Emacs 28.
  (let ((commit "11e850395448ee7012dba16bd6df103f5552ebfb")
        (revision "0"))
    (package
      (name "emacs-ledger-mode")
      (version (git-version "4.0.0" revision commit))
      (source
       (origin
         (method git-fetch)
         (uri (git-reference
               (url "https://github.com/ledger/ledger-mode")
               (commit commit)))
         (file-name (git-file-name name version))
         (sha256
          (base32 "0hzky36vrlb7kvpyz4gy3zn01zdlmlx0s58w6ggk5djbcvjc2rfx"))))
      (build-system emacs-build-system)
      (arguments
       (list
        ;; ledger-test.el is needed at runtime (but probably not for a good reason).
        #:exclude #~'()
        #:tests? #t
        #:phases
        #~(modify-phases %standard-phases
            (add-after 'unpack 'patch-path
              (lambda* (#:key inputs #:allow-other-keys)
                (make-file-writable "ledger-exec.el")
                (emacs-substitute-variables "ledger-exec.el"
                  ("ledger-binary-path" (search-input-file inputs "/bin/ledger")))))
            (add-after 'build 'build-doc
              (lambda _
                (let ((target (string-append #$output "/share/info")))
                  (mkdir-p target)
                  (invoke "makeinfo" "-o" target
                          "../source/doc/ledger-mode.texi"))))
            (replace 'check
              (lambda* (#:key tests? #:allow-other-keys)
                (when tests?
                  (with-directory-excursion "../source/test"
                    (invoke "make" "test-batch"))))))))
      (inputs
       (list ledger))
      (native-inputs
       (list texinfo))
      (home-page "https://ledger-cli.org/")
      (synopsis "Command-line double-entry accounting program")
      (description
       "Ledger is a powerful, double-entry accounting system that is
accessed from the UNIX command-line.  This may put off some users, since
there is no flashy UI, but for those who want unparalleled reporting
access to their data there are few alternatives.

Ledger uses text files for input.  It reads the files and generates
reports; there is no other database or stored state.  To use Ledger,
you create a file of your account names and transactions, run from the
command line with some options to specify input and requested reports, and
get output.  The output is generally plain text, though you could generate
a graph or html instead.  Ledger is simple in concept, surprisingly rich
in ability, and easy to use.

This package provides the Emacs mode.")
      (license license:gpl2+))))

(define-public emacs-hledger-mode
  (let ((commit "400bde42a8d2712af80cd7c773c9cdfbb63a515a")
        (revision "1"))
    (package
      (name "emacs-hledger-mode")
      (version (git-version "20220515" revision commit))
      (source (origin
                (method git-fetch)
                (uri (git-reference
                      (url "https://github.com/narendraj9/hledger-mode")
                      (commit commit)))
                (file-name (git-file-name name version))
                (sha256
                 (base32
                  "0xmcfpr3rxli1adwypg18npl8hb8ak5rg6a6i26inzzqja6vr897"))))
      (build-system emacs-build-system)
      (propagated-inputs
       (list emacs-popup
             emacs-async
             emacs-htmlize))
      (arguments
       '(#:include '("^[^/]+.el$")
         #:exclude '()))
      (home-page "https://github.com/narendraj9/hledger-mode")
      (synopsis "Mode for writing journal entries for hledger")
      (description
       "This major mode for Emacs enables writing and managing hledger
journal files.  It generates some useful reports along with some financial
ratios that can help you keep a check on your financial health for users of
the plaintext accounting system hledger.")
      (license license:gpl3))))

(define-public geierlein
  (package
    (name "geierlein")
    (version "0.9.13")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/stesie/geierlein")
             (commit (string-append "V" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32 "00zpwr3lk2vdmd60fgdwdk0xxs52wvnm19ln2m75yfphydvkglic"))))
    (build-system gnu-build-system)
    (arguments
     `(#:tests? #f                  ; would require npm, python and a lot more
       #:phases
        (modify-phases %standard-phases
          (delete 'configure)           ; no configure script
          (add-after 'unpack 'override-target-directory-and-tool-paths
            (lambda* (#:key inputs outputs #:allow-other-keys)
              (substitute* "Makefile"
                (("prefix := .*")
                 (string-append "prefix := " (assoc-ref outputs "out") "\n"))
                ;; Required for tests, unused for now:
                ;;(("PYTHON := .*")
                ;; (string-append (which "python") "\n")))
                (("INSTALL := .*")
                 (string-append "INSTALL := " (which "install") "\n")))
              (substitute* "bin/xgeierlein.in"
                ;; Use icecat as XULRUNNER
                (("^for search ")
                 (string-append "XULRUNNER=" (which "icecat") "\n"
                                "for search ")))
              #t)))))
    (inputs
     (list icecat))
    (home-page "https://stesie.github.io/geierlein/")
    (synopsis "Free Elster client, for sending Germany VAT declarations")
    (description
     "Geierlein is a free Elster client, i.e. an application that
sends VAT declarations to Germany's fiscal authorities.

Currently it is *not* possible to send returns that are due annually
(especially the income tax return) since the fiscal authority doesn't
allow doing that off the ERiC library (which is proprietary however).
It's not clear at the moment whether one day it will be possible to
do so.")
    (license license:agpl3+)))

(define-public electrum
  (package
    (name "electrum")
    (version "4.4.6")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://download.electrum.org/"
                           version "/Electrum-"
                           version ".tar.gz"))
       (sha256
        (base32 "1f0hb8xmqv1j9pf82xpyvxnn2dzmi93rhf0sh0iqakja2pbl4707"))
       (modules '((guix build utils)))
       (snippet
        '(begin
           ;; Delete the bundled dependencies.
           (delete-file-recursively "packages")))))
    (build-system python-build-system)
    (inputs
     (list libsecp256k1
           python-aiohttp
           python-aiohttp-socks
           python-aiorpcx
           python-attrs
           python-bitstring
           python-btchip-python
           python-certifi
           python-cryptography
           python-dnspython
           python-hidapi
           python-ledgerblue
           python-protobuf
           python-pyqt
           python-qdarkstyle
           python-qrcode
           zbar))
    (arguments
     `(#:tests? #f                      ; no tests
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'use-libsecp256k1-input
           (lambda* (#:key inputs #:allow-other-keys)
             (substitute* "electrum/ecc_fast.py"
               (("library_paths = \\[\\]")
                (string-append "library_paths = ['"
                               (assoc-ref inputs "libsecp256k1")
                               "/lib/libsecp256k1.so']"))))))))
    (home-page "https://electrum.org/")
    (synopsis "Bitcoin wallet")
    (description
     "Electrum is a lightweight Bitcoin client, based on a client-server
protocol.  It supports Simple Payment Verification (SPV) and deterministic key
generation from a seed.  Your secret keys are encrypted and are never sent to
other machines/servers.  Electrum does not download the Bitcoin blockchain.")
    (license license:expat)))

(define-public electron-cash
  (package
    (name "electron-cash")
    (version "4.4.1")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/Electron-Cash/Electron-Cash")
             (commit version)))
       (file-name (git-file-name name version))
       (sha256
        (base32 "11xhlssr7bvdv3p256k87y35vjzyfd93p72w8f2xy7j5jh6abhp1"))))
    (build-system python-build-system)
    (arguments
     (list
      #:tests? #f                       ; no tests
      #:modules '((guix build python-build-system)
                  (guix build qt-utils)
                  (guix build utils))
      #:imported-modules `(,@%python-build-system-modules
                           (guix build qt-utils))
      #:phases
      #~(modify-phases %standard-phases
          (add-after 'unpack 'create-output-directories
            (lambda _
              ;; setup.py installs to ~/.local/share if this doesn't exist.
              (mkdir-p (string-append #$output "/share"))))
          (add-after 'unpack 'use-libsecp256k1-input
            (lambda* (#:key inputs #:allow-other-keys)
              (substitute* "electroncash/secp256k1.py"
                (("libsecp256k1.so.0")
                 (search-input-file inputs "lib/libsecp256k1.so.0")))))
          (add-after 'install 'wrap-qt
            (lambda* (#:key outputs inputs #:allow-other-keys)
              (let ((out (assoc-ref outputs "out")))
                (wrap-qt-program "electron-cash"
                                 #:output out #:inputs inputs)))))))
    (inputs
     (list libevent
           libsecp256k1-bitcoin-cash
           openssl
           python-cython
           python-dateutil
           python-dnspython
           python-ecdsa
           python-hidapi
           python-jsonrpclib-pelix
           python-keepkey
           python-pathvalidate
           python-protobuf
           python-pyaes
           python-pyqt
           python-pysocks
           python-qdarkstyle
           python-qrcode
           python-requests
           python-stem
           python-trezor
           qtsvg-5
           zlib))
    (home-page "https://electroncash.org/")
    (synopsis "Bitcoin Cash wallet")
    (description
     "Electroncash is a lightweight Bitcoin Cash client, based on a client-server
protocol.  It supports Simple Payment Verification (SPV) and deterministic key
generation from a seed.  Your secret keys are encrypted and are never sent to
other machines/servers.  Electroncash does not download the Bitcoin Cash
blockchain.")
    (license license:expat)))

(define-public monero
  ;; This package bundles easylogging++ and lmdb.
  ;; The bundled easylogging++ is modified, and the changes will not be
  ;; upstreamed.
  ;; The devs deem the lmdb driver too critical a consenus component, to use
  ;; the system's dynamically linked library.
  (package
    (name "monero")
    (version "0.18.3.4")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/monero-project/monero")
             (commit (string-append "v" version))
             (recursive? #t)))
       (file-name (git-file-name name version))
       (patches (search-patches "monero-use-system-miniupnpc.patch"))
       (modules '((guix build utils)))
       (snippet
        '(begin
           ;; Delete bundled dependencies.
           (for-each
            delete-file-recursively
            '("external/miniupnp" "external/rapidjson"))))
       (sha256
        (base32 "0rjyxcggg7pdp5026kbb49mk7vnvldvbr7qlkn76n4sq20cpk3v9"))))
    (build-system cmake-build-system)
    (native-inputs
     (list doxygen
           graphviz
           pkg-config
           protobuf
           python
           qttools-5))
    (inputs
     (list boost
           cppzmq
           expat
           hidapi
           libsodium
           libunwind
           libusb
           miniupnpc
           openssl
           protobuf
           rapidjson
           readline
           unbound
           xz
           zeromq))
    (arguments
     (list #:out-of-source? #t
           #:configure-flags
           #~(list "-DARCH=default"
                   "-DBUILD_TESTS=ON"
                   (string-append "-DReadline_ROOT_DIR="
                                  #$(this-package-input "readline")))
           #:phases
           #~(modify-phases %standard-phases
               ;; tests/core_tests need a valid HOME
               (add-before 'configure 'set-home
                 (lambda _
                   (setenv "HOME" (getcwd))))
               (add-after 'set-home 'change-log-path
                 (lambda _
                   (substitute* "contrib/epee/src/mlog.cpp"
                     (("epee::string_tools::get_current_module_folder\\(\\)")
                      "\".bitmonero\"")
                     (("return \\(")
                      "return ((std::string(getenv(\"HOME\"))) / "))))
               (add-after 'change-log-path 'fix-file-permissions-for-tests
                 (lambda _
                   (for-each make-file-writable
                             (find-files "tests/data/" "wallet_9svHk1.*"))))
               (replace 'check
                 ;; Only try tests that don't need access to network or system
                 (lambda* (#:key tests? #:allow-other-keys)
                   ;; Core tests sometimes fail, at least on i686-linux.
                   ;; Let's disable them for now and just try hash tests
                   ;; and unit tests.
                   ;; (invoke "make" "ARGS=-R 'hash|core_tests' --verbose" "test")))
                   (when tests?
                     (invoke "make" "ARGS=-R 'hash' --verbose" "test")
                     (let ((excluded-unit-tests
                            (string-join
                             '("AddressFromURL.Success"
                               "AddressFromURL.Failure"
                               "DNSResolver.IPv4Success"
                               "DNSResolver.DNSSECSuccess"
                               "DNSResolver.DNSSECFailure"
                               "DNSResolver.GetTXTRecord"
                               "is_hdd.linux_os_root")
                             ":")))
                       (invoke "tests/unit_tests/unit_tests"
                               (string-append "--gtest_filter=-"
                                              excluded-unit-tests))))))
               (add-after 'install 'delete-unused-files
                 (lambda* (#:key outputs #:allow-other-keys)
                   (delete-file-recursively
                    (string-append #$output "/include")))))))
    (home-page "https://web.getmonero.org/")
    (synopsis "Command-line interface to the Monero currency")
    (description
     "Monero is a secure, private, untraceable currency.  This package provides
the Monero command line client and daemon.")
    (license license:bsd-3)))

(define-public monero-gui
  (package
    (name "monero-gui")
    (version "0.18.3.4")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/monero-project/monero-gui")
             (commit (string-append "v" version))
             (recursive? #t)))
       (file-name (git-file-name name version))
       (modules '((guix build utils)))
       (snippet
        '(begin
           ;; Delete bundled monero sources, we already have them.
           ;; See the 'extract-monero-sources' phase.
           (delete-file-recursively "monero")))
       (sha256
        (base32 "09x8184kbpw74qlak2x9amz7j3qkacnk9l0c1cws1d0fghlm6n9m"))))
    (build-system qt-build-system)
    (native-inputs
     `(,@(package-native-inputs monero)
       ("monero-source" ,(package-source monero))))
    (inputs
     (modify-inputs (package-inputs monero)
       (append libgcrypt
               monero
               p2pool
               qtbase-5
               qtdeclarative-5
               qtgraphicaleffects
               qtquickcontrols-5
               qtquickcontrols2-5
               qtsvg-5
               qtxmlpatterns)))
    (arguments
     (list #:tests? #f ; No tests
           #:configure-flags
           #~(list "-DARCH=default"
                   "-DENABLE_PASS_STRENGTH_METER=ON"
                   (string-append "-DReadline_ROOT_DIR="
                                  #$(this-package-input "readline")))
           #:phases
           #~(modify-phases %standard-phases
               (add-after 'unpack 'extract-monero-sources
                 ;; Some of the monero package source code is required
                 ;; to build the GUI.
                 (lambda* (#:key inputs #:allow-other-keys)
                   (mkdir-p "monero")
                   (copy-recursively (assoc-ref inputs "monero-source")
                                     "monero")))
               (add-after 'extract-monero-sources 'fix-build
                 (lambda _
                   (substitute* "src/version.js.in"
                     (("@VERSION_TAG_GUI@")
                      #$version))
                   (substitute* "external/CMakeLists.txt"
                     (("add_library\\(quirc" all)
                      (string-append
                       "set(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS} -fPIC\")\n"
                       all)))))
               (add-after 'unpack 'fix-p2pool-path
                 (lambda* (#:key inputs #:allow-other-keys)
                   (substitute* "src/p2pool/P2PoolManager.cpp"
                     ;; Location for files created by P2Pool
                     (("m_p2poolPath = QApplication::applicationDirPath\\(\\);")
                      "m_p2poolPath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);")
                     ;; Location of p2pool program
                     (("m_p2pool = m_p2poolPath \\+ \"/p2pool\";")
                      (string-append "m_p2pool = \""
                                     (search-input-file inputs "/bin/p2pool")
                                     "\";")))))
               (replace 'install
                 (lambda _
                   ;; Binary
                   (let ((dir (string-append #$output "/bin")))
                     (mkdir-p dir)
                     (install-file "../build/bin/monero-wallet-gui" dir))
                   ;; Icons
                   (for-each
                    (lambda (size)
                      (let ((dir (string-append #$output
                                                "/share/icons/hicolor/"
                                                size
                                                "/apps")))
                        (mkdir-p dir)
                        (copy-file (string-append "../source/images/appicons/"
                                                  size ".png")
                                   (string-append dir
                                                  "/monero-gui.png"))))
                    '("16x16" "24x24" "32x32" "48x48"
                      "64x64" "96x96" "128x128" "256x256"))
                   ;; Menu entry file
                   (let ((dir (string-append #$output "/share/applications")))
                     (mkdir-p dir)
                     (call-with-output-file
                         (string-append dir "/monero-gui.desktop")
                       (lambda (port)
                         (format port
                                 "[Desktop Entry]~@
                                  Type=Application~@
                                  Name=Monero wallet~@
                                  Exec=~a/bin/monero-wallet-gui~@
                                  Icon=monero-gui~@
                                  Categories=Office;Finance;~%"
                                 #$output))))))
               (add-after 'qt-wrap 'install-monerod-link
                 ;; The monerod program must be available so that
                 ;; monero-wallet-gui can start a Monero daemon if necessary.
                 (lambda* (#:key inputs #:allow-other-keys)
                   (symlink (search-input-file inputs "/bin/monerod")
                            (string-append #$output "/bin/monerod")))))))
    (home-page "https://web.getmonero.org/")
    (synopsis "Graphical user interface for the Monero currency")
    (description
     "Monero is a secure, private, untraceable currency.  This package provides
the Monero GUI client.")
    (license license:bsd-3)))

(define-public python-bech32
  (package
    (name "python-bech32")
    (version "1.2.0")
    (source (origin
              (method url-fetch)
              (uri (pypi-uri "bech32" version))
              (sha256
               (base32
                "16fq5cfy5id9hp123ylhpl55pf38xwk0hv7sziqpig838qhvhvbx"))))
    (build-system python-build-system)
    (home-page "https://github.com/fiatjaf/bech32")
    (synopsis "Reference implementation for Bech32 and Segwit addresses")
    (description "This package provides a python reference implementation for
Bech32 and segwit addresses.")
    (license license:expat)))

(define-public python-trezor-agent
  ;; It is called 'libagent' in pypi; i.e. this is the library as opposed to
  ;; the toplevel app called trezor-agent.
  (package
    (name "python-trezor-agent")
    (version "0.14.7")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/romanz/trezor-agent")
             (commit (string-append "v" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32 "04dds5bbw73nk36zm8d02qw6qr92nrlcf8r1cq8ba96mzi34jbk0"))))
    (build-system python-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'remove-requires-backports-shutil-which
           ;; Remove requires on backport of shutil_which, as python 3.4+ has
           ;; a built-in implementation supported in python-trezor-agent.
           (lambda _
             (substitute* "setup.py"
               (("'backports.shutil_which>=3.5.1',") ""))))
         (delete 'check)
         (add-after 'install 'check
           (lambda* (#:key tests? #:allow-other-keys)
             (when tests?
               (invoke "pytest" "-v")))))))
    (propagated-inputs
     (list python-bech32
           python-configargparse
           python-cryptography
           python-daemon
           python-docutils
           python-ecdsa
           python-hidapi
           python-mnemonic
           python-pymsgbox
           python-pynacl
           python-semver
           python-unidecode
           python-wheel))
    (native-inputs ; Only needed for running the tests
     (list gnupg
           python-mock
           python-pytest))
    (home-page "https://github.com/romanz/trezor-agent")
    (synopsis "Use hardware wallets as SSH and GPG agent")
    (description
     "@code{libagent} is a library that allows using TREZOR, Keepkey and
Ledger Nano as a hardware SSH/GPG agent.")
    (license license:lgpl3)))

(define-public trezor-gpg-pinentry-tk
  (package
    (name "trezor-gpg-pinentry-tk")
    (version "0.0.10")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/rendaw/trezor-gpg-pinentry-tk/")
             (commit (string-append "v" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32 "1mblx4favmw4nf7k9rfl00ivv77kgdiwghyz4xv5cp0v410kjaqc"))))
    (build-system python-build-system)
    (arguments
     `(#:tests? #f))        ; No test suite.
    (inputs
     `(("python-tkinter" ,python "tk")))
    (home-page "https://github.com/rendaw/trezor-gpg-pinentry-tk")
    (synopsis "GPG pinentry program for use with @code{trezor-agent}")
    (description
     "This package provides a GPG pinentry program for use with
@code{trezor-agent}, or for people with number-only PINs.  It displays
a grid of unlabeled buttons and supports configurable keyboard
settings.")
    (license license:bsd-2)))

(define-public python-mnemonic
  (package
    (name "python-mnemonic")
    (version "0.20")
    (source
      (origin
        (method url-fetch)
        (uri (pypi-uri "mnemonic" version))
        (sha256
          (base32 "1xi5qvj2rvi5almf9c89rl7hz1z4ms04d53pg818i4vpkmivavvw"))))
    (build-system python-build-system)
    (propagated-inputs
     (list python-pbkdf2))
    (home-page "https://github.com/trezor/python-mnemonic")
    (synopsis "Implementation of Bitcoin BIP-0039")
    (description "@code{mnemonic} is a library that provides an implementation
of Bitcoin BIP-0039.")
    (license license:expat)))

(define-public python-u2flib-host
  ;; The package is obsolete and superseded by python-fido2, but
  ;; needed for python-ledgerblue@0.1.44.
  (package
    (name "python-u2flib-host")
    (version "3.0.3")
    (source (origin
              (method url-fetch)
              (uri (pypi-uri "python-u2flib-host" version))
              (sha256
               (base32
                "02pwafd5kyjpc310ys0pgnd0adff1laz18naxxwsfrllqafqnrxb"))))
    (build-system python-build-system)
    (propagated-inputs (list python-hidapi python-requests))
    (native-inputs (list python-cryptography))
    (home-page "https://github.com/Yubico/python-u2flib-host")
    (synopsis "Python based U2F host library")
    (description
     "The package provides library functionality for communicating with a U2F device over USB.")
    (license license:bsd-2)))

(define-public python-ledgerblue
  (package
    (name "python-ledgerblue")
    (version "0.1.44")
    (source
      (origin
        (method url-fetch)
        (uri (pypi-uri "ledgerblue" version))
        (sha256
          (base32
            "0nbfa5i9ww7jsfc8cgy0r229pq2a1vj4xvn8mz0nxl7mx1wykqm4"))))
    (build-system python-build-system)
    (arguments
     `(#:tests? #f)) ; no tests
    (propagated-inputs
     (list python-ecpy
           python-future
           python-hidapi
           python-pillow
           python-protobuf
           python-pycryptodomex
           python-pyscard
           python-u2flib-host
           python-websocket-client))
    (home-page "https://github.com/LedgerHQ/blue-loader-python")
    (synopsis "Python library to communicate with Ledger Blue/Nano S")
    (description "@code{ledgerblue} is a Python library to communicate with
Ledger Blue/Nano S.")
    (license license:asl2.0)))

(define-public python-btchip-python
  (package
    (name "python-btchip-python")
    (version "0.1.32")
    (source
      (origin
        (method url-fetch)
        (uri (pypi-uri "btchip-python" version))
        (sha256
          (base32
            "0mcg3gfd0qk8lhral3vy9cfd4pii9kzs42q71pf6b3y0c70y1x9l"))))
    (build-system python-build-system)
    (arguments
     `(#:tests? #f)) ; those require PyQt4
    (propagated-inputs
      (list python-ecdsa python-hidapi))
    (home-page "https://github.com/LedgerHQ/btchip-python")
    (synopsis "Python library to communicate with Ledger Nano dongle")
    (description
      "This package provides a Python library to communicate with Ledger
Nano dongle.")
    (license license:asl2.0)))

(define-public python-trezor
  (package
    (name "python-trezor")
    (version "0.13.7")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/trezor/trezor-firmware/")
             (commit (string-append "python/v" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32 "13wyl9b15c8iscfakprwfvh2akw180hfqdjww79b78ywz51y7hdh"))
       (modules
        '((guix build utils)
          (srfi srfi-26)
          (srfi srfi-1)
          (ice-9 ftw)))
       (snippet
        '(begin
           ;; Delete everything except ./python/
           (for-each delete-file-recursively
                     (scandir "./" (negate (cut member <> '("python" "." "..")
                                                string=))))
           ;; Move ./python/* to the toplevel.
           (for-each (lambda (file-name)
                       (rename-file (string-append "./python/" file-name)
                                    (string-append "./" file-name)))
                     (scandir "./python/"
                              (negate (cut member <> '("." "..") string=))))
           (delete-file-recursively "./python")
           ;; Delete now broken symbolic links.
           (for-each delete-file
                     (append (find-files "." "^CHANGELOG.unreleased$")
                             (find-files "." "^.towncrier.template.md$")))))))
    (build-system python-build-system)
    (propagated-inputs
     (list python-attrs
           python-click
           python-construct-classes
           python-ecdsa
           python-hidapi
           python-libusb1
           python-mnemonic
           python-requests
           python-typing-extensions))
    (native-inputs ; Only needed for running the tests
     (list protobuf
           python-black
           python-isort
           python-pillow
           python-protobuf
           python-pyqt
           python-pytest
           python-simple-rlp
           python-wheel))
    (home-page "https://github.com/trezor/python-trezor")
    (synopsis "Python library for communicating with TREZOR Hardware Wallet")
    (description "@code{trezor} is a Python library for communicating with
TREZOR Hardware Wallet.")
    (license license:lgpl3)))

(define-public python-keepkey
  (package
    (name "python-keepkey")
    (version "6.0.3")
    (source
      (origin
        (method url-fetch)
        (uri (pypi-uri "keepkey" version))
        (sha256
          (base32
            "0z3d0m6364v9dv0njs4cd5m5ai6j6v35xaaxfxl90m9vmyxy81vd"))))
    (build-system python-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (delete 'check)
         (add-after 'install 'check
           (lambda* (#:key inputs outputs #:allow-other-keys)
             (add-installed-pythonpath inputs outputs)
             (apply invoke "python" (find-files "tests/unit" "\\.py$")))))))
    (propagated-inputs
     (list python-ecdsa python-hidapi python-libusb1 python-mnemonic
           python-protobuf))
    (home-page "https://github.com/keepkey/python-keepkey")
    (synopsis "Python library for communicating with KeepKey Hardware Wallet")
    (description "@code{keepkey} is a Python library for communicating with
the KeepKey Hardware Wallet.")
    (license license:lgpl3)))

(define-public ledger-agent
  (package
    (name "ledger-agent")
    (version "0.9.0")
    (source
     (origin
       (method url-fetch)
       (uri (pypi-uri "ledger_agent" version))
       (sha256
        (base32
         "03zj602m2rln9yvr08dswy56vzkbldp8b074ixwzz525dafblr92"))))
    (build-system python-build-system)
    (inputs
     (list python-ledgerblue python-trezor-agent))
    (home-page "https://github.com/romanz/trezor-agent")
    (synopsis "Ledger as hardware SSH/GPG agent")
    (description "This package allows using Ledger as hardware SSH/GPG agent.")
    (license license:lgpl3)))

(define-public trezor-agent
  (package
    (name "trezor-agent")
    ;; There are multiple Python apps/packages in the same git repo.  The git
    ;; tag seems to track libagent's version (which is called
    ;; python-trezor-agent in the Guix namespace). Currently trezor-agent's
    ;; version is set in `agents/trezor/setup.py` to a different value than
    ;; libagent, but as discussed with upstream in issue
    ;; https://github.com/romanz/trezor-agent/issues/369, we are copying our
    ;; version from that of libagent.
    (version (package-version python-trezor-agent))
    (source
     (origin
       (method git-fetch)
       (uri (origin-uri (package-source python-trezor-agent)))
       (file-name (git-file-name name version))
       (sha256
        (base32 "04dds5bbw73nk36zm8d02qw6qr92nrlcf8r1cq8ba96mzi34jbk0"))
       (modules
        '((guix build utils)
          (ice-9 ftw)
          (srfi srfi-1)
          (srfi srfi-26)))
       (snippet
        '(begin
           ;; Delete everything except ./agents/trezor/
           (for-each delete-file-recursively
                     (filter (lambda (full-name)
                               (not (string-prefix? "./agents/trezor/" full-name)))
                             (find-files ".")))
           ;; Move ./agents/trezor/* to the toplevel
           (for-each (lambda (file-name)
                       (rename-file (string-append "./agents/trezor/" file-name)
                                    (string-append "./" file-name)))
                     (scandir "./agents/trezor/"
                              (negate (cut member <> '("." "..") string=))))
           (delete-file-recursively "./agents")
           ;; Without deleting ./contrib the sanity-check phase fails. Reported
           ;; upstream as https://github.com/romanz/trezor-agent/issues/429.
           (delete-file-recursively "./contrib")
           ;; Without deleting ./libagent setuptools complains as follows:
           ;; "error: Multiple top-level packages discovered in a flat-layout: ['contrib', 'libagent']."
           (delete-file-recursively "./libagent")))))
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'relax-requirements
           (lambda _
             (substitute* "setup.py"
               (("'trezor\\[hidapi]>=0.12.0,<0.13'")
                "'trezor[hidapi]>=0.13'"))))
         (add-after 'wrap 'fixup-agent-py
           (lambda* (#:key inputs outputs #:allow-other-keys)
             (let* ((out (assoc-ref outputs "out")))
               ;; The wrap phase also wraps trezor_agent.py (besides the
               ;; public facing executable called trezor-agent). We need to
               ;; undo that wrapping. The reason this is needed is that the
               ;; python easy install generates a toplevel script (?) that
               ;; messes with argv[0] and then re-opens the python
               ;; module. This fails when the wrapped file is actually a shell
               ;; script, not a python file.
               (delete-file (string-append out "/bin/.trezor_agent.py-real"))
               ;; Overwrite the wrapped one with the real thing.
               (install-file "./trezor_agent.py"
                             (string-append out "/bin"))))))))
    (build-system python-build-system)
    (inputs
     (list python-trezor python-trezor-agent))
    (native-inputs ; Only needed for running the tests
     (list python-attrs
           python-bech32
           python-simple-rlp))
    (home-page "https://github.com/romanz/trezor-agent")
    (synopsis "Using Trezor as hardware SSH/GPG agent")
    (description "This package allows using Trezor as a hardware SSH/GPG
agent.")
    (license license:lgpl3)))

(define-public keepkey-agent
  (package
    (name "keepkey-agent")
    (version "0.9.0")
    (source
      (origin
        (method url-fetch)
        (uri (pypi-uri "keepkey_agent" version))
        (sha256
          (base32
            "03779gvlx70i0nnry98i4pl1d92604ix5x6jgdfkrdgzqbh5vj27"))))
    (build-system python-build-system)
    (inputs
     (list python-keepkey python-trezor-agent))
    (home-page "https://github.com/romanz/trezor-agent")
    (synopsis "KeepKey as hardware SSH/GPG agent")
    (description "This package allows using KeepKey as a hardware SSH/GPG
agent.")
    (license license:lgpl3)))

(define-public kitsas
  (package
    (name "kitsas")
    (version "5.4.1")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/artoh/kitupiikki")
                    (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "16zkfpl5d9ia202fqg5vrhjqdw0g6wp044ih6n7nz2hbxj9y3m1z"))))
    (build-system qt-build-system)
    (inputs (list libzip qtsvg qtwebengine qt5compat))
    (arguments
     (list #:tests? #f           ; tests do not even build with Qt6 anymore
           #:test-target "check"
           #:qtbase qtbase       ; use Qt6
           #:phases
           #~(modify-phases %standard-phases
               (replace 'configure
                 (lambda* _
                   (invoke "qmake" "kitsasproject.pro" "CONFIG+=release")))
               ;; The tests are not maintained and some don't even build
               (add-before 'configure 'disable-broken-tests
                 (lambda _
                   (substitute* "kitsasproject.pro"
                     ((" *(unittest|testit).*") "")
                     (("\\\\") ""))))
               (replace 'install
                 (lambda* _
                   (install-file "kitsas/kitsas"
                                 (string-append #$output "/bin/"))
                   (install-file "kitsas.png"
                                 (string-append #$output "/share/icons/"))
                   (install-file "kitsas.desktop"
                                 (string-append #$output "/share/applications/")))))))
    (home-page "https://kitsas.fi")
    (synopsis "Finnish bookkeeping software for small organisations")
    (description
     "Kitsas is a Finnish accounting program with the following goals and
features:

@itemize @bullet
@item Ease of use
@item Digital management of documents
@item Creating a digital archive
@item Built-in invoicing
@item Creating reports.
@end itemize")
    ;; GPLv3+ with additional terms:
    ;; - Modified versions of this software should be clearly mentioned as modified
    ;; - Kitsas Oy will not support any modified version of this software
    ;; - The name Kitsas Oy should not be used in any modified version
    (license license:gpl3+)))

(define-public python-stdnum
  (package
    (name "python-stdnum")
    (version "1.18")
    (source
     (origin
       (method url-fetch)
       (uri (pypi-uri "python-stdnum" version))
       (sha256
        (base32 "1h5y4qx75b6i2051ch8k0pcwkvhxzpaqd9mpsajkvqlsqkcn7ixw"))))
    (build-system python-build-system)
    (arguments
     '(#:phases (modify-phases %standard-phases
                  (replace 'check
                    (lambda _
                      (invoke "nosetests"))))))
    (native-inputs
     (list python-nose))
    (home-page "https://arthurdejong.org/python-stdnum/")
    (synopsis "Python module to handle standardized number and code formats")
    (description
     "This is a Python library that aims to provide functions to handle,
parse and validate standard numbers.
The module supports more than 100 different number formats
amongst which a great number of VAT and other tax numbers,
personal identity and company identification codes,
international standard numbers (ISBN, IBAN, EAN, etc.)
and various other formats.
The module also includes implementations of the Verhoeff,
Luhn and family of ISO/IEC 7064 check digit algorithms.")
    (license license:lgpl2.1+)))

(define-public python-duniterpy
  (package
    (name "python-duniterpy")
    (version "1.1.1")
    (source
     (origin
       (method url-fetch)
       (uri (pypi-uri "duniterpy" version))
       (sha256
        (base32 "0h0fsawsrjd50lb1bkysb21ph39qlhmiymd3r5vs695qxvbwaqaa"))))
    (build-system pyproject-build-system)
    (arguments
     ;; FIXME: Tests fail with: "TypeError: block_uid() missing 1 required
     ;; positional argument: 'value'".
     `(#:tests? #f
       #:phases (modify-phases %standard-phases
                  (add-after 'unpack 'loosen-requirements
                    (lambda _
                      (substitute* "pyproject.toml"
                        (("mnemonic = \"\\^0\\.19")
                         "mnemonic = \">=0.19")
                        (("jsonschema = \"\\^3\\.2")
                         "jsonschema = \">=3.2"))))
                  (add-after 'unpack 'adjust-for-new-libnacl
                    (lambda _
                      ;; Mimic upstream commit ad8f6a26e9e7067; remove
                      ;; for newer versions of duniterpy.
                      (substitute* "pyproject.toml"
                        (("libnacl = \"1\\.8")
                         "libnacl = \">=1.9"))
                      (substitute* "duniterpy/key/ascii_armor.py"
                        (("from libnacl\\.version import version as libnacl_version")
                         "import importlib.metadata
libnacl_version = importlib.metadata.version('libnacl')")))))))
    (native-inputs
     (list python-poetry-core))
    (propagated-inputs
     (list python-attrs
           python-base58
           python-graphql-core
           python-jsonschema
           python-libnacl
           python-mnemonic
           python-pyaes
           python-pypeg2
           python-websocket-client))
    (home-page "https://git.duniter.org/clients/python/duniterpy")
    (synopsis "Python implementation of Duniter API")
    (description "@code{duniterpy} is an implementation of
@uref{https://github.com/duniter/duniter/, duniter} API.  Its
main features are:
@itemize
@item Support Duniter's Basic Merkle API and protocol
@item Asynchronous/synchronous without threads
@item Support HTTP, HTTPS and Web Socket transport for Basic Merkle API
@item Support Elasticsearch Duniter4j API
@item Duniter signing key
@item Sign/verify and encrypt/decrypt messages with the Duniter credentials
@end itemize")
    (license license:gpl3+)))

(define-public silkaj
  (package
    (name "silkaj")
    (version "0.10.0")
    (source
     (origin
       (method url-fetch)
       (uri (pypi-uri "silkaj" version))
       (sha256
        (base32 "0p8jqnswrrxri8i2ikdz8mij7gks0yab3wdcb37jf2kjwmrwanpk"))))
    (build-system pyproject-build-system)
    (native-inputs
     (list python-poetry-core))
    (propagated-inputs
     (list python-click
           python-duniterpy
           python-pendulum
           python-tabulate
           python-texttable))
    (home-page "https://git.duniter.org/clients/python/silkaj")
    (synopsis "Command line client for Duniter network")
    (description "Silkaj is a command line client for the
@uref{https://github.com/duniter/duniter/, Duniter} network.

Its features are:
@itemize
@item information about currency,
@item issuers difficulty to generate next block,
@item network view of nodes,
@item list of last issuers,
@item send transactions,
@item get account amount.
@end itemize")
    (license license:agpl3+)))

(define-public grisbi
  (package
    (name "grisbi")
    (version "2.0.5")
    (source
     (origin
       (method url-fetch)
       (uri (string-append
             "mirror://sourceforge/grisbi/grisbi%20stable/"
             (version-major+minor version) ".x/" version
             "/grisbi-" version ".tar.bz2"))
       (sha256
        (base32
         "0gvsqw1z5wkakyi3bkq71pqb094a8lv2nbgnxw2zqkabzjmxnfmx"))))
    (build-system glib-or-gtk-build-system)
    (arguments
     `(#:configure-flags (list "--without-ofx")))
    (propagated-inputs
     (list dconf))
    (native-inputs
     (list `(,glib "bin") ; glib-compile-schemas
           pkg-config intltool))
    (inputs
     (list gtk+ libgsf))
    (synopsis "Personal accounting application")
    (description "Grisbi is a personal accounting application written by
French developers that is designed to follow French accounting rules.
Grisbi can manage multiple accounts, currencies and users.  It manages
third party, expenditure and receipt categories, budgetary lines,
financial years, budget estimates, bankcard management and other
information.")
    (home-page "https://grisbi.org")
    (license license:gpl2+)))

(define-public gbonds
  ;; The last "upstream" commit is from about 2008, but the Debian maintainers
  ;; have effectively become the upstream with an extensive series of patches.
  ;; However, the patches are stored "unapplied", and some enhancements (like
  ;; a decade's worth of new data files) rely on the Debian packaging tools,
  ;; so building normally even from the patched sources would miss them.
  ;; Here, we do all of the patching in the origin, so that the result of
  ;; `guix build --source` is actually useable for building without Guix.
  (let ((revision "1")
        (commit "3054ee2f90cc7c03ed6b131177d09701c7a4fced"))
    (package
      (name "gbonds")
      (version (git-version "2.0.3" revision commit))
      (source
       (let ((unapplied
              (origin
                (method git-fetch)
                (uri (git-reference
                      (url "https://salsa.debian.org/debian/gbonds.git")
                      (commit commit)))
                (sha256
                 (base32
                  "1sqzzfymzxbnq6cjs5wvjbnvcrkdlimlmj2h7mlcaa9qqdpsgfki"))
                (file-name (git-file-name name version)))))
         (origin
           (inherit unapplied)
           (patches
            ;; The order matters.
            (map (cut file-append unapplied "/debian/patches/" <>)
                 '("desktop-file"
                   "POTFILES"
                   "POTFILES.missing"
                   "commands-compile"
                   "egg-recent-model-compile"
                   "gbonds-name-case"
                   "copyright-update"
                   "website-url"
                   "link-libm"
                   "xmldocs"
                   "configure-compiler-warnings"
                   "omf"
                   "desktop-file-keywords"
                   "replace-g_strcasecmp"
                   "gtk3-port"
                   "gsettings-port"
                   "no-rarian-compat"
                   "extern-gb_prefs"
                   "use-treasury-api.patch")))
           (snippet
            #~(begin
                (use-modules (guix build utils)
                             (srfi srfi-26))

                ;; Remove generated files, which have not been patched.
                (for-each (lambda (pth)
                            (when (file-exists? pth)
                              (delete-file pth)))
                          `(;; Things `make maintainer-clean` would do.
                            "gbonds.spec"
                            "src/marshal.c"
                            "src/marshal.h"
                            ;; Things upstream's distclean missed.
                            "intltool-extract"
                            "intltool-merge"
                            "intltool-update"
                            ;; Autotools generated files.
                            "aclocal.m4"
                            "config.guess"
                            "config.h.in"
                            "config.log"
                            "config.sub"
                            "configure"
                            "depcomp"
                            "intltool-extract.in"
                            "intltool-merge.in"
                            "intltool-update.in"
                            "ltmain.sh"
                            ,@(find-files "." "^Makefile\\.in$")))

                ;; Arrange for `make install` to handle the additional
                ;; redemption data files added in the Debian packaging.
                (let* ((new-redemption-data-files
                        (find-files "debian" "^sb[[:digit:]]+\\.asc$"))
                       (names
                        (map (cut substring <> (string-length "debian/"))
                             new-redemption-data-files)))
                  (for-each rename-file
                            new-redemption-data-files
                            (map (cut string-append "data/" <>)
                                 names))
                  (substitute* "data/Makefile.am"
                    (("redemption_DATA = \\\\")
                     (apply string-append
                            "redemption_DATA = \\"
                            (map (cut string-append "\n\t" <> " \\")
                                 names))))))))))
      (outputs '("out" "debug"))
      (inputs (list gtk+
                    glib
                    json-glib
                    libxml2
                    libsoup-minimal-2
                    cairo
                    pango))
      (native-inputs (list autoconf
                           automake
                           intltool
                           libtool
                           patch
                           pkg-config))
      (build-system glib-or-gtk-build-system)
      (home-page "https://gbonds.sourceforge.net")
      (synopsis "@acronym{U.S.} Savings Bond inventory program for GNOME")
      (description
       "GBonds is a @acronym{U.S.} Savings Bond inventory program for the
GNOME desktop environment.  It allows you to track the current redemption
value and performance of your @acronym{U.S.} Savings Bonds and keep a valuable
record of the bonds you own.")
      (license license:gpl2+))))

(define-public trezord-udev-rules
  (let ((commit "bff7fdfe436c727982cc553bdfb29a9021b423b0")
        (revision "0"))
      (package
        (name "trezord-udev-rules")
        (version (git-version "0.0.0" revision commit))
        (source
         (origin
           (method git-fetch)
           (uri (git-reference
                 (url "https://github.com/trezor/trezor-common")
                 (commit commit)))
           (sha256
            (base32
             "14mrirrn68if7ja6qdk9qlxs1hv0f21vrxy5ncnms0gx9iwakp2l"))
           (file-name (git-file-name name version))))
        (build-system copy-build-system)
        (arguments
         '(#:install-plan
           '(("./udev/51-trezor.rules" "lib/udev/rules.d/"))))
        (home-page "https://github.com/trezor/trezor-common")
        (synopsis "Udev rules for trezord")
        (description
         "This contains the udev rules for trezord.  This will let a user run
trezord as a regular user instead of needing to it run as root.")
        (license license:lgpl3+))))

(define-public trezord
  (package
    (name "trezord")
    (version "2.0.33")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/trezor/trezord-go")
             (commit (string-append "v" version))))
       (sha256
        (base32 "0nnfh9qkb8ljajkxwrn3nn85zrsw10hp7c5i4zh60qgfyl0djppw"))
       (file-name (git-file-name name version))))
    (build-system go-build-system)
    (arguments
     `(#:go ,go-1.18
       #:import-path "github.com/trezor/trezord-go"))
    (native-inputs
     (list go-github-com-gorilla-csrf
           go-github-com-gorilla-handlers
           go-github-com-gorilla-mux
           go-gopkg-in-natefinch-lumberjack.v2))
    (home-page "https://trezor.io")
    (synopsis "Trezor Communication Daemon aka Trezor Bridge (written in Go)")
    (description "This allows a Trezor hardware wallet to communicate to the
Trezor wallet.")
    (license license:lgpl3+)))

(define-public libofx
  (package
    (name "libofx")
    (version "0.10.9")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/libofx/libofx")
                    (commit version)))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "120hyhs4fkxrgpvd2p0hpf5v8dq0jjql2fzllk77m33m1c82pr18"))))
    (build-system gnu-build-system)
    (arguments
     (list
      #:parallel-build? #f              ;fails with -j64
      #:configure-flags
      #~(list "--disable-static"
              (string-append "--with-opensp-includes="
                             (search-input-directory %build-inputs
                                                     "include/OpenSP")))))
    (native-inputs
     (list autoconf
           automake
           gengetopt
           help2man
           libtool
           pkg-config))
    (inputs
     (list curl
           libxml++-2
           opensp))
    (home-page "http://libofx.sourceforge.net/")
    (synopsis "Library supporting the Open Financial Exchange format")
    (description
     "The LibOFX library is an API designed to allow applications to very easily
support OFX command responses, usually provided by financial institutions.  The
following three utilities are included with the library:
@enumerate
@item @code{ofxdump}
@item @code{ofx2qif}
@item @code{ofxconnect}
@end enumerate")
    (license license:gpl2+)))

(define-public bitcoin-unlimited
  (package
    (name "bitcoin-unlimited")
    (version "2.1.0.0")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://gitlab.com/bitcoinunlimited/BCHUnlimited.git/")
             (commit (string-append "BCHunlimited" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32 "0cny12s03wsgx8iijg5cbr7r6wif9ck7dn98hsv9sz8xq1i5vjk4"))))
    (build-system gnu-build-system)
    (native-inputs
     (list autoconf
           automake
           libtool
           pkg-config
           python ; for the tests
           util-linux ; provides the hexdump command for tests
           qttools-5))
    (inputs
     (list bdb-4.8
           boost
           libevent
           miniupnpc
           openssl
           protobuf
           qrencode
           qtbase-5
           zeromq
           zlib))
    (arguments
     `(#:configure-flags
       (list
        ;; Boost is not found unless specified manually.
        (string-append "--with-boost="
                       (assoc-ref %build-inputs "boost"))
        ;; XXX: The configure script looks up Qt paths by
        ;; `pkg-config --variable=host_bins Qt5Core`, which fails to pick
        ;; up executables residing in 'qttools-5', so we specify them here.
        (string-append "ac_cv_path_LRELEASE="
                       (assoc-ref %build-inputs "qttools")
                       "/bin/lrelease")
        (string-append "ac_cv_path_LUPDATE="
                       (assoc-ref %build-inputs "qttools")
                       "/bin/lupdate")
        "--disable-static")
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'fix-tests
           (lambda _
             ;; Disable utilprocess_tests because it never ends.
             ;; It looks like it tries to start /bin/sleep and waits until it
             ;; is in the list of running processes, but /bin/sleep doesn't
             ;; exist.
             (substitute* "src/Makefile.test.include"
               (("test/utilprocess_tests.cpp")
                ""))
             ;; Disable PaymentServer failing test because it's using
             ;; an expired SSL certificate.
             (substitute* "src/qt/test/test_main.cpp"
               (("if \\(QTest::qExec\\(&test2\\) != 0\\)")
                "if (QTest::qExec(&test2) == 0)"))
             ;; The following test passes with OpenSSL 1.1, but fails with
             ;; OpenSSL 3.
             (substitute* "src/secp256k1/src/tests.c"
               (("run_ecdsa_der_parse\\(\\);")
                ""))))
         (add-before 'check 'set-home
           (lambda _
             ;; Tests write to $HOME
             (setenv "HOME" (getenv "TMPDIR")))))))
    (home-page "https://www.bitcoinunlimited.info/")
    (synopsis "Client for the Bitcoin Cash protocol")
    (description
     "Bitcoin Unlimited is a client for the Bitcoin Cash peer-to-peer
electronic cash system.  This package provides a command line client and
a Qt GUI.")
    (license license:expat)))

(define-public fulcrum
  (package
    (name "fulcrum")
    (version "1.9.1")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/cculianu/Fulcrum")
                    (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (modules '((guix build utils)))
              (snippet
                #~(for-each delete-file-recursively
                            '("src/Json/simdjson"
                              "src/bitcoin/secp256k1"
                              "src/robin_hood"
                              "src/zmq"
                              "staticlibs")))
              (sha256
               (base32
                "1110vanl6aczlq25i4ck9j4vr81in5icw4z383wyhjpcy6rwxsw2"))
              (patches
               (search-patches "fulcrum-1.9.1-unbundled-libraries.patch"))))
    (build-system gnu-build-system)
    (arguments
     (list #:configure-flags
           #~(list "CONFIG+=config_without_bundled_cppzmq"
                   "CONFIG+=config_without_bundled_robin_hood"
                   "CONFIG+=config_without_bundled_secp256k1"
                   "LIBS+=-lrocksdb"
                   #$@(if (target-64bit?) '("LIBS+=-lsimdjson") '())
                   (format #f "DEFINES+=GIT_COMMIT=\"\\\\\\~s\\\\\\\""
                           #$version)
                   (string-append "PREFIX=" #$output))
           #:phases
           #~(modify-phases %standard-phases
               (replace 'configure
                 (lambda* (#:key configure-flags #:allow-other-keys)
                   (apply invoke "qmake" configure-flags))))))
    (native-inputs (list pkg-config qttools-5))
    (inputs
     (append (list cppzmq
                   jemalloc
                   python
                   qtbase-5
                   robin-hood-hashing
                   rocksdb
                   zeromq
                   zlib)
             (if (target-64bit?)
                 (list simdjson-0.6)
                 '())))
    (home-page "https://github.com/cculianu/Fulcrum")
    (synopsis "Payment verification server for Bitcoin-like crypto-currencies")
    (description
     "Fulcrum is a @acronym{SPV, Simplified Payment Verification} server for
Bitcoin-like crypto-currencies.  The server indexes the blockchain of the
crypto-currency used, and the resulting index can be used by wallets to
perform queries to keep real-time track of balances.

Supported crypto-currencies:

@itemize
@item Bitcoin Core.
@item Bitcoin Cash-like.
@item Litecoin.
@end itemize")
    (license license:gpl3+)))

(define-public flowee
  (package
    (name "flowee")
    (version "2020.04.1")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://gitlab.com/FloweeTheHub/thehub/-/archive/"
                            version "/thehub-" version ".tar.gz"))
       (sha256
         (base32 "1vwvaxm3b71pfx8l4rrv06wqks6xdf2333w856b36s1bzvj53rhc"))))
    (build-system cmake-build-system)
    (arguments
     `(#:configure-flags '("-Dbuild_tests=ON" "-Denable_gui=OFF")
       #:phases
        (modify-phases %standard-phases
          (add-before 'configure 'make-qt-deterministic
            (lambda _
              ;; Make Qt deterministic.
              (setenv "QT_RCC_SOURCE_DATE_OVERRIDE" "1")
             #t))
          (add-before 'configure 'disable-black-box
            ;; the black-box testing runs full hubs and lets them interact.
            ;; this is more fragile and a slow machine, or low memory machine, may
            ;; make the tests timeout and fail.  We just disable them here.
            (lambda _
              (substitute* "testing/CMakeLists.txt"
                (("test_api") ""))
              (substitute* "testing/CMakeLists.txt"
                (("add_subdirectory\\(api\\)") ""))
              #t))
          (add-after 'configure 'set-build-info
            ;; Their genbuild.sh to generate a build.h fails in guix (no .git dir) .
            ;; Its purpose is to write the tag name in the build.h file. We do that
            ;; here instead.
            (lambda _
              (with-output-to-file "include/build.h"
                (lambda _
                  (display
                    (string-append "#define BUILD_DESC " "\"", version "\""))))))
          (add-before 'check 'set-home
            (lambda _
              (setenv "HOME" (getenv "TMPDIR")) ; tests write to $HOME
              #t))
          (replace 'check
            (lambda _
              (invoke "make" "check" "-C" "testing"))))))
    (inputs
     (list boost
           gmp
           libevent
           miniupnpc
           openssl
           qtbase-5))
    (native-inputs
     (list pkg-config qttools-5 util-linux))       ; provides the hexdump command for tests
    (home-page "https://flowee.org")
    (synopsis "Flowee infrastructure tools and services")
    (description
     "Flowee packages all tier-1 applications and services from the Flowee group.
This includes components like The Hub and Indexer which and various others
that allows you to run services and through them access the Bitcoin Cash networks.")
    (license license:gpl3+)))


(define-public beancount
  (package
    (name "beancount")
    (version "2.3.6")
    (source
     (origin
       (method git-fetch) ; no test data files in PyPI archive
       (uri (git-reference
             (url "https://github.com/beancount/beancount")
             (commit version)))
       (file-name (git-file-name name version))
       (sha256
        (base32 "1slxsjw29cyr2kbirdpijhpqspk55k38rpmk3zc02pr1wll62qsv"))
       (patches (search-patches "beancount-disable-googleapis-fonts.patch"))
       (modules '((guix build utils)))
       (snippet
        #~(begin
            ;; Remove broken experiments.
            (delete-file-recursively "experiments")
            ;; Remove bundled packages.
            (delete-file-recursively "third_party")))))
    (build-system pyproject-build-system)
    (arguments
     (list
      #:test-flags
      #~(list "-k" (string-append
                    ;; ModuleNotFoundError: No module named 'pytest'
                    "not test_parse_stdin"
                    ;; AssertionError: 5 not greater than 20
                    " and not test_setup"))
      #:phases
      #~(modify-phases %standard-phases
          (add-after 'unpack 'relax-requirements
            (lambda _
              (substitute* "setup.py"
                ;; Use compatible fork, and do not fail during sanity check.
                (("\"pdfminer2\",") ""))))
          (add-before 'check 'build-extensions
            (lambda _
              (invoke "python" "setup.py" "build_ext" "--inplace"))))))
    (propagated-inputs
     (list python-beautifulsoup4
           python-bottle
           python-chardet
           python-dateutil
           python-google-api-client
           python-google-auth-oauthlib
           python-lxml
           python-magic
           python-oauth2client
           python-ply
           python-requests))
    (native-inputs
     (list gnupg python-pdfminer-six python-pytest))
    (home-page "https://beancount.github.io/")
    (synopsis "Command-line double-entry accounting tool")
    (description
     "Beancount is a double-entry bookkeeping computer language that lets you
define financial transaction records in a text file, read them in memory,
generate a variety of reports from them, and provides a web interface.")
    (license license:gpl2)))

(define-public fava
  (package
    (name "fava")
    ;; XXX: A newer version requires Flask > 2.2, which is not available in
    ;; Guix yet.
    (version "1.24.4")
    (source
     (origin
       (method url-fetch)
       (uri (pypi-uri "fava" version))
       (sha256
        (base32 "1iwha9vx223iiyjqbixpz1lp8q766ikhi7xcap3pscjhldxlym4j"))))
    (build-system pyproject-build-system)
    (arguments
     (list
      #:phases
      #~(modify-phases %standard-phases
         (add-after 'unpack 'relax-requirements
           (lambda _
             (substitute* "setup.cfg"
               ((">=8,<10") ">8"))))
          ;; Tests write to $HOME.
          ;; FileNotFoundError: [Errno 2] No such file or directory
          (add-before 'check 'set-home
            (lambda _
              (setenv "HOME" "/tmp"))))))
    (propagated-inputs
     (list beancount
           python-babel
           python-cheroot
           python-click
           python-flask
           python-flask-babel
           python-jinja2
           python-markdown2
           python-ply
           python-simplejson
           python-werkzeug))
    (native-inputs
     (list python-pytest
           python-chardet
           python-dateutil
           python-setuptools-scm))
    (home-page "https://beancount.github.io/fava/")
    (synopsis "Web interface for the accounting tool Beancount")
    (description "Fava is a web interface for the double-entry bookkeeping
software Beancount with a focus on features and usability.")
    (license license:expat)))

(define-public emacs-beancount
  (package
    (name "emacs-beancount")
    (version "0.9.0")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/beancount/beancount-mode")
             (commit version)))
       (sha256
        (base32
         "01ivxgv1g0pkr0xi43366pghc3j3mmhk5bshis6kkn04bq04cx7f"))
       (file-name (git-file-name name version))))
    (build-system emacs-build-system)
    (home-page "https://github.com/beancount/beancount-mode")
    (synopsis "Emacs mode for Beancount")
    (description
     "Emacs-beancount is an Emacs mode for the Beancount accounting tool.")
    (license license:gpl3+)))

(define-public hledger-web
  (package
    (name "hledger-web")
    (version "1.27.1")
    (source (origin
              (method url-fetch)
              (uri (hackage-uri "hledger-web" version))
              (sha256
               (base32
                "151dxci7dld8626dzw823sr3d9iaac92wfzbfcbdz4jh9f7n07wa"))))
    (build-system haskell-build-system)
    (properties '((upstream-name . "hledger-web")))
    (inputs (list ghc-decimal
                  ghc-aeson
                  ghc-base64
                  ghc-blaze-html
                  ghc-blaze-markup
                  ghc-breakpoint
                  ghc-case-insensitive
                  ghc-clientsession
                  ghc-cmdargs
                  ghc-conduit
                  ghc-conduit-extra
                  ghc-data-default
                  ghc-extra
                  ghc-hjsmin
                  ghc-hledger
                  ghc-hledger-lib
                  ghc-hspec
                  ghc-http-client
                  ghc-http-conduit
                  ghc-http-types
                  ghc-megaparsec
                  ghc-network
                  ghc-shakespeare
                  ghc-unix-compat
                  ghc-unordered-containers
                  ghc-utf8-string
                  ghc-wai
                  ghc-wai-cors
                  ghc-wai-extra
                  ghc-wai-handler-launch
                  ghc-warp
                  ghc-yaml
                  ghc-yesod
                  ghc-yesod-core
                  ghc-yesod-form
                  ghc-yesod-static
                  ghc-yesod-test))
    (arguments
     (list
      #:haddock? #f
      #:phases
      #~(modify-phases %standard-phases
          ;; Tests write to $HOME.
          (add-before 'check 'set-home
            (lambda _
              (setenv "HOME" "/tmp")))
           (add-after 'register 'remove-libraries
             (lambda* (#:key outputs #:allow-other-keys)
               (delete-file-recursively (string-append (assoc-ref outputs "out") "/lib")))))))
    (home-page "http://hledger.org")
    (synopsis "Web-based user interface for the hledger accounting system")
    (description
     "This package provides a simple Web-based User
Interface (UI) for the hledger accounting system.  It can be used as a
local, single-user UI, or as a multi-user UI for viewing, adding, and
editing on the Web.")
    (license license:gpl3)))

(define-public quantlib
  (package
    (name "quantlib")
    (version "1.34")
    (source
     (origin
       (method url-fetch)
       (uri (string-append
             "https://github.com/lballabio/QuantLib/releases/download/v"
             version "/QuantLib-" version ".tar.gz"))
       (sha256
        (base32 "0l7yn9bal0csyix0ydzcfj003kma4sx7w5hyfxhh6mbnxn6am1zb"))))
    (build-system gnu-build-system)
    (arguments
     `(#:configure-flags
       ,#~(list "--disable-static"
                (string-append "--prefix=" #$output))))
    (inputs (list boost))
    (home-page "https://www.quantlib.org")
    (synopsis "Library for quantitative finance")
    (description
     "The QuantLib project is aimed at providing a comprehensive software
framework for quantitative finance.  QuantLib is a library for modeling,
trading, and risk management in real-life.")
    (license license:bsd-2)))

(define-public optionmatrix
  (package
    (name "optionmatrix")
    (version "1.4.3")
    (source
     (origin
       (method url-fetch)
       (uri (string-append
             "mirror://sourceforge/optionmatrix/optionmatrix-"
             version ".tar.xz"))
       (sha256
        (base32 "1zd0pfiphnijh1l94swb3mjrpmjsn37z11mklamd7zw6h2d4zh4d"))))
    (build-system gnu-build-system)
    (inputs
     (list gsl gtk+ ncurses))
    (native-inputs
     (list pkg-config texinfo
           (texlive-updmap.cfg (list texlive-epsf texlive-texinfo))))
    (home-page "https://anthonybradford.github.io/optionmatrix/")
    (synopsis "Financial derivative calculator")
    (description
     "The OptionMatrix programs are financial derivative calculators.  These
calculators are real-time multi-model option chain pricers with analytics and
interactive controls.  This package provides a GTK+ graphical user interface
(@code{optionmatrix}) and a curses interface (@code{optionmatrix_console}).")
    (license license:gpl3+)))

(define-public python-ta-lib
  (package
    (name "python-ta-lib")
    (version "0.4.32")
    (source
     (origin
       (method url-fetch)
       (uri (pypi-uri "TA-Lib" version))
       (sha256
        (base32 "186sgkpggy50gs2pa2p22zppl57xgfhpmja5l13xiskv44iw6x7v"))))
    (build-system python-build-system)
    (inputs
     (list ta-lib))
    (propagated-inputs
     (list python-numpy))
    (native-inputs
     (list python-cython python-nose python-pandas))
    (home-page "https://github.com/mrjbq7/ta-lib")
    (synopsis "Python wrapper for TA-Lib")
    (description
     "This is a Python wrapper for TA-Lib based on Cython.  TA-Lib is a library
providing common functions for the technical analysis of financial market data.")
    (license license:bsd-2)))

(define-public ta-lib
  (package
    (name "ta-lib")
    (version "0.4.0")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "mirror://sourceforge/ta-lib/ta-lib/"
                           version "/ta-lib-" version "-src.tar.gz"))
       (sha256
        (base32 "0lf69nna0aahwpgd9m9yjzbv2fbfn081djfznssa84f0n7y1xx4z"))))
    (build-system gnu-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'link-math-library
           (lambda _
             (substitute* "src/Makefile.am"
               (("ta_common/libta_common.la")
                "ta_common/libta_common.la -lm"))
             (substitute* "src/Makefile.in"
               (("\\$\\(libta_lib_la_LDFLAGS\\) \\$\\(LDFLAGS\\) -o \\$@")
                "$(libta_lib_la_LDFLAGS) $(LDFLAGS) -lm -o $@")))))
       ;; Parallel build fails with:
       ;; mv -f .deps/gen_code-gen_code.Tpo .deps/gen_code-gen_code.Po
       ;; mv: cannot stat '.deps/gen_code-gen_code.Tpo': No such file or directory
       ;; Makefile:254: recipe for target 'gen_code-gen_code.o' failed
       #:parallel-build? #f
       #:configure-flags '("--disable-static")))
    (home-page "https://ta-lib.org")
    (synopsis "Technical analysis library")
    (description
     "TA-Lib is a library providing common functions for the technical
analysis of financial market data.")
    (license license:bsd-3)))

(define-public python-mt-940
  (package
    (name "python-mt-940")
    (version "4.23.0")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/WoLpH/mt940.git")
                    (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "0z9w1qalcphsck3j6vkrs7k47ah9zq2rv0lm9nmcsgwpyp59qkyf"))))
    (properties '(("upstream-name" #{.}# "mt-940")))
    (build-system python-build-system)
    (arguments
     `(#:phases (modify-phases %standard-phases
                  (replace 'check
                    (lambda* (#:key tests? inputs outputs #:allow-other-keys)
                      (when tests?
                        ;; Remove custom --cov flags.
                        (delete-file "pytest.ini")
                        (invoke "pytest" "-vv")))))))
    (native-inputs (list python-flake8
                         python-pytest
                         python-pyyaml))
    (home-page "https://mt940.readthedocs.io/")
    (synopsis "Python parser for MT940-encoded SWIFT data")
    (description
     "A library to parse MT940 files, a bank account statement exchange
format used by SWIFT.  It returns smart Python collections for statistics
and manipulation.")
    (license license:bsd-3)))

(define-public xmrig
  (package
    (name "xmrig")
    (version "6.22.0")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/xmrig/xmrig")
             (commit (string-append "v" version))))
       (file-name (git-file-name name version))
       (sha256 (base32 "1h3qcs176xbfs1k2silr5rf13y0nag6qgsaz14qi3nrxxc0d8n4h"))
       (modules '((guix build utils)))
       (snippet
        ;; TODO: Try to use system libraries instead of bundled ones in
        ;; "src/3rdparty/". It requires changes to some "cmake/..." scripts
        ;; and to some source files.
        #~(begin
            (delete-file-recursively "src/3rdparty/hwloc")
            (substitute* "src/donate.h"
              (("constexpr const int kDefaultDonateLevel = 1;")
               "constexpr const int kDefaultDonateLevel = 0;")
              (("constexpr const int kMinimumDonateLevel = 1;")
               "constexpr const int kMinimumDonateLevel = 0;"))))))
    (build-system cmake-build-system)
    (inputs
     (list
      `(,hwloc "lib")
      libuv
      openssl))
    (arguments
     (list
      ;; There are no tests.
      #:tests? #f
      #:phases
      #~(modify-phases
         %standard-phases
         (replace 'install
           ;; There is no 'install' target, we must install xmrig manually
           (lambda* (#:key #:allow-other-keys)
             (install-file "xmrig"
                           (string-append #$output "/bin")))))))
    (home-page "https://xmrig.com/")
    (synopsis "Monero miner")
    (description
     "XMRig is a high-performance, cross-platform RandomX, KawPow,
CryptoNight and GhostRider unified CPU/GPU miner and RandomX benchmark.

Warning: upstream, by default, receives a percentage of the mining time.  This
anti-functionality has been neutralized in Guix, but possibly not in all other
distributions.

Warning: this software, because of its nature, has high energy consumption.
Also, the energy expenses might be higher than the cryptocurrency gained by
mining.")
    (license license:gpl3+)))

(define-public p2pool
  (package
    (name "p2pool")
    (version "4.1")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/SChernykh/p2pool")
             (commit (string-append "v" version))
             (recursive? #t)))
       (file-name (git-file-name name version))
       (sha256 (base32 "1ijj3ci0kx87yjv29c6p9wqj15aij7r87sdbjwhzcmbdf46krj3q"))
       (modules '((guix build utils)))
       (snippet
        #~(for-each delete-file-recursively
                    '("external/lib"
                      "external/src/cppzmq"
                      "external/src/curl"
                      "external/src/libuv"
                      "external/src/libzmq"
                      "external/src/rapidjson"
                      "external/src/robin-hood-hashing")))))
    (build-system cmake-build-system)
    (inputs
     (list cppzmq curl gss libuv rapidjson robin-hood-hashing zeromq))
    (arguments
     (list ; FIXME: Linking fails when LTO is activated.
           #:configure-flags #~(list "-DWITH_LTO=OFF")
           #:phases
           #~(modify-phases %standard-phases
               (replace 'check
                 (lambda* (#:key tests? #:allow-other-keys)
                   (when tests?
                     (mkdir-p "tests")
                     (chdir "tests")
                     (invoke "cmake" "-DWITH_LTO=OFF" "../../source/tests")
                     (invoke "make" "-j" (number->string (parallel-job-count)))
                     (invoke "gzip" "-d" "sidechain_dump.dat.gz")
                     (invoke "gzip" "-d" "sidechain_dump_mini.dat.gz")
                     (invoke "./p2pool_tests")
                     (chdir ".."))))
               (replace 'install
                 (lambda _
                   (install-file "p2pool" (string-append #$output "/bin")))))))
    (home-page "https://p2pool.io/")
    (synopsis "Decentralized Monero mining pool")
    (description "Monero P2Pool is a peer-to-peer Monero mining pool.  P2Pool
combines the advantages of pool and solo mining; you still fully control your
Monero node and what it mines, but you get frequent payouts like on a regular
pool.")
    (license license:gpl3)))

(define-public opentaxsolver
  ;; The OTS version is formatted like tax-year_version. So, at time of
  ;; writing, the version is 2023_21.03. Each part of this is used in
  ;; different places in the source uri, so it's convenient to have them
  ;; separately like this.
  (let ((tax-year "2023")
        (ots-version "21.03"))
    (package
      (name "opentaxsolver")
      (version (string-append tax-year "_" ots-version))
      (source
       (origin
         (method url-fetch)
         (uri (string-append "mirror://sourceforge/opentaxsolver/OTS_"
                             tax-year "/v" ots-version
                             "_linux/OpenTaxSolver" version "_linux64.tgz"))
         (sha256
          (base32
           "1i543bvclnyiwnyjlskhr2bxlsigggvwdhg2519rf12lsghgfszq"))
         (patches (search-patches "opentaxsolver-file-browser-fix.patch"))))
      (build-system glib-or-gtk-build-system)
      (arguments
       (list
        #:tests? #f                     ;no tests
        #:phases
        #~(modify-phases %standard-phases
            (delete 'configure)         ;no configure script
            ;; OTS does provide a shellscript that does exactly this, but we
            ;; need to do it ourselves to specify the correct compiler and to
            ;; delete the GUI binaries.
            (replace 'build
              (lambda _
                (delete-file "Run_taxsolve_GUI")
                (delete-file-recursively "bin")
                (mkdir "bin")
                (chdir "src/Gui_gtk")
                (invoke "make"
                        (string-append "CC=" #$(cc-for-target)))
                (chdir "..")
                (invoke "make"
                        (string-append "CC=" #$(cc-for-target)))))
            ;; OTS doesn't provide a `make install` target, because it assumes
            ;; it'll be run from the tarball. So, we do it ourselves, making
            ;; sure to replicate the directory structure of the tarball.
            (replace 'install
              (lambda _
                (copy-recursively "../bin"
                                  (string-append #$output "/bin"))
                (symlink (string-append #$output "/bin/ots_gui2")
                         (string-append #$output "/bin/Run_taxsolve_GUI"))
                (copy-recursively "../tax_form_files"
                                  (string-append #$output "/tax_form_files"))
                (copy-recursively "formdata"
                                  (string-append #$output "/src/formdata")))))))
      (native-inputs (list pkg-config))
      (inputs (list gtk+-2))
      (synopsis "Yearly tax preparation tool")
      (description
       "OpenTaxSolver is a program for calculating tax form entries for
federal and state personal income taxes.  It automatically fills out and
prints your forms for mailing.")
      (home-page "https://opentaxsolver.sourceforge.net/")
      (license license:gpl2+))))