aboutsummaryrefslogtreecommitdiff
path: root/src/include/taler_auditordb_plugin.h
blob: dab35acbf0d0eb6d739f701cdb78913a5781f369 (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
/*
  This file is part of TALER
  Copyright (C) 2014-2024 Taler Systems SA

  TALER 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, or (at your option) any later version.

  TALER 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
  TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
*/
/**
 * @file include/taler_auditordb_plugin.h
 * @brief Low-level (statement-level) database access for the auditor
 * @author Florian Dold
 * @author Christian Grothoff
 */
#ifndef TALER_AUDITORDB_PLUGIN_H
#define TALER_AUDITORDB_PLUGIN_H

#include <jansson.h>
#include <gnunet/gnunet_util_lib.h>
#include <gnunet/gnunet_db_lib.h>
#include "taler_util.h"
#include "taler_auditordb_lib.h"
#include "taler_signatures.h"


/**
 * Function called with the results of select_historic_denom_revenue()
 *
 * @param cls closure
 * @param serial_id row for the denomination revenue in the auditor database
 * @param denom_pub_hash hash of the denomination key
 * @param revenue_timestamp when did this profit get realized
 * @param revenue_balance what was the total profit made from
 *                        deposit fees, melting fees, refresh fees
 *                        and coins that were never returned?
 * @param loss_balance what was the total loss
 * @return sets the return value of select_denomination_info(),
 *         #GNUNET_OK to continue,
 *         #GNUNET_NO to stop processing further rows
 *         #GNUNET_SYSERR or other values on error.
 */
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_HistoricDenominationRevenueDataCallback)(
  void *cls,
  uint64_t serial_id,
  const struct TALER_DenominationHashP *denom_pub_hash,
  struct GNUNET_TIME_Timestamp revenue_timestamp,
  const struct TALER_Amount *revenue_balance,
  const struct TALER_Amount *loss_balance);


/**
 * Function called with the results of select_historic_reserve_revenue()
 *
 * @param cls closure
 * @param serial_id row ID in the history table
 * @param start_time beginning of aggregated time interval
 * @param end_time end of aggregated time interval
 * @param reserve_profits total profits made
 *
 * @return sets the return value of select_denomination_info(),
 *         #GNUNET_OK to continue,
 *         #GNUNET_NO to stop processing further rows
 *         #GNUNET_SYSERR or other values on error.
 */
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_HistoricReserveRevenueDataCallback)(
  void *cls,
  uint64_t serial_id,
  struct GNUNET_TIME_Timestamp start_time,
  struct GNUNET_TIME_Timestamp end_time,
  const struct TALER_Amount *reserve_profits);


/**
 * Information about a signing key of an exchange.
 */
struct TALER_AUDITORDB_ExchangeSigningKey
{

  /**
   * When does @e exchange_pub start to be used?
   */
  struct GNUNET_TIME_Timestamp ep_start;

  /**
   * When will the exchange stop signing with @e exchange_pub?
   */
  struct GNUNET_TIME_Timestamp ep_expire;

  /**
   * When does the signing key expire (for legal disputes)?
   */
  struct GNUNET_TIME_Timestamp ep_end;

  /**
   * What is the public offline signing key this is all about?
   */
  struct TALER_ExchangePublicKeyP exchange_pub;

  /**
   * Signature by the offline master key affirming the above.
   */
  struct TALER_MasterSignatureP master_sig;
};


/**
 * Information about a deposit confirmation we received from
 * a merchant.
 */
struct TALER_AUDITORDB_DepositConfirmation
{

  /**
   * Hash over the contract for which this deposit is made.
   */
  struct TALER_PrivateContractHashP h_contract_terms;

  /**
   * Hash over the policy extension for the deposit.
   */
  struct TALER_ExtensionPolicyHashP h_policy;

  /**
   * Hash over the wiring information of the merchant.
   */
  struct TALER_MerchantWireHashP h_wire;

  /**
   * Time when this deposit confirmation was generated by the exchange.
   */
  struct GNUNET_TIME_Timestamp exchange_timestamp;

  /**
   * How much time does the @e merchant have to issue a refund
   * request?  Zero if refunds are not allowed.  After this time, the
   * coin cannot be refunded.  Note that the wire transfer will not be
   * performed by the exchange until the refund deadline.  This value
   * is taken from the original deposit request.
   */
  struct GNUNET_TIME_Timestamp refund_deadline;

  /**
   * How much time does the @e exchange have to wire the funds?
   */
  struct GNUNET_TIME_Timestamp wire_deadline;

  /**
   * Amount to be deposited, excluding fee.  Calculated from the
   * amount with fee and the fee from the deposit request.
   */
  struct TALER_Amount total_without_fee;

  /**
   * Array of the coin public keys involved in the
   * batch deposit operation.
   */
  const struct TALER_CoinSpendPublicKeyP *coin_pubs;

  /**
   * Array of coin deposit signatures from the deposit operation.
   */
  const struct TALER_CoinSpendSignatureP *coin_sigs;

  /**
   * The Merchant's public key.  Allows the merchant to later refund
   * the transaction or to inquire about the wire transfer identifier.
   */
  struct TALER_MerchantPublicKeyP merchant;

  /**
   * Signature from the exchange of type
   * #TALER_SIGNATURE_EXCHANGE_CONFIRM_DEPOSIT.
   */
  struct TALER_ExchangeSignatureP exchange_sig;

  /**
   * Public signing key from the exchange matching @e exchange_sig.
   */
  struct TALER_ExchangePublicKeyP exchange_pub;

  /**
   * Exchange master signature over @e exchange_sig.
   */
  struct TALER_MasterSignatureP master_sig;

  /**
   * Row of this entry in the auditor database.
   */
  uint64_t row_id;

  /**
   * Length of the @e coin_pubs and @e coin_sigs arrays.
   */
  unsigned int num_coins;

  bool suppressed;

};

// MARK: CRUD

/**
 * Information about a row inconsistency
 */
struct TALER_AUDITORDB_Generic_Update
{
  uint64_t row_id;
  bool suppressed;
  bool ancient;
};

/**
 * Information about an arithmetic inconsistency
 */
struct TALER_AUDITORDB_AmountArithmeticInconsistency
{
  uint64_t row_id;
  uint64_t problem_row_id;
  char *operation;
  struct TALER_Amount exchange_amount;
  struct TALER_Amount auditor_amount;
  bool profitable;
  bool suppressed;
};

/**
 * Information about a coin inconsistency
 */
struct TALER_AUDITORDB_CoinInconsistency
{
  uint64_t row_id;
  char *operation;
  struct TALER_Amount exchange_amount;
  struct TALER_Amount auditor_amount;
  struct GNUNET_CRYPTO_EddsaPublicKey coin_pub;
  bool profitable;
};

