-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. * 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; 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. * 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 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 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 terms of the GNU Affero General Public License as published by the Free Software
@ -323,11 +323,13 @@ handle_version (struct TAH_RequestHandler *rh,
(void) connection_cls; (void) connection_cls;
if (NULL == ver) if (NULL == ver)
{ {
ver = json_pack ("{s:s, s:s, s:o}", ver = GNUNET_JSON_PACK (
"version", AUDITOR_PROTOCOL_VERSION, GNUNET_JSON_pack_string ("version",
"currency", TAH_currency, AUDITOR_PROTOCOL_VERSION),
"auditor_public_key", GNUNET_JSON_from_data_auto ( GNUNET_JSON_pack_string ("currency",
&auditor_pub)); TAH_currency),
GNUNET_JSON_pack_data_auto ("auditor_public_key",
&auditor_pub));
} }
if (NULL == ver) if (NULL == ver)
{ {

View File

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

View File

@ -1,6 +1,6 @@
/* /*
This file is part of TALER 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 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 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 *list = cls;
json_t *obj; json_t *obj;
obj = json_pack ("{s:o, s:s}", obj = GNUNET_JSON_PACK (
"master_pub", GNUNET_JSON_pack_data_auto ("master_pub",
GNUNET_JSON_from_data_auto (master_pub), master_pub),
"exchange_url", GNUNET_JSON_pack_string ("exchange_url",
exchange_url); exchange_url));
GNUNET_break (NULL != obj);
GNUNET_break (0 == GNUNET_break (0 ==
json_array_append_new (list, json_array_append_new (list,
obj)); obj));
@ -108,10 +107,11 @@ TAH_EXCHANGES_handler (struct TAH_RequestHandler *rh,
TALER_EC_GENERIC_DB_FETCH_FAILED, TALER_EC_GENERIC_DB_FETCH_FAILED,
"exchanges"); "exchanges");
} }
return TALER_MHD_reply_json_pack (connection, return TALER_MHD_REPLY_JSON_PACK (
MHD_HTTP_OK, connection,
"{s:o}", MHD_HTTP_OK,
"exchanges", ja); GNUNET_JSON_pack_array_steal ("exchanges",
ja));
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -52,6 +52,19 @@ TALER_JSON_pack_time_abs (const char *name,
struct GNUNET_TIME_Absolute at); 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 * Generate packer instruction for a JSON field of type
* absolute time in network byte order. * absolute time in network byte order.
@ -66,6 +79,19 @@ TALER_JSON_pack_time_abs_nbo (const char *name,
struct GNUNET_TIME_AbsoluteNBO at); 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 * Generate packer instruction for a JSON field of type
* relative time. * 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 struct GNUNET_JSON_PackSpec
TALER_JSON_pack_time_abs_nbo (const char *name, TALER_JSON_pack_time_abs_nbo (const char *name,
struct GNUNET_TIME_AbsoluteNBO at) 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 struct GNUNET_JSON_PackSpec
TALER_JSON_pack_time_rel (const char *name, TALER_JSON_pack_time_rel (const char *name,
struct GNUNET_TIME_Relative rt) struct GNUNET_TIME_Relative rt)