2020-03-20 22:34:17 +01:00
|
|
|
/*
|
|
|
|
This file is part of TALER
|
|
|
|
Copyright (C) 2016-2020 Taler Systems SA
|
|
|
|
|
|
|
|
TALER is free software; you can redistribute it and/or modify it under the
|
|
|
|
terms of the GNU Affero 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 Affero Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero Public License along with
|
|
|
|
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* @file auditor/report-lib.h
|
|
|
|
* @brief helper library to facilitate generation of audit reports
|
|
|
|
* @author Christian Grothoff
|
|
|
|
*/
|
|
|
|
#ifndef REPORT_LIB_H
|
|
|
|
#define REPORT_LIB_H
|
|
|
|
|
|
|
|
#include <gnunet/gnunet_util_lib.h>
|
|
|
|
#include "taler_auditordb_plugin.h"
|
|
|
|
#include "taler_exchangedb_lib.h"
|
|
|
|
#include "taler_json_lib.h"
|
|
|
|
#include "taler_bank_service.h"
|
|
|
|
#include "taler_signatures.h"
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2020-03-21 11:05:51 +01:00
|
|
|
* Command-line option "-r": TALER_ARL_restart audit from scratch
|
2020-03-20 22:34:17 +01:00
|
|
|
*/
|
2020-03-21 11:05:51 +01:00
|
|
|
extern int TALER_ARL_restart;
|
2020-03-20 22:34:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle to access the exchange's database.
|
|
|
|
*/
|
2020-03-21 11:05:51 +01:00
|
|
|
extern struct TALER_EXCHANGEDB_Plugin *TALER_ARL_edb;
|
2020-03-20 22:34:17 +01:00
|
|
|
|
|
|
|
/**
|
2020-03-21 11:05:51 +01:00
|
|
|
* Which TALER_ARL_currency are we doing the audit for?
|
2020-03-20 22:34:17 +01:00
|
|
|
*/
|
2020-03-21 11:05:51 +01:00
|
|
|
extern char *TALER_ARL_currency;
|
2020-03-20 22:34:17 +01:00
|
|
|
|
|
|
|
/**
|
2020-03-21 11:05:51 +01:00
|
|
|
* How many fractional digits does the TALER_ARL_currency use?
|
2020-03-20 22:34:17 +01:00
|
|
|
*/
|
2020-03-21 11:05:51 +01:00
|
|
|
extern struct TALER_Amount TALER_ARL_currency_round_unit;
|
2020-03-20 22:34:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Our configuration.
|
|
|
|
*/
|
2020-03-21 11:05:51 +01:00
|
|
|
extern const struct GNUNET_CONFIGURATION_Handle *TALER_ARL_cfg;
|
2020-03-20 22:34:17 +01:00
|
|
|
|
|
|
|
/**
|
2020-03-21 11:05:51 +01:00
|
|
|
* Our session with the #TALER_ARL_edb.
|
2020-03-20 22:34:17 +01:00
|
|
|
*/
|
2020-03-21 11:05:51 +01:00
|
|
|
extern struct TALER_EXCHANGEDB_Session *TALER_ARL_esession;
|
2020-03-20 22:34:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle to access the auditor's database.
|
|
|
|
*/
|
2020-03-21 11:05:51 +01:00
|
|
|
extern struct TALER_AUDITORDB_Plugin *TALER_ARL_adb;
|
2020-03-20 22:34:17 +01:00
|
|
|
|
|
|
|
/**
|
2020-03-21 11:05:51 +01:00
|
|
|
* Our session with the #TALER_ARL_adb.
|
2020-03-20 22:34:17 +01:00
|
|
|
*/
|
2020-03-21 11:05:51 +01:00
|
|
|
extern struct TALER_AUDITORDB_Session *TALER_ARL_asession;
|
2020-03-20 22:34:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Master public key of the exchange to audit.
|
|
|
|
*/
|
2020-03-21 11:05:51 +01:00
|
|
|
extern struct TALER_MasterPublicKeyP TALER_ARL_master_pub;
|
2020-03-20 22:34:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* At what time did the auditor process start?
|
|
|
|
*/
|
|
|
|
extern struct GNUNET_TIME_Absolute start_time;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert absolute time to human-readable JSON string.
|
|
|
|
*
|
|
|
|
* @param at time to convert
|
|
|
|
* @return human-readable string representing the time
|
|
|
|
*/
|
|
|
|
json_t *
|
2020-03-21 11:05:51 +01:00
|
|
|
TALER_ARL_TALER_ARL_json_from_time_abs_nbo (struct GNUNET_TIME_AbsoluteNBO at);
|
2020-03-20 22:34:17 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert absolute time to human-readable JSON string.
|
|
|
|
*
|
|
|
|
* @param at time to convert
|
|
|
|
* @return human-readable string representing the time
|
|
|
|
*/
|
|
|
|
json_t *
|
2020-03-21 11:05:51 +01:00
|
|
|
TALER_ARL_json_from_time_abs (struct GNUNET_TIME_Absolute at);
|
2020-03-20 22:34:17 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2020-03-21 11:05:51 +01:00
|
|
|
* Add @a object to the TALER_ARL_report @a array. Fail hard if this fails.
|
2020-03-20 22:34:17 +01:00
|
|
|
*
|
2020-03-21 11:05:51 +01:00
|
|
|
* @param array TALER_ARL_report array to append @a object to
|
2020-03-20 22:34:17 +01:00
|
|
|
* @param object object to append, should be check that it is not NULL
|
|
|
|
*/
|
|
|
|
void
|
2020-03-21 11:05:51 +01:00
|
|
|
TALER_ARL_report (json_t *array,
|
|
|
|
json_t *object);
|
2020-03-20 22:34:17 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Obtain information about a @a denom_pub.
|
|
|
|
*
|
|
|
|
* @param dh hash of the denomination public key to look up
|
|
|
|
* @param[out] issue set to detailed information about @a denom_pub, NULL if not found, must
|
|
|
|
* NOT be freed by caller
|
2020-03-21 11:05:51 +01:00
|
|
|
* @return TALER_ARL_transaction status code
|
2020-03-20 22:34:17 +01:00
|
|
|
*/
|
|
|
|
enum GNUNET_DB_QueryStatus
|
2020-03-21 11:05:51 +01:00
|
|
|
TALER_ARL_get_denomination_info_by_hash (
|
2020-03-20 22:34:17 +01:00
|
|
|
const struct GNUNET_HashCode *dh,
|
|
|
|
const struct TALER_DenominationKeyValidityPS **issue);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Obtain information about a @a denom_pub.
|
|
|
|
*
|
|
|
|
* @param denom_pub key to look up
|
|
|
|
* @param[out] issue set to detailed information about @a denom_pub, NULL if not found, must
|
|
|
|
* NOT be freed by caller
|
|
|
|
* @param[out] dh set to the hash of @a denom_pub, may be NULL
|
2020-03-21 11:05:51 +01:00
|
|
|
* @return TALER_ARL_transaction status code
|
2020-03-20 22:34:17 +01:00
|
|
|
*/
|
|
|
|
enum GNUNET_DB_QueryStatus
|
2020-03-21 11:05:51 +01:00
|
|
|
TALER_ARL_get_denomination_info (
|
2020-03-20 22:34:17 +01:00
|
|
|
const struct TALER_DenominationPublicKey *denom_pub,
|
|
|
|
const struct TALER_DenominationKeyValidityPS **issue,
|
|
|
|
struct GNUNET_HashCode *dh);
|
|
|
|
|
2020-03-21 11:05:51 +01:00
|
|
|
|
2020-03-20 22:34:17 +01:00
|
|
|
/**
|
|
|
|
* Type of an analysis function. Each analysis function runs in
|
|
|
|
* its own transaction scope and must thus be internally consistent.
|
|
|
|
*
|
|
|
|
* @param cls closure
|
|
|
|
* @return transaction status code
|
|
|
|
*/
|
|
|
|
typedef enum GNUNET_DB_QueryStatus
|
2020-03-21 11:05:51 +01:00
|
|
|
(*TALER_ARL_Analysis)(void *cls);
|
2020-03-20 22:34:17 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize DB sessions and run the analysis.
|
|
|
|
*
|
|
|
|
* @param ana analysis to run
|
|
|
|
* @param ana_cls closure for @ana
|
|
|
|
* @return #GNUNET_OK on success
|
|
|
|
*/
|
|
|
|
int
|
2020-03-21 11:05:51 +01:00
|
|
|
TALER_ARL_setup_sessions_and_run (TALER_ARL_Analysis ana,
|
|
|
|
void *ana_cls);
|
2020-03-20 22:34:17 +01:00
|
|
|
|
|
|
|
|
2020-03-21 11:05:51 +01:00
|
|
|
/**
|
|
|
|
* Setup global variables based on configuration.
|
|
|
|
*
|
|
|
|
* @param c configuration to use
|
|
|
|
* @return #GNUNET_OK on success
|
|
|
|
*/
|
2020-03-20 22:34:17 +01:00
|
|
|
int
|
2020-03-21 11:05:51 +01:00
|
|
|
TALER_ARL_init (const struct GNUNET_CONFIGURATION_Handle *c);
|
2020-03-20 22:34:17 +01:00
|
|
|
|
|
|
|
|
2020-03-21 11:05:51 +01:00
|
|
|
/**
|
|
|
|
* Generate the report and close connectios to the database.
|
|
|
|
*
|
|
|
|
* @param report the report to output, may be NULL for no report
|
|
|
|
*/
|
2020-03-20 22:34:17 +01:00
|
|
|
void
|
2020-03-21 11:05:51 +01:00
|
|
|
TALER_ARL_done (json_t *report);
|
2020-03-20 22:34:17 +01:00
|
|
|
|
|
|
|
#endif
|