/**
 * Information about a row inconsistency
 */
struct TALER_AUDITORDB_RowInconsistency
{
  uint64_t row_id;
  char *row_table;
  char *diagnostic;
  bool suppressed;
};

/**
 * Information about a bad sig loss
 */
struct TALER_AUDITORDB_BadSigLosses
{
  uint64_t row_id;
  uint64_t problem_row_id;
  char *operation;
  struct TALER_Amount loss;
  struct GNUNET_CRYPTO_EddsaPublicKey operation_specific_pub;
  bool suppressed;
};

/**
 * Information about a closure lags
 */
struct TALER_AUDITORDB_ClosureLags
{
  uint64_t row_id;
  uint64_t problem_row_id;
  struct TALER_Amount amount;
  struct GNUNET_TIME_Absolute deadline;
  struct TALER_WireTransferIdentifierRawP wtid;
  char *account;
  bool suppressed;
};

/**
 * Information about a emergency
 */
struct TALER_AUDITORDB_Emergency
{
  uint64_t row_id;
  struct TALER_DenominationHashP denompub_h;
  struct TALER_Amount denom_risk;
  struct TALER_Amount denom_loss;
  struct GNUNET_TIME_Absolute deposit_start;
  struct GNUNET_TIME_Absolute deposit_end;
  struct TALER_Amount value;
  bool suppressed;
};

/**
 * Information about an emergency by count
 */
struct TALER_AUDITORDB_EmergenciesByCount
{
  uint64_t row_id;
  struct TALER_DenominationHashP denompub_h;
  uint64_t num_issued;
  uint64_t num_known;
  struct TALER_Amount risk;
  struct GNUNET_TIME_Absolute start;
  struct GNUNET_TIME_Absolute deposit_end;
  struct TALER_Amount value;
  bool suppressed;
};

/**
 * Information about progress of the audit.
 */
struct TALER_AUDITORDB_Progress
{
  char *progress_key;
  uint64_t progress_offset;
};

/**
 * Information about a refreshes hanging
 */
struct TALER_AUDITORDB_RefreshesHanging
{
  uint64_t row_id;
  uint64_t problem_row_id;
  struct TALER_Amount amount;
};

/**
 * Information about a fee time inconsistency
 */
struct TALER_AUDITORDB_FeeTimeInconsistency
{
  uint64_t row_id;
  uint64_t problem_row_id;
  char *type;
  struct GNUNET_TIME_Absolute time;
  char *diagnostic;
};

/**
 * Information about a denom key validity withdraw inconsistency
 */
struct TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistency
{
  uint64_t row_id;
  uint64_t problem_row_id;
  struct GNUNET_TIME_Absolute execution_date;
  struct TALER_ReservePublicKeyP reserve_pub;
  struct TALER_DenominationHashP denompub_h;
  bool suppressed;
};

/**
 * Information about a purse not closed inconsistencies
 */
struct TALER_AUDITORDB_PurseNotClosedInconsistencies
{
  uint64_t row_id;
  struct GNUNET_CRYPTO_EddsaPublicKey purse_pub;
  struct TALER_Amount amount;
  struct GNUNET_TIME_Absolute expiration_date;
  bool suppressed;
};

/**
 * Information about a reserve balance insufficient inconsistency
 */
struct TALER_AUDITORDB_ReserveBalanceInsufficientInconsistency
{
  uint64_t row_id;
  struct GNUNET_CRYPTO_EddsaPublicKey reserve_pub;
  bool inconsistency_gain;
  struct TALER_Amount inconsistency_amount;
  bool suppressed;
};

/**
 * Information about a reserve in inconsistency
 */
struct TALER_AUDITORDB_ReserveInInconsistency
{
  uint64_t bank_row_id;
  struct TALER_Amount amount_exchange_expected;
  struct TALER_Amount amount_wired;
  struct TALER_ReservePublicKeyP reserve_pub;
  struct GNUNET_TIME_Absolute timestamp;
  char *account;
  char *diagnostic;
  bool suppressed;

};

/**
 * Information about a balance
 */
struct TALER_AUDITORDB_Balances
{
  uint64_t row_id;
  char *balance_key;
  struct TALER_Amount balance_value;
  bool suppressed;

};

/**
 * Function called with arithmetic inconsistencies stored in
 * the auditor's database.
 *
 * @param cls closure
 * @param dc the structure itself
 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
 */
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_AmountArithmeticInconsistencyCallback)(
  void *cls,
  const struct TALER_AUDITORDB_AmountArithmeticInconsistency *dc);

/**
 * Function called with coin inconsistencies stored in
 * the auditor's database.
 *
 * @param cls closure
 * @param serial_id location of the @a dc in the database
 * @param dc the structure itself
 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
 */
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_CoinInconsistencyCallback)(
  void *cls,
  uint64_t serial_id,
  const struct TALER_AUDITORDB_CoinInconsistency *dc);

/**
 * Function called with row inconsistencies stored in
 * the auditor's database.
 *
 * @param cls closure
 * @param serial_id location of the @a dc in the database
 * @param dc the structure itself
 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
 */
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_RowInconsistencyCallback)(
  void *cls,
  uint64_t serial_id,
  const struct TALER_AUDITORDB_RowInconsistency *dc);

/**
 * Function called with bad signature losses stored in
 * the auditor's database.
 *
 * @param cls closure
 * @param dc the structure itself
 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
 */
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_BadSigLossesCallback)(
  void *cls,
  const struct TALER_AUDITORDB_BadSigLosses *dc);

/**
 * Function called with closure lags stored in
 * the auditor's database.
 *
 * @param cls closure
 * @param dc the structure itself
 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
 */
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_ClosureLagsCallback)(
  void *cls,
  const struct TALER_AUDITORDB_ClosureLags *dc);

/**
 * Function called with emergencies stored in
 * the auditor's database.
 *
 * @param cls closure
 * @param dc the structure itself
 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
 */
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_EmergencyCallback)(
  void *cls,
  const struct TALER_AUDITORDB_Emergency *dc);

/**
 * Function called with emergencies stored in
 * the auditor's database.
 *
 * @param cls closure
 * @param dc the structure itself
 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
 */
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_EmergenciesByCountCallback)(
  void *cls,
  const struct TALER_AUDITORDB_EmergenciesByCount *dc);


/**
 * Function called with refreshes hanging stored in
 * the auditor's database.
 *
 * @param cls closure
 * @param dc the structure itself
 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
 */
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_RefreshesHangingCallback)(
  void *cls,
  const struct TALER_AUDITORDB_RefreshesHanging *dc);

