-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,10 +323,12 @@ 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",
TAH_currency),
GNUNET_JSON_pack_data_auto ("auditor_public_key",
&auditor_pub)); &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 (
connection,
MHD_HTTP_OK, MHD_HTTP_OK,
"{s:o}", GNUNET_JSON_pack_array_steal ("exchanges",
"exchanges", ja); 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),
GNUNET_JSON_pack_data_auto ("coin_pub",
coin_pub), coin_pub),
"exchange", TALER_JSON_from_amount (exchange), TALER_JSON_pack_amount ("exchange",
"auditor", TALER_JSON_from_amount (auditor), exchange),
"profitable", (json_int_t) profitable)); 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,11 +809,14 @@ 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),
TALER_JSON_pack_amount ("loss",
coin_value),
GNUNET_JSON_pack_data_auto ("coin_pub",
&coin.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,
@ -985,22 +1000,24 @@ 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"),
TALER_JSON_pack_time_abs_human ("time",
wfi->start_date))); 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"),
TALER_JSON_pack_time_abs_human ("time",
wfi->end_date))); 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,"
" s:o, s:o, s:o, s:I, s:I,"
" s:o, s:o, s:o }",
/* blocks #1 */ /* blocks #1 */
GNUNET_JSON_pack_array_steal (
"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 */
"bad_sig_losses", GNUNET_JSON_pack_array_steal ("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 */
"total_bad_sig_loss", TALER_JSON_pack_amount ("total_bad_sig_loss",
TALER_JSON_from_amount (&total_bad_sig_loss), &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),
"deposit_end", TALER_JSON_pack_time_abs_nbo_human ("deposit_end",
TALER_ARL_json_from_time_abs_nbo (
issue->expire_deposit), issue->expire_deposit),
"value", TALER_JSON_pack_amount_nbo ("value",
TALER_JSON_from_amount_nbo (&issue->value))); &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),
"deposit_end", TALER_JSON_pack_time_abs_nbo_human ("deposit_end",
TALER_ARL_json_from_time_abs_nbo (
issue->expire_deposit), issue->expire_deposit),
"value", TALER_JSON_pack_amount_nbo ("value",
TALER_JSON_from_amount_nbo (&issue->value))); &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,12 +1200,14 @@ 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",
rowid),
TALER_JSON_pack_amount ("loss",
loss_potential), loss_potential),
"coin_pub", GNUNET_JSON_from_data_auto ( GNUNET_JSON_pack_data_auto ("coin_pub",
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,
@ -1302,12 +1308,14 @@ 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",
rowid),
TALER_JSON_pack_amount ("loss",
amount_with_fee), amount_with_fee),
"coin_pub", GNUNET_JSON_from_data_auto ( GNUNET_JSON_pack_data_auto ("coin_pub",
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,
@ -1345,11 +1353,12 @@ 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),
TALER_JSON_pack_amount ("amount",
amount_with_fee), amount_with_fee),
"coin_pub", GNUNET_JSON_from_data_auto ( GNUNET_JSON_pack_data_auto ("coin_pub",
coin_pub))); coin_pub)));
TALER_ARL_amount_add (&total_refresh_hanging, TALER_ARL_amount_add (&total_refresh_hanging,
&total_refresh_hanging, &total_refresh_hanging,
@ -1653,12 +1662,14 @@ 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",
rowid),
TALER_JSON_pack_amount ("loss",
amount_with_fee), amount_with_fee),
"coin_pub", GNUNET_JSON_from_data_auto ( GNUNET_JSON_pack_data_auto ("coin_pub",
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,
@ -1679,12 +1690,14 @@ 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",
rowid),
TALER_JSON_pack_amount ("loss",
amount_with_fee), amount_with_fee),
"coin_pub", GNUNET_JSON_from_data_auto ( GNUNET_JSON_pack_data_auto ("coin_pub",
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,
@ -1850,12 +1863,14 @@ 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",
rowid),
TALER_JSON_pack_amount ("loss",
amount_with_fee), amount_with_fee),
"coin_pub", GNUNET_JSON_from_data_auto ( GNUNET_JSON_pack_data_auto ("coin_pub",
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,
@ -1961,11 +1976,14 @@ 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),
TALER_JSON_pack_amount ("loss",
amount),
GNUNET_JSON_pack_data_auto ("coin_pub",
&coin->denom_pub_hash))); &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,
@ -2018,11 +2036,14 @@ 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),
TALER_JSON_pack_amount ("loss",
amount),
GNUNET_JSON_pack_data_auto ("coin_pub",
&coin->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,
@ -2047,14 +2068,16 @@ 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",
amount),
GNUNET_JSON_pack_data_auto ("coin_pub",
&coin->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,
@ -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),
"value", TALER_JSON_pack_amount ("value",
TALER_JSON_from_amount (&coin_value), &coin_value),
"start_time", TALER_JSON_pack_time_abs_nbo_human ("start_time",
TALER_ARL_json_from_time_abs_nbo (
issue->start), issue->start),
"end_time", TALER_JSON_pack_time_abs_nbo_human ("end_time",
TALER_ARL_json_from_time_abs_nbo ( issue->
issue->expire_legal))); 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}",
/* 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 (
&total_deposit_fee_income), &total_deposit_fee_income),
"total_melt_fee_income", TALER_JSON_pack_amount ("total_melt_fee_income",
TALER_JSON_from_amount (&total_melt_fee_income), &total_melt_fee_income),
"total_refund_fee_income", TALER_JSON_pack_amount ("total_refund_fee_income",
TALER_JSON_from_amount (
&total_refund_fee_income), &total_refund_fee_income),
/* Block #2 */
/* Tested in test-auditor.sh #18 */ /* Tested in test-auditor.sh #18 */
"emergencies", GNUNET_JSON_pack_array_steal ("emergencies",
report_emergencies, report_emergencies),
/* Tested in test-auditor.sh #18 */ /* Tested in test-auditor.sh #18 */
"emergencies_risk_by_amount", TALER_JSON_pack_amount ("emergencies_risk_by_amount",
TALER_JSON_from_amount (
&reported_emergency_risk_by_amount), &reported_emergency_risk_by_amount),
/* Tested in test-auditor.sh #4/#5/#6/#13/#26 */ /* Tested in test-auditor.sh #4/#5/#6/#13/#26 */
"bad_sig_losses", GNUNET_JSON_pack_array_steal ("bad_sig_losses",
report_bad_sig_losses, report_bad_sig_losses),
/* Tested in test-auditor.sh #4/#5/#6/#13/#26 */ /* Tested in test-auditor.sh #4/#5/#6/#13/#26 */
"total_bad_sig_loss", TALER_JSON_pack_amount ("total_bad_sig_loss",
TALER_JSON_from_amount (&total_bad_sig_loss), &total_bad_sig_loss),
/* Tested in test-auditor.sh #31 */ /* Tested in test-auditor.sh #31 */
"row_inconsistencies", GNUNET_JSON_pack_array_steal ("row_inconsistencies",
report_row_inconsistencies, report_row_inconsistencies),
/* Block #3 */
/* Tested in test-auditor.sh #18 */ /* Tested in test-auditor.sh #18 */
"amount_arithmetic_inconsistencies", GNUNET_JSON_pack_array_steal ("amount_arithmetic_inconsistencies",
report_amount_arithmetic_inconsistencies, report_amount_arithmetic_inconsistencies),
"total_arithmetic_delta_plus", TALER_JSON_pack_amount ("total_arithmetic_delta_plus",
TALER_JSON_from_amount (
&total_arithmetic_delta_plus), &total_arithmetic_delta_plus),
"total_arithmetic_delta_minus", TALER_JSON_pack_amount ("total_arithmetic_delta_minus",
TALER_JSON_from_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 */ /* Tested in test-auditor.sh #12 */
"total_refresh_hanging", GNUNET_JSON_pack_array_steal ("refresh_hanging",
TALER_JSON_from_amount (&total_refresh_hanging), report_refreshs_hanging),
/* Tested in test-auditor.sh #12 */ TALER_JSON_pack_amount ("total_recoup_loss",
"refresh_hanging", &total_recoup_loss),
report_refreshs_hanging,
/* Block #4 */
"total_recoup_loss",
TALER_JSON_from_amount (&total_recoup_loss),
/* Tested in test-auditor.sh #18 */ /* Tested in test-auditor.sh #18 */
"emergencies_by_count", GNUNET_JSON_pack_array_steal ("emergencies_by_count",
report_emergencies_by_count, report_emergencies_by_count),
/* Tested in test-auditor.sh #18 */ /* Tested in test-auditor.sh #18 */
"emergencies_risk_by_count", TALER_JSON_pack_amount ("emergencies_risk_by_count",
TALER_JSON_from_amount (
&reported_emergency_risk_by_count), &reported_emergency_risk_by_count),
/* Tested in test-auditor.sh #18 */ /* Tested in test-auditor.sh #18 */
"emergencies_loss", TALER_JSON_pack_amount ("emergencies_loss",
TALER_JSON_from_amount (
&reported_emergency_loss), &reported_emergency_loss),
/* Tested in test-auditor.sh #18 */ /* Tested in test-auditor.sh #18 */
"emergencies_loss_by_count", TALER_JSON_pack_amount ("emergencies_loss_by_count",
TALER_JSON_from_amount (
&reported_emergency_loss_by_count), &reported_emergency_loss_by_count),
/* Block #5 */ GNUNET_JSON_pack_uint64 ("start_ppc_withdraw_serial_id",
"start_ppc_withdraw_serial_id", ppc_start.last_withdraw_serial_id),
(json_int_t) ppc_start.last_withdraw_serial_id, GNUNET_JSON_pack_uint64 ("start_ppc_deposit_serial_id",
"start_ppc_deposit_serial_id", ppc_start.last_deposit_serial_id),
(json_int_t) ppc_start.last_deposit_serial_id, GNUNET_JSON_pack_uint64 ("start_ppc_melt_serial_id",
"start_ppc_melt_serial_id", ppc_start.last_melt_serial_id),
(json_int_t) ppc_start.last_melt_serial_id, GNUNET_JSON_pack_uint64 ("start_ppc_refund_serial_id",
"start_ppc_refund_serial_id", ppc_start.last_refund_serial_id),
(json_int_t) ppc_start.last_refund_serial_id, GNUNET_JSON_pack_uint64 ("start_ppc_recoup_serial_id",
"start_ppc_recoup_serial_id", ppc_start.last_recoup_serial_id),
(json_int_t) ppc_start.last_recoup_serial_id, GNUNET_JSON_pack_uint64 ("start_ppc_recoup_refresh_serial_id",
/* Block #6 */ ppc_start.
"start_ppc_recoup_refresh_serial_id", last_recoup_refresh_serial_id),
(json_int_t) ppc_start. GNUNET_JSON_pack_uint64 ("end_ppc_withdraw_serial_id",
last_recoup_refresh_serial_id, ppc.last_withdraw_serial_id),
"end_ppc_withdraw_serial_id", GNUNET_JSON_pack_uint64 ("end_ppc_deposit_serial_id",
(json_int_t) ppc.last_withdraw_serial_id, ppc.last_deposit_serial_id),
"end_ppc_deposit_serial_id", GNUNET_JSON_pack_uint64 ("end_ppc_melt_serial_id",
(json_int_t) ppc.last_deposit_serial_id, ppc.last_melt_serial_id),
"end_ppc_melt_serial_id", GNUNET_JSON_pack_uint64 ("end_ppc_refund_serial_id",
(json_int_t) ppc.last_melt_serial_id, ppc.last_refund_serial_id),
"end_ppc_refund_serial_id", GNUNET_JSON_pack_uint64 ("end_ppc_recoup_serial_id",
(json_int_t) ppc.last_refund_serial_id, ppc.last_recoup_serial_id),
/* Block #7 */ GNUNET_JSON_pack_uint64 ("end_ppc_recoup_refresh_serial_id",
"end_ppc_recoup_serial_id", ppc.last_recoup_refresh_serial_id),
(json_int_t) ppc.last_recoup_serial_id, TALER_JSON_pack_time_abs_human ("auditor_start_time",
"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), start_time),
"auditor_end_time", TALER_JSON_pack_time_abs_human ("auditor_end_time",
TALER_ARL_json_from_time_abs (
GNUNET_TIME_absolute_get ()), GNUNET_TIME_absolute_get ()),
"total_irregular_recoups", TALER_JSON_pack_amount ("total_irregular_recoups",
TALER_JSON_from_amount (
&total_irregular_recoups), &total_irregular_recoups),
/* Block #8 */ GNUNET_JSON_pack_array_steal ("unsigned_denominations",
"unsigned_denominations", report_denominations_without_sigs)));
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),
"amount", TALER_JSON_pack_amount ("amount",
TALER_JSON_from_amount (&dc->amount_without_fee), &dc->amount_without_fee),
"rowid", GNUNET_JSON_pack_uint64 ("rowid",
(json_int_t) serial_id, serial_id),
"account", GNUNET_JSON_pack_data_auto ("account",
GNUNET_JSON_from_data_auto (&dc->h_wire))); &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,
"missing_deposit_confirmation_total",
TALER_JSON_from_amount (
&total_missed_deposit_confirmations), &total_missed_deposit_confirmations),
"auditor_start_time", TALER_JSON_pack_time_abs_human ("auditor_start_time",
TALER_ARL_json_from_time_abs (
start_time), start_time),
"auditor_end_time", TALER_JSON_pack_time_abs_human ("auditor_end_time",
TALER_ARL_json_from_time_abs ( GNUNET_TIME_absolute_get ())));
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,13 +557,14 @@ 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),
GNUNET_JSON_pack_data_auto ("reserve_pub",
reserve_pub), reserve_pub),
"denompub_h", GNUNET_JSON_from_data_auto ( GNUNET_JSON_pack_data_auto ("denompub_h",
&wsrd.h_denomination_pub))); &wsrd.h_denomination_pub)));
} }
@ -569,12 +578,14 @@ 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",
rowid),
TALER_JSON_pack_amount ("loss",
amount_with_fee), amount_with_fee),
"key_pub", GNUNET_JSON_from_data_auto ( GNUNET_JSON_pack_data_auto ("key_pub",
reserve_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,
@ -712,11 +723,14 @@ 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),
TALER_JSON_pack_amount ("loss",
amount),
GNUNET_JSON_pack_data_auto ("key_pub",
&coin->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,
@ -778,11 +792,14 @@ 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_JSON_pack_amount ("loss",
amount),
GNUNET_JSON_pack_data_auto ("key_pub",
&TALER_ARL_master_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,
@ -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),
"gain", TALER_JSON_pack_amount ("gain",
TALER_JSON_from_amount (&nbalance))); &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),
"exchange", TALER_JSON_pack_amount ("exchange",
TALER_JSON_from_amount (&reserve.balance), &reserve.balance),
"auditor", TALER_JSON_pack_amount ("auditor",
TALER_JSON_from_amount (&nbalance))); &nbalance)));
} }
} }
} /* end of 'if (internal_checks)' */ } /* end of 'if (internal_checks)' */
@ -1160,15 +1175,14 @@ 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)));
} }
} }
@ -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),
"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),
"diagnostic", GNUNET_JSON_pack_string ("diagnostic",
"could not determine closing fee")); "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,"
" 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 */
"reserve_balance_insufficient_inconsistencies", "reserve_balance_insufficient_inconsistencies",
report_reserve_balance_insufficient_inconsistencies, report_reserve_balance_insufficient_inconsistencies),
/* Tested in test-auditor.sh #3 */ /* Tested in test-auditor.sh #3 */
"total_loss_balance_insufficient", TALER_JSON_pack_amount ("total_loss_balance_insufficient",
TALER_JSON_from_amount (
&total_balance_insufficient_loss), &total_balance_insufficient_loss),
/* Tested in test-auditor.sh #3 */ /* Tested in test-auditor.sh #3 */
GNUNET_JSON_pack_array_steal (
"reserve_balance_summary_wrong_inconsistencies", "reserve_balance_summary_wrong_inconsistencies",
report_reserve_balance_summary_wrong_inconsistencies, report_reserve_balance_summary_wrong_inconsistencies),
"total_balance_summary_delta_plus", TALER_JSON_pack_amount ("total_balance_summary_delta_plus",
TALER_JSON_from_amount (
&total_balance_summary_delta_plus), &total_balance_summary_delta_plus),
"total_balance_summary_delta_minus", TALER_JSON_pack_amount ("total_balance_summary_delta_minus",
TALER_JSON_from_amount (
&total_balance_summary_delta_minus), &total_balance_summary_delta_minus),
/* blocks #2 */ /* blocks #2 */
"total_escrow_balance", TALER_JSON_pack_amount ("total_escrow_balance",
TALER_JSON_from_amount (&total_escrow_balance), &total_escrow_balance),
"total_withdraw_fee_income", TALER_JSON_pack_amount ("total_withdraw_fee_income",
TALER_JSON_from_amount (
&total_withdraw_fee_income), &total_withdraw_fee_income),
/* Tested in test-auditor.sh #21 */ /* Tested in test-auditor.sh #21 */
"reserve_not_closed_inconsistencies", GNUNET_JSON_pack_array_steal ("reserve_not_closed_inconsistencies",
report_reserve_not_closed_inconsistencies, report_reserve_not_closed_inconsistencies),
/* Tested in test-auditor.sh #21 */ /* Tested in test-auditor.sh #21 */
"total_balance_reserve_not_closed", TALER_JSON_pack_amount ("total_balance_reserve_not_closed",
TALER_JSON_from_amount (
&total_balance_reserve_not_closed), &total_balance_reserve_not_closed),
/* Tested in test-auditor.sh #7 */ /* Tested in test-auditor.sh #7 */
"bad_sig_losses", GNUNET_JSON_pack_array_steal ("bad_sig_losses",
report_bad_sig_losses, report_bad_sig_losses),
/* blocks #3 */
/* Tested in test-auditor.sh #7 */ /* Tested in test-auditor.sh #7 */
"total_bad_sig_loss", TALER_JSON_pack_amount ("total_bad_sig_loss",
TALER_JSON_from_amount (&total_bad_sig_loss), &total_bad_sig_loss),
/* Tested in test-revocation.sh #4 */ /* Tested in test-revocation.sh #4 */
"row_inconsistencies", GNUNET_JSON_pack_array_steal ("row_inconsistencies",
report_row_inconsistencies, report_row_inconsistencies),
/* Tested in test-auditor.sh #23 */ /* Tested in test-auditor.sh #23 */
GNUNET_JSON_pack_array_steal (
"denomination_key_validity_withdraw_inconsistencies", "denomination_key_validity_withdraw_inconsistencies",
denomination_key_validity_withdraw_inconsistencies, denomination_key_validity_withdraw_inconsistencies),
"amount_arithmetic_inconsistencies", GNUNET_JSON_pack_array_steal ("amount_arithmetic_inconsistencies",
report_amount_arithmetic_inconsistencies, report_amount_arithmetic_inconsistencies),
"total_arithmetic_delta_plus", TALER_JSON_pack_amount ("total_arithmetic_delta_plus",
TALER_JSON_from_amount (
&total_arithmetic_delta_plus), &total_arithmetic_delta_plus),
/* blocks #4 */ TALER_JSON_pack_amount ("total_arithmetic_delta_minus",
"total_arithmetic_delta_minus",
TALER_JSON_from_amount (
&total_arithmetic_delta_minus), &total_arithmetic_delta_minus),
"auditor_start_time", TALER_JSON_pack_time_abs_human ("auditor_start_time",
TALER_ARL_json_from_time_abs (
start_time), start_time),
"auditor_end_time", TALER_JSON_pack_time_abs_human ("auditor_end_time",
TALER_ARL_json_from_time_abs (
GNUNET_TIME_absolute_get ()), GNUNET_TIME_absolute_get ()),
"total_irregular_recoups", TALER_JSON_pack_amount ("total_irregular_recoups",
TALER_JSON_from_amount (
&total_irregular_recoups), &total_irregular_recoups),
"start_ppr_reserve_in_serial_id", GNUNET_JSON_pack_uint64 ("start_ppr_reserve_in_serial_id",
(json_int_t) ppr_start.last_reserve_in_serial_id, ppr_start.last_reserve_in_serial_id),
/* blocks #5 */ GNUNET_JSON_pack_uint64 ("start_ppr_reserve_out_serial_id",
"start_ppr_reserve_out_serial_id", ppr_start.last_reserve_out_serial_id),
(json_int_t) ppr_start. GNUNET_JSON_pack_uint64 ("start_ppr_reserve_recoup_serial_id",
last_reserve_out_serial_id, ppr_start.last_reserve_recoup_serial_id),
"start_ppr_reserve_recoup_serial_id", GNUNET_JSON_pack_uint64 ("start_ppr_reserve_close_serial_id",
(json_int_t) ppr_start. ppr_start.last_reserve_close_serial_id),
last_reserve_recoup_serial_id, GNUNET_JSON_pack_uint64 ("end_ppr_reserve_in_serial_id",
"start_ppr_reserve_close_serial_id", ppr.last_reserve_in_serial_id),
(json_int_t) ppr_start. GNUNET_JSON_pack_uint64 ("end_ppr_reserve_out_serial_id",
last_reserve_close_serial_id, ppr.last_reserve_out_serial_id),
"end_ppr_reserve_in_serial_id", GNUNET_JSON_pack_uint64 ("end_ppr_reserve_recoup_serial_id",
(json_int_t) ppr.last_reserve_in_serial_id, ppr.last_reserve_recoup_serial_id),
"end_ppr_reserve_out_serial_id", GNUNET_JSON_pack_uint64 ("end_ppr_reserve_close_serial_id",
(json_int_t) ppr.last_reserve_out_serial_id, ppr.last_reserve_close_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,"
" s:o, s:o, s:o, s:I, s:I,"
" s:o, s:o, s:o }",
/* blocks of 5 */
/* Tested in test-auditor.sh #11, #15, #20 */ /* Tested in test-auditor.sh #11, #15, #20 */
"wire_out_amount_inconsistencies", GNUNET_JSON_pack_array_steal ("wire_out_amount_inconsistencies",
report_wire_out_inconsistencies, report_wire_out_inconsistencies),
"total_wire_out_delta_plus", TALER_JSON_pack_amount ("total_wire_out_delta_plus",
TALER_JSON_from_amount (
&total_bad_amount_out_plus), &total_bad_amount_out_plus),
/* Tested in test-auditor.sh #11, #15, #19 */ /* Tested in test-auditor.sh #11, #15, #19 */
"total_wire_out_delta_minus", TALER_JSON_pack_amount ("total_wire_out_delta_minus",
TALER_JSON_from_amount (
&total_bad_amount_out_minus), &total_bad_amount_out_minus),
/* Tested in test-auditor.sh #2 */ /* Tested in test-auditor.sh #2 */
"reserve_in_amount_inconsistencies", GNUNET_JSON_pack_array_steal ("reserve_in_amount_inconsistencies",
report_reserve_in_inconsistencies, report_reserve_in_inconsistencies),
/* Tested in test-auditor.sh #2 */ /* Tested in test-auditor.sh #2 */
"total_wire_in_delta_plus", TALER_JSON_pack_amount ("total_wire_in_delta_plus",
TALER_JSON_from_amount (
&total_bad_amount_in_plus), &total_bad_amount_in_plus),
/* block */
/* Tested in test-auditor.sh #3 */ /* Tested in test-auditor.sh #3 */
"total_wire_in_delta_minus", TALER_JSON_pack_amount ("total_wire_in_delta_minus",
TALER_JSON_from_amount (
&total_bad_amount_in_minus), &total_bad_amount_in_minus),
/* Tested in test-auditor.sh #9 */ /* Tested in test-auditor.sh #9 */
"missattribution_in_inconsistencies", GNUNET_JSON_pack_array_steal ("missattribution_in_inconsistencies",
report_missattribution_in_inconsistencies, report_missattribution_in_inconsistencies),
/* Tested in test-auditor.sh #9 */ /* Tested in test-auditor.sh #9 */
"total_missattribution_in", TALER_JSON_pack_amount ("total_missattribution_in",
TALER_JSON_from_amount (
&total_missattribution_in), &total_missattribution_in),
"row_inconsistencies", GNUNET_JSON_pack_array_steal ("row_inconsistencies",
report_row_inconsistencies, report_row_inconsistencies),
/* Tested in test-auditor.sh #10/#17 */ /* Tested in test-auditor.sh #10/#17 */
"row_minor_inconsistencies", GNUNET_JSON_pack_array_steal ("row_minor_inconsistencies",
report_row_minor_inconsistencies, report_row_minor_inconsistencies),
/* block */
/* Tested in test-auditor.sh #19 */ /* Tested in test-auditor.sh #19 */
"total_wire_format_amount", TALER_JSON_pack_amount ("total_wire_format_amount",
TALER_JSON_from_amount (
&total_wire_format_amount), &total_wire_format_amount),
/* Tested in test-auditor.sh #19 */ /* Tested in test-auditor.sh #19 */
"wire_format_inconsistencies", GNUNET_JSON_pack_array_steal ("wire_format_inconsistencies",
report_wire_format_inconsistencies, report_wire_format_inconsistencies),
/* Tested in test-auditor.sh #1 */ /* Tested in test-auditor.sh #1 */
"total_amount_lag", TALER_JSON_pack_amount ("total_amount_lag",
TALER_JSON_from_amount (&total_amount_lag), &total_amount_lag),
/* Tested in test-auditor.sh #1 */ /* Tested in test-auditor.sh #1 */
"lag_details", GNUNET_JSON_pack_array_steal ("lag_details",
report_lags, report_lags),
/* Tested in test-auditor.sh #22 */ /* Tested in test-auditor.sh #22 */
"total_closure_amount_lag", TALER_JSON_pack_amount ("total_closure_amount_lag",
TALER_JSON_from_amount (
&total_closure_amount_lag), &total_closure_amount_lag),
/* blocks of 5 */
/* Tested in test-auditor.sh #22 */ /* Tested in test-auditor.sh #22 */
"reserve_lag_details", GNUNET_JSON_pack_array_steal ("reserve_lag_details",
report_closure_lags, report_closure_lags),
"wire_auditor_start_time", TALER_JSON_pack_time_abs_human ("wire_auditor_start_time",
TALER_ARL_json_from_time_abs (
start_time), start_time),
"wire_auditor_end_time", TALER_JSON_pack_time_abs_human ("wire_auditor_end_time",
TALER_ARL_json_from_time_abs (
GNUNET_TIME_absolute_get ()), GNUNET_TIME_absolute_get ()),
"start_pp_reserve_close_uuid", GNUNET_JSON_pack_uint64 ("start_pp_reserve_close_uuid",
(json_int_t) start_pp.last_reserve_close_uuid, start_pp.last_reserve_close_uuid),
"end_pp_reserve_close_uuid", GNUNET_JSON_pack_uint64 ("end_pp_reserve_close_uuid",
(json_int_t) pp.last_reserve_close_uuid, pp.last_reserve_close_uuid),
/* blocks of 5 */ TALER_JSON_pack_time_abs_human ("start_pp_last_timestamp",
"start_pp_last_timestamp",
TALER_ARL_json_from_time_abs (
start_pp.last_timestamp), start_pp.last_timestamp),
"end_pp_last_timestamp", TALER_JSON_pack_time_abs_human ("end_pp_last_timestamp",
TALER_ARL_json_from_time_abs (
pp.last_timestamp), pp.last_timestamp),
"account_progress", GNUNET_JSON_pack_array_steal ("account_progress",
report_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->amount),
TALER_JSON_pack_time_abs_human ("deadline",
rc->execution_date), rc->execution_date),
"wtid", GNUNET_JSON_from_data_auto (&rc->wtid), GNUNET_JSON_pack_data_auto ("wtid",
"account", rc->receiver_account)); &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,19 +841,21 @@ 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",
amount),
TALER_JSON_pack_time_abs_human ("deadline",
deadline), deadline),
"coin_pub", GNUNET_JSON_from_data_auto ( GNUNET_JSON_pack_data_auto ("coin_pub",
coin_pub), coin_pub),
"account", wire); GNUNET_JSON_pack_object_incref ("account",
GNUNET_break (NULL != rep); (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")));
@ -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",
&zero),
TALER_JSON_pack_amount ("amount_justified",
amount), amount),
"wtid", GNUNET_JSON_from_data_auto (wtid), GNUNET_JSON_pack_data_auto ("wtid",
"timestamp", TALER_ARL_json_from_time_abs ( wtid),
TALER_JSON_pack_time_abs_human ("timestamp",
date), date),
"diagnostic", "wire transfer not made (yet?)", GNUNET_JSON_pack_string ("diagnostic",
"account_section", wa->section_name)); "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),
TALER_JSON_pack_amount ("amount_wired",
&roi->details.amount), &roi->details.amount),
"amount_justified", TALER_JSON_from_amount ( TALER_JSON_pack_amount ("amount_justified",
&zero), &zero),
"wtid", GNUNET_JSON_from_data_auto (wtid), GNUNET_JSON_pack_data_auto ("wtid", wtid),
"timestamp", TALER_ARL_json_from_time_abs ( TALER_JSON_pack_time_abs_human ("timestamp",
date), date),
"diagnostic", "receiver account mismatch", GNUNET_JSON_pack_string ("diagnostic",
"target", payto_uri, "receiver account mismatch"),
"account_section", wa->section_name)); 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),
TALER_JSON_pack_amount ("amount_wired",
&zero), &zero),
"amount_justified", TALER_JSON_from_amount ( TALER_JSON_pack_amount ("amount_justified",
amount), amount),
"wtid", GNUNET_JSON_from_data_auto (wtid), GNUNET_JSON_pack_data_auto ("wtid",
"timestamp", TALER_ARL_json_from_time_abs ( wtid),
TALER_JSON_pack_time_abs_human ("timestamp",
date), date),
"diagnostic", "receiver account mismatch", GNUNET_JSON_pack_string ("diagnostic",
"target", roi->details.credit_account_url, "receiver account mismatch"),
"account_section", wa->section_name)); 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),
TALER_JSON_pack_amount ("amount_justified",
amount), amount),
"amount_wired", TALER_JSON_from_amount ( TALER_JSON_pack_amount ("amount_wired",
&roi->details.amount), &roi->details.amount),
"wtid", GNUNET_JSON_from_data_auto (wtid), GNUNET_JSON_pack_data_auto ("wtid",
"timestamp", TALER_ARL_json_from_time_abs ( wtid),
TALER_JSON_pack_time_abs_human ("timestamp",
date), date),
"diagnostic", "wire amount does not match", GNUNET_JSON_pack_string ("diagnostic",
"account_section", wa->section_name)); "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),
TALER_JSON_pack_amount ("amount_wired",
&roi->details.amount), &roi->details.amount),
"amount_justified", TALER_JSON_from_amount ( TALER_JSON_pack_amount ("amount_justified",
&zero), &zero),
"wtid", GNUNET_JSON_from_data_auto ( GNUNET_JSON_pack_data_auto ("wtid",
&roi->details.wtid), &roi->details.wtid),
"timestamp", TALER_ARL_json_from_time_abs ( TALER_JSON_pack_time_abs_human ("timestamp",
roi->details.execution_date), roi->details.
"account_section", execution_date),
wa->section_name, GNUNET_JSON_pack_string ("account_section",
"diagnostic", wa->section_name),
"justification for wire transfer not found")); 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),
GNUNET_JSON_pack_data_auto ("wire_offset_hash",
&rii->row_off_hash), &rii->row_off_hash),
"diagnostic", "duplicate wire offset")); 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),
GNUNET_JSON_pack_data_auto ("reserve_pub",
&rii->details.reserve_pub), &rii->details.reserve_pub),
"timestamp", TALER_ARL_json_from_time_abs ( TALER_JSON_pack_time_abs_human ("timestamp",
rii->details.execution_date), rii->details.
"account", wa->section_name, execution_date),
"diagnostic", GNUNET_JSON_pack_string ("account",
"incoming wire transfer claimed by exchange not found")); 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),
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),
GNUNET_JSON_pack_data_auto ("reserve_pub",
&rii->details.reserve_pub), &rii->details.reserve_pub),
"timestamp", TALER_ARL_json_from_time_abs ( TALER_JSON_pack_time_abs_human ("timestamp",
rii->details.execution_date), rii->details.
"diagnostic", "wire subject does not match")); 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),
TALER_JSON_pack_amount ("amount_exchange_expected",
&zero), &zero),
"amount_wired", TALER_JSON_from_amount ( TALER_JSON_pack_amount ("amount_wired",
&details->amount), &details->amount),
"reserve_pub", GNUNET_JSON_from_data_auto ( GNUNET_JSON_pack_data_auto ("reserve_pub",
&details->reserve_pub), &details->reserve_pub),
"timestamp", TALER_ARL_json_from_time_abs ( TALER_JSON_pack_time_abs_human ("timestamp",
details->execution_date), 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, 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),
TALER_JSON_pack_amount ("amount_exchange_expected",
&rii->details.amount), &rii->details.amount),
"amount_wired", TALER_JSON_from_amount ( TALER_JSON_pack_amount ("amount_wired",
&details->amount), &details->amount),
"reserve_pub", GNUNET_JSON_from_data_auto ( GNUNET_JSON_pack_data_auto ("reserve_pub",
&details->reserve_pub), &details->reserve_pub),
"timestamp", TALER_ARL_json_from_time_abs ( TALER_JSON_pack_time_abs_human ("timestamp",
details->execution_date), 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, if (0 < TALER_amount_cmp (&details->amount,
&rii->details.amount)) &rii->details.amount))
{ {
@ -1751,12 +1771,15 @@ 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",
row_off),
GNUNET_JSON_pack_data_auto (
"reserve_pub",
&rii->details.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,
@ -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",
rowid),
GNUNET_JSON_pack_data_auto ("reserve_pub",
reserve_pub), reserve_pub),
"amount_with_fee", TALER_JSON_from_amount ( TALER_JSON_pack_amount ("amount_with_fee",
amount_with_fee), amount_with_fee),
"closing_fee", TALER_JSON_from_amount ( TALER_JSON_pack_amount ("closing_fee",
closing_fee), closing_fee),
"diagnostic", GNUNET_JSON_pack_string ("diagnostic",
"closing fee above total amount")); "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)