-more json_pack cleaning

This commit is contained in:
Christian Grothoff 2021-07-31 21:40:48 +02:00
parent 1d54400a02
commit fde9dc80f6
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
12 changed files with 902 additions and 888 deletions

View File

@ -113,35 +113,6 @@ TALER_ARL_do_abort (void)
}
/**
* Convert absolute time to human-readable JSON string.
*
* @param at time to convert
* @return human-readable string representing the time
*/
json_t *
TALER_ARL_json_from_time_abs_nbo (struct GNUNET_TIME_AbsoluteNBO at)
{
return json_string
(GNUNET_STRINGS_absolute_time_to_string
(GNUNET_TIME_absolute_ntoh (at)));
}
/**
* Convert absolute time to human-readable JSON string.
*
* @param at time to convert
* @return human-readable string representing the time
*/
json_t *
TALER_ARL_json_from_time_abs (struct GNUNET_TIME_Absolute at)
{
return json_string
(GNUNET_STRINGS_absolute_time_to_string (at));
}
/**
* Add @a object to the report @a array. Fail hard if this fails.
*

View File

@ -90,26 +90,6 @@ extern char *TALER_ARL_auditor_url;
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 *
TALER_ARL_json_from_time_abs_nbo (struct GNUNET_TIME_AbsoluteNBO at);
/**
* Convert absolute time to human-readable JSON string.
*
* @param at time to convert
* @return human-readable string representing the time
*/
json_t *
TALER_ARL_json_from_time_abs (struct GNUNET_TIME_Absolute at);
/**
* Add @a object to the report @a array. Fail hard if this fails.
*

View File

@ -1,6 +1,6 @@
/*
This file is part of TALER
Copyright (C) 2014-2020 Taler Systems SA
Copyright (C) 2014-2021 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
@ -323,10 +323,12 @@ handle_version (struct TAH_RequestHandler *rh,
(void) connection_cls;
if (NULL == ver)
{
ver = json_pack ("{s:s, s:s, s:o}",
"version", AUDITOR_PROTOCOL_VERSION,
"currency", TAH_currency,
"auditor_public_key", GNUNET_JSON_from_data_auto (
ver = GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("version",
AUDITOR_PROTOCOL_VERSION),
GNUNET_JSON_pack_string ("currency",
TAH_currency),
GNUNET_JSON_pack_data_auto ("auditor_public_key",
&auditor_pub));
}
if (NULL == ver)

View File

@ -228,10 +228,10 @@ verify_and_execute_deposit_confirmation (
TALER_EC_GENERIC_DB_STORE_FAILED,
"deposit confirmation");
}
return TALER_MHD_reply_json_pack (connection,
return TALER_MHD_REPLY_JSON_PACK (connection,
MHD_HTTP_OK,
"{s:s}",
"status", "DEPOSIT_CONFIRMATION_OK");
GNUNET_JSON_pack_string ("status",
"DEPOSIT_CONFIRMATION_OK"));
}

View File

@ -1,6 +1,6 @@
/*
This file is part of TALER
Copyright (C) 2014-2020 Taler Systems SA
Copyright (C) 2014-2021 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
@ -45,12 +45,11 @@ add_exchange (void *cls,
json_t *list = cls;
json_t *obj;
obj = json_pack ("{s:o, s:s}",
"master_pub",
GNUNET_JSON_from_data_auto (master_pub),
"exchange_url",
exchange_url);
GNUNET_break (NULL != obj);
obj = GNUNET_JSON_PACK (
GNUNET_JSON_pack_data_auto ("master_pub",
master_pub),
GNUNET_JSON_pack_string ("exchange_url",
exchange_url));
GNUNET_break (0 ==
json_array_append_new (list,
obj));
@ -108,10 +107,11 @@ TAH_EXCHANGES_handler (struct TAH_RequestHandler *rh,
TALER_EC_GENERIC_DB_FETCH_FAILED,
"exchanges");
}
return TALER_MHD_reply_json_pack (connection,
return TALER_MHD_REPLY_JSON_PACK (
connection,
MHD_HTTP_OK,
"{s:o}",
"exchanges", ja);
GNUNET_JSON_pack_array_steal ("exchanges",
ja));
}

View File

@ -1,6 +1,6 @@
/*
This file is part of TALER
Copyright (C) 2016-2020 Taler Systems SA
Copyright (C) 2016-2021 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
@ -163,12 +163,17 @@ report_amount_arithmetic_inconsistency (
exchange);
}
TALER_ARL_report (report_amount_arithmetic_inconsistencies,
json_pack ("{s:s, s:I, s:o, s:o, s:I}",
"operation", operation,
"rowid", (json_int_t) rowid,
"exchange", TALER_JSON_from_amount (exchange),
"auditor", TALER_JSON_from_amount (auditor),
"profitable", (json_int_t) profitable));
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("operation",
operation),
GNUNET_JSON_pack_uint64 ("rowid",
rowid),
TALER_JSON_pack_amount ("exchange",
exchange),
TALER_JSON_pack_amount ("auditor",
auditor),
GNUNET_JSON_pack_int64 ("profitable",
profitable)));
if (0 != profitable)
{
target = (1 == profitable)
@ -222,13 +227,17 @@ report_coin_arithmetic_inconsistency (
exchange);
}
TALER_ARL_report (report_coin_inconsistencies,
json_pack ("{s:s, s:o, s:o, s:o, s:I}",
"operation", operation,
"coin_pub", GNUNET_JSON_from_data_auto (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("operation",
operation),
GNUNET_JSON_pack_data_auto ("coin_pub",
coin_pub),
"exchange", TALER_JSON_from_amount (exchange),
"auditor", TALER_JSON_from_amount (auditor),
"profitable", (json_int_t) profitable));
TALER_JSON_pack_amount ("exchange",
exchange),
TALER_JSON_pack_amount ("auditor",
auditor),
GNUNET_JSON_pack_int64 ("profitable",
profitable)));
if (0 != profitable)
{
target = (1 == profitable)
@ -254,10 +263,13 @@ report_row_inconsistency (const char *table,
const char *diagnostic)
{
TALER_ARL_report (report_row_inconsistencies,
json_pack ("{s:s, s:I, s:s}",
"table", table,
"row", (json_int_t) rowid,
"diagnostic", diagnostic));
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("table",
table),
GNUNET_JSON_pack_uint64 ("row",
rowid),
GNUNET_JSON_pack_string ("diagnostic",
diagnostic)));
}
@ -797,11 +809,14 @@ wire_transfer_information_cb (
denom_pub))
{
TALER_ARL_report (report_bad_sig_losses,
json_pack ("{s:s, s:I, s:o, s:o}",
"operation", "wire",
"row", (json_int_t) rowid,
"loss", TALER_JSON_from_amount (coin_value),
"coin_pub", GNUNET_JSON_from_data_auto (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("operation",
"wire"),
GNUNET_JSON_pack_uint64 ("row",
rowid),
TALER_JSON_pack_amount ("loss",
coin_value),
GNUNET_JSON_pack_data_auto ("coin_pub",
&coin.coin_pub)));
TALER_ARL_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss,
@ -985,22 +1000,24 @@ get_wire_fee (struct AggregationContext *ac,
(wfi->prev->end_date.abs_value_us > wfi->start_date.abs_value_us) )
{
TALER_ARL_report (report_fee_time_inconsistencies,
json_pack ("{s:s, s:s, s:o}",
"type", method,
"diagnostic",
"start date before previous end date",
"time", TALER_ARL_json_from_time_abs (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("type",
method),
GNUNET_JSON_pack_string ("diagnostic",
"start date before previous end date"),
TALER_JSON_pack_time_abs_human ("time",
wfi->start_date)));
}
if ( (NULL != wfi->next) &&
(wfi->next->start_date.abs_value_us >= wfi->end_date.abs_value_us) )
{
TALER_ARL_report (report_fee_time_inconsistencies,
json_pack ("{s:s, s:s, s:o}",
"type", method,
"diagnostic",
"end date date after next start date",
"time", TALER_ARL_json_from_time_abs (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("type",
method),
GNUNET_JSON_pack_string ("diagnostic",
"end date date after next start date"),
TALER_JSON_pack_time_abs_human ("time",
wfi->end_date)));
}
return &wfi->wire_fee;
@ -1164,13 +1181,15 @@ check_wire_out_cb (void *cls,
}
TALER_ARL_report (report_wire_out_inconsistencies,
json_pack ("{s:O, s:I, s:o, s:o}",
"destination_account", wire,
"rowid", (json_int_t) rowid,
"expected",
TALER_JSON_from_amount (&final_amount),
"claimed",
TALER_JSON_from_amount (amount)));
GNUNET_JSON_PACK (
GNUNET_JSON_pack_object_incref ("destination_account",
(json_t *) wire),
GNUNET_JSON_pack_uint64 ("rowid",
rowid),
TALER_JSON_pack_amount ("expected",
&final_amount),
TALER_JSON_pack_amount ("claimed",
amount)));
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
return GNUNET_OK;
@ -1323,8 +1342,6 @@ run (void *cls,
const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *c)
{
json_t *report;
(void) cls;
(void) args;
(void) cfgfile;
@ -1333,7 +1350,7 @@ run (void *cls,
if (GNUNET_OK !=
TALER_ARL_init (c))
{
global_ret = 1;
global_ret = EXIT_FAILURE;
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@ -1387,71 +1404,71 @@ run (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Audit failed\n");
TALER_ARL_done (NULL);
global_ret = 1;
global_ret = EXIT_FAILURE;
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Audit complete\n");
report = json_pack ("{s:o, s:o, s:o, s:o, s:o,"
" s:o, s:o, s:o, s:o, s:o,"
" s:o, s:o, s:o, s:I, s:I,"
" s:o, s:o, s:o }",
TALER_ARL_done (GNUNET_JSON_PACK (
/* blocks #1 */
GNUNET_JSON_pack_array_steal (
"wire_out_inconsistencies",
report_wire_out_inconsistencies,
report_wire_out_inconsistencies),
/* Tested in test-auditor.sh #23 */
TALER_JSON_pack_amount (
"total_wire_out_delta_plus",
TALER_JSON_from_amount (
&total_wire_out_delta_plus),
/* Tested in test-auditor.sh #23 */
TALER_JSON_pack_amount (
"total_wire_out_delta_minus",
TALER_JSON_from_amount (
&total_wire_out_delta_minus),
/* Tested in test-auditor.sh #28/32 */
"bad_sig_losses",
report_bad_sig_losses,
GNUNET_JSON_pack_array_steal ("bad_sig_losses",
report_bad_sig_losses),
/* Tested in test-auditor.sh #28/32 */
"total_bad_sig_loss",
TALER_JSON_from_amount (&total_bad_sig_loss),
TALER_JSON_pack_amount ("total_bad_sig_loss",
&total_bad_sig_loss),
/* block #2 */
/* Tested in test-auditor.sh #15 */
GNUNET_JSON_pack_array_steal (
"row_inconsistencies",
report_row_inconsistencies,
report_row_inconsistencies),
GNUNET_JSON_pack_array_steal (
"coin_inconsistencies",
report_coin_inconsistencies,
"total_coin_delta_plus",
TALER_JSON_from_amount (&total_coin_delta_plus),
"total_coin_delta_minus",
TALER_JSON_from_amount (
report_coin_inconsistencies),
TALER_JSON_pack_amount ("total_coin_delta_plus",
&total_coin_delta_plus),
TALER_JSON_pack_amount ("total_coin_delta_minus",
&total_coin_delta_minus),
GNUNET_JSON_pack_array_steal (
"amount_arithmetic_inconsistencies",
report_amount_arithmetic_inconsistencies,
report_amount_arithmetic_inconsistencies),
/* block #3 */
TALER_JSON_pack_amount (
"total_arithmetic_delta_plus",
TALER_JSON_from_amount (
&total_arithmetic_delta_plus),
TALER_JSON_pack_amount (
"total_arithmetic_delta_minus",
TALER_JSON_from_amount (
&total_arithmetic_delta_minus),
TALER_JSON_pack_amount (
"total_aggregation_fee_income",
TALER_JSON_from_amount (
&total_aggregation_fee_income),
GNUNET_JSON_pack_uint64 (
"start_ppa_wire_out_serial_id",
(json_int_t) ppa_start.last_wire_out_serial_id,
ppa_start.last_wire_out_serial_id),
GNUNET_JSON_pack_uint64 (
"end_ppa_wire_out_serial_id",
(json_int_t) ppa.last_wire_out_serial_id,
ppa.last_wire_out_serial_id),
/* block #4 */
TALER_JSON_pack_time_abs_human (
"auditor_start_time",
TALER_ARL_json_from_time_abs (
start_time),
TALER_JSON_pack_time_abs_human (
"auditor_end_time",
TALER_ARL_json_from_time_abs (
GNUNET_TIME_absolute_get ()),
GNUNET_JSON_pack_array_steal (
"wire_fee_time_inconsistencies",
report_fee_time_inconsistencies
);
GNUNET_break (NULL != report);
TALER_ARL_done (report);
report_fee_time_inconsistencies)));
}
@ -1489,7 +1506,7 @@ main (int argc,
if (GNUNET_OK !=
GNUNET_STRINGS_get_utf8_args (argc, argv,
&argc, &argv))
return 4;
return EXIT_INVALIDARGUMENT;
ret = GNUNET_PROGRAM_run (
argc,
argv,
@ -1500,9 +1517,9 @@ main (int argc,
NULL);
GNUNET_free_nz ((void *) argv);
if (GNUNET_SYSERR == ret)
return 3;
return EXIT_INVALIDARGUMENT;
if (GNUNET_NO == ret)
return 0;
return EXIT_SUCCESS;
return global_ret;
}

View File

@ -1,6 +1,6 @@
/*
This file is part of TALER
Copyright (C) 2016-2020 Taler Systems SA
Copyright (C) 2016-2021 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
@ -285,21 +285,19 @@ report_emergency_by_amount (
GNUNET_h2s (&issue->denom_hash),
TALER_amount2s (loss));
TALER_ARL_report (report_emergencies,
json_pack ("{s:o, s:o, s:o, s:o, s:o, s:o}",
"denompub_hash",
GNUNET_JSON_from_data_auto (&issue->denom_hash),
"denom_risk",
TALER_JSON_from_amount (risk),
"denom_loss",
TALER_JSON_from_amount (loss),
"start",
TALER_ARL_json_from_time_abs_nbo (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_data_auto ("denompub_hash",
&issue->denom_hash),
TALER_JSON_pack_amount ("denom_risk",
risk),
TALER_JSON_pack_amount ("denom_loss",
loss),
TALER_JSON_pack_time_abs_nbo_human ("start",
issue->start),
"deposit_end",
TALER_ARL_json_from_time_abs_nbo (
TALER_JSON_pack_time_abs_nbo_human ("deposit_end",
issue->expire_deposit),
"value",
TALER_JSON_from_amount_nbo (&issue->value)));
TALER_JSON_pack_amount_nbo ("value",
&issue->value)));
TALER_ARL_amount_add (&reported_emergency_risk_by_amount,
&reported_emergency_risk_by_amount,
risk);
@ -333,23 +331,21 @@ report_emergency_by_count (
struct TALER_Amount denom_value;
TALER_ARL_report (report_emergencies_by_count,
json_pack ("{s:o, s:I, s:I, s:o, s:o, s:o, s:o}",
"denompub_hash",
GNUNET_JSON_from_data_auto (&issue->denom_hash),
"num_issued",
(json_int_t) num_issued,
"num_known",
(json_int_t) num_known,
"denom_risk",
TALER_JSON_from_amount (risk),
"start",
TALER_ARL_json_from_time_abs_nbo (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_data_auto ("denompub_hash",
&issue->denom_hash),
GNUNET_JSON_pack_uint64 ("num_issued",
num_issued),
GNUNET_JSON_pack_uint64 ("num_known",
num_known),
TALER_JSON_pack_amount ("denom_risk",
risk),
TALER_JSON_pack_time_abs_nbo_human ("start",
issue->start),
"deposit_end",
TALER_ARL_json_from_time_abs_nbo (
TALER_JSON_pack_time_abs_nbo_human ("deposit_end",
issue->expire_deposit),
"value",
TALER_JSON_from_amount_nbo (&issue->value)));
TALER_JSON_pack_amount_nbo ("value",
&issue->value)));
TALER_ARL_amount_add (&reported_emergency_risk_by_count,
&reported_emergency_risk_by_count,
risk);
@ -406,12 +402,17 @@ report_amount_arithmetic_inconsistency (
exchange);
}
TALER_ARL_report (report_amount_arithmetic_inconsistencies,
json_pack ("{s:s, s:I, s:o, s:o, s:I}",
"operation", operation,
"rowid", (json_int_t) rowid,
"exchange", TALER_JSON_from_amount (exchange),
"auditor", TALER_JSON_from_amount (auditor),
"profitable", (json_int_t) profitable));
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("operation",
operation),
GNUNET_JSON_pack_uint64 ("rowid",
rowid),
TALER_JSON_pack_amount ("exchange",
exchange),
TALER_JSON_pack_amount ("auditor",
auditor),
GNUNET_JSON_pack_int64 ("profitable",
profitable)));
if (0 != profitable)
{
target = (1 == profitable)
@ -437,10 +438,13 @@ report_row_inconsistency (const char *table,
const char *diagnostic)
{
TALER_ARL_report (report_row_inconsistencies,
json_pack ("{s:s, s:I, s:s}",
"table", table,
"row", (json_int_t) rowid,
"diagnostic", diagnostic));
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("table",
table),
GNUNET_JSON_pack_uint64 ("row",
rowid),
GNUNET_JSON_pack_string ("diagnostic",
diagnostic)));
}
@ -1196,12 +1200,14 @@ check_known_coin (const char *operation,
denom_pub))
{
TALER_ARL_report (report_bad_sig_losses,
json_pack ("{s:s, s:I, s:o, s:o}",
"operation", operation,
"row", (json_int_t) rowid,
"loss", TALER_JSON_from_amount (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("operation",
operation),
GNUNET_JSON_pack_uint64 ("row",
rowid),
TALER_JSON_pack_amount ("loss",
loss_potential),
"coin_pub", GNUNET_JSON_from_data_auto (
GNUNET_JSON_pack_data_auto ("coin_pub",
coin_pub)));
TALER_ARL_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss,
@ -1302,12 +1308,14 @@ refresh_session_cb (void *cls,
&coin_pub->eddsa_pub))
{
TALER_ARL_report (report_bad_sig_losses,
json_pack ("{s:s, s:I, s:o, s:o}",
"operation", "melt",
"row", (json_int_t) rowid,
"loss", TALER_JSON_from_amount (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("operation",
"melt"),
GNUNET_JSON_pack_uint64 ("row",
rowid),
TALER_JSON_pack_amount ("loss",
amount_with_fee),
"coin_pub", GNUNET_JSON_from_data_auto (
GNUNET_JSON_pack_data_auto ("coin_pub",
coin_pub)));
TALER_ARL_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss,
@ -1345,11 +1353,12 @@ refresh_session_cb (void *cls,
with invalid data, even if the exchange is correctly operating. We
still report it. */
TALER_ARL_report (report_refreshs_hanging,
json_pack ("{s:I, s:o, s:o}",
"row", (json_int_t) rowid,
"amount", TALER_JSON_from_amount (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_uint64 ("row",
rowid),
TALER_JSON_pack_amount ("amount",
amount_with_fee),
"coin_pub", GNUNET_JSON_from_data_auto (
GNUNET_JSON_pack_data_auto ("coin_pub",
coin_pub)));
TALER_ARL_amount_add (&total_refresh_hanging,
&total_refresh_hanging,
@ -1653,12 +1662,14 @@ deposit_cb (void *cls,
&dr.h_wire))
{
TALER_ARL_report (report_bad_sig_losses,
json_pack ("{s:s, s:I, s:o, s:o}",
"operation", "deposit",
"row", (json_int_t) rowid,
"loss", TALER_JSON_from_amount (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("operation",
"deposit"),
GNUNET_JSON_pack_uint64 ("row",
rowid),
TALER_JSON_pack_amount ("loss",
amount_with_fee),
"coin_pub", GNUNET_JSON_from_data_auto (
GNUNET_JSON_pack_data_auto ("coin_pub",
coin_pub)));
TALER_ARL_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss,
@ -1679,12 +1690,14 @@ deposit_cb (void *cls,
&coin_pub->eddsa_pub))
{
TALER_ARL_report (report_bad_sig_losses,
json_pack ("{s:s, s:I, s:o, s:o}",
"operation", "deposit",
"row", (json_int_t) rowid,
"loss", TALER_JSON_from_amount (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("operation",
"deposit"),
GNUNET_JSON_pack_uint64 ("row",
rowid),
TALER_JSON_pack_amount ("loss",
amount_with_fee),
"coin_pub", GNUNET_JSON_from_data_auto (
GNUNET_JSON_pack_data_auto ("coin_pub",
coin_pub)));
TALER_ARL_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss,
@ -1850,12 +1863,14 @@ refund_cb (void *cls,
&merchant_pub->eddsa_pub))
{
TALER_ARL_report (report_bad_sig_losses,
json_pack ("{s:s, s:I, s:o, s:o}",
"operation", "refund",
"row", (json_int_t) rowid,
"loss", TALER_JSON_from_amount (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("operation",
"refund"),
GNUNET_JSON_pack_uint64 ("row",
rowid),
TALER_JSON_pack_amount ("loss",
amount_with_fee),
"coin_pub", GNUNET_JSON_from_data_auto (
GNUNET_JSON_pack_data_auto ("coin_pub",
coin_pub)));
TALER_ARL_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss,
@ -1961,11 +1976,14 @@ check_recoup (struct CoinContext *cc,
denom_pub))
{
TALER_ARL_report (report_bad_sig_losses,
json_pack ("{s:s, s:I, s:o, s:o}",
"operation", operation,
"row", (json_int_t) rowid,
"loss", TALER_JSON_from_amount (amount),
"coin_pub", GNUNET_JSON_from_data_auto (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("operation",
operation),
GNUNET_JSON_pack_uint64 ("row",
rowid),
TALER_JSON_pack_amount ("loss",
amount),
GNUNET_JSON_pack_data_auto ("coin_pub",
&coin->denom_pub_hash)));
TALER_ARL_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss,
@ -2018,11 +2036,14 @@ check_recoup (struct CoinContext *cc,
&coin->coin_pub.eddsa_pub))
{
TALER_ARL_report (report_bad_sig_losses,
json_pack ("{s:s, s:I, s:o, s:o}",
"operation", operation,
"row", (json_int_t) rowid,
"loss", TALER_JSON_from_amount (amount),
"coin_pub", GNUNET_JSON_from_data_auto (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("operation",
operation),
GNUNET_JSON_pack_uint64 ("row",
rowid),
TALER_JSON_pack_amount ("loss",
amount),
GNUNET_JSON_pack_data_auto ("coin_pub",
&coin->coin_pub)));
TALER_ARL_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss,
@ -2047,14 +2068,16 @@ check_recoup (struct CoinContext *cc,
{
/* Woopsie, we allowed recoup on non-revoked denomination!? */
TALER_ARL_report (report_bad_sig_losses,
json_pack ("{s:s, s:s, s:I, s:o, s:o}",
"operation",
operation,
"hint",
"denomination not revoked",
"row", (json_int_t) rowid,
"loss", TALER_JSON_from_amount (amount),
"coin_pub", GNUNET_JSON_from_data_auto (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("operation",
operation),
GNUNET_JSON_pack_string ("hint",
"denomination not revoked"),
GNUNET_JSON_pack_uint64 ("row",
rowid),
TALER_JSON_pack_amount ("loss",
amount),
GNUNET_JSON_pack_data_auto ("coin_pub",
&coin->coin_pub)));
TALER_ARL_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss,
@ -2273,18 +2296,16 @@ check_denomination (
&auditor_sig))
{
TALER_ARL_report (report_denominations_without_sigs,
json_pack ("{s:o, s:o, s:o, s:o}",
"denomination",
GNUNET_JSON_from_data_auto (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_data_auto ("denomination",
&issue->denom_hash),
"value",
TALER_JSON_from_amount (&coin_value),
"start_time",
TALER_ARL_json_from_time_abs_nbo (
TALER_JSON_pack_amount ("value",
&coin_value),
TALER_JSON_pack_time_abs_nbo_human ("start_time",
issue->start),
"end_time",
TALER_ARL_json_from_time_abs_nbo (
issue->expire_legal)));
TALER_JSON_pack_time_abs_nbo_human ("end_time",
issue->
expire_legal)));
}
}
}
@ -2533,8 +2554,6 @@ run (void *cls,
const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *c)
{
json_t *report;
(void) cls;
(void) args;
(void) cfgfile;
@ -2543,7 +2562,7 @@ run (void *cls,
if (GNUNET_OK !=
TALER_ARL_init (c))
{
global_ret = 1;
global_ret = EXIT_FAILURE;
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@ -2617,121 +2636,92 @@ run (void *cls,
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Audit complete\n");
report = json_pack ("{s:o, s:o, s:o, s:o, s:o,"
" s:o, s:o, s:o, s:o, s:o,"
" s:o, s:o, s:o, s:o, s:o,"
" s:o, s:o, s:o, s:o, s:o,"
" s:I, s:I, s:I, s:I, s:I,"
" s:I, s:I, s:I, s:I, s:I,"
" s:I, s:I, s:o, s:o, s:o,"
" s:o}",
/* Block #1 */
"total_escrow_balance",
TALER_JSON_from_amount (&total_escrow_balance),
"total_active_risk",
TALER_JSON_from_amount (&total_risk),
"total_deposit_fee_income",
TALER_JSON_from_amount (
TALER_ARL_done (
GNUNET_JSON_PACK (
TALER_JSON_pack_amount ("total_escrow_balance",
&total_escrow_balance),
TALER_JSON_pack_amount ("total_active_risk",
&total_risk),
TALER_JSON_pack_amount ("total_deposit_fee_income",
&total_deposit_fee_income),
"total_melt_fee_income",
TALER_JSON_from_amount (&total_melt_fee_income),
"total_refund_fee_income",
TALER_JSON_from_amount (
TALER_JSON_pack_amount ("total_melt_fee_income",
&total_melt_fee_income),
TALER_JSON_pack_amount ("total_refund_fee_income",
&total_refund_fee_income),
/* Block #2 */
/* Tested in test-auditor.sh #18 */
"emergencies",
report_emergencies,
GNUNET_JSON_pack_array_steal ("emergencies",
report_emergencies),
/* Tested in test-auditor.sh #18 */
"emergencies_risk_by_amount",
TALER_JSON_from_amount (
TALER_JSON_pack_amount ("emergencies_risk_by_amount",
&reported_emergency_risk_by_amount),
/* Tested in test-auditor.sh #4/#5/#6/#13/#26 */
"bad_sig_losses",
report_bad_sig_losses,
GNUNET_JSON_pack_array_steal ("bad_sig_losses",
report_bad_sig_losses),
/* Tested in test-auditor.sh #4/#5/#6/#13/#26 */
"total_bad_sig_loss",
TALER_JSON_from_amount (&total_bad_sig_loss),
TALER_JSON_pack_amount ("total_bad_sig_loss",
&total_bad_sig_loss),
/* Tested in test-auditor.sh #31 */
"row_inconsistencies",
report_row_inconsistencies,
/* Block #3 */
GNUNET_JSON_pack_array_steal ("row_inconsistencies",
report_row_inconsistencies),
/* Tested in test-auditor.sh #18 */
"amount_arithmetic_inconsistencies",
report_amount_arithmetic_inconsistencies,
"total_arithmetic_delta_plus",
TALER_JSON_from_amount (
GNUNET_JSON_pack_array_steal ("amount_arithmetic_inconsistencies",
report_amount_arithmetic_inconsistencies),
TALER_JSON_pack_amount ("total_arithmetic_delta_plus",
&total_arithmetic_delta_plus),
"total_arithmetic_delta_minus",
TALER_JSON_from_amount (
TALER_JSON_pack_amount ("total_arithmetic_delta_minus",
&total_arithmetic_delta_minus),
TALER_JSON_pack_amount ("total_refresh_hanging",
&total_refresh_hanging),
/* Tested in test-auditor.sh #12 */
"total_refresh_hanging",
TALER_JSON_from_amount (&total_refresh_hanging),
/* Tested in test-auditor.sh #12 */
"refresh_hanging",
report_refreshs_hanging,
/* Block #4 */
"total_recoup_loss",
TALER_JSON_from_amount (&total_recoup_loss),
GNUNET_JSON_pack_array_steal ("refresh_hanging",
report_refreshs_hanging),
TALER_JSON_pack_amount ("total_recoup_loss",
&total_recoup_loss),
/* Tested in test-auditor.sh #18 */
"emergencies_by_count",
report_emergencies_by_count,
GNUNET_JSON_pack_array_steal ("emergencies_by_count",
report_emergencies_by_count),
/* Tested in test-auditor.sh #18 */
"emergencies_risk_by_count",
TALER_JSON_from_amount (
TALER_JSON_pack_amount ("emergencies_risk_by_count",
&reported_emergency_risk_by_count),
/* Tested in test-auditor.sh #18 */
"emergencies_loss",
TALER_JSON_from_amount (
TALER_JSON_pack_amount ("emergencies_loss",
&reported_emergency_loss),
/* Tested in test-auditor.sh #18 */
"emergencies_loss_by_count",
TALER_JSON_from_amount (
TALER_JSON_pack_amount ("emergencies_loss_by_count",
&reported_emergency_loss_by_count),
/* Block #5 */
"start_ppc_withdraw_serial_id",
(json_int_t) ppc_start.last_withdraw_serial_id,
"start_ppc_deposit_serial_id",
(json_int_t) ppc_start.last_deposit_serial_id,
"start_ppc_melt_serial_id",
(json_int_t) ppc_start.last_melt_serial_id,
"start_ppc_refund_serial_id",
(json_int_t) ppc_start.last_refund_serial_id,
"start_ppc_recoup_serial_id",
(json_int_t) ppc_start.last_recoup_serial_id,
/* Block #6 */
"start_ppc_recoup_refresh_serial_id",
(json_int_t) ppc_start.
last_recoup_refresh_serial_id,
"end_ppc_withdraw_serial_id",
(json_int_t) ppc.last_withdraw_serial_id,
"end_ppc_deposit_serial_id",
(json_int_t) ppc.last_deposit_serial_id,
"end_ppc_melt_serial_id",
(json_int_t) ppc.last_melt_serial_id,
"end_ppc_refund_serial_id",
(json_int_t) ppc.last_refund_serial_id,
/* Block #7 */
"end_ppc_recoup_serial_id",
(json_int_t) ppc.last_recoup_serial_id,
"end_ppc_recoup_refresh_serial_id",
(json_int_t) ppc.last_recoup_refresh_serial_id,
"auditor_start_time",
TALER_ARL_json_from_time_abs (
GNUNET_JSON_pack_uint64 ("start_ppc_withdraw_serial_id",
ppc_start.last_withdraw_serial_id),
GNUNET_JSON_pack_uint64 ("start_ppc_deposit_serial_id",
ppc_start.last_deposit_serial_id),
GNUNET_JSON_pack_uint64 ("start_ppc_melt_serial_id",
ppc_start.last_melt_serial_id),
GNUNET_JSON_pack_uint64 ("start_ppc_refund_serial_id",
ppc_start.last_refund_serial_id),
GNUNET_JSON_pack_uint64 ("start_ppc_recoup_serial_id",
ppc_start.last_recoup_serial_id),
GNUNET_JSON_pack_uint64 ("start_ppc_recoup_refresh_serial_id",
ppc_start.
last_recoup_refresh_serial_id),
GNUNET_JSON_pack_uint64 ("end_ppc_withdraw_serial_id",
ppc.last_withdraw_serial_id),
GNUNET_JSON_pack_uint64 ("end_ppc_deposit_serial_id",
ppc.last_deposit_serial_id),
GNUNET_JSON_pack_uint64 ("end_ppc_melt_serial_id",
ppc.last_melt_serial_id),
GNUNET_JSON_pack_uint64 ("end_ppc_refund_serial_id",
ppc.last_refund_serial_id),
GNUNET_JSON_pack_uint64 ("end_ppc_recoup_serial_id",
ppc.last_recoup_serial_id),
GNUNET_JSON_pack_uint64 ("end_ppc_recoup_refresh_serial_id",
ppc.last_recoup_refresh_serial_id),
TALER_JSON_pack_time_abs_human ("auditor_start_time",
start_time),
"auditor_end_time",
TALER_ARL_json_from_time_abs (
TALER_JSON_pack_time_abs_human ("auditor_end_time",
GNUNET_TIME_absolute_get ()),
"total_irregular_recoups",
TALER_JSON_from_amount (
TALER_JSON_pack_amount ("total_irregular_recoups",
&total_irregular_recoups),
/* Block #8 */
"unsigned_denominations",
report_denominations_without_sigs
);
GNUNET_break (NULL != report);
TALER_ARL_done (report);
GNUNET_JSON_pack_array_steal ("unsigned_denominations",
report_denominations_without_sigs)));
}
@ -2769,7 +2759,7 @@ main (int argc,
if (GNUNET_OK !=
GNUNET_STRINGS_get_utf8_args (argc, argv,
&argc, &argv))
return 4;
return EXIT_INVALIDARGUMENT;
ret = GNUNET_PROGRAM_run (
argc,
argv,
@ -2780,9 +2770,9 @@ main (int argc,
NULL);
GNUNET_free_nz ((void *) argv);
if (GNUNET_SYSERR == ret)
return 3;
return EXIT_INVALIDARGUMENT;
if (GNUNET_NO == ret)
return 0;
return EXIT_SUCCESS;
return global_ret;
}

View File

@ -1,6 +1,6 @@
/*
This file is part of TALER
Copyright (C) 2016-2020 Taler Systems SA
Copyright (C) 2016-2021 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
@ -146,16 +146,15 @@ test_dc (void *cls,
}
/* deposit confirmation missing! report! */
TALER_ARL_report (report_deposit_confirmation_inconsistencies,
json_pack ("{s:o, s:o, s:I, s:o}",
"timestamp",
TALER_ARL_json_from_time_abs (
GNUNET_JSON_PACK (
TALER_JSON_pack_time_abs_human ("timestamp",
dc->exchange_timestamp),
"amount",
TALER_JSON_from_amount (&dc->amount_without_fee),
"rowid",
(json_int_t) serial_id,
"account",
GNUNET_JSON_from_data_auto (&dc->h_wire)));
TALER_JSON_pack_amount ("amount",
&dc->amount_without_fee),
GNUNET_JSON_pack_uint64 ("rowid",
serial_id),
GNUNET_JSON_pack_data_auto ("account",
&dc->h_wire)));
dcc->first_missed_coin_serial = GNUNET_MIN (dcc->first_missed_coin_serial,
serial_id);
dcc->missed_count++;
@ -295,7 +294,7 @@ run (void *cls,
if (GNUNET_OK !=
TALER_ARL_init (c))
{
global_ret = 1;
global_ret = EXIT_FAILURE;
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@ -306,32 +305,23 @@ run (void *cls,
TALER_ARL_setup_sessions_and_run (&analyze_deposit_confirmations,
NULL))
{
global_ret = 1;
global_ret = EXIT_FAILURE;
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Deposit audit complete\n");
{
json_t *report;
report = json_pack ("{s:o, s:I, s:o, s:o, s:o}",
"deposit_confirmation_inconsistencies",
report_deposit_confirmation_inconsistencies,
"missing_deposit_confirmation_count",
(json_int_t) number_missed_deposit_confirmations,
"missing_deposit_confirmation_total",
TALER_JSON_from_amount (
TALER_ARL_done (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_array_steal ("deposit_confirmation_inconsistencies",
report_deposit_confirmation_inconsistencies),
GNUNET_JSON_pack_uint64 ("missing_deposit_confirmation_count",
number_missed_deposit_confirmations),
TALER_JSON_pack_amount ("missing_deposit_confirmation_total",
&total_missed_deposit_confirmations),
"auditor_start_time",
TALER_ARL_json_from_time_abs (
TALER_JSON_pack_time_abs_human ("auditor_start_time",
start_time),
"auditor_end_time",
TALER_ARL_json_from_time_abs (
GNUNET_TIME_absolute_get ())
);
GNUNET_break (NULL != report);
TALER_ARL_done (report);
}
TALER_JSON_pack_time_abs_human ("auditor_end_time",
GNUNET_TIME_absolute_get ())));
}
@ -369,7 +359,7 @@ main (int argc,
if (GNUNET_OK !=
GNUNET_STRINGS_get_utf8_args (argc, argv,
&argc, &argv))
return 4;
return EXIT_INVALIDARGUMENT;
ret = GNUNET_PROGRAM_run (
argc,
argv,
@ -381,9 +371,9 @@ main (int argc,
NULL);
GNUNET_free_nz ((void *) argv);
if (GNUNET_SYSERR == ret)
return 3;
return EXIT_INVALIDARGUMENT;
if (GNUNET_NO == ret)
return 0;
return EXIT_SUCCESS;
return global_ret;
}

View File

@ -1,6 +1,6 @@
/*
This file is part of TALER
Copyright (C) 2016-2020 Taler Systems SA
Copyright (C) 2016-2021 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
@ -191,12 +191,17 @@ report_amount_arithmetic_inconsistency (
exchange);
}
TALER_ARL_report (report_amount_arithmetic_inconsistencies,
json_pack ("{s:s, s:I, s:o, s:o, s:I}",
"operation", operation,
"rowid", (json_int_t) rowid,
"exchange", TALER_JSON_from_amount (exchange),
"auditor", TALER_JSON_from_amount (auditor),
"profitable", (json_int_t) profitable));
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("operation",
operation),
GNUNET_JSON_pack_uint64 ("rowid",
rowid),
TALER_JSON_pack_amount ("exchange",
exchange),
TALER_JSON_pack_amount ("auditor",
auditor),
GNUNET_JSON_pack_int64 ("profitable",
profitable)));
if (0 != profitable)
{
target = (1 == profitable)
@ -222,10 +227,13 @@ report_row_inconsistency (const char *table,
const char *diagnostic)
{
TALER_ARL_report (report_row_inconsistencies,
json_pack ("{s:s, s:I, s:s}",
"table", table,
"row", (json_int_t) rowid,
"diagnostic", diagnostic));
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("table",
table),
GNUNET_JSON_pack_uint64 ("row",
rowid),
GNUNET_JSON_pack_string ("diagnostic",
diagnostic)));
}
@ -549,13 +557,14 @@ handle_reserve_out (void *cls,
(expire_withdraw.abs_value_us < execution_date.abs_value_us) )
{
TALER_ARL_report (denomination_key_validity_withdraw_inconsistencies,
json_pack ("{s:I, s:o, s:o, s:o}",
"row", (json_int_t) rowid,
"execution_date",
TALER_ARL_json_from_time_abs (execution_date),
"reserve_pub", GNUNET_JSON_from_data_auto (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_uint64 ("row",
rowid),
TALER_JSON_pack_time_abs_human ("execution_date",
execution_date),
GNUNET_JSON_pack_data_auto ("reserve_pub",
reserve_pub),
"denompub_h", GNUNET_JSON_from_data_auto (
GNUNET_JSON_pack_data_auto ("denompub_h",
&wsrd.h_denomination_pub)));
}
@ -569,12 +578,14 @@ handle_reserve_out (void *cls,
&reserve_pub->eddsa_pub))
{
TALER_ARL_report (report_bad_sig_losses,
json_pack ("{s:s, s:I, s:o, s:o}",
"operation", "withdraw",
"row", (json_int_t) rowid,
"loss", TALER_JSON_from_amount (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("operation",
"withdraw"),
GNUNET_JSON_pack_uint64 ("row",
rowid),
TALER_JSON_pack_amount ("loss",
amount_with_fee),
"key_pub", GNUNET_JSON_from_data_auto (
GNUNET_JSON_pack_data_auto ("key_pub",
reserve_pub)));
TALER_ARL_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss,
@ -712,11 +723,14 @@ handle_recoup_by_reserve (
&coin->coin_pub.eddsa_pub))
{
TALER_ARL_report (report_bad_sig_losses,
json_pack ("{s:s, s:I, s:o, s:o}",
"operation", "recoup",
"row", (json_int_t) rowid,
"loss", TALER_JSON_from_amount (amount),
"key_pub", GNUNET_JSON_from_data_auto (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("operation",
"recoup"),
GNUNET_JSON_pack_uint64 ("row",
rowid),
TALER_JSON_pack_amount ("loss",
amount),
GNUNET_JSON_pack_data_auto ("key_pub",
&coin->coin_pub)));
TALER_ARL_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss,
@ -778,11 +792,14 @@ handle_recoup_by_reserve (
(0 == strcmp (rev, "master signature invalid")) )
{
TALER_ARL_report (report_bad_sig_losses,
json_pack ("{s:s, s:I, s:o, s:o}",
"operation", "recoup-master",
"row", (json_int_t) rev_rowid,
"loss", TALER_JSON_from_amount (amount),
"key_pub", GNUNET_JSON_from_data_auto (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("operation",
"recoup-master"),
GNUNET_JSON_pack_uint64 ("row",
rev_rowid),
TALER_JSON_pack_amount ("loss",
amount),
GNUNET_JSON_pack_data_auto ("key_pub",
&TALER_ARL_master_pub)));
TALER_ARL_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss,
@ -1051,11 +1068,11 @@ verify_reserve_balance (void *cls,
&total_balance_insufficient_loss,
&loss);
TALER_ARL_report (report_reserve_balance_insufficient_inconsistencies,
json_pack ("{s:o, s:o}",
"reserve_pub",
GNUNET_JSON_from_data_auto (&rs->reserve_pub),
"loss",
TALER_JSON_from_amount (&loss)));
GNUNET_JSON_PACK (
GNUNET_JSON_pack_data_auto ("reserve_pub",
&rs->reserve_pub),
TALER_JSON_pack_amount ("loss",
&loss)));
/* Continue with a reserve balance of zero */
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (balance.currency,
@ -1083,12 +1100,11 @@ verify_reserve_balance (void *cls,
not an actualized gain and could be trivially corrected by
restoring the summary. *///
TALER_ARL_report (report_reserve_balance_insufficient_inconsistencies,
json_pack ("{s:o, s:o}",
"reserve_pub",
GNUNET_JSON_from_data_auto (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_data_auto ("reserve_pub",
&rs->reserve_pub),
"gain",
TALER_JSON_from_amount (&nbalance)));
TALER_JSON_pack_amount ("gain",
&nbalance)));
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
{
GNUNET_break (0);
@ -1126,14 +1142,13 @@ verify_reserve_balance (void *cls,
&delta);
}
TALER_ARL_report (report_reserve_balance_summary_wrong_inconsistencies,
json_pack ("{s:o, s:o, s:o}",
"reserve_pub",
GNUNET_JSON_from_data_auto (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_data_auto ("reserve_pub",
&rs->reserve_pub),
"exchange",
TALER_JSON_from_amount (&reserve.balance),
"auditor",
TALER_JSON_from_amount (&nbalance)));
TALER_JSON_pack_amount ("exchange",
&reserve.balance),
TALER_JSON_pack_amount ("auditor",
&nbalance)));
}
}
} /* end of 'if (internal_checks)' */
@ -1160,15 +1175,14 @@ verify_reserve_balance (void *cls,
TALER_ARL_amount_add (&total_balance_reserve_not_closed,
&total_balance_reserve_not_closed,
&nbalance);
TALER_ARL_report (report_reserve_not_closed_inconsistencies,
json_pack ("{s:o, s:o, s:o}",
"reserve_pub",
GNUNET_JSON_from_data_auto (
TALER_ARL_report (
report_reserve_not_closed_inconsistencies,
GNUNET_JSON_PACK (
GNUNET_JSON_pack_data_auto ("reserve_pub",
&rs->reserve_pub),
"balance",
TALER_JSON_from_amount (&nbalance),
"expiration_time",
TALER_ARL_json_from_time_abs (
TALER_JSON_pack_amount ("balance",
&nbalance),
TALER_JSON_pack_time_abs_human ("expiration_time",
rs->a_expiration_date)));
}
}
@ -1179,17 +1193,15 @@ verify_reserve_balance (void *cls,
&total_balance_reserve_not_closed,
&nbalance);
TALER_ARL_report (report_reserve_not_closed_inconsistencies,
json_pack ("{s:o, s:o, s:o, s:s}",
"reserve_pub",
GNUNET_JSON_from_data_auto (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_data_auto ("reserve_pub",
&rs->reserve_pub),
"balance",
TALER_JSON_from_amount (&nbalance),
"expiration_time",
TALER_ARL_json_from_time_abs (
TALER_JSON_pack_amount ("balance",
&nbalance),
TALER_JSON_pack_time_abs_human ("expiration_time",
rs->a_expiration_date),
"diagnostic",
"could not determine closing fee"));
GNUNET_JSON_pack_string ("diagnostic",
"could not determine closing fee")));
}
}
@ -1489,7 +1501,7 @@ run (void *cls,
if (GNUNET_OK !=
TALER_ARL_init (c))
{
global_ret = 1;
global_ret = EXIT_FAILURE;
return;
}
if (GNUNET_OK !=
@ -1501,7 +1513,7 @@ run (void *cls,
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchangedb",
"IDLE_RESERVE_EXPIRATION_TIME");
global_ret = 1;
global_ret = EXIT_FAILURE;
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@ -1559,103 +1571,77 @@ run (void *cls,
TALER_ARL_setup_sessions_and_run (&analyze_reserves,
NULL))
{
global_ret = 1;
global_ret = EXIT_FAILURE;
return;
}
{
json_t *report;
report = json_pack ("{s:o, s:o, s:o, s:o, s:o,"
" s:o, s:o, s:o, s:o, s:o,"
" s:o, s:o, s:o, s:o, s:o,"
" s:o, s:o, s:o, s:o, s:I,"
" s:I, s:I, s:I, s:I, s:I,"
" s:I, s:I }",
/* blocks #1 */
TALER_ARL_done (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_array_steal (
"reserve_balance_insufficient_inconsistencies",
report_reserve_balance_insufficient_inconsistencies,
report_reserve_balance_insufficient_inconsistencies),
/* Tested in test-auditor.sh #3 */
"total_loss_balance_insufficient",
TALER_JSON_from_amount (
TALER_JSON_pack_amount ("total_loss_balance_insufficient",
&total_balance_insufficient_loss),
/* Tested in test-auditor.sh #3 */
GNUNET_JSON_pack_array_steal (
"reserve_balance_summary_wrong_inconsistencies",
report_reserve_balance_summary_wrong_inconsistencies,
"total_balance_summary_delta_plus",
TALER_JSON_from_amount (
report_reserve_balance_summary_wrong_inconsistencies),
TALER_JSON_pack_amount ("total_balance_summary_delta_plus",
&total_balance_summary_delta_plus),
"total_balance_summary_delta_minus",
TALER_JSON_from_amount (
TALER_JSON_pack_amount ("total_balance_summary_delta_minus",
&total_balance_summary_delta_minus),
/* blocks #2 */
"total_escrow_balance",
TALER_JSON_from_amount (&total_escrow_balance),
"total_withdraw_fee_income",
TALER_JSON_from_amount (
TALER_JSON_pack_amount ("total_escrow_balance",
&total_escrow_balance),
TALER_JSON_pack_amount ("total_withdraw_fee_income",
&total_withdraw_fee_income),
/* Tested in test-auditor.sh #21 */
"reserve_not_closed_inconsistencies",
report_reserve_not_closed_inconsistencies,
GNUNET_JSON_pack_array_steal ("reserve_not_closed_inconsistencies",
report_reserve_not_closed_inconsistencies),
/* Tested in test-auditor.sh #21 */
"total_balance_reserve_not_closed",
TALER_JSON_from_amount (
TALER_JSON_pack_amount ("total_balance_reserve_not_closed",
&total_balance_reserve_not_closed),
/* Tested in test-auditor.sh #7 */
"bad_sig_losses",
report_bad_sig_losses,
/* blocks #3 */
GNUNET_JSON_pack_array_steal ("bad_sig_losses",
report_bad_sig_losses),
/* Tested in test-auditor.sh #7 */
"total_bad_sig_loss",
TALER_JSON_from_amount (&total_bad_sig_loss),
TALER_JSON_pack_amount ("total_bad_sig_loss",
&total_bad_sig_loss),
/* Tested in test-revocation.sh #4 */
"row_inconsistencies",
report_row_inconsistencies,
GNUNET_JSON_pack_array_steal ("row_inconsistencies",
report_row_inconsistencies),
/* Tested in test-auditor.sh #23 */
GNUNET_JSON_pack_array_steal (
"denomination_key_validity_withdraw_inconsistencies",
denomination_key_validity_withdraw_inconsistencies,
"amount_arithmetic_inconsistencies",
report_amount_arithmetic_inconsistencies,
"total_arithmetic_delta_plus",
TALER_JSON_from_amount (
denomination_key_validity_withdraw_inconsistencies),
GNUNET_JSON_pack_array_steal ("amount_arithmetic_inconsistencies",
report_amount_arithmetic_inconsistencies),
TALER_JSON_pack_amount ("total_arithmetic_delta_plus",
&total_arithmetic_delta_plus),
/* blocks #4 */
"total_arithmetic_delta_minus",
TALER_JSON_from_amount (
TALER_JSON_pack_amount ("total_arithmetic_delta_minus",
&total_arithmetic_delta_minus),
"auditor_start_time",
TALER_ARL_json_from_time_abs (
TALER_JSON_pack_time_abs_human ("auditor_start_time",
start_time),
"auditor_end_time",
TALER_ARL_json_from_time_abs (
TALER_JSON_pack_time_abs_human ("auditor_end_time",
GNUNET_TIME_absolute_get ()),
"total_irregular_recoups",
TALER_JSON_from_amount (
TALER_JSON_pack_amount ("total_irregular_recoups",
&total_irregular_recoups),
"start_ppr_reserve_in_serial_id",
(json_int_t) ppr_start.last_reserve_in_serial_id,
/* blocks #5 */
"start_ppr_reserve_out_serial_id",
(json_int_t) ppr_start.
last_reserve_out_serial_id,
"start_ppr_reserve_recoup_serial_id",
(json_int_t) ppr_start.
last_reserve_recoup_serial_id,
"start_ppr_reserve_close_serial_id",
(json_int_t) ppr_start.
last_reserve_close_serial_id,
"end_ppr_reserve_in_serial_id",
(json_int_t) ppr.last_reserve_in_serial_id,
"end_ppr_reserve_out_serial_id",
(json_int_t) ppr.last_reserve_out_serial_id,
/* blocks #6 */
"end_ppr_reserve_recoup_serial_id",
(json_int_t) ppr.last_reserve_recoup_serial_id,
"end_ppr_reserve_close_serial_id",
(json_int_t) ppr.last_reserve_close_serial_id
);
GNUNET_break (NULL != report);
TALER_ARL_done (report);
}
GNUNET_JSON_pack_uint64 ("start_ppr_reserve_in_serial_id",
ppr_start.last_reserve_in_serial_id),
GNUNET_JSON_pack_uint64 ("start_ppr_reserve_out_serial_id",
ppr_start.last_reserve_out_serial_id),
GNUNET_JSON_pack_uint64 ("start_ppr_reserve_recoup_serial_id",
ppr_start.last_reserve_recoup_serial_id),
GNUNET_JSON_pack_uint64 ("start_ppr_reserve_close_serial_id",
ppr_start.last_reserve_close_serial_id),
GNUNET_JSON_pack_uint64 ("end_ppr_reserve_in_serial_id",
ppr.last_reserve_in_serial_id),
GNUNET_JSON_pack_uint64 ("end_ppr_reserve_out_serial_id",
ppr.last_reserve_out_serial_id),
GNUNET_JSON_pack_uint64 ("end_ppr_reserve_recoup_serial_id",
ppr.last_reserve_recoup_serial_id),
GNUNET_JSON_pack_uint64 ("end_ppr_reserve_close_serial_id",
ppr.last_reserve_close_serial_id)));
}
@ -1693,7 +1679,7 @@ main (int argc,
if (GNUNET_OK !=
GNUNET_STRINGS_get_utf8_args (argc, argv,
&argc, &argv))
return 4;
return EXIT_INVALIDARGUMENT;
ret = GNUNET_PROGRAM_run (
argc,
argv,
@ -1704,9 +1690,9 @@ main (int argc,
NULL);
GNUNET_free_nz ((void *) argv);
if (GNUNET_SYSERR == ret)
return 3;
return EXIT_INVALIDARGUMENT;
if (GNUNET_NO == ret)
return 0;
return EXIT_SUCCESS;
return global_ret;
}

View File

@ -1,6 +1,6 @@
/*
This file is part of TALER
Copyright (C) 2017-2020 Taler Systems SA
Copyright (C) 2017-2021 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
@ -457,93 +457,69 @@ do_shutdown (void *cls)
(void) cls;
if (NULL != report_row_inconsistencies)
{
json_t *report;
GNUNET_assert (NULL != report_row_minor_inconsistencies);
report = json_pack ("{s:o, s:o, s:o, s:o, s:o,"
" s:o, s:o, s:o, s:o, s:o,"
" s:o, s:o, s:o, s:o, s:o,"
" s:o, s:o, s:o, s:I, s:I,"
" s:o, s:o, s:o }",
/* blocks of 5 */
TALER_ARL_done (
GNUNET_JSON_PACK (
/* Tested in test-auditor.sh #11, #15, #20 */
"wire_out_amount_inconsistencies",
report_wire_out_inconsistencies,
"total_wire_out_delta_plus",
TALER_JSON_from_amount (
GNUNET_JSON_pack_array_steal ("wire_out_amount_inconsistencies",
report_wire_out_inconsistencies),
TALER_JSON_pack_amount ("total_wire_out_delta_plus",
&total_bad_amount_out_plus),
/* Tested in test-auditor.sh #11, #15, #19 */
"total_wire_out_delta_minus",
TALER_JSON_from_amount (
TALER_JSON_pack_amount ("total_wire_out_delta_minus",
&total_bad_amount_out_minus),
/* Tested in test-auditor.sh #2 */
"reserve_in_amount_inconsistencies",
report_reserve_in_inconsistencies,
GNUNET_JSON_pack_array_steal ("reserve_in_amount_inconsistencies",
report_reserve_in_inconsistencies),
/* Tested in test-auditor.sh #2 */
"total_wire_in_delta_plus",
TALER_JSON_from_amount (
TALER_JSON_pack_amount ("total_wire_in_delta_plus",
&total_bad_amount_in_plus),
/* block */
/* Tested in test-auditor.sh #3 */
"total_wire_in_delta_minus",
TALER_JSON_from_amount (
TALER_JSON_pack_amount ("total_wire_in_delta_minus",
&total_bad_amount_in_minus),
/* Tested in test-auditor.sh #9 */
"missattribution_in_inconsistencies",
report_missattribution_in_inconsistencies,
GNUNET_JSON_pack_array_steal ("missattribution_in_inconsistencies",
report_missattribution_in_inconsistencies),
/* Tested in test-auditor.sh #9 */
"total_missattribution_in",
TALER_JSON_from_amount (
TALER_JSON_pack_amount ("total_missattribution_in",
&total_missattribution_in),
"row_inconsistencies",
report_row_inconsistencies,
GNUNET_JSON_pack_array_steal ("row_inconsistencies",
report_row_inconsistencies),
/* Tested in test-auditor.sh #10/#17 */
"row_minor_inconsistencies",
report_row_minor_inconsistencies,
/* block */
GNUNET_JSON_pack_array_steal ("row_minor_inconsistencies",
report_row_minor_inconsistencies),
/* Tested in test-auditor.sh #19 */
"total_wire_format_amount",
TALER_JSON_from_amount (
TALER_JSON_pack_amount ("total_wire_format_amount",
&total_wire_format_amount),
/* Tested in test-auditor.sh #19 */
"wire_format_inconsistencies",
report_wire_format_inconsistencies,
GNUNET_JSON_pack_array_steal ("wire_format_inconsistencies",
report_wire_format_inconsistencies),
/* Tested in test-auditor.sh #1 */
"total_amount_lag",
TALER_JSON_from_amount (&total_amount_lag),
TALER_JSON_pack_amount ("total_amount_lag",
&total_amount_lag),
/* Tested in test-auditor.sh #1 */
"lag_details",
report_lags,
GNUNET_JSON_pack_array_steal ("lag_details",
report_lags),
/* Tested in test-auditor.sh #22 */
"total_closure_amount_lag",
TALER_JSON_from_amount (
TALER_JSON_pack_amount ("total_closure_amount_lag",
&total_closure_amount_lag),
/* blocks of 5 */
/* Tested in test-auditor.sh #22 */
"reserve_lag_details",
report_closure_lags,
"wire_auditor_start_time",
TALER_ARL_json_from_time_abs (
GNUNET_JSON_pack_array_steal ("reserve_lag_details",
report_closure_lags),
TALER_JSON_pack_time_abs_human ("wire_auditor_start_time",
start_time),
"wire_auditor_end_time",
TALER_ARL_json_from_time_abs (
TALER_JSON_pack_time_abs_human ("wire_auditor_end_time",
GNUNET_TIME_absolute_get ()),
"start_pp_reserve_close_uuid",
(json_int_t) start_pp.last_reserve_close_uuid,
"end_pp_reserve_close_uuid",
(json_int_t) pp.last_reserve_close_uuid,
/* blocks of 5 */
"start_pp_last_timestamp",
TALER_ARL_json_from_time_abs (
GNUNET_JSON_pack_uint64 ("start_pp_reserve_close_uuid",
start_pp.last_reserve_close_uuid),
GNUNET_JSON_pack_uint64 ("end_pp_reserve_close_uuid",
pp.last_reserve_close_uuid),
TALER_JSON_pack_time_abs_human ("start_pp_last_timestamp",
start_pp.last_timestamp),
"end_pp_last_timestamp",
TALER_ARL_json_from_time_abs (
TALER_JSON_pack_time_abs_human ("end_pp_last_timestamp",
pp.last_timestamp),
"account_progress",
report_account_progress
);
GNUNET_break (NULL != report);
TALER_ARL_done (report);
GNUNET_JSON_pack_array_steal ("account_progress",
report_account_progress)));
report_wire_out_inconsistencies = NULL;
report_reserve_in_inconsistencies = NULL;
report_row_inconsistencies = NULL;
@ -639,13 +615,17 @@ check_pending_rc (void *cls,
if ( (0 != rc->amount.value) ||
(0 != rc->amount.fraction) )
TALER_ARL_report (report_closure_lags,
json_pack ("{s:I, s:o, s:o, s:o, s:s}",
"row", (json_int_t) rc->rowid,
"amount", TALER_JSON_from_amount (&rc->amount),
"deadline", TALER_ARL_json_from_time_abs (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_uint64 ("row",
rc->rowid),
TALER_JSON_pack_amount ("amount",
&rc->amount),
TALER_JSON_pack_time_abs_human ("deadline",
rc->execution_date),
"wtid", GNUNET_JSON_from_data_auto (&rc->wtid),
"account", rc->receiver_account));
GNUNET_JSON_pack_data_auto ("wtid",
&rc->wtid),
GNUNET_JSON_pack_string ("account",
rc->receiver_account)));
pp.last_reserve_close_uuid
= GNUNET_MIN (pp.last_reserve_close_uuid,
rc->rowid);
@ -711,20 +691,19 @@ commit (enum GNUNET_DB_QueryStatus qs)
GNUNET_assert (0 ==
json_array_append_new (
report_account_progress,
json_pack (
"{s:s, s:I, s:I, s:I, s:I}",
"account",
wa->section_name,
"start_reserve_in",
(json_int_t) wa->start_pp.last_reserve_in_serial_id,
"end_reserve_in",
(json_int_t) wa->pp.last_reserve_in_serial_id,
"start_wire_out",
(json_int_t) wa->start_pp.last_wire_out_serial_id,
"end_wire_out",
(json_int_t) wa->pp.last_wire_out_serial_id
))
);
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("account",
wa->section_name),
GNUNET_JSON_pack_uint64 ("start_reserve_in",
wa->start_pp.
last_reserve_in_serial_id),
GNUNET_JSON_pack_uint64 ("end_reserve_in",
wa->pp.last_reserve_in_serial_id),
GNUNET_JSON_pack_uint64 ("start_wire_out",
wa->start_pp.
last_wire_out_serial_id),
GNUNET_JSON_pack_uint64 ("end_wire_out",
wa->pp.last_wire_out_serial_id))));
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == wa->qsx)
qs = TALER_ARL_adb->update_wire_auditor_account_progress (
TALER_ARL_adb->cls,
@ -862,19 +841,21 @@ wire_missing_cb (void *cls,
&tiny_amount))
return; /* acceptable, amount was tiny */
}
rep = json_pack ("{s:I, s:o, s:o, s:o, s:O}",
"row", (json_int_t) rowid,
"amount", TALER_JSON_from_amount (amount),
"deadline", TALER_ARL_json_from_time_abs (
rep = GNUNET_JSON_PACK (
GNUNET_JSON_pack_uint64 ("row",
rowid),
TALER_JSON_pack_amount ("amount",
amount),
TALER_JSON_pack_time_abs_human ("deadline",
deadline),
"coin_pub", GNUNET_JSON_from_data_auto (
GNUNET_JSON_pack_data_auto ("coin_pub",
coin_pub),
"account", wire);
GNUNET_break (NULL != rep);
GNUNET_JSON_pack_object_incref ("account",
(json_t *) wire));
if (internal_checks)
{
/* the 'done' bit is only useful in 'internal' mode */
GNUNET_break (0 ==
GNUNET_assert (0 ==
json_object_set (rep,
"claimed_done",
json_string ((done) ? "yes" : "no")));
@ -969,10 +950,13 @@ check_time_difference (const char *table,
GNUNET_STRINGS_relative_time_to_string (delta,
GNUNET_YES));
TALER_ARL_report (report_row_minor_inconsistencies,
json_pack ("{s:s, s:I, s:s}",
"table", table,
"row", (json_int_t) rowid,
"diagnostic", details));
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("table",
table),
GNUNET_JSON_pack_uint64 ("row",
rowid),
GNUNET_JSON_pack_string ("diagnostic",
details)));
GNUNET_free (details);
}
@ -1018,16 +1002,21 @@ wire_out_cb (void *cls,
This is moderately harmless, it might just be that the aggreator
has not yet fully caught up with the transfers it should do. */
TALER_ARL_report (report_wire_out_inconsistencies,
json_pack ("{s:I, s:o, s:o, s:o, s:o, s:s, s:s}",
"row", (json_int_t) rowid,
"amount_wired", TALER_JSON_from_amount (&zero),
"amount_justified", TALER_JSON_from_amount (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_uint64 ("row",
rowid),
TALER_JSON_pack_amount ("amount_wired",
&zero),
TALER_JSON_pack_amount ("amount_justified",
amount),
"wtid", GNUNET_JSON_from_data_auto (wtid),
"timestamp", TALER_ARL_json_from_time_abs (
GNUNET_JSON_pack_data_auto ("wtid",
wtid),
TALER_JSON_pack_time_abs_human ("timestamp",
date),
"diagnostic", "wire transfer not made (yet?)",
"account_section", wa->section_name));
GNUNET_JSON_pack_string ("diagnostic",
"wire transfer not made (yet?)"),
GNUNET_JSON_pack_string ("account_section",
wa->section_name)));
TALER_ARL_amount_add (&total_bad_amount_out_minus,
&total_bad_amount_out_minus,
amount);
@ -1046,34 +1035,44 @@ wire_out_cb (void *cls,
we should count the wire transfer as entirely spurious, and
additionally consider the justified wire transfer as missing. */
TALER_ARL_report (report_wire_out_inconsistencies,
json_pack ("{s:I, s:o, s:o, s:o, s:o, s:s, s:s, s:s}",
"row", (json_int_t) rowid,
"amount_wired", TALER_JSON_from_amount (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_uint64 ("row",
rowid),
TALER_JSON_pack_amount ("amount_wired",
&roi->details.amount),
"amount_justified", TALER_JSON_from_amount (
TALER_JSON_pack_amount ("amount_justified",
&zero),
"wtid", GNUNET_JSON_from_data_auto (wtid),
"timestamp", TALER_ARL_json_from_time_abs (
GNUNET_JSON_pack_data_auto ("wtid", wtid),
TALER_JSON_pack_time_abs_human ("timestamp",
date),
"diagnostic", "receiver account mismatch",
"target", payto_uri,
"account_section", wa->section_name));
GNUNET_JSON_pack_string ("diagnostic",
"receiver account mismatch"),
GNUNET_JSON_pack_string ("target",
payto_uri),
GNUNET_JSON_pack_string ("account_section",
wa->section_name)));
TALER_ARL_amount_add (&total_bad_amount_out_plus,
&total_bad_amount_out_plus,
&roi->details.amount);
TALER_ARL_report (report_wire_out_inconsistencies,
json_pack ("{s:I, s:o, s:o, s:o, s:o, s:s, s:s, s:s}",
"row", (json_int_t) rowid,
"amount_wired", TALER_JSON_from_amount (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_uint64 ("row",
rowid),
TALER_JSON_pack_amount ("amount_wired",
&zero),
"amount_justified", TALER_JSON_from_amount (
TALER_JSON_pack_amount ("amount_justified",
amount),
"wtid", GNUNET_JSON_from_data_auto (wtid),
"timestamp", TALER_ARL_json_from_time_abs (
GNUNET_JSON_pack_data_auto ("wtid",
wtid),
TALER_JSON_pack_time_abs_human ("timestamp",
date),
"diagnostic", "receiver account mismatch",
"target", roi->details.credit_account_url,
"account_section", wa->section_name));
GNUNET_JSON_pack_string ("diagnostic",
"receiver account mismatch"),
GNUNET_JSON_pack_string ("target",
roi->details.
credit_account_url),
GNUNET_JSON_pack_string ("account_section",
wa->section_name)));
TALER_ARL_amount_add (&total_bad_amount_out_minus,
&total_bad_amount_out_minus,
amount);
@ -1086,17 +1085,21 @@ wire_out_cb (void *cls,
amount))
{
TALER_ARL_report (report_wire_out_inconsistencies,
json_pack ("{s:I, s:o, s:o, s:o, s:o, s:s, s:s}",
"row", (json_int_t) rowid,
"amount_justified", TALER_JSON_from_amount (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_uint64 ("row",
rowid),
TALER_JSON_pack_amount ("amount_justified",
amount),
"amount_wired", TALER_JSON_from_amount (
TALER_JSON_pack_amount ("amount_wired",
&roi->details.amount),
"wtid", GNUNET_JSON_from_data_auto (wtid),
"timestamp", TALER_ARL_json_from_time_abs (
GNUNET_JSON_pack_data_auto ("wtid",
wtid),
TALER_JSON_pack_time_abs_human ("timestamp",
date),
"diagnostic", "wire amount does not match",
"account_section", wa->section_name));
GNUNET_JSON_pack_string ("diagnostic",
"wire amount does not match"),
GNUNET_JSON_pack_string ("account_section",
wa->section_name)));
if (0 < TALER_amount_cmp (amount,
&roi->details.amount))
{
@ -1229,20 +1232,22 @@ complain_out_not_found (void *cls,
if (GNUNET_YES == ctx.found)
return GNUNET_OK;
TALER_ARL_report (report_wire_out_inconsistencies,
json_pack ("{s:I, s:o, s:o, s:o, s:o, s:s, s:s}",
"row", (json_int_t) 0,
"amount_wired", TALER_JSON_from_amount (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_uint64 ("row",
0),
TALER_JSON_pack_amount ("amount_wired",
&roi->details.amount),
"amount_justified", TALER_JSON_from_amount (
TALER_JSON_pack_amount ("amount_justified",
&zero),
"wtid", GNUNET_JSON_from_data_auto (
GNUNET_JSON_pack_data_auto ("wtid",
&roi->details.wtid),
"timestamp", TALER_ARL_json_from_time_abs (
roi->details.execution_date),
"account_section",
wa->section_name,
"diagnostic",
"justification for wire transfer not found"));
TALER_JSON_pack_time_abs_human ("timestamp",
roi->details.
execution_date),
GNUNET_JSON_pack_string ("account_section",
wa->section_name),
GNUNET_JSON_pack_string ("diagnostic",
"justification for wire transfer not found")));
TALER_ARL_amount_add (&total_bad_amount_out_plus,
&total_bad_amount_out_plus,
&roi->details.amount);
@ -1379,11 +1384,13 @@ history_debit_cb (void *cls,
&total_wire_format_amount,
&details->amount);
TALER_ARL_report (report_wire_format_inconsistencies,
json_pack ("{s:o, s:I, s:s}",
"amount", TALER_JSON_from_amount (
GNUNET_JSON_PACK (
TALER_JSON_pack_amount ("amount",
&details->amount),
"wire_offset", (json_int_t) row_off,
"diagnostic", diagnostic));
GNUNET_JSON_pack_uint64 ("wire_offset",
row_off),
GNUNET_JSON_pack_string ("diagnostic",
diagnostic)));
GNUNET_free (diagnostic);
return GNUNET_OK;
}
@ -1518,13 +1525,15 @@ reserve_in_cb (void *cls,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
{
TALER_ARL_report (report_row_inconsistencies,
json_pack ("{s:s, s:I, s:o, s:s}",
"table", "reserves_in",
"row", (json_int_t) rowid,
"wire_offset_hash",
GNUNET_JSON_from_data_auto (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("table",
"reserves_in"),
GNUNET_JSON_pack_uint64 ("row",
rowid),
GNUNET_JSON_pack_data_auto ("wire_offset_hash",
&rii->row_off_hash),
"diagnostic", "duplicate wire offset"));
GNUNET_JSON_pack_string ("diagnostic",
"duplicate wire offset")));
GNUNET_free (rii);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
@ -1555,19 +1564,22 @@ complain_in_not_found (void *cls,
(void) key;
TALER_ARL_report (report_reserve_in_inconsistencies,
json_pack ("{s:I, s:o, s:o, s:o, s:o, s:s, s:s}",
"row", (json_int_t) rii->rowid,
"amount_exchange_expected",
TALER_JSON_from_amount (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_uint64 ("row",
rii->rowid),
TALER_JSON_pack_amount ("amount_exchange_expected",
&rii->details.amount),
"amount_wired", TALER_JSON_from_amount (&zero),
"reserve_pub", GNUNET_JSON_from_data_auto (
TALER_JSON_pack_amount ("amount_wired",
&zero),
GNUNET_JSON_pack_data_auto ("reserve_pub",
&rii->details.reserve_pub),
"timestamp", TALER_ARL_json_from_time_abs (
rii->details.execution_date),
"account", wa->section_name,
"diagnostic",
"incoming wire transfer claimed by exchange not found"));
TALER_JSON_pack_time_abs_human ("timestamp",
rii->details.
execution_date),
GNUNET_JSON_pack_string ("account",
wa->section_name),
GNUNET_JSON_pack_string ("diagnostic",
"incoming wire transfer claimed by exchange not found")));
TALER_ARL_amount_add (&total_bad_amount_in_minus,
&total_bad_amount_in_minus,
&rii->details.amount);
@ -1668,35 +1680,41 @@ history_credit_cb (void *cls,
&rii->details.reserve_pub))
{
TALER_ARL_report (report_reserve_in_inconsistencies,
json_pack ("{s:I, s:I, s:o, s:o, s:o, s:o, s:s}",
"row", (json_int_t) rii->rowid,
"bank_row", (json_int_t) row_off,
"amount_exchange_expected",
TALER_JSON_from_amount (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_uint64 ("row",
rii->rowid),
GNUNET_JSON_pack_uint64 ("bank_row",
row_off),
TALER_JSON_pack_amount ("amount_exchange_expected",
&rii->details.amount),
"amount_wired", TALER_JSON_from_amount (&zero),
"reserve_pub", GNUNET_JSON_from_data_auto (
TALER_JSON_pack_amount ("amount_wired",
&zero),
GNUNET_JSON_pack_data_auto ("reserve_pub",
&rii->details.reserve_pub),
"timestamp", TALER_ARL_json_from_time_abs (
rii->details.execution_date),
"diagnostic", "wire subject does not match"));
TALER_JSON_pack_time_abs_human ("timestamp",
rii->details.
execution_date),
GNUNET_JSON_pack_string ("diagnostic",
"wire subject does not match")));
TALER_ARL_amount_add (&total_bad_amount_in_minus,
&total_bad_amount_in_minus,
&rii->details.amount);
TALER_ARL_report (report_reserve_in_inconsistencies,
json_pack ("{s:I, s:I, s:o, s:o, s:o, s:o, s:s}",
"row", (json_int_t) rii->rowid,
"bank_row", (json_int_t) row_off,
"amount_exchange_expected",
TALER_JSON_from_amount (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_uint64 ("row",
rii->rowid),
GNUNET_JSON_pack_uint64 ("bank_row",
row_off),
TALER_JSON_pack_amount ("amount_exchange_expected",
&zero),
"amount_wired", TALER_JSON_from_amount (
TALER_JSON_pack_amount ("amount_wired",
&details->amount),
"reserve_pub", GNUNET_JSON_from_data_auto (
GNUNET_JSON_pack_data_auto ("reserve_pub",
&details->reserve_pub),
"timestamp", TALER_ARL_json_from_time_abs (
TALER_JSON_pack_time_abs_human ("timestamp",
details->execution_date),
"diagnostic", "wire subject does not match"));
GNUNET_JSON_pack_string ("diagnostic",
"wire subject does not match")));
TALER_ARL_amount_add (&total_bad_amount_in_plus,
&total_bad_amount_in_plus,
@ -1707,19 +1725,21 @@ history_credit_cb (void *cls,
&details->amount))
{
TALER_ARL_report (report_reserve_in_inconsistencies,
json_pack ("{s:I, s:I, s:o, s:o, s:o, s:o, s:s}",
"row", (json_int_t) rii->rowid,
"bank_row", (json_int_t) row_off,
"amount_exchange_expected",
TALER_JSON_from_amount (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_uint64 ("row",
rii->rowid),
GNUNET_JSON_pack_uint64 ("bank_row",
row_off),
TALER_JSON_pack_amount ("amount_exchange_expected",
&rii->details.amount),
"amount_wired", TALER_JSON_from_amount (
TALER_JSON_pack_amount ("amount_wired",
&details->amount),
"reserve_pub", GNUNET_JSON_from_data_auto (
GNUNET_JSON_pack_data_auto ("reserve_pub",
&details->reserve_pub),
"timestamp", TALER_ARL_json_from_time_abs (
TALER_JSON_pack_time_abs_human ("timestamp",
details->execution_date),
"diagnostic", "wire amount does not match"));
GNUNET_JSON_pack_string ("diagnostic",
"wire amount does not match")));
if (0 < TALER_amount_cmp (&details->amount,
&rii->details.amount))
{
@ -1751,12 +1771,15 @@ history_credit_cb (void *cls,
rii->details.debit_account_url))
{
TALER_ARL_report (report_missattribution_in_inconsistencies,
json_pack ("{s:o, s:I, s:I, s:o}",
"amount", TALER_JSON_from_amount (
GNUNET_JSON_PACK (
TALER_JSON_pack_amount ("amount",
&rii->details.amount),
"row", (json_int_t) rii->rowid,
"bank_row", (json_int_t) row_off,
"reserve_pub", GNUNET_JSON_from_data_auto (
GNUNET_JSON_pack_uint64 ("row",
rii->rowid),
GNUNET_JSON_pack_uint64 ("bank_row",
row_off),
GNUNET_JSON_pack_data_auto (
"reserve_pub",
&rii->details.reserve_pub)));
TALER_ARL_amount_add (&total_missattribution_in,
&total_missattribution_in,
@ -1766,11 +1789,15 @@ history_credit_cb (void *cls,
rii->details.execution_date.abs_value_us)
{
TALER_ARL_report (report_row_minor_inconsistencies,
json_pack ("{s:s, s:I, s:I, s:s}",
"table", "reserves_in",
"row", (json_int_t) rii->rowid,
"bank_row", (json_int_t) row_off,
"diagnostic", "execution date mismatch"));
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("table",
"reserves_in"),
GNUNET_JSON_pack_uint64 ("row",
rii->rowid),
GNUNET_JSON_pack_uint64 ("bank_row",
row_off),
GNUNET_JSON_pack_string ("diagnostic",
"execution date mismatch")));
}
cleanup:
GNUNET_assert (GNUNET_OK ==
@ -1893,17 +1920,19 @@ reserve_closed_cb (void *cls,
closing_fee))
{
TALER_ARL_report (report_row_inconsistencies,
json_pack ("{s:s, s:I, s:o, s:o, s:o, s:s}",
"table", "reserves_closures",
"row", (json_int_t) rowid,
"reserve_pub", GNUNET_JSON_from_data_auto (
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("table",
"reserves_closures"),
GNUNET_JSON_pack_uint64 ("row",
rowid),
GNUNET_JSON_pack_data_auto ("reserve_pub",
reserve_pub),
"amount_with_fee", TALER_JSON_from_amount (
TALER_JSON_pack_amount ("amount_with_fee",
amount_with_fee),
"closing_fee", TALER_JSON_from_amount (
TALER_JSON_pack_amount ("closing_fee",
closing_fee),
"diagnostic",
"closing fee above total amount"));
GNUNET_JSON_pack_string ("diagnostic",
"closing fee above total amount")));
GNUNET_free (rc);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;

View File

@ -52,6 +52,19 @@ TALER_JSON_pack_time_abs (const char *name,
struct GNUNET_TIME_Absolute at);
/**
* Generate packer instruction for a JSON field of type
* absolute time creating a human-readable timestamp.
*
* @param name name of the field to add to the object
* @param at absolute time to pack
* @return json pack specification
*/
struct GNUNET_JSON_PackSpec
TALER_JSON_pack_time_abs_human (const char *name,
struct GNUNET_TIME_Absolute at);
/**
* Generate packer instruction for a JSON field of type
* absolute time in network byte order.
@ -66,6 +79,19 @@ TALER_JSON_pack_time_abs_nbo (const char *name,
struct GNUNET_TIME_AbsoluteNBO at);
/**
* Generate packer instruction for a JSON field of type
* absolute time creating a human-readable timestamp.
*
* @param name name of the field to add to the object
* @param at absolute time to pack
* @return json pack specification
*/
struct GNUNET_JSON_PackSpec
TALER_JSON_pack_time_abs_nbo_human (const char *name,
struct GNUNET_TIME_AbsoluteNBO at);
/**
* Generate packer instruction for a JSON field of type
* relative time.

View File

@ -35,6 +35,20 @@ TALER_JSON_pack_time_abs (const char *name,
}
struct GNUNET_JSON_PackSpec
TALER_JSON_pack_time_abs_human (const char *name,
struct GNUNET_TIME_Absolute at)
{
struct GNUNET_JSON_PackSpec ps = {
.field_name = name,
.object = json_string (
GNUNET_STRINGS_absolute_time_to_string (at))
};
return ps;
}
struct GNUNET_JSON_PackSpec
TALER_JSON_pack_time_abs_nbo (const char *name,
struct GNUNET_TIME_AbsoluteNBO at)
@ -44,6 +58,15 @@ TALER_JSON_pack_time_abs_nbo (const char *name,
}
struct GNUNET_JSON_PackSpec
TALER_JSON_pack_time_abs_nbo_human (const char *name,
struct GNUNET_TIME_AbsoluteNBO at)
{
return TALER_JSON_pack_time_abs_human (name,
GNUNET_TIME_absolute_ntoh (at));
}
struct GNUNET_JSON_PackSpec
TALER_JSON_pack_time_rel (const char *name,
struct GNUNET_TIME_Relative rt)