/**
 * Function called with fee time inconsistency stored in
 * the auditor's database.
 *
 * @param cls closure
 * @param dc the structure itself
 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
 */
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_FeeTimeInconsistencyCallback)(
  void *cls,
  const struct TALER_AUDITORDB_FeeTimeInconsistency *dc);

/**
 * Function called with fee denomination key validity withdraw inconsistency stored in
 * the auditor's database.
 *
 * @param cls closure
 * @param dc the structure itself
 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
 */
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistencyCallback)(
  void *cls,
  const struct
  TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistency *dc);

/**
 * Function called with purse not closed inconsistencies stored in
 * the auditor's database.
 *
 * @param cls closure
 * @param dc the structure itself
 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
 */
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_PurseNotClosedInconsistenciesCallback)(
  void *cls,
  const struct TALER_AUDITORDB_PurseNotClosedInconsistencies *dc);

/**
 * Function called with reserve balance insufficient inconsistency stored in
 * the auditor's database.
 *
 * @param cls closure
 * @param dc the structure itself
 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
 */
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_ReserveBalanceInsufficientInconsistencyCallback)(
  void *cls,
  const struct TALER_AUDITORDB_ReserveBalanceInsufficientInconsistency *dc);

typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_BalancesCallback)(
  void *cls,
  const struct TALER_AUDITORDB_Balances *dc);

typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_ProgressPointsCallback)(
  void *cls,
  const struct TALER_AUDITORDB_Progress *pp);

/**
 * Balance values for a reserve (or all reserves).
 */
struct TALER_AUDITORDB_ReserveFeeBalance
{
  /**
   * Remaining funds.
   */
  struct TALER_Amount reserve_balance;

  /**
   * Losses from operations that should not have
   * happened (e.g. negative balance).
   */
  struct TALER_Amount reserve_loss;

  /**
   * Fees charged for withdraw.
   */
  struct TALER_Amount withdraw_fee_balance;

  /**
   * Fees charged for closing.
   */
  struct TALER_Amount close_fee_balance;

  /**
   * Fees charged for purse creation.
   */
  struct TALER_Amount purse_fee_balance;

  /**
   * Opening fees charged.
   */
  struct TALER_Amount open_fee_balance;

  /**
   * History fees charged.
   */
  struct TALER_Amount history_fee_balance;
};


/**
 * Balance data for denominations in circulation.
 */
struct TALER_AUDITORDB_DenominationCirculationData
{
  /**
   * Amount of outstanding coins in circulation.
   */
  struct TALER_Amount denom_balance;

  /**
   * Amount lost due coins illicitly accepted (effectively, a
   * negative @a denom_balance).
   */
  struct TALER_Amount denom_loss;

  /**
   * Total amount that could still be theoretically lost in the future due to
   * recoup operations.  (Total put into circulation minus @e recoup_loss).
   */
  struct TALER_Amount denom_risk;

  /**
   * Amount lost due to recoups.
   */
  struct TALER_Amount recoup_loss;

  /**
   * Number of coins of this denomination that the exchange signed into
   * existence.
   */
  uint64_t num_issued;
};

struct TALER_AUDITORDB_DenominationsWithoutSigs
{
  uint64_t row_id;
  struct TALER_DenominationHashP denompub_h;
  struct TALER_Amount value;
  struct GNUNET_TIME_Absolute start_time;
  struct GNUNET_TIME_Absolute end_time;
  bool suppressed;
};

struct TALER_AUDITORDB_MisattributionInInconsistency
{
  uint64_t row_id;
  struct TALER_Amount amount;
  uint64_t bank_row;
  struct TALER_ReservePublicKeyP reserve_pub;
  bool suppressed;

};

struct TALER_AUDITORDB_Reserves
{
  uint64_t row_id;
  uint64_t auditor_reserves_rowid;
  struct TALER_ReservePublicKeyP reserve_pub;
  struct TALER_Amount reserve_balance;
  struct TALER_Amount reserve_loss;
  struct TALER_Amount withdraw_fee_balance;
  struct TALER_Amount close_fee_balance;
  struct TALER_Amount purse_fee_balance;
  struct TALER_Amount open_fee_balance;
  struct TALER_Amount history_fee_balance;
  struct GNUNET_TIME_Absolute expiration_date;
  char *origin_account;
  bool suppressed;

};

struct TALER_AUDITORDB_Purses
{
  uint64_t row_id;
  uint64_t auditor_purses_rowid;
  struct TALER_PurseContractPublicKeyP purse_pub;
  struct TALER_Amount balance;
  struct TALER_Amount target;
  struct GNUNET_TIME_Absolute expiration_date;
  bool suppressed;

};

struct TALER_AUDITORDB_HistoricDenominationRevenue
{
  uint64_t row_id;
  struct TALER_DenominationHashP denom_pub_hash;
  struct GNUNET_TIME_Absolute revenue_timestamp;
  struct TALER_Amount revenue_balance;
  struct TALER_Amount loss_balance;
  bool suppressed;

};

struct TALER_AUDITORDB_DenominationPending
{
  uint64_t row_id;
  struct TALER_DenominationHashP denom_pub_hash;
  struct TALER_Amount denom_balance;
  struct TALER_Amount denom_loss;
  uint64_t num_issued;
  struct TALER_Amount denom_risk;
  struct TALER_Amount recoup_loss;
  bool suppressed;

};

struct TALER_AUDITORDB_HistoricReserveSummary
{
  uint64_t row_id;
  struct GNUNET_TIME_Absolute start_date;
  struct GNUNET_TIME_Absolute end_date;
  struct TALER_Amount reserve_profits;
  bool suppressed;

};

struct TALER_AUDITORDB_ExchangeSignkeys
{
  uint64_t row_id;
  struct TALER_ExchangePublicKeyP exchange_pub;
  struct TALER_MasterSignatureP master_sig;
  struct GNUNET_TIME_Absolute ep_valid_from;
  struct GNUNET_TIME_Absolute ep_expire_sign;
  struct GNUNET_TIME_Absolute ep_expire_legal;
  bool suppressed;

};

struct TALER_AUDITORDB_WireFormatInconsistency
{
  uint64_t row_id;
  struct TALER_Amount amount;
  uint64_t wire_offset;
  char *diagnostic;
  bool suppressed;

};

struct TALER_AUDITORDB_WireOutInconsistency
{
  uint64_t row_id;
  char *destination_account;
  char *diagnostic;
  uint64_t wire_out_row_id;
  struct TALER_Amount expected;
  struct TALER_Amount claimed;
  bool suppressed;

};

