taler_auditordb_plugin.h (61898B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2014-2024 Taler Systems SA 4 5 TALER is free software; you can redistribute it and/or modify it under the 6 terms of the GNU General Public License as published by the Free Software 7 Foundation; either version 3, or (at your option) any later version. 8 9 TALER is distributed in the hope that it will be useful, but WITHOUT ANY 10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 13 You should have received a copy of the GNU General Public License along with 14 TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 */ 16 /** 17 * @file include/taler/taler_auditordb_plugin.h 18 * @brief Low-level (statement-level) database access for the auditor 19 * @author Florian Dold 20 * @author Christian Grothoff 21 */ 22 #ifndef TALER_AUDITORDB_PLUGIN_H 23 #define TALER_AUDITORDB_PLUGIN_H 24 25 #include <jansson.h> 26 #include <gnunet/gnunet_util_lib.h> 27 #include <gnunet/gnunet_db_lib.h> 28 #include <taler/taler_util.h> 29 #include <taler/taler_auditordb_lib.h> 30 #include <taler/taler_signatures.h> 31 32 33 /** 34 * Function called with the results of select_historic_denom_revenue() 35 * 36 * @param cls closure 37 * @param serial_id row for the denomination revenue in the auditor database 38 * @param denom_pub_hash hash of the denomination key 39 * @param revenue_timestamp when did this profit get realized 40 * @param revenue_balance what was the total profit made from 41 * deposit fees, melting fees, refresh fees 42 * and coins that were never returned? 43 * @param loss_balance what was the total loss 44 * @return sets the return value of select_denomination_info(), 45 * #GNUNET_OK to continue, 46 * #GNUNET_NO to stop processing further rows 47 * #GNUNET_SYSERR or other values on error. 48 */ 49 typedef enum GNUNET_GenericReturnValue 50 (*TALER_AUDITORDB_HistoricDenominationRevenueDataCallback)( 51 void *cls, 52 uint64_t serial_id, 53 const struct TALER_DenominationHashP *denom_pub_hash, 54 struct GNUNET_TIME_Timestamp revenue_timestamp, 55 const struct TALER_Amount *revenue_balance, 56 const struct TALER_Amount *loss_balance); 57 58 59 /** 60 * Function called with the results of select_historic_reserve_revenue() 61 * 62 * @param cls closure 63 * @param serial_id row ID in the history table 64 * @param start_time beginning of aggregated time interval 65 * @param end_time end of aggregated time interval 66 * @param reserve_profits total profits made 67 * 68 * @return sets the return value of select_denomination_info(), 69 * #GNUNET_OK to continue, 70 * #GNUNET_NO to stop processing further rows 71 * #GNUNET_SYSERR or other values on error. 72 */ 73 typedef enum GNUNET_GenericReturnValue 74 (*TALER_AUDITORDB_HistoricReserveRevenueDataCallback)( 75 void *cls, 76 uint64_t serial_id, 77 struct GNUNET_TIME_Timestamp start_time, 78 struct GNUNET_TIME_Timestamp end_time, 79 const struct TALER_Amount *reserve_profits); 80 81 82 /** 83 * Information about a signing key of an exchange. 84 */ 85 struct TALER_AUDITORDB_ExchangeSigningKey 86 { 87 88 /** 89 * When does @e exchange_pub start to be used? 90 */ 91 struct GNUNET_TIME_Timestamp ep_start; 92 93 /** 94 * When will the exchange stop signing with @e exchange_pub? 95 */ 96 struct GNUNET_TIME_Timestamp ep_expire; 97 98 /** 99 * When does the signing key expire (for legal disputes)? 100 */ 101 struct GNUNET_TIME_Timestamp ep_end; 102 103 /** 104 * What is the public offline signing key this is all about? 105 */ 106 struct TALER_ExchangePublicKeyP exchange_pub; 107 108 /** 109 * Signature by the offline master key affirming the above. 110 */ 111 struct TALER_MasterSignatureP master_sig; 112 }; 113 114 115 /** 116 * Information about a deposit confirmation we received from 117 * a merchant. 118 */ 119 struct TALER_AUDITORDB_DepositConfirmation 120 { 121 122 /** 123 * Hash over the contract for which this deposit is made. 124 */ 125 struct TALER_PrivateContractHashP h_contract_terms; 126 127 /** 128 * Hash over the policy extension for the deposit. 129 */ 130 struct TALER_ExtensionPolicyHashP h_policy; 131 132 /** 133 * Hash over the wiring information of the merchant. 134 */ 135 struct TALER_MerchantWireHashP h_wire; 136 137 /** 138 * Time when this deposit confirmation was generated by the exchange. 139 */ 140 struct GNUNET_TIME_Timestamp exchange_timestamp; 141 142 /** 143 * How much time does the @e merchant have to issue a refund 144 * request? Zero if refunds are not allowed. After this time, the 145 * coin cannot be refunded. Note that the wire transfer will not be 146 * performed by the exchange until the refund deadline. This value 147 * is taken from the original deposit request. 148 */ 149 struct GNUNET_TIME_Timestamp refund_deadline; 150 151 /** 152 * How much time does the @e exchange have to wire the funds? 153 */ 154 struct GNUNET_TIME_Timestamp wire_deadline; 155 156 /** 157 * Amount to be deposited, excluding fee. Calculated from the 158 * amount with fee and the fee from the deposit request. 159 */ 160 struct TALER_Amount total_without_fee; 161 162 /** 163 * Array of the coin public keys involved in the 164 * batch deposit operation. 165 */ 166 const struct TALER_CoinSpendPublicKeyP *coin_pubs; 167 168 /** 169 * Array of coin deposit signatures from the deposit operation. 170 */ 171 const struct TALER_CoinSpendSignatureP *coin_sigs; 172 173 /** 174 * The Merchant's public key. Allows the merchant to later refund 175 * the transaction or to inquire about the wire transfer identifier. 176 */ 177 struct TALER_MerchantPublicKeyP merchant; 178 179 /** 180 * Signature from the exchange of type 181 * #TALER_SIGNATURE_EXCHANGE_CONFIRM_DEPOSIT. 182 */ 183 struct TALER_ExchangeSignatureP exchange_sig; 184 185 /** 186 * Public signing key from the exchange matching @e exchange_sig. 187 */ 188 struct TALER_ExchangePublicKeyP exchange_pub; 189 190 /** 191 * Exchange master signature over @e exchange_sig. 192 */ 193 struct TALER_MasterSignatureP master_sig; 194 195 /** 196 * Row of this entry in the auditor database. 197 */ 198 uint64_t row_id; 199 200 /** 201 * Length of the @e coin_pubs and @e coin_sigs arrays. 202 */ 203 unsigned int num_coins; 204 205 bool suppressed; 206 207 }; 208 209 // MARK: CRUD 210 211 /** 212 * Information about a row inconsistency 213 */ 214 struct TALER_AUDITORDB_Generic_Update 215 { 216 uint64_t row_id; 217 bool suppressed; 218 bool ancient; 219 }; 220 221 /** 222 * Information about an arithmetic inconsistency 223 */ 224 struct TALER_AUDITORDB_AmountArithmeticInconsistency 225 { 226 uint64_t row_id; 227 uint64_t problem_row_id; 228 char *operation; 229 struct TALER_Amount exchange_amount; 230 struct TALER_Amount auditor_amount; 231 bool profitable; 232 bool suppressed; 233 }; 234 235 /** 236 * Information about a coin inconsistency 237 */ 238 struct TALER_AUDITORDB_CoinInconsistency 239 { 240 uint64_t row_id; 241 char *operation; 242 struct TALER_Amount exchange_amount; 243 struct TALER_Amount auditor_amount; 244 struct GNUNET_CRYPTO_EddsaPublicKey coin_pub; 245 bool profitable; 246 }; 247 248 /** 249 * Information about a row inconsistency 250 */ 251 struct TALER_AUDITORDB_RowInconsistency 252 { 253 uint64_t row_id; 254 char *row_table; 255 char *diagnostic; 256 bool suppressed; 257 }; 258 259 /** 260 * Information about a bad sig loss 261 */ 262 struct TALER_AUDITORDB_BadSigLosses 263 { 264 uint64_t row_id; 265 uint64_t problem_row_id; 266 char *operation; 267 struct TALER_Amount loss; 268 struct GNUNET_CRYPTO_EddsaPublicKey operation_specific_pub; 269 bool suppressed; 270 }; 271 272 /** 273 * Information about a closure lags 274 */ 275 struct TALER_AUDITORDB_ClosureLags 276 { 277 uint64_t row_id; 278 uint64_t problem_row_id; 279 struct TALER_Amount amount; 280 struct GNUNET_TIME_Absolute deadline; 281 struct TALER_WireTransferIdentifierRawP wtid; 282 struct TALER_FullPayto account; 283 bool suppressed; 284 }; 285 286 /** 287 * Information about a emergency 288 */ 289 struct TALER_AUDITORDB_Emergency 290 { 291 uint64_t row_id; 292 struct TALER_DenominationHashP denompub_h; 293 struct TALER_Amount denom_risk; 294 struct TALER_Amount denom_loss; 295 struct GNUNET_TIME_Absolute deposit_start; 296 struct GNUNET_TIME_Absolute deposit_end; 297 struct TALER_Amount value; 298 bool suppressed; 299 }; 300 301 /** 302 * Information about an emergency by count 303 */ 304 struct TALER_AUDITORDB_EmergenciesByCount 305 { 306 uint64_t row_id; 307 struct TALER_DenominationHashP denompub_h; 308 uint64_t num_issued; 309 uint64_t num_known; 310 struct TALER_Amount risk; 311 struct GNUNET_TIME_Absolute start; 312 struct GNUNET_TIME_Absolute deposit_end; 313 struct TALER_Amount value; 314 bool suppressed; 315 }; 316 317 /** 318 * Information about progress of the audit. 319 */ 320 struct TALER_AUDITORDB_Progress 321 { 322 char *progress_key; 323 uint64_t progress_offset; 324 }; 325 326 327 /** 328 * Information about a fee time inconsistency 329 */ 330 struct TALER_AUDITORDB_FeeTimeInconsistency 331 { 332 uint64_t row_id; 333 uint64_t problem_row_id; 334 char *type; 335 struct GNUNET_TIME_Absolute time; 336 char *diagnostic; 337 }; 338 339 /** 340 * Information about a denom key validity withdraw inconsistency 341 */ 342 struct TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistency 343 { 344 uint64_t row_id; 345 uint64_t problem_row_id; 346 struct GNUNET_TIME_Absolute execution_date; 347 struct TALER_ReservePublicKeyP reserve_pub; 348 struct TALER_DenominationHashP denompub_h; 349 bool suppressed; 350 }; 351 352 /** 353 * Information about a purse not closed inconsistencies 354 */ 355 struct TALER_AUDITORDB_PurseNotClosedInconsistencies 356 { 357 uint64_t row_id; 358 struct GNUNET_CRYPTO_EddsaPublicKey purse_pub; 359 struct TALER_Amount amount; 360 struct GNUNET_TIME_Absolute expiration_date; 361 bool suppressed; 362 }; 363 364 /** 365 * Information about a reserve balance insufficient inconsistency 366 */ 367 struct TALER_AUDITORDB_ReserveBalanceInsufficientInconsistency 368 { 369 uint64_t row_id; 370 struct GNUNET_CRYPTO_EddsaPublicKey reserve_pub; 371 bool inconsistency_gain; 372 struct TALER_Amount inconsistency_amount; 373 bool suppressed; 374 }; 375 376 /** 377 * Information about a reserve in inconsistency 378 */ 379 struct TALER_AUDITORDB_ReserveInInconsistency 380 { 381 uint64_t serial_id; 382 uint64_t bank_row_id; 383 struct TALER_Amount amount_exchange_expected; 384 struct TALER_Amount amount_wired; 385 struct TALER_ReservePublicKeyP reserve_pub; 386 struct GNUNET_TIME_Absolute timestamp; 387 struct TALER_FullPayto account; 388 char *diagnostic; 389 bool suppressed; 390 391 }; 392 393 /** 394 * Information about a balance 395 */ 396 struct TALER_AUDITORDB_Balances 397 { 398 uint64_t row_id; 399 char *balance_key; 400 struct TALER_Amount balance_value; 401 bool suppressed; 402 403 }; 404 405 /** 406 * Function called with arithmetic inconsistencies stored in 407 * the auditor's database. 408 * 409 * @param cls closure 410 * @param dc the structure itself 411 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating 412 */ 413 typedef enum GNUNET_GenericReturnValue 414 (*TALER_AUDITORDB_AmountArithmeticInconsistencyCallback)( 415 void *cls, 416 const struct TALER_AUDITORDB_AmountArithmeticInconsistency *dc); 417 418 /** 419 * Function called with coin inconsistencies stored in 420 * the auditor's database. 421 * 422 * @param cls closure 423 * @param serial_id location of the @a dc in the database 424 * @param dc the structure itself 425 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating 426 */ 427 typedef enum GNUNET_GenericReturnValue 428 (*TALER_AUDITORDB_CoinInconsistencyCallback)( 429 void *cls, 430 uint64_t serial_id, 431 const struct TALER_AUDITORDB_CoinInconsistency *dc); 432 433 /** 434 * Function called with row inconsistencies stored in 435 * the auditor's database. 436 * 437 * @param cls closure 438 * @param serial_id location of the @a dc in the database 439 * @param dc the structure itself 440 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating 441 */ 442 typedef enum GNUNET_GenericReturnValue 443 (*TALER_AUDITORDB_RowInconsistencyCallback)( 444 void *cls, 445 uint64_t serial_id, 446 const struct TALER_AUDITORDB_RowInconsistency *dc); 447 448 /** 449 * Function called with bad signature losses stored in 450 * the auditor's database. 451 * 452 * @param cls closure 453 * @param dc the structure itself 454 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating 455 */ 456 typedef enum GNUNET_GenericReturnValue 457 (*TALER_AUDITORDB_BadSigLossesCallback)( 458 void *cls, 459 const struct TALER_AUDITORDB_BadSigLosses *dc); 460 461 /** 462 * Function called with closure lags stored in 463 * the auditor's database. 464 * 465 * @param cls closure 466 * @param dc the structure itself 467 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating 468 */ 469 typedef enum GNUNET_GenericReturnValue 470 (*TALER_AUDITORDB_ClosureLagsCallback)( 471 void *cls, 472 const struct TALER_AUDITORDB_ClosureLags *dc); 473 474 /** 475 * Function called with emergencies stored in 476 * the auditor's database. 477 * 478 * @param cls closure 479 * @param dc the structure itself 480 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating 481 */ 482 typedef enum GNUNET_GenericReturnValue 483 (*TALER_AUDITORDB_EmergencyCallback)( 484 void *cls, 485 const struct TALER_AUDITORDB_Emergency *dc); 486 487 /** 488 * Function called with emergencies stored in 489 * the auditor's database. 490 * 491 * @param cls closure 492 * @param dc the structure itself 493 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating 494 */ 495 typedef enum GNUNET_GenericReturnValue 496 (*TALER_AUDITORDB_EmergenciesByCountCallback)( 497 void *cls, 498 const struct TALER_AUDITORDB_EmergenciesByCount *dc); 499 500 501 /** 502 * Function called with fee time inconsistency stored in 503 * the auditor's database. 504 * 505 * @param cls closure 506 * @param dc the structure itself 507 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating 508 */ 509 typedef enum GNUNET_GenericReturnValue 510 (*TALER_AUDITORDB_FeeTimeInconsistencyCallback)( 511 void *cls, 512 const struct TALER_AUDITORDB_FeeTimeInconsistency *dc); 513 514 /** 515 * Function called with fee denomination key validity withdraw inconsistency stored in 516 * the auditor's database. 517 * 518 * @param cls closure 519 * @param dc the structure itself 520 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating 521 */ 522 typedef enum GNUNET_GenericReturnValue 523 (*TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistencyCallback)( 524 void *cls, 525 const struct 526 TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistency *dc); 527 528 /** 529 * Function called with purse not closed inconsistencies stored in 530 * the auditor's database. 531 * 532 * @param cls closure 533 * @param dc the structure itself 534 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating 535 */ 536 typedef enum GNUNET_GenericReturnValue 537 (*TALER_AUDITORDB_PurseNotClosedInconsistenciesCallback)( 538 void *cls, 539 const struct TALER_AUDITORDB_PurseNotClosedInconsistencies *dc); 540 541 /** 542 * Function called with reserve balance insufficient inconsistency stored in 543 * the auditor's database. 544 * 545 * @param cls closure 546 * @param dc the structure itself 547 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating 548 */ 549 typedef enum GNUNET_GenericReturnValue 550 (*TALER_AUDITORDB_ReserveBalanceInsufficientInconsistencyCallback)( 551 void *cls, 552 const struct TALER_AUDITORDB_ReserveBalanceInsufficientInconsistency *dc); 553 554 typedef enum GNUNET_GenericReturnValue 555 (*TALER_AUDITORDB_BalancesCallback)( 556 void *cls, 557 const struct TALER_AUDITORDB_Balances *dc); 558 559 typedef enum GNUNET_GenericReturnValue 560 (*TALER_AUDITORDB_ProgressPointsCallback)( 561 void *cls, 562 const struct TALER_AUDITORDB_Progress *pp); 563 564 /** 565 * Balance values for a reserve (or all reserves). 566 */ 567 struct TALER_AUDITORDB_ReserveFeeBalance 568 { 569 /** 570 * Remaining funds. 571 */ 572 struct TALER_Amount reserve_balance; 573 574 /** 575 * Losses from operations that should not have 576 * happened (e.g. negative balance). 577 */ 578 struct TALER_Amount reserve_loss; 579 580 /** 581 * Fees charged for withdraw. 582 */ 583 struct TALER_Amount withdraw_fee_balance; 584 585 /** 586 * Fees charged for closing. 587 */ 588 struct TALER_Amount close_fee_balance; 589 590 /** 591 * Fees charged for purse creation. 592 */ 593 struct TALER_Amount purse_fee_balance; 594 595 /** 596 * Opening fees charged. 597 */ 598 struct TALER_Amount open_fee_balance; 599 600 /** 601 * History fees charged. 602 */ 603 struct TALER_Amount history_fee_balance; 604 }; 605 606 607 /** 608 * Balance data for denominations in circulation. 609 */ 610 struct TALER_AUDITORDB_DenominationCirculationData 611 { 612 /** 613 * Amount of outstanding coins in circulation. 614 */ 615 struct TALER_Amount denom_balance; 616 617 /** 618 * Amount lost due coins illicitly accepted (effectively, a 619 * negative @a denom_balance). 620 */ 621 struct TALER_Amount denom_loss; 622 623 /** 624 * Total amount that could still be theoretically lost in the future due to 625 * recoup operations. (Total put into circulation minus @e recoup_loss). 626 */ 627 struct TALER_Amount denom_risk; 628 629 /** 630 * Amount lost due to recoups. 631 */ 632 struct TALER_Amount recoup_loss; 633 634 /** 635 * Number of coins of this denomination that the exchange signed into 636 * existence. 637 */ 638 uint64_t num_issued; 639 }; 640 641 struct TALER_AUDITORDB_DenominationsWithoutSigs 642 { 643 uint64_t row_id; 644 struct TALER_DenominationHashP denompub_h; 645 struct TALER_Amount value; 646 struct GNUNET_TIME_Absolute start_time; 647 struct GNUNET_TIME_Absolute end_time; 648 bool suppressed; 649 }; 650 651 struct TALER_AUDITORDB_MisattributionInInconsistency 652 { 653 uint64_t row_id; 654 struct TALER_Amount amount; 655 uint64_t bank_row; 656 struct TALER_ReservePublicKeyP reserve_pub; 657 bool suppressed; 658 659 }; 660 661 struct TALER_AUDITORDB_Reserves 662 { 663 uint64_t row_id; 664 uint64_t auditor_reserves_rowid; 665 struct TALER_ReservePublicKeyP reserve_pub; 666 struct TALER_Amount reserve_balance; 667 struct TALER_Amount reserve_loss; 668 struct TALER_Amount withdraw_fee_balance; 669 struct TALER_Amount close_fee_balance; 670 struct TALER_Amount purse_fee_balance; 671 struct TALER_Amount open_fee_balance; 672 struct TALER_Amount history_fee_balance; 673 struct GNUNET_TIME_Absolute expiration_date; 674 struct TALER_FullPayto origin_account; 675 bool suppressed; 676 677 }; 678 679 struct TALER_AUDITORDB_Purses 680 { 681 uint64_t row_id; 682 uint64_t auditor_purses_rowid; 683 struct TALER_PurseContractPublicKeyP purse_pub; 684 struct TALER_Amount balance; 685 struct TALER_Amount target; 686 struct GNUNET_TIME_Absolute expiration_date; 687 bool suppressed; 688 689 }; 690 691 struct TALER_AUDITORDB_HistoricDenominationRevenue 692 { 693 uint64_t row_id; 694 struct TALER_DenominationHashP denom_pub_hash; 695 struct GNUNET_TIME_Absolute revenue_timestamp; 696 struct TALER_Amount revenue_balance; 697 struct TALER_Amount loss_balance; 698 bool suppressed; 699 700 }; 701 702 struct TALER_AUDITORDB_DenominationPending 703 { 704 uint64_t row_id; 705 struct TALER_DenominationHashP denom_pub_hash; 706 struct TALER_Amount denom_balance; 707 struct TALER_Amount denom_loss; 708 uint64_t num_issued; 709 struct TALER_Amount denom_risk; 710 struct TALER_Amount recoup_loss; 711 bool suppressed; 712 713 }; 714 715 struct TALER_AUDITORDB_HistoricReserveSummary 716 { 717 uint64_t row_id; 718 struct GNUNET_TIME_Absolute start_date; 719 struct GNUNET_TIME_Absolute end_date; 720 struct TALER_Amount reserve_profits; 721 bool suppressed; 722 723 }; 724 725 struct TALER_AUDITORDB_ExchangeSignkeys 726 { 727 uint64_t row_id; 728 struct TALER_ExchangePublicKeyP exchange_pub; 729 struct TALER_MasterSignatureP master_sig; 730 struct GNUNET_TIME_Absolute ep_valid_from; 731 struct GNUNET_TIME_Absolute ep_expire_sign; 732 struct GNUNET_TIME_Absolute ep_expire_legal; 733 bool suppressed; 734 735 }; 736 737 struct TALER_AUDITORDB_WireFormatInconsistency 738 { 739 uint64_t row_id; 740 struct TALER_Amount amount; 741 uint64_t wire_offset; 742 char *diagnostic; 743 bool suppressed; 744 745 }; 746 747 struct TALER_AUDITORDB_WireOutInconsistency 748 { 749 uint64_t row_id; 750 struct TALER_FullPayto destination_account; 751 char *diagnostic; 752 uint64_t wire_out_row_id; 753 struct TALER_Amount expected; 754 struct TALER_Amount claimed; 755 bool suppressed; 756 757 }; 758 759 struct TALER_AUDITORDB_RowMinorInconsistencies 760 { 761 uint64_t row_id; 762 char *row_table; 763 uint64_t problem_row; 764 char *diagnostic; 765 bool suppressed; 766 }; 767 768 769 struct TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistency 770 { 771 uint64_t row_id; 772 struct TALER_ReservePublicKeyP reserve_pub; 773 struct TALER_Amount exchange_amount; 774 struct TALER_Amount auditor_amount; 775 bool suppressed; 776 777 }; 778 779 struct TALER_AUDITORDB_ReserveNotClosedInconsistency 780 { 781 uint64_t row_id; 782 struct TALER_ReservePublicKeyP reserve_pub; 783 struct TALER_Amount balance; 784 struct GNUNET_TIME_Absolute expiration_time; 785 char *diagnostic; 786 bool suppressed; 787 788 }; 789 790 /** 791 * Function called with deposit confirmations stored in 792 * the auditor's database. 793 * 794 * @param cls closure 795 * @param dc the deposit confirmation itself 796 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating 797 */ 798 typedef enum GNUNET_GenericReturnValue 799 (*TALER_AUDITORDB_DepositConfirmationCallback)( 800 void *cls, 801 const struct TALER_AUDITORDB_DepositConfirmation *dc); 802 803 804 /** 805 * Function called on deposits that are past their due date 806 * and have not yet seen a wire transfer. 807 * 808 * @param cls closure 809 * @param row_id row ID of the alert in the auditor database 810 * @param batch_deposit_serial_id where in the exchange table are we 811 * @param total_amount value of all missing deposits, including fees 812 * @param wire_target_h_payto hash of the recipient account's payto URI 813 * @param deadline what was the earliest requested wire transfer deadline 814 * @param suppressed true if this report was suppressed 815 */ 816 typedef void 817 (*TALER_AUDITORDB_WireMissingCallback) ( 818 void *cls, 819 uint64_t row_id, 820 uint64_t batch_deposit_serial_id, 821 const struct TALER_Amount *total_amount, 822 const struct TALER_FullPaytoHashP *wire_target_h_payto, 823 struct GNUNET_TIME_Timestamp deadline, 824 bool suppressed); 825 826 827 /** 828 * Function called on expired purses. 829 * 830 * @param cls closure 831 * @param purse_pub public key of the purse 832 * @param balance amount of money in the purse 833 * @param expiration_date when did the purse expire? 834 * @return #GNUNET_OK to continue to iterate 835 */ 836 typedef enum GNUNET_GenericReturnValue 837 (*TALER_AUDITORDB_ExpiredPurseCallback)( 838 void *cls, 839 const struct TALER_PurseContractPublicKeyP *purse_pub, 840 const struct TALER_Amount *balance, 841 struct GNUNET_TIME_Timestamp expiration_date); 842 843 844 typedef enum GNUNET_GenericReturnValue 845 (*TALER_AUDITORDB_ReserveInInconsistencyCallback)( 846 void *cls, 847 const struct TALER_AUDITORDB_ReserveInInconsistency *dc); 848 849 typedef enum GNUNET_GenericReturnValue 850 (*TALER_AUDITORDB_ReserveNotClosedInconsistencyCallback)( 851 void *cls, 852 const struct TALER_AUDITORDB_ReserveNotClosedInconsistency *dc); 853 854 typedef enum GNUNET_GenericReturnValue 855 (*TALER_AUDITORDB_DenominationsWithoutSigsCallback)( 856 void *cls, 857 const struct TALER_AUDITORDB_DenominationsWithoutSigs *dc); 858 859 typedef enum GNUNET_GenericReturnValue 860 (*TALER_AUDITORDB_MisattributionInInconsistencyCallback)( 861 void *cls, 862 const struct TALER_AUDITORDB_MisattributionInInconsistency *dc); 863 864 typedef enum GNUNET_GenericReturnValue 865 (*TALER_AUDITORDB_ReservesCallback)( 866 void *cls, 867 uint64_t serial_id, 868 const struct TALER_AUDITORDB_Reserves *dc); 869 870 typedef enum GNUNET_GenericReturnValue 871 (*TALER_AUDITORDB_PursesCallback)( 872 void *cls, 873 uint64_t serial_id, 874 const struct TALER_AUDITORDB_Purses *dc); 875 876 typedef enum GNUNET_GenericReturnValue 877 (*TALER_AUDITORDB_HistoricDenominationRevenueCallback)( 878 void *cls, 879 uint64_t serial_id, 880 const struct TALER_AUDITORDB_HistoricDenominationRevenue *dc); 881 882 typedef enum GNUNET_GenericReturnValue 883 (*TALER_AUDITORDB_DenominationPendingCallback)( 884 void *cls, 885 uint64_t serial_id, 886 const struct TALER_AUDITORDB_DenominationPending *dc); 887 888 typedef enum GNUNET_GenericReturnValue 889 (*TALER_AUDITORDB_HistoricReserveSummaryCallback)( 890 void *cls, 891 uint64_t serial_id, 892 const struct TALER_AUDITORDB_HistoricReserveSummary *dc); 893 894 typedef enum GNUNET_GenericReturnValue 895 (*TALER_AUDITORDB_ExchangeSignkeysCallback)( 896 void *cls, 897 uint64_t serial_id, 898 const struct TALER_AUDITORDB_ExchangeSignkeys *dc); 899 900 901 typedef enum GNUNET_GenericReturnValue 902 (*TALER_AUDITORDB_WireFormatInconsistencyCallback)( 903 void *cls, 904 const struct TALER_AUDITORDB_WireFormatInconsistency *dc); 905 906 typedef enum GNUNET_GenericReturnValue 907 (*TALER_AUDITORDB_WireOutInconsistencyCallback)( 908 void *cls, 909 const struct TALER_AUDITORDB_WireOutInconsistency *dc); 910 911 typedef enum GNUNET_GenericReturnValue 912 (*TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistencyCallback)( 913 void *cls, 914 const struct TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistency *dc); 915 916 typedef enum GNUNET_GenericReturnValue 917 (*TALER_AUDITORDB_RowMinorInconsistenciesCallback)( 918 void *cls, 919 const struct TALER_AUDITORDB_RowMinorInconsistencies *dc); 920 921 922 /** 923 * Information about an early aggregation event. 924 */ 925 struct TALER_AUDITORDB_EarlyAggregation 926 { 927 /** 928 * Row of the event in the auditor database. 929 */ 930 uint64_t row_id; 931 932 /** 933 * Row of the batch deposit in the exchange database. 934 */ 935 uint64_t batch_deposit_serial_id; 936 937 /** 938 * FIXME 939 */ 940 uint64_t tracking_serial_id; 941 942 /** 943 * Total amount involved. 944 */ 945 struct TALER_Amount total; 946 947 /** 948 * True if this report was previously suppressed. 949 */ 950 bool suppressed; 951 }; 952 953 954 /** 955 * Function to call with information about early aggregations. 956 * 957 * @param cls closure 958 * @param ea event data 959 * @return #GNUNET_OK to continue to iterate 960 */ 961 typedef enum GNUNET_GenericReturnValue 962 (*TALER_AUDITORDB_EarlyAggregationsCallback)( 963 void *cls, 964 const struct TALER_AUDITORDB_EarlyAggregation *ea); 965 966 /** 967 * @brief The plugin API, returned from the plugin's "init" function. 968 * The argument given to "init" is simply a configuration handle. 969 * 970 * Functions starting with "get_" return one result, functions starting 971 * with "select_" return multiple results via callbacks. 972 */ 973 struct TALER_AUDITORDB_Plugin 974 { 975 976 /** 977 * Closure for all callbacks. 978 */ 979 void *cls; 980 981 /** 982 * Name of the library which generated this plugin. Set by the 983 * plugin loader. 984 */ 985 char *library_name; 986 987 /** 988 * Fully connect to the db if the connection does not exist yet 989 * and check that there is no transaction currently running. 990 * 991 * @param cls the @e cls of this struct with the plugin-specific state 992 * @return #GNUNET_OK on success 993 * #GNUNET_NO if we rolled back an earlier transaction 994 * #GNUNET_SYSERR if we have no DB connection 995 */ 996 enum GNUNET_GenericReturnValue 997 (*preflight)(void *cls); 998 999 1000 /** 1001 * Register callback to be invoked on events of type @a es. 1002 * 1003 * @param cls database context to use 1004 * @param es specification of the event to listen for 1005 * @param timeout how long to wait for the event 1006 * @param cb function to call when the event happens, possibly 1007 * mulrewardle times (until cancel is invoked) 1008 * @param cb_cls closure for @a cb 1009 * @return handle useful to cancel the listener 1010 */ 1011 struct GNUNET_DB_EventHandler * 1012 (*event_listen) (void *cls, 1013 const struct GNUNET_DB_EventHeaderP *es, 1014 struct GNUNET_TIME_Relative timeout, 1015 GNUNET_DB_EventCallback cb, 1016 void *cb_cls); 1017 1018 /** 1019 * Stop notifications. 1020 * 1021 * @param eh handle to unregister. 1022 */ 1023 void 1024 (*event_listen_cancel) (struct GNUNET_DB_EventHandler *eh); 1025 1026 1027 /** 1028 * Notify all that listen on @a es of an event. 1029 * 1030 * @param cls database context to use 1031 * @param es specification of the event to generate 1032 * @param extra additional event data provided 1033 * @param extra_size number of bytes in @a extra 1034 */ 1035 void 1036 (*event_notify) (void *cls, 1037 const struct GNUNET_DB_EventHeaderP *es, 1038 const void *extra, 1039 size_t extra_size); 1040 1041 1042 /** 1043 * Drop all auditor tables OR deletes recoverable auditor state. 1044 * This should only be used by testcases or when restarting the 1045 * auditor from scratch. 1046 * 1047 * @param cls the `struct PostgresClosure` with the plugin-specific state 1048 * @param drop_exchangelist drop all tables, including schema versioning 1049 * and the exchange and deposit_confirmations table; NOT to be 1050 * used when restarting the auditor 1051 * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure 1052 */ 1053 enum GNUNET_GenericReturnValue 1054 (*drop_tables)(void *cls, 1055 bool drop_exchangelist); 1056 1057 1058 /** 1059 * Create the necessary tables if they are not present 1060 * 1061 * @param cls the @e cls of this struct with the plugin-specific state 1062 * @param support_partitions true to support partitioning 1063 * @param num_partitions number of partitions to use 1064 * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure 1065 */ 1066 enum GNUNET_GenericReturnValue 1067 (*create_tables)(void *cls, 1068 bool support_partitions, 1069 uint32_t num_partitions); 1070 1071 1072 /** 1073 * Start a transaction. 1074 * 1075 * @param cls the @e cls of this struct with the plugin-specific state 1076 * @return #GNUNET_OK on success 1077 */ 1078 enum GNUNET_GenericReturnValue 1079 (*start)(void *cls); 1080 1081 1082 /** 1083 * Commit a transaction. 1084 * 1085 * @param cls the @e cls of this struct with the plugin-specific state 1086 * @return transaction status code 1087 */ 1088 enum GNUNET_DB_QueryStatus 1089 (*commit)(void *cls); 1090 1091 1092 /** 1093 * Abort/rollback a transaction. 1094 * 1095 * @param cls the @e cls of this struct with the plugin-specific state 1096 */ 1097 void 1098 (*rollback) (void *cls); 1099 1100 1101 /** 1102 * Function called to perform "garbage collection" on the 1103 * database, expiring records we no longer require. 1104 * 1105 * @param cls closure 1106 * @return #GNUNET_OK on success, 1107 * #GNUNET_SYSERR on DB errors 1108 */ 1109 enum GNUNET_GenericReturnValue 1110 (*gc)(void *cls); 1111 1112 1113 /** 1114 * Insert information about the auditor's progress with an exchange's 1115 * data. 1116 * 1117 * @param cls the @e cls of this struct with the plugin-specific state 1118 * @param progress_key name of the progress indicator 1119 * @param progress_offset offset until which we have made progress 1120 * @param ... NULL terminated list of additional key-value pairs to insert 1121 * @return transaction status code 1122 */ 1123 enum GNUNET_DB_QueryStatus 1124 (*insert_auditor_progress)( 1125 void *cls, 1126 const char *progress_key, 1127 uint64_t progress_offset, 1128 ...); 1129 1130 /** 1131 * Update information about the progress of the auditor. There 1132 * must be an existing record for the exchange. 1133 * 1134 * @param cls the @e cls of this struct with the plugin-specific state 1135 * @param progress_key name of the progress indicator 1136 * @param progress_offset offset until which we have made progress 1137 * @param ... NULL terminated list of additional key-value pairs to update 1138 * @return transaction status code 1139 */ 1140 enum GNUNET_DB_QueryStatus 1141 (*update_auditor_progress)( 1142 void *cls, 1143 const char *progress_key, 1144 uint64_t progress_offset, 1145 ...); 1146 1147 /** 1148 * Get information about the progress of the auditor. 1149 * 1150 * @param cls the @e cls of this struct with the plugin-specific state 1151 * @param progress_key name of the progress indicator 1152 * @param[out] progress_offset set to offset until which we have made progress, set to 0 if key was not found 1153 * @param ... NULL terminated list of additional key-value pairs to fetch 1154 * @return transaction status code 1155 */ 1156 enum GNUNET_DB_QueryStatus 1157 (*get_auditor_progress)(void *cls, 1158 const char *progress_key, 1159 uint64_t *progress_offset, 1160 ...); 1161 1162 1163 /** 1164 * Insert information about a balance tracked by the auditor. There must not be an 1165 * existing record. 1166 * 1167 * @param cls the @e cls of this struct with the plugin-specific state 1168 * @param balance_key key of the balance to store 1169 * @param balance_value value to store 1170 * @param ... NULL terminated list of additional key-value pairs to insert 1171 * @return transaction status code 1172 */ 1173 enum GNUNET_DB_QueryStatus 1174 (*insert_balance)(void *cls, 1175 const char *balance_key, 1176 const struct TALER_Amount *balance_value, 1177 ...); 1178 1179 1180 /** 1181 * Insert information about a balance tracked by the auditor. Destructively updates an 1182 * existing record, which must already exist. 1183 * 1184 * @param cls the @e cls of this struct with the plugin-specific state 1185 * @param balance_key key of the balance to store 1186 * @param balance_amount value to store 1187 * @param ... NULL terminated list of additional key-value pairs to update 1188 * @return transaction status code 1189 */ 1190 enum GNUNET_DB_QueryStatus 1191 (*update_balance)(void *cls, 1192 const char *balance_key, 1193 const struct TALER_Amount *balance_amount, 1194 ...); 1195 1196 1197 /** 1198 * Get summary information about balance tracked by the auditor. 1199 * 1200 * @param cls the @e cls of this struct with the plugin-specific state 1201 * @param balance_key key of the balance to store 1202 * @param[out] balance_value set to amount stored under @a balance_key, set to invalid amount (all zero) if key was not found 1203 * @param ... NULL terminated list of additional key-value pairs to fetch 1204 * @return transaction status code 1205 */ 1206 enum GNUNET_DB_QueryStatus 1207 (*get_balance)(void *cls, 1208 const char *balance_key, 1209 struct TALER_Amount *balance_value, 1210 ...); 1211 1212 1213 /** 1214 * Get information about balances from the database. 1215 * 1216 * @param cls the @e cls of this struct with the plugin-specific state 1217 * @param balance_key only return this particular balance 1218 * @param cb function to call with results 1219 * @param cb_cls closure for @a cb 1220 * @return query result status 1221 */ 1222 enum GNUNET_DB_QueryStatus 1223 (*get_balances)( 1224 void *cls, 1225 const char *balance_key, 1226 TALER_AUDITORDB_BalancesCallback cb, 1227 void *cb_cls); 1228 1229 /** 1230 * Get information about progress from the database. 1231 * 1232 * @param cls the @e cls of this struct with the plugin-specific state 1233 * @param progress_key only return this particular progress point 1234 * @param cb function to call with results 1235 * @param cb_cls closure for @a cb 1236 * @return query result status 1237 */ 1238 enum GNUNET_DB_QueryStatus 1239 (*get_progress_points)( 1240 void *cls, 1241 const char *progress_key, 1242 TALER_AUDITORDB_ProgressPointsCallback cb, 1243 void *cb_cls); 1244 1245 /** 1246 * Insert information about a signing key of the exchange. 1247 * 1248 * @param cls the @e cls of this struct with the plugin-specific state 1249 * @param sk signing key information to store 1250 * @return query result status 1251 */ 1252 enum GNUNET_DB_QueryStatus 1253 (*insert_exchange_signkey)( 1254 void *cls, 1255 const struct TALER_AUDITORDB_ExchangeSigningKey *sk); 1256 1257 1258 /** 1259 * Insert information about a deposit confirmation into the database. 1260 * 1261 * @param cls the @e cls of this struct with the plugin-specific state 1262 * @param dc deposit confirmation information to store 1263 * @return query result status 1264 */ 1265 enum GNUNET_DB_QueryStatus 1266 (*insert_deposit_confirmation)( 1267 void *cls, 1268 const struct TALER_AUDITORDB_DepositConfirmation *dc); 1269 1270 1271 /** 1272 * Get information about deposit confirmations from the database. 1273 * 1274 * @param cls the @e cls of this struct with the plugin-specific state 1275 * @param offset row/serial ID where to start the iteration (0 from 1276 * the start, exclusive, i.e. serial_ids must start from 1) 1277 * @param return_suppressed should suppressed rows be returned anyway? 1278 * @param cb function to call with results 1279 * @param cb_cls closure for @a cb 1280 * @return query result status 1281 */ 1282 enum GNUNET_DB_QueryStatus 1283 (*get_deposit_confirmations)( 1284 void *cls, 1285 int64_t limit, 1286 uint64_t offset, 1287 bool return_suppressed, 1288 TALER_AUDITORDB_DepositConfirmationCallback cb, 1289 void *cb_cls); 1290 1291 1292 /** 1293 * Get information about arithmetic inconsistencies from the database. 1294 * 1295 * @param cls the @e cls of this struct with the plugin-specific state 1296 * @param start_id row/serial ID where to start the iteration (0 from 1297 * the start, exclusive, i.e. serial_ids must start from 1) 1298 * @param return_suppressed should suppressed rows be returned anyway? 1299 * @param cb function to call with results 1300 * @param cb_cls closure for @a cb 1301 * @return query result status 1302 */ 1303 enum GNUNET_DB_QueryStatus 1304 (*get_amount_arithmetic_inconsistency)( 1305 void *cls, 1306 int64_t limit, 1307 uint64_t offset, 1308 bool return_suppressed, 1309 TALER_AUDITORDB_AmountArithmeticInconsistencyCallback cb, 1310 void *cb_cls); 1311 1312 enum GNUNET_DB_QueryStatus 1313 (*get_coin_inconsistency)( 1314 void *cls, 1315 int64_t limit, 1316 uint64_t offset, 1317 bool return_suppressed, 1318 TALER_AUDITORDB_CoinInconsistencyCallback cb, 1319 void *cb_cls); 1320 1321 enum GNUNET_DB_QueryStatus 1322 (*get_row_inconsistency)( 1323 void *cls, 1324 int64_t limit, 1325 uint64_t offset, 1326 bool return_suppressed, 1327 TALER_AUDITORDB_RowInconsistencyCallback cb, 1328 void *cb_cls); 1329 1330 enum GNUNET_DB_QueryStatus 1331 (*get_emergency)( 1332 void *cls, 1333 int64_t limit, 1334 uint64_t offset, 1335 bool return_suppressed, 1336 TALER_AUDITORDB_EmergencyCallback cb, 1337 void *cb_cls); 1338 1339 enum GNUNET_DB_QueryStatus 1340 (*get_emergency_by_count)( 1341 void *cls, 1342 int64_t limit, 1343 uint64_t offset, 1344 bool return_suppressed, 1345 TALER_AUDITORDB_EmergenciesByCountCallback cb, 1346 void *cb_cls); 1347 1348 enum GNUNET_DB_QueryStatus 1349 (*get_denomination_key_validity_withdraw_inconsistency)( 1350 void *cls, 1351 int64_t limit, 1352 uint64_t offset, 1353 bool return_suppressed, 1354 TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistencyCallback cb, 1355 void *cb_cls); 1356 1357 enum GNUNET_DB_QueryStatus 1358 (*get_purse_not_closed_inconsistencies)( 1359 void *cls, 1360 int64_t limit, 1361 uint64_t offset, 1362 bool return_suppressed, 1363 TALER_AUDITORDB_PurseNotClosedInconsistenciesCallback cb, 1364 void *cb_cls); 1365 1366 enum GNUNET_DB_QueryStatus 1367 (*get_reserve_balance_insufficient_inconsistency)( 1368 void *cls, 1369 int64_t limit, 1370 uint64_t offset, 1371 bool return_suppressed, 1372 TALER_AUDITORDB_ReserveBalanceInsufficientInconsistencyCallback cb, 1373 void *cb_cls); 1374 1375 enum GNUNET_DB_QueryStatus 1376 (*get_bad_sig_losses)( 1377 void *cls, 1378 int64_t limit, 1379 uint64_t offset, 1380 bool return_suppressed, 1381 const struct GNUNET_CRYPTO_EddsaPublicKey *op_spec_pub, 1382 const char *op, 1383 TALER_AUDITORDB_BadSigLossesCallback cb, 1384 void *cb_cls); 1385 1386 enum GNUNET_DB_QueryStatus 1387 (*get_auditor_closure_lags)( 1388 void *cls, 1389 int64_t limit, 1390 uint64_t offset, 1391 bool return_suppressed, 1392 TALER_AUDITORDB_ClosureLagsCallback cb, 1393 void *cb_cls); 1394 1395 /** 1396 * A previously missing wire transfer may have been found. Remove an alert 1397 * (if we raised one). 1398 * 1399 * @param cls plugin closure 1400 * @param amount wire transfer amount 1401 * @param wtid wire transfer subject 1402 * @param credit_account_uri destination account 1403 * @return #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if no matching alert was 1404 * found 1405 */ 1406 enum GNUNET_DB_QueryStatus 1407 (*delete_auditor_closure_lag)( 1408 void *cls, 1409 const struct TALER_Amount *amount, 1410 const struct TALER_WireTransferIdentifierRawP *wtid, 1411 struct TALER_FullPayto credit_account_uri); 1412 1413 /** 1414 * Delete information about a deposit confirmation from the database. 1415 * 1416 * @param cls the @e cls of this struct with the plugin-specific state 1417 * @param row_id row to delete 1418 * @return query result status 1419 */ 1420 enum GNUNET_DB_QueryStatus 1421 (*delete_amount_arithmetic_inconsistency)( 1422 void *cls, 1423 uint64_t row_id); 1424 1425 enum GNUNET_DB_QueryStatus 1426 (*delete_coin_inconsistency)( 1427 void *cls, 1428 uint64_t row_id); 1429 1430 enum GNUNET_DB_QueryStatus 1431 (*delete_row_inconsistency)( 1432 void *cls, 1433 uint64_t row_id); 1434 1435 enum GNUNET_DB_QueryStatus 1436 (*delete_emergency)( 1437 void *cls, 1438 uint64_t row_id); 1439 1440 enum GNUNET_DB_QueryStatus 1441 (*delete_emergency_by_count)( 1442 void *cls, 1443 uint64_t row_id); 1444 1445 enum GNUNET_DB_QueryStatus 1446 (*delete_denomination_key_validity_withdraw_inconsistency)( 1447 void *cls, 1448 uint64_t row_id); 1449 1450 enum GNUNET_DB_QueryStatus 1451 (*delete_purse_not_closed_inconsistencies)( 1452 void *cls, 1453 uint64_t row_id); 1454 1455 enum GNUNET_DB_QueryStatus 1456 (*delete_reserve_balance_insufficient_inconsistency)( 1457 void *cls, 1458 uint64_t row_id); 1459 1460 enum GNUNET_DB_QueryStatus 1461 (*delete_bad_sig_losses)( 1462 void *cls, 1463 uint64_t row_id); 1464 1465 enum GNUNET_DB_QueryStatus 1466 (*delete_auditor_closure_lags)( 1467 void *cls, 1468 uint64_t row_id); 1469 1470 enum GNUNET_DB_QueryStatus 1471 (*delete_progress)( 1472 void *cls, 1473 uint64_t row_id); 1474 1475 /** 1476 * Insert information about a deposit confirmation into the database. 1477 * 1478 * @param cls the @e cls of this struct with the plugin-specific state 1479 * @param dc deposit confirmation information to store 1480 * @return query result status 1481 */ 1482 enum GNUNET_DB_QueryStatus 1483 (*insert_amount_arithmetic_inconsistency)( 1484 void *cls, 1485 const struct TALER_AUDITORDB_AmountArithmeticInconsistency *dc); 1486 1487 enum GNUNET_DB_QueryStatus 1488 (*insert_coin_inconsistency)( 1489 void *cls, 1490 const struct TALER_AUDITORDB_CoinInconsistency *dc); 1491 1492 enum GNUNET_DB_QueryStatus 1493 (*insert_row_inconsistency)( 1494 void *cls, 1495 const struct TALER_AUDITORDB_RowInconsistency *dc); 1496 1497 enum GNUNET_DB_QueryStatus 1498 (*insert_emergency)( 1499 void *cls, 1500 const struct TALER_AUDITORDB_Emergency *dc); 1501 1502 enum GNUNET_DB_QueryStatus 1503 (*insert_emergency_by_count)( 1504 void *cls, 1505 const struct TALER_AUDITORDB_EmergenciesByCount *dc); 1506 1507 enum GNUNET_DB_QueryStatus 1508 (*insert_denomination_key_validity_withdraw_inconsistency)( 1509 void *cls, 1510 const struct 1511 TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistency *dc); 1512 1513 enum GNUNET_DB_QueryStatus 1514 (*insert_purse_not_closed_inconsistencies)( 1515 void *cls, 1516 const struct TALER_AUDITORDB_PurseNotClosedInconsistencies *dc); 1517 1518 enum GNUNET_DB_QueryStatus 1519 (*insert_reserve_balance_insufficient_inconsistency)( 1520 void *cls, 1521 const struct TALER_AUDITORDB_ReserveBalanceInsufficientInconsistency *dc); 1522 1523 enum GNUNET_DB_QueryStatus 1524 (*insert_bad_sig_losses)( 1525 void *cls, 1526 const struct TALER_AUDITORDB_BadSigLosses *dc); 1527 1528 enum GNUNET_DB_QueryStatus 1529 (*insert_auditor_closure_lags)( 1530 void *cls, 1531 const struct TALER_AUDITORDB_ClosureLags *dc); 1532 1533 enum GNUNET_DB_QueryStatus 1534 (*update_generic_suppressed)( 1535 void *cls, 1536 enum TALER_AUDITORDB_DeletableSuppressableTables table, 1537 uint64_t row_id, 1538 bool suppressed); 1539 1540 enum GNUNET_DB_QueryStatus 1541 (*delete_generic)( 1542 void *cls, 1543 enum TALER_AUDITORDB_DeletableSuppressableTables table, 1544 uint64_t row_id); 1545 1546 /** 1547 * Lookup information about reserve-in-inconsistency from the database. 1548 * 1549 * @param cls the @e cls of this struct with the plugin-specific state 1550 * @param bank_row_id row of the transaction at the bank 1551 * @param[out] dc set to the transaction details 1552 * @return query result status 1553 */ 1554 enum GNUNET_DB_QueryStatus 1555 (*lookup_reserve_in_inconsistency) ( 1556 void *cls, 1557 uint64_t bank_row_id, 1558 struct TALER_AUDITORDB_ReserveInInconsistency *dc); 1559 1560 1561 enum GNUNET_DB_QueryStatus 1562 (*get_reserve_in_inconsistency)( 1563 void *cls, 1564 int64_t limit, 1565 uint64_t offset, 1566 bool return_suppressed, 1567 TALER_AUDITORDB_ReserveInInconsistencyCallback cb, 1568 void *cb_cls); 1569 1570 1571 /** 1572 * Delete information about an reserve-in-inconsistency from the database. 1573 * 1574 * @param cls the @e cls of this struct with the plugin-specific state 1575 * @param row_id row of the inconsistency in our table 1576 * @return query result status 1577 */ 1578 enum GNUNET_DB_QueryStatus 1579 (*delete_reserve_in_inconsistency)( 1580 void *cls, 1581 uint64_t row_id); 1582 1583 1584 enum GNUNET_DB_QueryStatus 1585 (*insert_reserve_in_inconsistency)( 1586 void *cls, 1587 const struct TALER_AUDITORDB_ReserveInInconsistency *dc); 1588 1589 1590 /** 1591 * Return any reserve incoming inconsistency associated with the 1592 * given @a bank_row_id. 1593 * 1594 * @param cls closure 1595 * @param bank_row_id row to select by 1596 * @param[out] dc details to return 1597 */ 1598 enum GNUNET_DB_QueryStatus 1599 (*select_reserve_in_inconsistency)( 1600 void *cls, 1601 uint64_t bank_row_id, 1602 struct TALER_AUDITORDB_ReserveInInconsistency *dc); 1603 1604 enum GNUNET_DB_QueryStatus 1605 (*get_reserve_not_closed_inconsistency)( 1606 void *cls, 1607 int64_t limit, 1608 uint64_t offset, 1609 bool return_suppressed, 1610 TALER_AUDITORDB_ReserveNotClosedInconsistencyCallback cb, 1611 void *cb_cls); 1612 1613 /** 1614 * Returns all aggregations that were found that were done 1615 * too early. 1616 * 1617 * @param cls closure 1618 * @param limit number of rows to return, negative to iterate backwards 1619 * @param offset starting offset, exclusive 1620 * @param return_suppressed true to also return suppressed events 1621 * @param cb function to call with results 1622 * @param cb_cls closure for @a cb 1623 * @return transaction status 1624 */ 1625 enum GNUNET_DB_QueryStatus 1626 (*select_early_aggregations)( 1627 void *cls, 1628 int64_t limit, 1629 uint64_t offset, 1630 bool return_suppressed, 1631 TALER_AUDITORDB_EarlyAggregationsCallback cb, 1632 void *cb_cls); 1633 1634 1635 enum GNUNET_DB_QueryStatus 1636 (*delete_reserve_not_closed_inconsistency)( 1637 void *cls, 1638 uint64_t row_id); 1639 1640 1641 enum GNUNET_DB_QueryStatus 1642 (*insert_reserve_not_closed_inconsistency)( 1643 void *cls, 1644 const struct TALER_AUDITORDB_ReserveNotClosedInconsistency *dc); 1645 1646 enum GNUNET_DB_QueryStatus 1647 (*get_denominations_without_sigs)( 1648 void *cls, 1649 int64_t limit, 1650 uint64_t offset, 1651 bool return_suppressed, 1652 TALER_AUDITORDB_DenominationsWithoutSigsCallback cb, 1653 void *cb_cls); 1654 1655 1656 enum GNUNET_DB_QueryStatus 1657 (*delete_denominations_without_sigs)( 1658 void *cls, 1659 uint64_t row_id); 1660 1661 1662 enum GNUNET_DB_QueryStatus 1663 (*insert_denominations_without_sigs)( 1664 void *cls, 1665 const struct TALER_AUDITORDB_DenominationsWithoutSigs *dc); 1666 1667 enum GNUNET_DB_QueryStatus 1668 (*get_misattribution_in_inconsistency)( 1669 void *cls, 1670 int64_t limit, 1671 uint64_t offset, 1672 bool return_suppressed, 1673 TALER_AUDITORDB_MisattributionInInconsistencyCallback cb, 1674 void *cb_cls); 1675 1676 1677 enum GNUNET_DB_QueryStatus 1678 (*delete_misattribution_in_inconsistency)( 1679 void *cls, 1680 uint64_t row_id); 1681 1682 1683 enum GNUNET_DB_QueryStatus 1684 (*insert_misattribution_in_inconsistency)( 1685 void *cls, 1686 const struct TALER_AUDITORDB_MisattributionInInconsistency *dc); 1687 1688 enum GNUNET_DB_QueryStatus 1689 (*get_reserves)( 1690 void *cls, 1691 int64_t limit, 1692 uint64_t offset, 1693 TALER_AUDITORDB_ReservesCallback cb, 1694 void *cb_cls); 1695 1696 enum GNUNET_DB_QueryStatus 1697 (*get_purses)( 1698 void *cls, 1699 int64_t limit, 1700 uint64_t offset, 1701 TALER_AUDITORDB_PursesCallback cb, 1702 void *cb_cls); 1703 1704 1705 enum GNUNET_DB_QueryStatus 1706 (*delete_purses)( 1707 void *cls, 1708 uint64_t row_id); 1709 1710 enum GNUNET_DB_QueryStatus 1711 (*get_denomination_pending)( 1712 void *cls, 1713 int64_t limit, 1714 uint64_t offset, 1715 TALER_AUDITORDB_DenominationPendingCallback cb, 1716 void *cb_cls); 1717 1718 enum GNUNET_DB_QueryStatus 1719 (*delete_denomination_pending)( 1720 void *cls, 1721 uint64_t row_id); 1722 1723 enum GNUNET_DB_QueryStatus 1724 (*insert_denomination_pending)( 1725 void *cls, 1726 const struct TALER_AUDITORDB_DenominationPending *dc); 1727 1728 enum GNUNET_DB_QueryStatus 1729 (*get_exchange_signkeys)( 1730 void *cls, 1731 int64_t limit, 1732 uint64_t offset, 1733 bool return_suppressed, 1734 TALER_AUDITORDB_ExchangeSignkeysCallback cb, 1735 void *cb_cls); 1736 1737 enum GNUNET_DB_QueryStatus 1738 (*get_wire_format_inconsistency)( 1739 void *cls, 1740 int64_t limit, 1741 uint64_t offset, 1742 bool return_suppressed, 1743 TALER_AUDITORDB_WireFormatInconsistencyCallback cb, 1744 void *cb_cls); 1745 1746 1747 enum GNUNET_DB_QueryStatus 1748 (*delete_wire_format_inconsistency)( 1749 void *cls, 1750 uint64_t row_id); 1751 1752 1753 enum GNUNET_DB_QueryStatus 1754 (*insert_wire_format_inconsistency)( 1755 void *cls, 1756 const struct TALER_AUDITORDB_WireFormatInconsistency *dc); 1757 1758 enum GNUNET_DB_QueryStatus 1759 (*get_wire_out_inconsistency)( 1760 void *cls, 1761 int64_t limit, 1762 uint64_t offset, 1763 bool return_suppressed, 1764 TALER_AUDITORDB_WireOutInconsistencyCallback cb, 1765 void *cb_cls); 1766 1767 1768 enum GNUNET_DB_QueryStatus 1769 (*delete_wire_out_inconsistency)( 1770 void *cls, 1771 uint64_t row_id); 1772 1773 1774 enum GNUNET_DB_QueryStatus 1775 (*insert_wire_out_inconsistency)( 1776 void *cls, 1777 const struct TALER_AUDITORDB_WireOutInconsistency *dc); 1778 1779 enum GNUNET_DB_QueryStatus 1780 (*delete_wire_out_inconsistency_if_matching)( 1781 void *cls, 1782 const struct TALER_AUDITORDB_WireOutInconsistency *dc); 1783 1784 enum GNUNET_DB_QueryStatus 1785 (*get_reserve_balance_summary_wrong_inconsistency)( 1786 void *cls, 1787 int64_t limit, 1788 uint64_t offset, 1789 bool return_suppressed, 1790 TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistencyCallback cb, 1791 void *cb_cls); 1792 1793 1794 enum GNUNET_DB_QueryStatus 1795 (*delete_reserve_balance_summary_wrong_inconsistency)( 1796 void *cls, 1797 uint64_t row_id); 1798 1799 1800 enum GNUNET_DB_QueryStatus 1801 (*insert_reserve_balance_summary_wrong_inconsistency)( 1802 void *cls, 1803 const struct TALER_AUDITORDB_ReserveBalanceSummaryWrongInconsistency *dc); 1804 1805 enum GNUNET_DB_QueryStatus 1806 (*get_row_minor_inconsistencies)( 1807 void *cls, 1808 int64_t limit, 1809 uint64_t offset, 1810 bool return_suppressed, 1811 TALER_AUDITORDB_RowMinorInconsistenciesCallback cb, 1812 void *cb_cls); 1813 1814 1815 enum GNUNET_DB_QueryStatus 1816 (*delete_row_minor_inconsistencies)( 1817 void *cls, 1818 uint64_t row_id); 1819 1820 1821 enum GNUNET_DB_QueryStatus 1822 (*insert_row_minor_inconsistencies)( 1823 void *cls, 1824 const struct TALER_AUDITORDB_RowMinorInconsistencies *dc); 1825 1826 enum GNUNET_DB_QueryStatus 1827 (*get_fee_time_inconsistency)( 1828 void *cls, 1829 int64_t limit, 1830 uint64_t offset, 1831 bool return_suppressed, 1832 TALER_AUDITORDB_FeeTimeInconsistencyCallback cb, 1833 void *cb_cls); 1834 1835 1836 enum GNUNET_DB_QueryStatus 1837 (*delete_fee_time_inconsistency)( 1838 void *cls, 1839 uint64_t row_id); 1840 1841 1842 enum GNUNET_DB_QueryStatus 1843 (*insert_fee_time_inconsistency)( 1844 void *cls, 1845 const struct TALER_AUDITORDB_FeeTimeInconsistency *dc); 1846 1847 /** 1848 * Insert information about a reserve. There must not be an 1849 * existing record for the reserve. 1850 * 1851 * @param cls the @e cls of this struct with the plugin-specific state 1852 * @param reserve_pub public key of the reserve 1853 * @param rfb balance amounts for the reserve 1854 * @param expiration_date expiration date of the reserve 1855 * @param origin_account where did the money in the reserve originally come from 1856 * @return transaction status code 1857 */ 1858 enum GNUNET_DB_QueryStatus 1859 (*insert_reserve_info)( 1860 void *cls, 1861 const struct TALER_ReservePublicKeyP *reserve_pub, 1862 const struct TALER_AUDITORDB_ReserveFeeBalance *rfb, 1863 struct GNUNET_TIME_Timestamp expiration_date, 1864 const struct TALER_FullPayto origin_account); 1865 1866 1867 /** 1868 * Update information about a reserve. Destructively updates an 1869 * existing record, which must already exist. 1870 * 1871 * @param cls the @e cls of this struct with the plugin-specific state 1872 * @param reserve_pub public key of the reserve 1873 * @param rfb balance amounts for the reserve 1874 * @param expiration_date expiration date of the reserve 1875 * @return transaction status code 1876 */ 1877 enum GNUNET_DB_QueryStatus 1878 (*update_reserve_info)( 1879 void *cls, 1880 const struct TALER_ReservePublicKeyP *reserve_pub, 1881 const struct TALER_AUDITORDB_ReserveFeeBalance *rfb, 1882 struct GNUNET_TIME_Timestamp expiration_date); 1883 1884 1885 /** 1886 * Get information about a reserve. 1887 * 1888 * @param cls the @e cls of this struct with the plugin-specific state 1889 * @param reserve_pub public key of the reserve 1890 * @param[out] rowid which row did we get the information from 1891 * @param[out] rfb set to balances associated with the reserve 1892 * @param[out] expiration_date expiration date of the reserve 1893 * @param[out] sender_account from where did the money in the reserve originally come from 1894 * @return transaction status code 1895 */ 1896 enum GNUNET_DB_QueryStatus 1897 (*get_reserve_info)( 1898 void *cls, 1899 const struct TALER_ReservePublicKeyP *reserve_pub, 1900 uint64_t *rowid, 1901 struct TALER_AUDITORDB_ReserveFeeBalance *rfb, 1902 struct GNUNET_TIME_Timestamp *expiration_date, 1903 struct TALER_FullPayto *sender_account); 1904 1905 1906 /** 1907 * Delete information about a reserve. 1908 * 1909 * @param cls the @e cls of this struct with the plugin-specific state 1910 * @param reserve_pub public key of the reserve 1911 * @return transaction status code 1912 */ 1913 enum GNUNET_DB_QueryStatus 1914 (*del_reserve_info)(void *cls, 1915 const struct TALER_ReservePublicKeyP *reserve_pub); 1916 1917 1918 /** 1919 * Insert new row into the early aggregation table. This can happen simply 1920 * because of when the taler-helper-auditor-transfer looks at which of the 1921 * two tables. If it is cleared in the next iteration, this is perfectly 1922 * expected. 1923 * 1924 * @param cls the @e cls of this struct with the plugin-specific state 1925 * @param batch_deposit_serial_id where in the batch deposit table are we 1926 * @param tracking_serial_id where in the tracking table are we 1927 * @param total_amount value of all missing deposits, including fees 1928 * @return transaction status code 1929 */ 1930 enum GNUNET_DB_QueryStatus 1931 (*insert_early_aggregation)( 1932 void *cls, 1933 uint64_t batch_deposit_serial_id, 1934 uint64_t tracking_serial_id, 1935 const struct TALER_Amount *total_amount); 1936 1937 1938 /** 1939 * Delete a row from the early aggregation table. 1940 * Usually done when the expected aggregation 1941 * was finally detected. 1942 * 1943 * @param cls the @e cls of this struct with the plugin-specific state 1944 * @param batch_deposit_serial_id which entry to delete 1945 * @return transaction status code 1946 */ 1947 enum GNUNET_DB_QueryStatus 1948 (*delete_early_aggregation)( 1949 void *cls, 1950 uint64_t batch_deposit_serial_id); 1951 1952 1953 /** 1954 * Insert new row into the pending deposits table. 1955 * 1956 * @param cls the @e cls of this struct with the plugin-specific state 1957 * @param batch_deposit_serial_id where in the table are we 1958 * @param total_amount value of all missing deposits, including fees 1959 * @param wire_target_h_payto hash of the recipient account's payto URI 1960 * @param deadline what was the requested wire transfer deadline 1961 * @return transaction status code 1962 */ 1963 enum GNUNET_DB_QueryStatus 1964 (*insert_pending_deposit)( 1965 void *cls, 1966 uint64_t batch_deposit_serial_id, 1967 const struct TALER_FullPaytoHashP *wire_target_h_payto, 1968 const struct TALER_Amount *total_amount, 1969 struct GNUNET_TIME_Timestamp deadline); 1970 1971 1972 /** 1973 * Delete a row from the pending deposit table. 1974 * Usually done when the respective wire transfer 1975 * was finally detected. 1976 * 1977 * @param cls the @e cls of this struct with the plugin-specific state 1978 * @param batch_deposit_serial_id which entry to delete 1979 * @return transaction status code 1980 */ 1981 enum GNUNET_DB_QueryStatus 1982 (*delete_pending_deposit)( 1983 void *cls, 1984 uint64_t batch_deposit_serial_id); 1985 1986 1987 /** 1988 * Return (batch) deposits for which we have not yet 1989 * seen the required wire transfer. 1990 * 1991 * @param deadline only return up to this deadline 1992 * @param limit number of rows to return, negative to iterate backwards 1993 * @param offset starting offset, exclusive 1994 * @param return_suppressed true to also return suppressed events 1995 * @param cb function to call on each entry 1996 * @param cb_cls closure for @a cb 1997 * @return transaction status code 1998 */ 1999 enum GNUNET_DB_QueryStatus 2000 (*select_pending_deposits)( 2001 void *cls, 2002 struct GNUNET_TIME_Absolute deadline, 2003 int64_t limit, 2004 uint64_t offset, 2005 bool return_suppressed, 2006 TALER_AUDITORDB_WireMissingCallback cb, 2007 void *cb_cls); 2008 2009 2010 /** 2011 * Insert information about a purse. There must not be an 2012 * existing record for the purse. 2013 * 2014 * @param cls the @e cls of this struct with the plugin-specific state 2015 * @param purse_pub public key of the purse 2016 * @param balance balance of the purse 2017 * @param expiration_date expiration date of the purse 2018 * @return transaction status code 2019 */ 2020 enum GNUNET_DB_QueryStatus 2021 (*insert_purse_info)( 2022 void *cls, 2023 const struct TALER_PurseContractPublicKeyP *purse_pub, 2024 const struct TALER_Amount *balance, 2025 struct GNUNET_TIME_Timestamp expiration_date); 2026 2027 2028 /** 2029 * Update information about a purse. Destructively updates an 2030 * existing record, which must already exist. 2031 * 2032 * @param cls the @e cls of this struct with the plugin-specific state 2033 * @param purse_pub public key of the purse 2034 * @param balance new balance for the purse 2035 * @return transaction status code 2036 */ 2037 enum GNUNET_DB_QueryStatus 2038 (*update_purse_info)( 2039 void *cls, 2040 const struct TALER_PurseContractPublicKeyP *purse_pub, 2041 const struct TALER_Amount *balance); 2042 2043 2044 /** 2045 * Get information about a purse. 2046 * 2047 * @param cls the @e cls of this struct with the plugin-specific state 2048 * @param purse_pub public key of the purse 2049 * @param[out] rowid which row did we get the information from 2050 * @param[out] balance set to balance of the purse 2051 * @param[out] expiration_date expiration date of the purse 2052 * @return transaction status code 2053 */ 2054 enum GNUNET_DB_QueryStatus 2055 (*get_purse_info)( 2056 void *cls, 2057 const struct TALER_PurseContractPublicKeyP *purse_pub, 2058 uint64_t *rowid, 2059 struct TALER_Amount *balance, 2060 struct GNUNET_TIME_Timestamp *expiration_date); 2061 2062 2063 /** 2064 * Delete information about a purse. 2065 * 2066 * @param cls the @e cls of this struct with the plugin-specific state 2067 * @param purse_pub public key of the reserve 2068 * @return transaction status code 2069 */ 2070 enum GNUNET_DB_QueryStatus 2071 (*delete_purse_info)( 2072 void *cls, 2073 const struct TALER_PurseContractPublicKeyP *purse_pub); 2074 2075 2076 /** 2077 * Get information about expired purses. 2078 * 2079 * @param cls the @e cls of this struct with the plugin-specific state 2080 * @param cb function to call on expired purses 2081 * @param cb_cls closure for @a cb 2082 * @return transaction status code 2083 */ 2084 enum GNUNET_DB_QueryStatus 2085 (*select_purse_expired)( 2086 void *cls, 2087 TALER_AUDITORDB_ExpiredPurseCallback cb, 2088 void *cb_cls); 2089 2090 2091 /** 2092 * Insert information about a denomination key's balances. There 2093 * must not be an existing record for the denomination key. 2094 * 2095 * @param cls the @e cls of this struct with the plugin-specific state 2096 * @param denom_pub_hash hash of the denomination public key 2097 * @param dcd denomination circulation data to store 2098 * @return transaction status code 2099 */ 2100 enum GNUNET_DB_QueryStatus 2101 (*insert_denomination_balance)( 2102 void *cls, 2103 const struct TALER_DenominationHashP *denom_pub_hash, 2104 const struct TALER_AUDITORDB_DenominationCirculationData *dcd); 2105 2106 2107 /** 2108 * Update information about a denomination key's balances. There 2109 * must be an existing record for the denomination key. 2110 * 2111 * @param cls the @e cls of this struct with the plugin-specific state 2112 * @param denom_pub_hash hash of the denomination public key 2113 * @param dcd denomination circulation data to store 2114 * @return transaction status code 2115 */ 2116 enum GNUNET_DB_QueryStatus 2117 (*update_denomination_balance)( 2118 void *cls, 2119 const struct TALER_DenominationHashP *denom_pub_hash, 2120 const struct TALER_AUDITORDB_DenominationCirculationData *dcd); 2121 2122 /** 2123 * Delete information about a denomination key's balances. 2124 * 2125 * @param cls the @e cls of this struct with the plugin-specific state 2126 * @param denom_pub_hash hash of the denomination public key 2127 * @return transaction status code 2128 */ 2129 enum GNUNET_DB_QueryStatus 2130 (*del_denomination_balance)( 2131 void *cls, 2132 const struct TALER_DenominationHashP *denom_pub_hash); 2133 2134 2135 /** 2136 * Get information about a denomination key's balances. 2137 * 2138 * @param cls the @e cls of this struct with the plugin-specific state 2139 * @param denom_pub_hash hash of the denomination public key 2140 * @param[out] dcd denomination circulation data to initialize 2141 * @return transaction status code 2142 */ 2143 enum GNUNET_DB_QueryStatus 2144 (*get_denomination_balance)( 2145 void *cls, 2146 const struct TALER_DenominationHashP *denom_pub_hash, 2147 struct TALER_AUDITORDB_DenominationCirculationData *dcd); 2148 2149 2150 /** 2151 * Insert information about an exchange's historic 2152 * revenue about a denomination key. 2153 * 2154 * @param cls the @e cls of this struct with the plugin-specific state 2155 * @param denom_pub_hash hash of the denomination key 2156 * @param revenue_timestamp when did this profit get realized 2157 * @param revenue_balance what was the total profit made from 2158 * deposit fees, melting fees, refresh fees 2159 * and coins that were never returned? 2160 * @param recoup_loss_balance total losses from recoups of revoked denominations 2161 * @return transaction status code 2162 */ 2163 enum GNUNET_DB_QueryStatus 2164 (*insert_historic_denom_revenue)( 2165 void *cls, 2166 const struct TALER_DenominationHashP *denom_pub_hash, 2167 struct GNUNET_TIME_Timestamp revenue_timestamp, 2168 const struct TALER_Amount *revenue_balance, 2169 const struct TALER_Amount *recoup_loss_balance); 2170 2171 2172 /** 2173 * Obtain all of the historic denomination key revenue. 2174 * 2175 * @param cls the @e cls of this struct with the plugin-specific state 2176 * @param cb function to call with the results 2177 * @param cb_cls closure for @a cb 2178 * @return transaction status code 2179 */ 2180 enum GNUNET_DB_QueryStatus 2181 (*select_historic_denom_revenue)( 2182 void *cls, 2183 int64_t limit, 2184 uint64_t offset, 2185 TALER_AUDITORDB_HistoricDenominationRevenueDataCallback cb, 2186 void *cb_cls); 2187 2188 2189 /** 2190 * Insert information about an exchange's historic revenue from reserves. 2191 * 2192 * @param cls the @e cls of this struct with the plugin-specific state 2193 * @param start_time beginning of aggregated time interval 2194 * @param end_time end of aggregated time interval 2195 * @param reserve_profits total profits made 2196 * @return transaction status code 2197 */ 2198 enum GNUNET_DB_QueryStatus 2199 (*insert_historic_reserve_revenue)( 2200 void *cls, 2201 struct GNUNET_TIME_Timestamp start_time, 2202 struct GNUNET_TIME_Timestamp end_time, 2203 const struct TALER_Amount *reserve_profits); 2204 2205 2206 /** 2207 * Return information about an exchange's historic revenue from reserves. 2208 * 2209 * @param cls the @e cls of this struct with the plugin-specific state 2210 * @param limit number of rows to return, negative to iterate backwards 2211 * @param offset starting offset, exclusive 2212 * @param cb function to call with results 2213 * @param cb_cls closure for @a cb 2214 * @return transaction status code 2215 */ 2216 enum GNUNET_DB_QueryStatus 2217 (*select_historic_reserve_revenue)( 2218 void *cls, 2219 int64_t limit, 2220 uint64_t offset, 2221 TALER_AUDITORDB_HistoricReserveRevenueDataCallback cb, 2222 void *cb_cls); 2223 2224 }; 2225 2226 2227 #endif /* _TALER_AUDITOR_DB_H */