aboutsummaryrefslogtreecommitdiff
path: root/src/include/taler_auditordb_plugin.h
blob: 7a972c64a41cb6ab745e396b39fa2edc9f5e869c (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
/*
  This file is part of TALER
  Copyright (C) 2014-2018 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_auditordb_lib.h"
#include "taler_signatures.h"


/**
 * Function called with information about exchanges this
 * auditor is monitoring.
 *
 * @param cls closure
 * @param master_pub master public key of the exchange
 * @param exchange_url base URL of the exchange's API
 */
typedef void
(*TALER_AUDITORDB_ExchangeCallback)(void *cls,
                                    const struct
                                    TALER_MasterPublicKeyP *master_pub,
                                    const char *exchange_url);


/**
 * Function called with the results of select_denomination_info()
 *
 * @param cls closure
 * @param issue issuing information with value, fees and other info about the denomination.
 *
 * @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 int
(*TALER_AUDITORDB_DenominationInfoDataCallback)(void *cls,
                                                const struct
                                                TALER_DenominationKeyValidityPS
                                                *issue);


/**
 * Function called with the results of select_historic_denom_revenue()
 *
 * @param cls closure
 * @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 int
(*TALER_AUDITORDB_HistoricDenominationRevenueDataCallback)(void *cls,
                                                           const struct
                                                           GNUNET_HashCode *
                                                           denom_pub_hash,
                                                           struct
                                                           GNUNET_TIME_Absolute
                                                           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 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 int
(*TALER_AUDITORDB_HistoricReserveRevenueDataCallback)(void *cls,
                                                      struct
                                                      GNUNET_TIME_Absolute
                                                      start_time,
                                                      struct
                                                      GNUNET_TIME_Absolute
                                                      end_time,
                                                      const struct
                                                      TALER_Amount *
                                                      reserve_profits);


/**
 * Structure for remembering the wire auditor's progress over the
 * various tables and (auditor) transactions.
 */
struct TALER_AUDITORDB_WireProgressPoint
{

  /**
   * Time until which we have confirmed that all wire transactions
   * that the exchange should do, have indeed been done.
   */
  struct GNUNET_TIME_Absolute last_timestamp;
};


/**
 * Structure for remembering the wire auditor's progress over the
 * various tables and (auditor) transactions per wire account.
 */
struct TALER_AUDITORDB_WireAccountProgressPoint
{
  /**
   * serial ID of the last reserve_in transfer the wire auditor processed
   */
  uint64_t last_reserve_in_serial_id;

  /**
   * serial ID of the last wire_out the wire auditor processed
   */
  uint64_t last_wire_out_serial_id;

};


/**
 * Structure for remembering the auditor's progress over the various
 * tables and (auditor) transactions when analyzing reserves.
 */
struct TALER_AUDITORDB_ProgressPointReserve
{
  /**
   * serial ID of the last reserve_in transfer the auditor processed
   */
  uint64_t last_reserve_in_serial_id;

  /**
   * serial ID of the last reserve_out the auditor processed
   */
  uint64_t last_reserve_out_serial_id;

  /**
   * serial ID of the last payback entry the auditor processed when
   * considering reserves.
   */
  uint64_t last_reserve_payback_serial_id;

  /**
   * serial ID of the last reserve_close
   * entry the auditor processed.
   */
  uint64_t last_reserve_close_serial_id;

};


/**
 * Structure for remembering the auditor's progress over the various
 * tables and (auditor) transactions when analyzing reserves.
 */
struct TALER_AUDITORDB_ProgressPointDepositConfirmation
{
  /**
   * serial ID of the last deposit_confirmation the auditor processed
   */
  uint64_t last_deposit_confirmation_serial_id;


};


/**
 * Structure for remembering the auditor's progress over the various
 * tables and (auditor) transactions when analyzing aggregations.
 */
struct TALER_AUDITORDB_ProgressPointAggregation
{

  /**
   * serial ID of the last prewire transfer the auditor processed
   */
  uint64_t last_wire_out_serial_id;
};


/**
 * Structure for remembering the auditor's progress over the various
 * tables and (auditor) transactions when analyzing coins.
 */
struct TALER_AUDITORDB_ProgressPointCoin
{
  /**
   * serial ID of the last withdraw the auditor processed
   */
  uint64_t last_withdraw_serial_id;

  /**
   * serial ID of the last deposit the auditor processed
   */
  uint64_t last_deposit_serial_id;

  /**
   * serial ID of the last refresh the auditor processed
   */
  uint64_t last_melt_serial_id;

  /**
   * serial ID of the last refund the auditor processed
   */
  uint64_t last_refund_serial_id;

  /**
   * Serial ID of the last payback operation the auditor processed.
   */
  uint64_t last_payback_serial_id;

  /**
   * Serial ID of the last payback-of-refresh operation the auditor processed.
   */
  uint64_t last_payback_refresh_serial_id;

};


/**
 * Information about a signing key of an exchange.
 */
struct TALER_AUDITORDB_ExchangeSigningKey
{
  /**
   * Public master key of the exchange that certified @e master_sig.
   */
  struct TALER_MasterPublicKeyP master_public_key;

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

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

  /**
   * When does the signing key expire (for legal disputes)?
   */
  struct GNUNET_TIME_Absolute 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 GNUNET_HashCode h_contract_terms;

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

  /**
   * Time when this confirmation was generated.
   */
  struct GNUNET_TIME_Absolute 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_Absolute refund_deadline;

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

  /**
   * The coin's public key.  This is the value that must have been
   * signed (blindly) by the Exchange.  The deposit request is to be
   * signed by the corresponding private key (using EdDSA).
   */
  struct TALER_CoinSpendPublicKeyP coin_pub;

  /**
   * 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;

  /**
   * Master public key of the exchange corresponding to @e master_sig.
   * Identifies the exchange this is about.
   */
  struct TALER_MasterPublicKeyP master_public_key;

};


/**
 * Function called with deposit confirmations stored in
 * the auditor's database.
 *
 * @param cls closure
 * @param serial_id location of the @a dc in the database
 * @param dc the deposit confirmation itself
 */
typedef void
(*TALER_AUDITORDB_DepositConfirmationCallback)(void *cls,
                                               uint64_t serial_id,
                                               const struct
                                               TALER_AUDITORDB_DepositConfirmation
                                               *dc);


/**
 * Handle for one session with the database.
 */
struct TALER_AUDITORDB_Session;


/**
 * @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;

  /**
   * Get the thread-local database-handle.
   * Connect to the db if the connection does not exist yet.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param the database connection, or NULL on error
   */
  struct TALER_AUDITORDB_Session *
  (*get_session) (void *cls);


  /**
   * Drop the Taler tables.  This should only be used in testcases.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param drop_exchangelist should we also drop the list of audited exchanges
   * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
   */
  int
  (*drop_tables) (void *cls,
                  int drop_exchangelist);


  /**
   * Create the necessary tables if they are not present
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
   */
  int
  (*create_tables) (void *cls);


  /**
   * Start a transaction.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @return #GNUNET_OK on success
   */
  int
  (*start) (void *cls,
            struct TALER_AUDITORDB_Session *session);


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


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


  /**
   * 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
   */
  int
  (*gc) (void *cls);


  /**
   * Insert information about an exchange this auditor will be auditing.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to the database
   * @param master_pub master public key of the exchange
   * @param exchange_url public (base) URL of the API of the exchange
   * @return query result status
   */
  enum GNUNET_DB_QueryStatus
  (*insert_exchange)(void *cls,
                     struct TALER_AUDITORDB_Session *session,
                     const struct TALER_MasterPublicKeyP *master_pub,
                     const char *exchange_url);


  /**
   * Delete an exchange from the list of exchanges this auditor is auditing.
   * Warning: this will cascade and delete all knowledge of this auditor related
   * to this exchange!
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to the database
   * @param master_pub master public key of the exchange
   * @return query result status
   */
  enum GNUNET_DB_QueryStatus
  (*delete_exchange)(void *cls,
                     struct TALER_AUDITORDB_Session *session,
                     const struct TALER_MasterPublicKeyP *master_pub);


  /**
   * Obtain information about exchanges this auditor is auditing.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to the database
   * @param master_pub master public key of the exchange
   * @param exchange_url public (base) URL of the API of the exchange
   * @return query result status
   */
  enum GNUNET_DB_QueryStatus
  (*list_exchanges)(void *cls,
                    struct TALER_AUDITORDB_Session *session,
                    TALER_AUDITORDB_ExchangeCallback 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 session connection to the database
   * @param sk signing key information to store
   * @return query result status
   */
  enum GNUNET_DB_QueryStatus
  (*insert_exchange_signkey)(void *cls,
                             struct TALER_AUDITORDB_Session *session,
                             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 session connection to the database
   * @param dc deposit confirmation information to store
   * @return query result status
   */
  enum GNUNET_DB_QueryStatus
  (*insert_deposit_confirmation)(void *cls,
                                 struct TALER_AUDITORDB_Session *session,
                                 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 session connection to the database
   * @param master_pub for which exchange do we want to get deposit confirmations
   * @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 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,
                               struct TALER_AUDITORDB_Session *session,
                               const struct
                               TALER_MasterPublicKeyP *master_public_key,
                               uint64_t start_id,
                               TALER_AUDITORDB_DepositConfirmationCallback cb,
                               void *cb_cls);


  /**
   * Insert information about a denomination key and in particular
   * the properties (value, fees, expiration times) the coins signed
   * with this key have.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param issue issuing information with value, fees and other info about the denomination
   * @return status of database operation
   */
  enum GNUNET_DB_QueryStatus
  (*insert_denomination_info)(void *cls,
                              struct TALER_AUDITORDB_Session *session,
                              const struct
                              TALER_DenominationKeyValidityPS *issue);


  /**
   * Get information about denomination keys of a particular exchange.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param master_pub master public key of the exchange
   * @param cb function to call with the results
   * @param cb_cls closure for @a cb
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*select_denomination_info)(void *cls,
                              struct TALER_AUDITORDB_Session *session,
                              const struct TALER_MasterPublicKeyP *master_pub,
                              TALER_AUDITORDB_DenominationInfoDataCallback cb,
                              void *cb_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 session connection to use
   * @param master_pub master key of the exchange
   * @param ppc where is the auditor in processing
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*insert_auditor_progress_coin)(void *cls,
                                  struct TALER_AUDITORDB_Session *session,
                                  const struct
                                  TALER_MasterPublicKeyP *master_pub,
                                  const struct
                                  TALER_AUDITORDB_ProgressPointCoin *ppc);


  /**
   * 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 session connection to use
   * @param master_pub master key of the exchange
   * @param ppc where is the auditor in processing
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*update_auditor_progress_coin)(void *cls,
                                  struct TALER_AUDITORDB_Session *session,
                                  const struct
                                  TALER_MasterPublicKeyP *master_pub,
                                  const struct
                                  TALER_AUDITORDB_ProgressPointCoin *ppc);


  /**
   * Get information about the progress of the auditor.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param master_pub master key of the exchange
   * @param[out] ppc set to where the auditor is in processing
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*get_auditor_progress_coin)(void *cls,
                               struct TALER_AUDITORDB_Session *session,
                               const struct TALER_MasterPublicKeyP *master_pub,
                               struct TALER_AUDITORDB_ProgressPointCoin *ppc);

  /**
 * 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 session connection to use
 * @param master_pub master key of the exchange
 * @param ppr where is the auditor in processing
 * @return transaction status code
 */
  enum GNUNET_DB_QueryStatus
  (*insert_auditor_progress_reserve)(void *cls,
                                     struct TALER_AUDITORDB_Session *session,
                                     const struct
                                     TALER_MasterPublicKeyP *master_pub,
                                     const struct
                                     TALER_AUDITORDB_ProgressPointReserve *ppr);


  /**
   * 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 session connection to use
   * @param master_pub master key of the exchange
   * @param ppr where is the auditor in processing
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*update_auditor_progress_reserve)(void *cls,
                                     struct TALER_AUDITORDB_Session *session,
                                     const struct
                                     TALER_MasterPublicKeyP *master_pub,
                                     const struct
                                     TALER_AUDITORDB_ProgressPointReserve *ppr);


  /**
   * Get information about the progress of the auditor.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param master_pub master key of the exchange
   * @param[out] ppr set to where the auditor is in processing
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*get_auditor_progress_reserve)(void *cls,
                                  struct TALER_AUDITORDB_Session *session,
                                  const struct
                                  TALER_MasterPublicKeyP *master_pub,
                                  struct TALER_AUDITORDB_ProgressPointReserve *
                                  ppr);

  /**
   * 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 session connection to use
   * @param master_pub master key of the exchange
   * @param ppdc where is the auditor in processing
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*insert_auditor_progress_deposit_confirmation)(void *cls,
                                                  struct TALER_AUDITORDB_Session
                                                  *session,
                                                  const struct
                                                  TALER_MasterPublicKeyP *
                                                  master_pub,
                                                  const struct
                                                  TALER_AUDITORDB_ProgressPointDepositConfirmation
                                                  *ppdc);


  /**
   * 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 session connection to use
   * @param master_pub master key of the exchange
   * @param ppdc where is the auditor in processing
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*update_auditor_progress_deposit_confirmation)(void *cls,
                                                  struct TALER_AUDITORDB_Session
                                                  *session,
                                                  const struct
                                                  TALER_MasterPublicKeyP *
                                                  master_pub,
                                                  const struct
                                                  TALER_AUDITORDB_ProgressPointDepositConfirmation
                                                  *ppdc);


  /**
   * Get information about the progress of the auditor.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param master_pub master key of the exchange
   * @param[out] ppdc set to where the auditor is in processing
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*get_auditor_progress_deposit_confirmation)(void *cls,
                                               struct TALER_AUDITORDB_Session *
                                               session,
                                               const struct
                                               TALER_MasterPublicKeyP *
                                               master_pub,
                                               struct
                                               TALER_AUDITORDB_ProgressPointDepositConfirmation
                                               *ppdc);


  /**
   * 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 session connection to use
   * @param master_pub master key of the exchange
   * @param ppa where is the auditor in processing
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*insert_auditor_progress_aggregation)(void *cls,
                                         struct TALER_AUDITORDB_Session *session,
                                         const struct
                                         TALER_MasterPublicKeyP *master_pub,
                                         const struct
                                         TALER_AUDITORDB_ProgressPointAggregation
                                         *ppa);


  /**
   * 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 session connection to use
   * @param master_pub master key of the exchange
   * @param ppa where is the auditor in processing
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*update_auditor_progress_aggregation)(void *cls,
                                         struct TALER_AUDITORDB_Session *session,
                                         const struct
                                         TALER_MasterPublicKeyP *master_pub,
                                         const struct
                                         TALER_AUDITORDB_ProgressPointAggregation
                                         *ppa);


  /**
   * Get information about the progress of the auditor.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param master_pub master key of the exchange
   * @param[out] ppa set to where the auditor is in processing
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*get_auditor_progress_aggregation)(void *cls,
                                      struct TALER_AUDITORDB_Session *session,
                                      const struct
                                      TALER_MasterPublicKeyP *master_pub,
                                      struct
                                      TALER_AUDITORDB_ProgressPointAggregation *
                                      ppa);


  /**
   * Insert information about the wire auditor's progress with an exchange's
   * data.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param master_pub master key of the exchange
   * @param account_name name of the wire account we are auditing
   * @param pp where is the auditor in processing
   * @param in_wire_off how far are we in the incoming wire transaction history
   * @param out_wire_off how far are we in the outgoing wire transaction history
   * @param wire_off_size how many bytes do @a in_wire_off and @a out_wire_off take?
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*insert_wire_auditor_account_progress)(void *cls,
                                          struct TALER_AUDITORDB_Session *
                                          session,
                                          const struct
                                          TALER_MasterPublicKeyP *master_pub,
                                          const char *account_name,
                                          const struct
                                          TALER_AUDITORDB_WireAccountProgressPoint
                                          *pp,
                                          const void *in_wire_off,
                                          const void *out_wire_off,
                                          size_t wire_off_size);


  /**
   * Update information about the progress of the wire auditor.  There
   * must be an existing record for the exchange.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param master_pub master key of the exchange
   * @param account_name name of the wire account we are auditing
   * @param pp where is the auditor in processing
   * @param in_wire_off how far are we in the incoming wire transaction history
   * @param out_wire_off how far are we in the outgoing wire transaction history
   * @param wire_off_size how many bytes do @a in_wire_off and @a out_wire_off take?
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*update_wire_auditor_account_progress)(void *cls,
                                          struct TALER_AUDITORDB_Session *
                                          session,
                                          const struct
                                          TALER_MasterPublicKeyP *master_pub,
                                          const char *account_name,
                                          const struct
                                          TALER_AUDITORDB_WireAccountProgressPoint
                                          *pp,
                                          const void *in_wire_off,
                                          const void *out_wire_off,
                                          size_t wire_off_size);


  /**
   * Get information about the progress of the wire auditor.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param master_pub master key of the exchange
   * @param account_name name of the wire account we are auditing
   * @param[out] pp where is the auditor in processing
   * @param[out] in_wire_off how far are we in the incoming wire transaction history
   * @param[out] out_wire_off how far are we in the outgoing wire transaction history
   * @param[out] wire_off_size how many bytes do @a in_wire_off and @a out_wire_off take?
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*get_wire_auditor_account_progress)(void *cls,
                                       struct TALER_AUDITORDB_Session *session,
                                       const struct
                                       TALER_MasterPublicKeyP *master_pub,
                                       const char *account_name,
                                       struct
                                       TALER_AUDITORDB_WireAccountProgressPoint
                                       *pp,
                                       void **in_wire_off,
                                       void **out_wire_off,
                                       size_t *wire_off_size);


  /**
   * Insert information about the wire auditor's progress with an exchange's
   * data.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param master_pub master key of the exchange
   * @param account_name name of the wire account we are auditing
   * @param pp where is the auditor in processing
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*insert_wire_auditor_progress)(void *cls,
                                  struct TALER_AUDITORDB_Session *session,
                                  const struct
                                  TALER_MasterPublicKeyP *master_pub,
                                  const struct
                                  TALER_AUDITORDB_WireProgressPoint *pp);


  /**
   * Update information about the progress of the wire auditor.  There
   * must be an existing record for the exchange.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param master_pub master key of the exchange
   * @param account_name name of the wire account we are auditing
   * @param pp where is the auditor in processing
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*update_wire_auditor_progress)(void *cls,
                                  struct TALER_AUDITORDB_Session *session,
                                  const struct
                                  TALER_MasterPublicKeyP *master_pub,
                                  const struct
                                  TALER_AUDITORDB_WireProgressPoint *pp);


  /**
   * Get information about the progress of the wire auditor.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param master_pub master key of the exchange
   * @param account_name name of the wire account we are auditing
   * @param[out] pp set to where the auditor is in processing
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*get_wire_auditor_progress)(void *cls,
                               struct TALER_AUDITORDB_Session *session,
                               const struct TALER_MasterPublicKeyP *master_pub,
                               struct TALER_AUDITORDB_WireProgressPoint *pp);


  /**
   * 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 session connection to use
   * @param reserve_pub public key of the reserve
   * @param master_pub master public key of the exchange
   * @param reserve_balance amount stored in the reserve
   * @param withdraw_fee_balance amount the exchange gained in withdraw fees
   *                             due to withdrawals from this reserve
   * @param expiration_date expiration date of the reserve
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*insert_reserve_info)(void *cls,
                         struct TALER_AUDITORDB_Session *session,
                         const struct TALER_ReservePublicKeyP *reserve_pub,
                         const struct TALER_MasterPublicKeyP *master_pub,
                         const struct TALER_Amount *reserve_balance,
                         const struct TALER_Amount *withdraw_fee_balance,
                         struct GNUNET_TIME_Absolute expiration_date);


  /**
   * 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 session connection to use
   * @param reserve_pub public key of the reserve
   * @param master_pub master public key of the exchange
   * @param reserve_balance amount stored in the reserve
   * @param withdraw_fee_balance amount the exchange gained in withdraw fees
   *                             due to withdrawals from this reserve
   * @param expiration_date expiration date of the reserve
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*update_reserve_info)(void *cls,
                         struct TALER_AUDITORDB_Session *session,
                         const struct TALER_ReservePublicKeyP *reserve_pub,
                         const struct TALER_MasterPublicKeyP *master_pub,
                         const struct TALER_Amount *reserve_balance,
                         const struct TALER_Amount *withdraw_fee_balance,
                         struct GNUNET_TIME_Absolute expiration_date);


  /**
   * Get information about a reserve.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param reserve_pub public key of the reserve
   * @param master_pub master public key of the exchange
   * @param[out] rowid which row did we get the information from
   * @param[out] reserve_balance amount stored in the reserve
   * @param[out] withdraw_fee_balance amount the exchange gained in withdraw fees
   *                             due to withdrawals from this reserve
   * @param[out] expiration_date expiration date of the reserve
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*get_reserve_info)(void *cls,
                      struct TALER_AUDITORDB_Session *session,
                      const struct TALER_ReservePublicKeyP *reserve_pub,
                      const struct TALER_MasterPublicKeyP *master_pub,
                      uint64_t *rowid,
                      struct TALER_Amount *reserve_balance,
                      struct TALER_Amount *withdraw_fee_balance,
                      struct GNUNET_TIME_Absolute *expiration_date);


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


  /**
   * Insert information about all reserves.  There must not be an
   * existing record for the @a master_pub.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param master_pub master public key of the exchange
   * @param reserve_balance amount stored in the reserve
   * @param withdraw_fee_balance amount the exchange gained in withdraw fees
   *                             due to withdrawals from this reserve
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*insert_reserve_summary)(void *cls,
                            struct TALER_AUDITORDB_Session *session,
                            const struct TALER_MasterPublicKeyP *master_pub,
                            const struct TALER_Amount *reserve_balance,
                            const struct TALER_Amount *withdraw_fee_balance);


  /**
   * Update information about all reserves.  Destructively updates an
   * existing record, which must already exist.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param master_pub master public key of the exchange
   * @param reserve_balance amount stored in the reserve
   * @param withdraw_fee_balance amount the exchange gained in withdraw fees
   *                             due to withdrawals from this reserve
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*update_reserve_summary)(void *cls,
                            struct TALER_AUDITORDB_Session *session,
                            const struct TALER_MasterPublicKeyP *master_pub,
                            const struct TALER_Amount *reserve_balance,
                            const struct TALER_Amount *withdraw_fee_balance);


  /**
   * Get summary information about all reserves.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param master_pub master public key of the exchange
   * @param[out] reserve_balance amount stored in the reserve
   * @param[out] withdraw_fee_balance amount the exchange gained in withdraw fees
   *                             due to withdrawals from this reserve
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*get_reserve_summary)(void *cls,
                         struct TALER_AUDITORDB_Session *session,
                         const struct TALER_MasterPublicKeyP *master_pub,
                         struct TALER_Amount *reserve_balance,
                         struct TALER_Amount *withdraw_fee_balance);


  /**
   * Insert information about exchange's wire fee balance. There must not be an
   * existing record for the same @a master_pub.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param master_pub master public key of the exchange
   * @param wire_fee_balance amount the exchange gained in wire fees
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*insert_wire_fee_summary)(void *cls,
                             struct TALER_AUDITORDB_Session *session,
                             const struct TALER_MasterPublicKeyP *master_pub,
                             const struct TALER_Amount *wire_fee_balance);


  /**
   * Insert information about exchange's wire fee balance.  Destructively updates an
   * existing record, which must already exist.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param master_pub master public key of the exchange
   * @param wire_fee_balance amount the exchange gained in wire fees
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*update_wire_fee_summary)(void *cls,
                             struct TALER_AUDITORDB_Session *session,
                             const struct TALER_MasterPublicKeyP *master_pub,
                             const struct TALER_Amount *wire_fee_balance);


  /**
   * Get summary information about an exchanges wire fee balance.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param master_pub master public key of the exchange
   * @param[out] wire_fee_balance set amount the exchange gained in wire fees
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*get_wire_fee_summary)(void *cls,
                          struct TALER_AUDITORDB_Session *session,
                          const struct TALER_MasterPublicKeyP *master_pub,
                          struct TALER_Amount *wire_fee_balance);


  /**
   * 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 session connection to use
   * @param denom_pub_hash hash of the denomination public key
   * @param denom_balance value of coins outstanding with this denomination key
   * @param denom_risk value of coins issued with this denomination key
   * @param denom_payback value of coins paid back if this denomination key was revoked
   * @param num_issued how many coins of this denomination did the exchange blind-sign
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*insert_denomination_balance)(void *cls,
                                 struct TALER_AUDITORDB_Session *session,
                                 const struct GNUNET_HashCode *denom_pub_hash,
                                 const struct TALER_Amount *denom_balance,
                                 const struct TALER_Amount *denom_risk,
                                 const struct TALER_Amount *payback_loss,
                                 uint64_t num_issued);


  /**
   * 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 session connection to use
   * @param denom_pub_hash hash of the denomination public key
   * @param denom_balance value of coins outstanding with this denomination key
   * @param denom_risk value of coins issued with this denomination key
   * @param denom_payback value of coins paid back if this denomination key was revoked
   * @param num_issued how many coins of this denomination did the exchange blind-sign
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*update_denomination_balance)(void *cls,
                                 struct TALER_AUDITORDB_Session *session,
                                 const struct GNUNET_HashCode *denom_pub_hash,
                                 const struct TALER_Amount *denom_balance,
                                 const struct TALER_Amount *denom_risk,
                                 const struct TALER_Amount *payback_loss,
                                 uint64_t num_issued);


  /**
   * Get information about a denomination key's balances.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param denom_pub_hash hash of the denomination public key
   * @param[out] denom_balance value of coins outstanding with this denomination key
   * @param[out] denom_risk value of coins issued with this denomination key
   * @param[out] denom_payback value of coins paid back if this denomination key was revoked
   * @param[out] num_issued how many coins of this denomination did the exchange blind-sign
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*get_denomination_balance)(void *cls,
                              struct TALER_AUDITORDB_Session *session,
                              const struct GNUNET_HashCode *denom_pub_hash,
                              struct TALER_Amount *denom_balance,
                              struct TALER_Amount *denom_risk,
                              struct TALER_Amount *payback_loss,
                              uint64_t *num_issued);


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


  /**
   * Insert information about an exchange's denomination balances.  There
   * must not be an existing record for the exchange.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param master_pub master key of the exchange
   * @param denom_balance value of coins outstanding with this denomination key
   * @param deposit_fee_balance total deposit fees collected for this DK
   * @param melt_fee_balance total melt fees collected for this DK
   * @param refund_fee_balance total refund fees collected for this DK
   * @param risk maximum risk exposure of the exchange
   * @param payback_loss actual losses from payback (actualized @a risk)
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*insert_balance_summary)(void *cls,
                            struct TALER_AUDITORDB_Session *session,
                            const struct TALER_MasterPublicKeyP *master_pub,
                            const struct TALER_Amount *denom_balance,
                            const struct TALER_Amount *deposit_fee_balance,
                            const struct TALER_Amount *melt_fee_balance,
                            const struct TALER_Amount *refund_fee_balance,
                            const struct TALER_Amount *risk,
                            const struct TALER_Amount *payback_loss);


  /**
   * Update information about an exchange's denomination balances.  There
   * must be an existing record for the exchange.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param master_pub master key of the exchange
   * @param denom_balance value of coins outstanding with this denomination key
   * @param deposit_fee_balance total deposit fees collected for this DK
   * @param melt_fee_balance total melt fees collected for this DK
   * @param refund_fee_balance total refund fees collected for this DK
   * @param risk maximum risk exposure of the exchange
   * @param payback_loss actual losses from payback (actualized @a risk)
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*update_balance_summary)(void *cls,
                            struct TALER_AUDITORDB_Session *session,
                            const struct TALER_MasterPublicKeyP *master_pub,
                            const struct TALER_Amount *denom_balance,
                            const struct TALER_Amount *deposit_fee_balance,
                            const struct TALER_Amount *melt_fee_balance,
                            const struct TALER_Amount *refund_fee_balance,
                            const struct TALER_Amount *risk,
                            const struct TALER_Amount *payback_loss);


  /**
   * Get information about an exchange's denomination balances.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param master_pub master key of the exchange
   * @param[out] denom_balance value of coins outstanding with this denomination key
   * @param[out] deposit_fee_balance total deposit fees collected for this DK
   * @param[out] melt_fee_balance total melt fees collected for this DK
   * @param[out] refund_fee_balance total refund fees collected for this DK
   * @param[out] risk maximum risk exposure of the exchange
   * @param[out] payback_loss actual losses from payback (actualized @a risk)
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*get_balance_summary)(void *cls,
                         struct TALER_AUDITORDB_Session *session,
                         const struct TALER_MasterPublicKeyP *master_pub,
                         struct TALER_Amount *denom_balance,
                         struct TALER_Amount *deposit_fee_balance,
                         struct TALER_Amount *melt_fee_balance,
                         struct TALER_Amount *refund_fee_balance,
                         struct TALER_Amount *risk,
                         struct TALER_Amount *payback_loss);


  /**
   * 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 session connection to use
   * @param master_pub master key of the exchange
   * @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 payback_loss_balance total losses from paybacks of revoked denominations
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*insert_historic_denom_revenue)(void *cls,
                                   struct TALER_AUDITORDB_Session *session,
                                   const struct
                                   TALER_MasterPublicKeyP *master_pub,
                                   const struct GNUNET_HashCode *denom_pub_hash,
                                   struct GNUNET_TIME_Absolute
                                   revenue_timestamp,
                                   const struct TALER_Amount *revenue_balance,
                                   const struct
                                   TALER_Amount *payback_loss_balance);


  /**
   * Obtain all of the historic denomination key revenue
   * of the given @a master_pub.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param master_pub master key of the exchange
   * @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,
                                   struct TALER_AUDITORDB_Session *session,
                                   const struct
                                   TALER_MasterPublicKeyP *master_pub,
                                   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 session connection to use
   * @param master_pub master key of the exchange
   * @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 TALER_AUDITORDB_Session *session,
                                     const struct
                                     TALER_MasterPublicKeyP *master_pub,
                                     struct GNUNET_TIME_Absolute start_time,
                                     struct GNUNET_TIME_Absolute 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 session connection to use
   * @param master_pub master key of the exchange
   * @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,
                                     struct TALER_AUDITORDB_Session *session,
                                     const struct
                                     TALER_MasterPublicKeyP *master_pub,
                                     TALER_AUDITORDB_HistoricReserveRevenueDataCallback
                                     cb,
                                     void *cb_cls);



  /**
   * Insert information about the predicted exchange's bank
   * account balance.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param master_pub master key of the exchange
   * @param balance what the bank account balance of the exchange should show
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*insert_predicted_result)(void *cls,
                             struct TALER_AUDITORDB_Session *session,
                             const struct TALER_MasterPublicKeyP *master_pub,
                             const struct TALER_Amount *balance);


  /**
   * Update information about an exchange's predicted balance.  There
   * must be an existing record for the exchange.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param master_pub master key of the exchange
   * @param balance what the bank account balance of the exchange should show
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*update_predicted_result)(void *cls,
                             struct TALER_AUDITORDB_Session *session,
                             const struct TALER_MasterPublicKeyP *master_pub,
                             const struct TALER_Amount *balance);


  /**
   * Get an exchange's predicted balance.
   *
   * @param cls the @e cls of this struct with the plugin-specific state
   * @param session connection to use
   * @param master_pub master key of the exchange
   * @param[out] balance expected bank account balance of the exchange
   * @return transaction status code
   */
  enum GNUNET_DB_QueryStatus
  (*get_predicted_balance)(void *cls,
                           struct TALER_AUDITORDB_Session *session,
                           const struct TALER_MasterPublicKeyP *master_pub,
                           struct TALER_Amount *balance);


};


#endif /* _TALER_AUDITOR_DB_H */