struct TALER_AUDITORDB_RowMinorInconsistencies
{
  uint64_t row_id;
  char *row_table;
  uint64_t problem_row;
  char *diagnostic;
  bool suppressed;
};


struct TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistency
{
  uint64_t row_id;
  struct TALER_ReservePublicKeyP reserve_pub;
  struct TALER_Amount exchange_amount;
  struct TALER_Amount auditor_amount;
  bool suppressed;

};

struct TALER_AUDITORDB_ReserveNotClosedInconsistency
{
  uint64_t row_id;
  struct TALER_ReservePublicKeyP reserve_pub;
  struct TALER_Amount balance;
  struct GNUNET_TIME_Absolute expiration_time;
  char *diagnostic;
  bool suppressed;

};

/**
 * Function called with deposit confirmations stored in
 * the auditor's database.
 *
 * @param cls closure
 * @param dc the deposit confirmation itself
 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
 */
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_DepositConfirmationCallback)(
  void *cls,
  const struct TALER_AUDITORDB_DepositConfirmation *dc);


/**
 * Function called on deposits that are past their due date
 * and have not yet seen a wire transfer.
 *
 * @param cls closure
 * @param batch_deposit_serial_id where in the table are we
 * @param total_amount value of all missing deposits, including fees
 * @param wire_target_h_payto hash of the recipient account's payto URI
 * @param deadline what was the earliest requested wire transfer deadline
 */
typedef void
(*TALER_AUDITORDB_WireMissingCallback) (
  void *cls,
  uint64_t batch_deposit_serial_id,
  const struct TALER_Amount *total_amount,
  const struct TALER_FullPaytoHashP *wire_target_h_payto,
  struct GNUNET_TIME_Timestamp deadline);


/**
 * Function called on expired purses.
 *
 * @param cls closure
 * @param purse_pub public key of the purse
 * @param balance amount of money in the purse
 * @param expiration_date when did the purse expire?
 * @return #GNUNET_OK to continue to iterate
 */
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_ExpiredPurseCallback)(
  void *cls,
  const struct TALER_PurseContractPublicKeyP *purse_pub,
  const struct TALER_Amount *balance,
  struct GNUNET_TIME_Timestamp expiration_date);


typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_ReserveInInconsistencyCallback)(
  void *cls,
  uint64_t serial_id,
  const struct TALER_AUDITORDB_ReserveInInconsistency *dc);

typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_ReserveNotClosedInconsistencyCallback)(
  void *cls,
  const struct TALER_AUDITORDB_ReserveNotClosedInconsistency *dc);

typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_DenominationsWithoutSigsCallback)(
  void *cls,
  const struct TALER_AUDITORDB_DenominationsWithoutSigs *dc);

typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_MisattributionInInconsistencyCallback)(
  void *cls,
  const struct TALER_AUDITORDB_MisattributionInInconsistency *dc);

typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_ReservesCallback)(
  void *cls,
  uint64_t serial_id,
  const struct TALER_AUDITORDB_Reserves *dc);

typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_PursesCallback)(
  void *cls,
  uint64_t serial_id,
  const struct TALER_AUDITORDB_Purses *dc);

typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_HistoricDenominationRevenueCallback)(
  void *cls,
  uint64_t serial_id,
  const struct TALER_AUDITORDB_HistoricDenominationRevenue *dc);

typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_DenominationPendingCallback)(
  void *cls,
  uint64_t serial_id,
  const struct TALER_AUDITORDB_DenominationPending *dc);

typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_HistoricReserveSummaryCallback)(
  void *cls,
  uint64_t serial_id,
  const struct TALER_AUDITORDB_HistoricReserveSummary *dc);

typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_ExchangeSignkeysCallback)(
  void *cls,
  uint64_t serial_id,
  const struct TALER_AUDITORDB_ExchangeSignkeys *dc);


typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_WireFormatInconsistencyCallback)(
  void *cls,
  const struct TALER_AUDITORDB_WireFormatInconsistency *dc);

typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_WireOutInconsistencyCallback)(
  void *cls,
  const struct TALER_AUDITORDB_WireOutInconsistency *dc);

typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistencyCallback)(
  void *cls,
  const struct TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistency *dc);

typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_RowMinorInconsistenciesCallback)(
  void *cls,
  const struct TALER_AUDITORDB_RowMinorInconsistencies *dc);


/**
 * @brief The plugin API, returned from the plugin's "init" function.
 * The argument given to "init" is simply a configuration handle.
 *
 * Functions starting with "get_" return one result, functions starting
 * with "select_" return multiple results via callbacks.
 */
struct TALER_AUDITORDB_Plugin
{

  /**
   * Closure for all callbacks.
   */
  void *cls;

  /**
   * Name of the library which generated this plugin.  Set by the
   * plugin loader.
   */
  char *library_name;

  /**
   * Fully connect to the db if the connection does not exist yet
   * and check that there is no transaction currently running.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @return #GNUNET_OK on success
   *         #GNUNET_NO if we rolled back an earlier transaction
   *         #GNUNET_SYSERR if we have no DB connection
   */
  enum GNUNET_GenericReturnValue
    (*preflight)(void *cls);


  /**
   * Register callback to be invoked on events of type @a es.
   *
   * @param cls database context to use
   * @param es specification of the event to listen for
   * @param timeout how long to wait for the event
   * @param cb function to call when the event happens, possibly
   *         mulrewardle times (until cancel is invoked)
   * @param cb_cls closure for @a cb
   * @return handle useful to cancel the listener
   */
  struct GNUNET_DB_EventHandler *
  (*event_listen) (void *cls,
                   const struct GNUNET_DB_EventHeaderP *es,
                   struct GNUNET_TIME_Relative timeout,
                   GNUNET_DB_EventCallback cb,
                   void *cb_cls);

  /**
   * Stop notifications.
   *
   * @param eh handle to unregister.
   */
  void
  (*event_listen_cancel) (struct GNUNET_DB_EventHandler *eh);


  /**
   * Notify all that listen on @a es of an event.
   *
   * @param cls database context to use
   * @param es specification of the event to generate
   * @param extra additional event data provided
   * @param extra_size number of bytes in @a extra
   */
  void
  (*event_notify) (void *cls,
                   const struct GNUNET_DB_EventHeaderP *es,
                   const void *extra,
                   size_t extra_size);


  /**
   * Drop all auditor tables OR deletes recoverable auditor state.
   * This should only be used by testcases or when restarting the
   * auditor from scratch.
   *
   * @param cls the `struct PostgresClosure` with the plugin-specific state
   * @param drop_exchangelist drop all tables, including schema versioning
   *        and the exchange and deposit_confirmations table; NOT to be
   *        used when restarting the auditor
   * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
   */
  enum GNUNET_GenericReturnValue
    (*drop_tables)(void *cls,
                   bool drop_exchangelist);


  /**
   * Create the necessary tables if they are not present
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param support_partitions true to support partitioning
   * @param num_partitions number of partitions to use
   * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
   */
  enum GNUNET_GenericReturnValue
    (*create_tables)(void *cls,
                     bool support_partitions,
                     uint32_t num_partitions);


  /**
   * Start a transaction.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @return #GNUNET_OK on success
   */
  enum GNUNET_GenericReturnValue
    (*start)(void *cls);


  /**
   * Commit a transaction.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*commit)(void *cls);


  /**
   * Abort/rollback a transaction.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   */
  void
  (*rollback) (void *cls);


  /**
   * Function called to perform "garbage collection" on the
   * database, expiring records we no longer require.
   *
   * @param cls closure
   * @return #GNUNET_OK on success,
   *         #GNUNET_SYSERR on DB errors
   */
  enum GNUNET_GenericReturnValue
    (*gc)(void *cls);


  /**
   * Insert information about the auditor's progress with an exchange's
   * data.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param progress_key name of the progress indicator
   * @param progress_offset offset until which we have made progress
   * @param ... NULL terminated list of additional key-value pairs to insert
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*insert_auditor_progress)(
    void *cls,
    const char *progress_key,
    uint64_t progress_offset,
    ...);

  /**
   * Update information about the progress of the auditor.  There
   * must be an existing record for the exchange.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param progress_key name of the progress indicator
   * @param progress_offset offset until which we have made progress
   * @param ... NULL terminated list of additional key-value pairs to update
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*update_auditor_progress)(
    void *cls,
    const char *progress_key,
    uint64_t progress_offset,
    ...);

  /**
   * Get information about the progress of the auditor.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param progress_key name of the progress indicator
   * @param[out] progress_offset set to offset until which we have made progress, set to 0 if key was not found
   * @param ... NULL terminated list of additional key-value pairs to fetch
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*get_auditor_progress)(void *cls,
                            const char *progress_key,
                            uint64_t *progress_offset,
                            ...);


  /**
   * Insert information about a balance tracked by the auditor. There must not be an
   * existing record.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param balance_key key of the balance to store
   * @param balance_value value to store
   * @param ... NULL terminated list of additional key-value pairs to insert
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*insert_balance)(void *cls,
                      const char *balance_key,
                      const struct TALER_Amount *balance_value,
                      ...);


  /**
   * Insert information about a balance tracked by the auditor.  Destructively updates an
   * existing record, which must already exist.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param balance_key key of the balance to store
   * @param balance_amount value to store
   * @param ... NULL terminated list of additional key-value pairs to update
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*update_balance)(void *cls,
                      const char *balance_key,
                      const struct TALER_Amount *balance_amount,
                      ...);


  /**
   * Get summary information about balance tracked by the auditor.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param balance_key key of the balance to store
   * @param[out] balance_value set to amount stored under @a balance_key, set to invalid amount (all zero) if key was not found
   * @param ... NULL terminated list of additional key-value pairs to fetch
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*get_balance)(void *cls,
                   const char *balance_key,
                   struct TALER_Amount *balance_value,
                   ...);


  /**
   * Get information about balances from the database.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param balance_key only return this particular balance
   * @param cb function to call with results
   * @param cb_cls closure for @a cb
   * @return query result status
   */
  enum GNUNET_DB_QueryStatus
    (*get_balances)(
    void *cls,
    const char *balance_key,
    TALER_AUDITORDB_BalancesCallback cb,
    void *cb_cls);

  /**
   * Get information about progress from the database.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param progress_key only return this particular progress point
   * @param cb function to call with results
   * @param cb_cls closure for @a cb
   * @return query result status
   */
  enum GNUNET_DB_QueryStatus
    (*get_progress_points)(
    void *cls,
    const char *progress_key,
    TALER_AUDITORDB_ProgressPointsCallback cb,
    void *cb_cls);

  /**
   * Insert information about a signing key of the exchange.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param sk signing key information to store
   * @return query result status
   */
  enum GNUNET_DB_QueryStatus
    (*insert_exchange_signkey)(
    void *cls,
    const struct TALER_AUDITORDB_ExchangeSigningKey *sk);


  /**
   * Insert information about a deposit confirmation into the database.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param dc deposit confirmation information to store
   * @return query result status
   */
  enum GNUNET_DB_QueryStatus
    (*insert_deposit_confirmation)(
    void *cls,
    const struct TALER_AUDITORDB_DepositConfirmation *dc);


  /**
   * Get information about deposit confirmations from the database.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param offset row/serial ID where to start the iteration (0 from
   *                  the start, exclusive, i.e. serial_ids must start from 1)
   * @param return_suppressed should suppressed rows be returned anyway?
   * @param cb function to call with results
   * @param cb_cls closure for @a cb
   * @return query result status
   */
  enum GNUNET_DB_QueryStatus
    (*get_deposit_confirmations)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    bool return_suppressed,
    TALER_AUDITORDB_DepositConfirmationCallback cb,
    void *cb_cls);


  // MARK: CRUD

  /**
   * Get information about arithmetic inconsistencies from the database.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param start_id row/serial ID where to start the iteration (0 from
   *                  the start, exclusive, i.e. serial_ids must start from 1)
   * @param return_suppressed should suppressed rows be returned anyway?
   * @param cb function to call with results
   * @param cb_cls closure for @a cb
   * @return query result status
   */
  enum GNUNET_DB_QueryStatus
    (*get_amount_arithmetic_inconsistency)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    bool return_suppressed,
    TALER_AUDITORDB_AmountArithmeticInconsistencyCallback cb,
    void *cb_cls);

  enum GNUNET_DB_QueryStatus
    (*get_coin_inconsistency)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    bool return_suppressed,
    TALER_AUDITORDB_CoinInconsistencyCallback cb,
    void *cb_cls);

  enum GNUNET_DB_QueryStatus
    (*get_row_inconsistency)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    bool return_suppressed,
    TALER_AUDITORDB_RowInconsistencyCallback cb,
    void *cb_cls);

  enum GNUNET_DB_QueryStatus
    (*get_emergency)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    bool return_suppressed,
    TALER_AUDITORDB_EmergencyCallback cb,
    void *cb_cls);

  enum GNUNET_DB_QueryStatus
    (*get_emergency_by_count)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    bool return_suppressed,
    TALER_AUDITORDB_EmergenciesByCountCallback cb,
    void *cb_cls);

  enum GNUNET_DB_QueryStatus
    (*get_denomination_key_validity_withdraw_inconsistency)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    bool return_suppressed,
    TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistencyCallback cb,
    void *cb_cls);

  enum GNUNET_DB_QueryStatus
    (*get_purse_not_closed_inconsistencies)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    bool return_suppressed,
    TALER_AUDITORDB_PurseNotClosedInconsistenciesCallback cb,
    void *cb_cls);

  enum GNUNET_DB_QueryStatus
    (*get_reserve_balance_insufficient_inconsistency)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    bool return_suppressed,
    TALER_AUDITORDB_ReserveBalanceInsufficientInconsistencyCallback cb,
    void *cb_cls);

  enum GNUNET_DB_QueryStatus
    (*get_bad_sig_losses)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    bool return_suppressed,
    const struct GNUNET_CRYPTO_EddsaPublicKey *op_spec_pub,
    const char *op,
    TALER_AUDITORDB_BadSigLossesCallback cb,
    void *cb_cls);

  enum GNUNET_DB_QueryStatus
    (*get_auditor_closure_lags)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    bool return_suppressed,
    TALER_AUDITORDB_ClosureLagsCallback cb,
    void *cb_cls);

  enum GNUNET_DB_QueryStatus
    (*get_refreshes_hanging)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    bool return_suppressed,
    TALER_AUDITORDB_RefreshesHangingCallback cb,
    void *cb_cls);

  /**
   * Delete information about a deposit confirmation from the database.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param row_id row to delete
   * @return query result status
   */
  enum GNUNET_DB_QueryStatus
    (*delete_amount_arithmetic_inconsistency)(
    void *cls,
    uint64_t row_id);

  enum GNUNET_DB_QueryStatus
    (*delete_coin_inconsistency)(
    void *cls,
    uint64_t row_id);

  enum GNUNET_DB_QueryStatus
    (*delete_row_inconsistency)(
    void *cls,
    uint64_t row_id);

  enum GNUNET_DB_QueryStatus
    (*delete_emergency)(
    void *cls,
    uint64_t row_id);

  enum GNUNET_DB_QueryStatus
    (*delete_emergency_by_count)(
    void *cls,
    uint64_t row_id);

  enum GNUNET_DB_QueryStatus
    (*delete_denomination_key_validity_withdraw_inconsistency)(
    void *cls,
    uint64_t row_id);

  enum GNUNET_DB_QueryStatus
    (*delete_purse_not_closed_inconsistencies)(
    void *cls,
    uint64_t row_id);

  enum GNUNET_DB_QueryStatus
    (*delete_reserve_balance_insufficient_inconsistency)(
    void *cls,
    uint64_t row_id);

  enum GNUNET_DB_QueryStatus
    (*delete_bad_sig_losses)(
    void *cls,
    uint64_t row_id);

  enum GNUNET_DB_QueryStatus
    (*delete_auditor_closure_lags)(
    void *cls,
    uint64_t row_id);

  enum GNUNET_DB_QueryStatus
    (*delete_progress)(
    void *cls,
    uint64_t row_id);

  enum GNUNET_DB_QueryStatus
    (*delete_refreshes_hanging)(
    void *cls,
    uint64_t row_id);


  /**
* Insert information about a deposit confirmation into the database.
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param dc deposit confirmation information to store
* @return query result status
*/
  enum GNUNET_DB_QueryStatus
    (*insert_amount_arithmetic_inconsistency)(
    void *cls,
    const struct TALER_AUDITORDB_AmountArithmeticInconsistency *dc);

  enum GNUNET_DB_QueryStatus
    (*insert_coin_inconsistency)(
    void *cls,
    const struct TALER_AUDITORDB_CoinInconsistency *dc);

  enum GNUNET_DB_QueryStatus
    (*insert_row_inconsistency)(
    void *cls,
    const struct TALER_AUDITORDB_RowInconsistency *dc);

  enum GNUNET_DB_QueryStatus
    (*insert_emergency)(
    void *cls,
    const struct TALER_AUDITORDB_Emergency *dc);

  enum GNUNET_DB_QueryStatus
    (*insert_emergency_by_count)(
    void *cls,
    const struct TALER_AUDITORDB_EmergenciesByCount *dc);

  enum GNUNET_DB_QueryStatus
    (*insert_denomination_key_validity_withdraw_inconsistency)(
    void *cls,
    const struct
    TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistency *dc);

  enum GNUNET_DB_QueryStatus
    (*insert_purse_not_closed_inconsistencies)(
    void *cls,
    const struct TALER_AUDITORDB_PurseNotClosedInconsistencies *dc);

  enum GNUNET_DB_QueryStatus
    (*insert_reserve_balance_insufficient_inconsistency)(
    void *cls,
    const struct TALER_AUDITORDB_ReserveBalanceInsufficientInconsistency *dc);

  enum GNUNET_DB_QueryStatus
    (*insert_bad_sig_losses)(
    void *cls,
    const struct TALER_AUDITORDB_BadSigLosses *dc);

  enum GNUNET_DB_QueryStatus
    (*insert_auditor_closure_lags)(
    void *cls,
    const struct TALER_AUDITORDB_ClosureLags *dc);

  enum GNUNET_DB_QueryStatus
    (*insert_refreshes_hanging)(
    void *cls,
    const struct TALER_AUDITORDB_RefreshesHanging *dc);

  enum GNUNET_DB_QueryStatus
    (*update_generic_suppressed)(
    void *cls,
    enum TALER_AUDITORDB_DeletableSuppressableTables table,
    uint64_t row_id,
    bool suppressed);

  enum GNUNET_DB_QueryStatus
    (*delete_generic)(
    void *cls,
    enum TALER_AUDITORDB_DeletableSuppressableTables table,
    uint64_t row_id);

  enum GNUNET_DB_QueryStatus
    (*get_reserve_in_inconsistency)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    bool return_suppressed,
    TALER_AUDITORDB_ReserveInInconsistencyCallback cb,
    void *cb_cls);


  enum GNUNET_DB_QueryStatus
    (*delete_reserve_in_inconsistency)(
    void *cls,
    uint64_t row_id);


  enum GNUNET_DB_QueryStatus
    (*insert_reserve_in_inconsistency)(
    void *cls,
    const struct TALER_AUDITORDB_ReserveInInconsistency *dc);

  enum GNUNET_DB_QueryStatus
    (*get_reserve_not_closed_inconsistency)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    bool return_suppressed,
    TALER_AUDITORDB_ReserveNotClosedInconsistencyCallback cb,
    void *cb_cls);


  enum GNUNET_DB_QueryStatus
    (*delete_reserve_not_closed_inconsistency)(
    void *cls,
    uint64_t row_id);


  enum GNUNET_DB_QueryStatus
    (*insert_reserve_not_closed_inconsistency)(
    void *cls,
    const struct TALER_AUDITORDB_ReserveNotClosedInconsistency *dc);

  enum GNUNET_DB_QueryStatus
    (*get_denominations_without_sigs)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    bool return_suppressed,
    TALER_AUDITORDB_DenominationsWithoutSigsCallback cb,
    void *cb_cls);


  enum GNUNET_DB_QueryStatus
    (*delete_denominations_without_sigs)(
    void *cls,
    uint64_t row_id);


  enum GNUNET_DB_QueryStatus
    (*insert_denominations_without_sigs)(
    void *cls,
    const struct TALER_AUDITORDB_DenominationsWithoutSigs *dc);

  enum GNUNET_DB_QueryStatus
    (*get_misattribution_in_inconsistency)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    bool return_suppressed,
    TALER_AUDITORDB_MisattributionInInconsistencyCallback cb,
    void *cb_cls);


  enum GNUNET_DB_QueryStatus
    (*delete_misattribution_in_inconsistency)(
    void *cls,
    uint64_t row_id);


  enum GNUNET_DB_QueryStatus
    (*insert_misattribution_in_inconsistency)(
    void *cls,
    const struct TALER_AUDITORDB_MisattributionInInconsistency *dc);

  enum GNUNET_DB_QueryStatus
    (*get_reserves)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    TALER_AUDITORDB_ReservesCallback cb,
    void *cb_cls);

  enum GNUNET_DB_QueryStatus
    (*get_purses)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    TALER_AUDITORDB_PursesCallback cb,
    void *cb_cls);


  enum GNUNET_DB_QueryStatus
    (*delete_purses)(
    void *cls,
    uint64_t row_id);

  enum GNUNET_DB_QueryStatus
    (*get_denomination_pending)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    TALER_AUDITORDB_DenominationPendingCallback cb,
    void *cb_cls);

  enum GNUNET_DB_QueryStatus
    (*delete_denomination_pending)(
    void *cls,
    uint64_t row_id);

  enum GNUNET_DB_QueryStatus
    (*insert_denomination_pending)(
    void *cls,
    const struct TALER_AUDITORDB_DenominationPending *dc);

  enum GNUNET_DB_QueryStatus
    (*get_exchange_signkeys)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    bool return_suppressed,
    TALER_AUDITORDB_ExchangeSignkeysCallback cb,
    void *cb_cls);

  enum GNUNET_DB_QueryStatus
    (*get_wire_format_inconsistency)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    bool return_suppressed,
    TALER_AUDITORDB_WireFormatInconsistencyCallback cb,
    void *cb_cls);


  enum GNUNET_DB_QueryStatus
    (*delete_wire_format_inconsistency)(
    void *cls,
    uint64_t row_id);


  enum GNUNET_DB_QueryStatus
    (*insert_wire_format_inconsistency)(
    void *cls,
    const struct TALER_AUDITORDB_WireFormatInconsistency *dc);

  enum GNUNET_DB_QueryStatus
    (*get_wire_out_inconsistency)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    bool return_suppressed,
    TALER_AUDITORDB_WireOutInconsistencyCallback cb,
    void *cb_cls);


  enum GNUNET_DB_QueryStatus
    (*delete_wire_out_inconsistency)(
    void *cls,
    uint64_t row_id);


  enum GNUNET_DB_QueryStatus
    (*insert_wire_out_inconsistency)(
    void *cls,
    const struct TALER_AUDITORDB_WireOutInconsistency *dc);

  enum GNUNET_DB_QueryStatus
    (*delete_wire_out_inconsistency_if_matching)(
    void *cls,
    const struct TALER_AUDITORDB_WireOutInconsistency *dc);

  enum GNUNET_DB_QueryStatus
    (*get_reserve_balance_summary_wrong_inconsistency)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    bool return_suppressed,
    TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistencyCallback cb,
    void *cb_cls);


  enum GNUNET_DB_QueryStatus
    (*delete_reserve_balance_summary_wrong_inconsistency)(
    void *cls,
    uint64_t row_id);


  enum GNUNET_DB_QueryStatus
    (*insert_reserve_balance_summary_wrong_inconsistency)(
    void *cls,
    const struct TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistency *dc);

  enum GNUNET_DB_QueryStatus
    (*get_row_minor_inconsistencies)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    bool return_suppressed,
    TALER_AUDITORDB_RowMinorInconsistenciesCallback cb,
    void *cb_cls);


  enum GNUNET_DB_QueryStatus
    (*delete_row_minor_inconsistencies)(
    void *cls,
    uint64_t row_id);


  enum GNUNET_DB_QueryStatus
    (*insert_row_minor_inconsistencies)(
    void *cls,
    const struct TALER_AUDITORDB_RowMinorInconsistencies *dc);

  enum GNUNET_DB_QueryStatus
    (*get_fee_time_inconsistency)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    bool return_suppressed,
    TALER_AUDITORDB_FeeTimeInconsistencyCallback cb,
    void *cb_cls);


  enum GNUNET_DB_QueryStatus
    (*delete_fee_time_inconsistency)(
    void *cls,
    uint64_t row_id);


  enum GNUNET_DB_QueryStatus
    (*insert_fee_time_inconsistency)(
    void *cls,
    const struct TALER_AUDITORDB_FeeTimeInconsistency *dc);

  /**
 * Insert information about a reserve.  There must not be an
 * existing record for the reserve.
 *
 * @param cls the @e cls of this struct with the plugin-specific state
 * @param reserve_pub public key of the reserve
 * @param rfb balance amounts for the reserve
 * @param expiration_date expiration date of the reserve
 * @param origin_account where did the money in the reserve originally come from
 * @return transaction status code
 */
  enum GNUNET_DB_QueryStatus
    (*insert_reserve_info)(
    void *cls,
    const struct TALER_ReservePublicKeyP *reserve_pub,
    const struct TALER_AUDITORDB_ReserveFeeBalance *rfb,
    struct GNUNET_TIME_Timestamp expiration_date,
    const char *origin_account);


  /**
   * Update information about a reserve.  Destructively updates an
   * existing record, which must already exist.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param reserve_pub public key of the reserve
   * @param rfb balance amounts for the reserve
   * @param expiration_date expiration date of the reserve
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*update_reserve_info)(
    void *cls,
    const struct TALER_ReservePublicKeyP *reserve_pub,
    const struct TALER_AUDITORDB_ReserveFeeBalance *rfb,
    struct GNUNET_TIME_Timestamp expiration_date);


  /**
   * Get information about a reserve.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param reserve_pub public key of the reserve
   * @param[out] rowid which row did we get the information from
   * @param[out] rfb set to balances associated with the reserve
   * @param[out] expiration_date expiration date of the reserve
   * @param[out] sender_account from where did the money in the reserve originally come from
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*get_reserve_info)(
    void *cls,
    const struct TALER_ReservePublicKeyP *reserve_pub,
    uint64_t *rowid,
    struct TALER_AUDITORDB_ReserveFeeBalance *rfb,
    struct GNUNET_TIME_Timestamp *expiration_date,
    char **sender_account);


  /**
   * Delete information about a reserve.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param reserve_pub public key of the reserve
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*del_reserve_info)(void *cls,
                        const struct TALER_ReservePublicKeyP *reserve_pub);


  /**
   * Insert new row into the pending deposits table.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param batch_deposit_serial_id where in the table are we
   * @param total_amount value of all missing deposits, including fees
   * @param wire_target_h_payto hash of the recipient account's payto URI
   * @param deadline what was the requested wire transfer deadline
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*insert_pending_deposit)(
    void *cls,
    uint64_t batch_deposit_serial_id,
    const struct TALER_FullPaytoHashP *wire_target_h_payto,
    const struct TALER_Amount *total_amount,
    struct GNUNET_TIME_Timestamp deadline);


  /**
   * Delete a row from the pending deposit table.
   * Usually done when the respective wire transfer
   * was finally detected.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param batch_deposit_serial_id which entry to delete
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*delete_pending_deposit)(
    void *cls,
    uint64_t batch_deposit_serial_id);


  /**
   * Return (batch) deposits for which we have not yet
   * seen the required wire transfer.
   *
   * @param deadline only return up to this deadline
   * @param cb function to call on each entry
   * @param cb_cls closure for @a cb
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*select_pending_deposits)(
    void *cls,
    struct GNUNET_TIME_Absolute deadline,
    TALER_AUDITORDB_WireMissingCallback cb,
    void *cb_cls);


  /**
   * Insert information about a purse.  There must not be an
   * existing record for the purse.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param purse_pub public key of the purse
   * @param balance balance of the purse
   * @param expiration_date expiration date of the purse
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*insert_purse_info)(
    void *cls,
    const struct TALER_PurseContractPublicKeyP *purse_pub,
    const struct TALER_Amount *balance,
    struct GNUNET_TIME_Timestamp expiration_date);


  /**
   * Update information about a purse.  Destructively updates an
   * existing record, which must already exist.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param purse_pub public key of the purse
   * @param balance new balance for the purse
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*update_purse_info)(
    void *cls,
    const struct TALER_PurseContractPublicKeyP *purse_pub,
    const struct TALER_Amount *balance);


  /**
   * Get information about a purse.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param purse_pub public key of the purse
   * @param[out] rowid which row did we get the information from
   * @param[out] balance set to balance of the purse
   * @param[out] expiration_date expiration date of the purse
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*get_purse_info)(
    void *cls,
    const struct TALER_PurseContractPublicKeyP *purse_pub,
    uint64_t *rowid,
    struct TALER_Amount *balance,
    struct GNUNET_TIME_Timestamp *expiration_date);


  /**
   * Delete information about a purse.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param purse_pub public key of the reserve
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*delete_purse_info)(
    void *cls,
    const struct TALER_PurseContractPublicKeyP *purse_pub);


  /**
   * Get information about expired purses.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param cb function to call on expired purses
   * @param cb_cls closure for @a cb
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*select_purse_expired)(
    void *cls,
    TALER_AUDITORDB_ExpiredPurseCallback cb,
    void *cb_cls);


  /**
   * Insert information about a denomination key's balances.  There
   * must not be an existing record for the denomination key.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param denom_pub_hash hash of the denomination public key
   * @param dcd denomination circulation data to store
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*insert_denomination_balance)(
    void *cls,
    const struct TALER_DenominationHashP *denom_pub_hash,
    const struct TALER_AUDITORDB_DenominationCirculationData *dcd);


  /**
   * Update information about a denomination key's balances.  There
   * must be an existing record for the denomination key.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param denom_pub_hash hash of the denomination public key
   * @param dcd denomination circulation data to store
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*update_denomination_balance)(
    void *cls,
    const struct TALER_DenominationHashP *denom_pub_hash,
    const struct TALER_AUDITORDB_DenominationCirculationData *dcd);

  /**
   * Delete information about a denomination key's balances.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param denom_pub_hash hash of the denomination public key
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*del_denomination_balance)(
    void *cls,
    const struct TALER_DenominationHashP *denom_pub_hash);


  /**
   * Get information about a denomination key's balances.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param denom_pub_hash hash of the denomination public key
   * @param[out] dcd denomination circulation data to initialize
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*get_denomination_balance)(
    void *cls,
    const struct TALER_DenominationHashP *denom_pub_hash,
    struct TALER_AUDITORDB_DenominationCirculationData *dcd);


  /**
   * Insert information about an exchange's historic
   * revenue about a denomination key.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param denom_pub_hash hash of the denomination key
   * @param revenue_timestamp when did this profit get realized
   * @param revenue_balance what was the total profit made from
   *                        deposit fees, melting fees, refresh fees
   *                        and coins that were never returned?
   * @param recoup_loss_balance total losses from recoups of revoked denominations
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*insert_historic_denom_revenue)(
    void *cls,
    const struct TALER_DenominationHashP *denom_pub_hash,
    struct GNUNET_TIME_Timestamp revenue_timestamp,
    const struct TALER_Amount *revenue_balance,
    const struct TALER_Amount *recoup_loss_balance);


  /**
   * Obtain all of the historic denomination key revenue.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param cb function to call with the results
   * @param cb_cls closure for @a cb
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*select_historic_denom_revenue)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    TALER_AUDITORDB_HistoricDenominationRevenueDataCallback cb,
    void *cb_cls);


  /**
   * Insert information about an exchange's historic revenue from reserves.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param start_time beginning of aggregated time interval
   * @param end_time end of aggregated time interval
   * @param reserve_profits total profits made
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*insert_historic_reserve_revenue)(
    void *cls,
    struct GNUNET_TIME_Timestamp start_time,
    struct GNUNET_TIME_Timestamp end_time,
    const struct TALER_Amount *reserve_profits);


  /**
   * Return information about an exchange's historic revenue from reserves.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param cb function to call with results
   * @param cb_cls closure for @a cb
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
    (*select_historic_reserve_revenue)(
    void *cls,
    int64_t limit,
    uint64_t offset,
    TALER_AUDITORDB_HistoricReserveRevenueDataCallback cb,
    void *cb_cls);

};


#endif /* _TALER_AUDITOR_DB_H */