summaryrefslogtreecommitdiff
path: root/src/auditor/taler-helper-auditor-coins.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/auditor/taler-helper-auditor-coins.c')
-rw-r--r--src/auditor/taler-helper-auditor-coins.c723
1 files changed, 381 insertions, 342 deletions
diff --git a/src/auditor/taler-helper-auditor-coins.c b/src/auditor/taler-helper-auditor-coins.c
index a3c8afb54..f88f39eaf 100644
--- a/src/auditor/taler-helper-auditor-coins.c
+++ b/src/auditor/taler-helper-auditor-coins.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2016-2022 Taler Systems SA
+ Copyright (C) 2016-2024 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero Public License as published by the Free Software
@@ -45,14 +45,37 @@
static int global_ret;
/**
- * Checkpointing our progress for coins.
+ * Run in test mode. Exit when idle instead of
+ * going to sleep and waiting for more work.
+ *
+ * FIXME: not yet implemented!
*/
-static struct TALER_AUDITORDB_ProgressPointCoin ppc;
+static int test_mode;
/**
* Checkpointing our progress for coins.
*/
-static struct TALER_AUDITORDB_ProgressPointCoin ppc_start;
+static TALER_ARL_DEF_PP (coins_withdraw_serial_id);
+static TALER_ARL_DEF_PP (coins_deposit_serial_id);
+static TALER_ARL_DEF_PP (coins_melt_serial_id);
+static TALER_ARL_DEF_PP (coins_refund_serial_id);
+static TALER_ARL_DEF_PP (coins_recoup_serial_id);
+static TALER_ARL_DEF_PP (coins_recoup_refresh_serial_id);
+static TALER_ARL_DEF_PP (coins_purse_deposits_serial_id);
+static TALER_ARL_DEF_PP (coins_purse_refunds_serial_id);
+
+
+/**
+ * Global coin balance sheet (for coins).
+ */
+static TALER_ARL_DEF_AB (coin_balance_risk);
+static TALER_ARL_DEF_AB (total_escrowed);
+static TALER_ARL_DEF_AB (coin_irregular_loss);
+static TALER_ARL_DEF_AB (coin_melt_fee_revenue);
+static TALER_ARL_DEF_AB (coin_deposit_fee_revenue);
+static TALER_ARL_DEF_AB (coin_refund_fee_revenue);
+static TALER_ARL_DEF_AB (total_recoup_loss);
+
/**
* Array of reports about denomination keys with an
@@ -67,7 +90,7 @@ static json_t *report_emergencies;
static json_t *report_emergencies_by_count;
/**
- * Array of reports about row inconsitencies.
+ * Array of reports about row inconsistencies.
*/
static json_t *report_row_inconsistencies;
@@ -112,40 +135,6 @@ static struct TALER_Amount reported_emergency_loss;
*/
static struct TALER_Amount reported_emergency_loss_by_count;
-/**
- * Expected balance in the escrow account.
- */
-static struct TALER_Amount total_escrow_balance;
-
-/**
- * Active risk exposure.
- */
-static struct TALER_Amount total_risk;
-
-/**
- * Actualized risk (= loss) from recoups.
- */
-static struct TALER_Amount total_recoup_loss;
-
-/**
- * Recoups we made on denominations that were not revoked (!?).
- */
-static struct TALER_Amount total_irregular_recoups;
-
-/**
- * Total deposit fees earned.
- */
-static struct TALER_Amount total_deposit_fee_income;
-
-/**
- * Total melt fees earned.
- */
-static struct TALER_Amount total_melt_fee_income;
-
-/**
- * Total refund fees earned.
- */
-static struct TALER_Amount total_refund_fee_income;
/**
* Array of reports about coin operations with bad signatures.
@@ -153,15 +142,10 @@ static struct TALER_Amount total_refund_fee_income;
static json_t *report_bad_sig_losses;
/**
- * Total amount lost by operations for which signatures were invalid.
- */
-static struct TALER_Amount total_bad_sig_loss;
-
-/**
* Array of refresh transactions where the /refresh/reveal has not yet
* happened (and may of course never happen).
*/
-static json_t *report_refreshs_hanging;
+static json_t *report_refreshes_hanging;
/**
* Total amount lost by operations for which signatures were invalid.
@@ -207,9 +191,9 @@ coin_history_index (const struct TALER_CoinSpendPublicKeyP *coin_pub)
{
uint32_t i;
- memcpy (&i,
- coin_pub,
- sizeof (i));
+ GNUNET_memcpy (&i,
+ coin_pub,
+ sizeof (i));
return i % MAX_COIN_HISTORIES;
}
@@ -470,10 +454,24 @@ check_coin_history (const struct TALER_CoinSpendPublicKeyP *coin_pub,
struct TALER_Amount refunded;
struct TALER_Amount deposit_fee;
bool have_refund;
+ uint64_t etag_out;
- qs = TALER_ARL_edb->get_coin_transactions (TALER_ARL_edb->cls,
- coin_pub,
- &tl);
+ /* TODO: could use 'etag' mechanism to only fetch transactions
+ we did not yet process, instead of going over them
+ again and again. */
+ {
+ struct TALER_Amount balance;
+ struct TALER_DenominationHashP h_denom_pub;
+
+ qs = TALER_ARL_edb->get_coin_transactions (TALER_ARL_edb->cls,
+ coin_pub,
+ 0,
+ 0,
+ &etag_out,
+ &balance,
+ &h_denom_pub,
+ &tl);
+ }
if (0 >= qs)
return qs;
GNUNET_assert (GNUNET_OK ==
@@ -539,8 +537,22 @@ check_coin_history (const struct TALER_CoinSpendPublicKeyP *coin_pub,
&spent,
&pos->details.purse_deposit->amount);
break;
- }
- }
+ case TALER_EXCHANGEDB_TT_PURSE_REFUND:
+ TALER_ARL_amount_add (&refunded,
+ &refunded,
+ &tl->details.purse_refund->refund_amount);
+ TALER_ARL_amount_add (&spent,
+ &spent,
+ &pos->details.purse_refund->refund_fee);
+ have_refund = true;
+ break;
+ case TALER_EXCHANGEDB_TT_RESERVE_OPEN:
+ TALER_ARL_amount_add (&spent,
+ &spent,
+ &tl->details.reserve_open->coin_contribution);
+ break;
+ } /* switch (pos->type) */
+ } /* for (...) */
if (have_refund)
{
@@ -591,33 +603,9 @@ check_coin_history (const struct TALER_CoinSpendPublicKeyP *coin_pub,
struct DenominationSummary
{
/**
- * Total value of outstanding (not deposited) coins issued with this
- * denomination key.
- */
- struct TALER_Amount denom_balance;
-
- /**
- * Total losses made (once coins deposited exceed
- * coins withdrawn and thus the @e denom_balance is
- * effectively negative).
+ * Information about the circulation.
*/
- struct TALER_Amount denom_loss;
-
- /**
- * Total value of coins issued with this denomination key.
- */
- struct TALER_Amount denom_risk;
-
- /**
- * Total value of coins subjected to recoup with this denomination key.
- */
- struct TALER_Amount denom_recoup;
-
- /**
- * How many coins (not their amount!) of this denomination
- * did the exchange issue overall?
- */
- uint64_t num_issued;
+ struct TALER_AUDITORDB_DenominationCirculationData dcd;
/**
* Denomination key information for this denomination.
@@ -680,11 +668,7 @@ init_denomination (const struct TALER_DenominationHashP *denom_hash,
qs = TALER_ARL_adb->get_denomination_balance (TALER_ARL_adb->cls,
denom_hash,
- &ds->denom_balance,
- &ds->denom_loss,
- &ds->denom_risk,
- &ds->denom_recoup,
- &ds->num_issued);
+ &ds->dcd);
if (0 > qs)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
@@ -698,22 +682,22 @@ init_denomination (const struct TALER_DenominationHashP *denom_hash,
{
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &ds->denom_balance));
+ &ds->dcd.denom_balance));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &ds->denom_loss));
+ &ds->dcd.denom_loss));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &ds->denom_risk));
+ &ds->dcd.denom_risk));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &ds->denom_recoup));
+ &ds->dcd.recoup_loss));
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting balance for denomination `%s' is %s (%llu)\n",
GNUNET_h2s (&denom_hash->hash),
- TALER_amount2s (&ds->denom_balance),
- (unsigned long long) ds->num_issued);
+ TALER_amount2s (&ds->dcd.denom_balance),
+ (unsigned long long) ds->dcd.num_issued);
qs = TALER_ARL_edb->get_denomination_revocation (TALER_ARL_edb->cls,
denom_hash,
&msig,
@@ -828,15 +812,14 @@ sync_denomination (void *cls,
else
qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
if ( (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) &&
- ( (0 != ds->denom_risk.value) ||
- (0 != ds->denom_risk.fraction) ) )
+ (! TALER_amount_is_zero (&ds->dcd.denom_risk)) )
{
/* The denomination expired and carried a balance; we can now
book the remaining balance as profit, and reduce our risk
exposure by the accumulated risk of the denomination. */
- TALER_ARL_amount_subtract (&total_risk,
- &total_risk,
- &ds->denom_risk);
+ TALER_ARL_amount_subtract (&TALER_ARL_USE_AB (coin_balance_risk),
+ &TALER_ARL_USE_AB (coin_balance_risk),
+ &ds->dcd.denom_risk);
/* If the above fails, our risk assessment is inconsistent!
This is really, really bad (auditor-internal invariant
would be violated). Hence we can "safely" assert. If
@@ -844,22 +827,20 @@ sync_denomination (void *cls,
in the auditor _or_ the auditor's database is corrupt. */
}
if ( (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) &&
- ( (0 != ds->denom_balance.value) ||
- (0 != ds->denom_balance.fraction) ) )
+ (! TALER_amount_is_zero (&ds->dcd.denom_balance)) )
{
/* book denom_balance coin expiration profits! */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Denomination `%s' expired, booking %s in expiration profits\n",
GNUNET_h2s (denom_hash),
- TALER_amount2s (&ds->denom_balance));
+ TALER_amount2s (&ds->dcd.denom_balance));
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
(qs = TALER_ARL_adb->insert_historic_denom_revenue (
TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
&denom_h,
expire_deposit,
- &ds->denom_balance,
- &ds->denom_recoup)))
+ &ds->dcd.denom_balance,
+ &ds->dcd.recoup_loss)))
{
/* Failed to store profits? Bad database */
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
@@ -876,8 +857,8 @@ sync_denomination (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Final balance for denomination `%s' is %s (%llu)\n",
GNUNET_h2s (denom_hash),
- TALER_amount2s (&ds->denom_balance),
- (unsigned long long) ds->num_issued);
+ TALER_amount2s (&ds->dcd.denom_balance),
+ (unsigned long long) ds->dcd.num_issued);
cnt = TALER_ARL_edb->count_known_coins (TALER_ARL_edb->cls,
&denom_h);
if (0 > cnt)
@@ -889,39 +870,31 @@ sync_denomination (void *cls,
}
else
{
- if (ds->num_issued < (uint64_t) cnt)
+ if (ds->dcd.num_issued < (uint64_t) cnt)
{
/* more coins deposited than issued! very bad */
report_emergency_by_count (issue,
- ds->num_issued,
+ ds->dcd.num_issued,
cnt,
- &ds->denom_risk);
+ &ds->dcd.denom_risk);
}
if (ds->report_emergency)
{
/* Value of coins deposited exceed value of coins
issued! Also very bad! */
report_emergency_by_amount (issue,
- &ds->denom_risk,
- &ds->denom_loss);
+ &ds->dcd.denom_risk,
+ &ds->dcd.denom_loss);
}
if (ds->in_db)
qs = TALER_ARL_adb->update_denomination_balance (TALER_ARL_adb->cls,
&denom_h,
- &ds->denom_balance,
- &ds->denom_loss,
- &ds->denom_risk,
- &ds->denom_recoup,
- ds->num_issued);
+ &ds->dcd);
else
qs = TALER_ARL_adb->insert_denomination_balance (TALER_ARL_adb->cls,
&denom_h,
- &ds->denom_balance,
- &ds->denom_loss,
- &ds->denom_risk,
- &ds->denom_recoup,
- ds->num_issued);
+ &ds->dcd);
}
}
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
@@ -983,8 +956,9 @@ withdraw_cb (void *cls,
(void) execution_date;
(void) amount_with_fee;
- GNUNET_assert (rowid >= ppc.last_withdraw_serial_id); /* should be monotonically increasing */
- ppc.last_withdraw_serial_id = rowid + 1;
+ GNUNET_assert (rowid >=
+ TALER_ARL_USE_PP (coins_withdraw_serial_id)); /* should be monotonically increasing */
+ TALER_ARL_USE_PP (coins_withdraw_serial_id) = rowid + 1;
qs = TALER_ARL_get_denomination_info (denom_pub,
&issue,
@@ -1018,22 +992,22 @@ withdraw_cb (void *cls,
"Issued coin in denomination `%s' of total value %s\n",
GNUNET_h2s (&dh.hash),
TALER_amount2s (&issue->value));
- ds->num_issued++;
- TALER_ARL_amount_add (&ds->denom_balance,
- &ds->denom_balance,
- &issue->value);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"New balance of denomination `%s' is %s\n",
GNUNET_h2s (&dh.hash),
- TALER_amount2s (&ds->denom_balance));
- TALER_ARL_amount_add (&total_escrow_balance,
- &total_escrow_balance,
+ TALER_amount2s (&ds->dcd.denom_balance));
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_escrowed),
+ &TALER_ARL_USE_AB (total_escrowed),
&issue->value);
- TALER_ARL_amount_add (&total_risk,
- &total_risk,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_balance_risk),
+ &TALER_ARL_USE_AB (coin_balance_risk),
&issue->value);
- TALER_ARL_amount_add (&ds->denom_risk,
- &ds->denom_risk,
+ ds->dcd.num_issued++;
+ TALER_ARL_amount_add (&ds->dcd.denom_balance,
+ &ds->dcd.denom_balance,
+ &issue->value);
+ TALER_ARL_amount_add (&ds->dcd.denom_risk,
+ &ds->dcd.denom_risk,
&issue->value);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
@@ -1187,8 +1161,8 @@ check_known_coin (
loss_potential),
GNUNET_JSON_pack_data_auto ("coin_pub",
coin_pub)));
- TALER_ARL_amount_add (&total_bad_sig_loss,
- &total_bad_sig_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_irregular_loss),
+ &TALER_ARL_USE_AB (coin_irregular_loss),
loss_potential);
}
TALER_denom_sig_free (&ci.denom_sig);
@@ -1199,7 +1173,7 @@ check_known_coin (
/**
* Update the denom balance in @a dso reducing it by
* @a amount_with_fee. If this is not possible, report
- * an emergency. Also updates the #total_escrow_balance.
+ * an emergency. Also updates the balance.
*
* @param dso denomination summary to update
* @param rowid responsible row (for logging)
@@ -1214,19 +1188,19 @@ reduce_denom_balance (struct DenominationSummary *dso,
if (TALER_ARL_SR_INVALID_NEGATIVE ==
TALER_ARL_amount_subtract_neg (&tmp,
- &dso->denom_balance,
+ &dso->dcd.denom_balance,
amount_with_fee))
{
- TALER_ARL_amount_add (&dso->denom_loss,
- &dso->denom_loss,
+ TALER_ARL_amount_add (&dso->dcd.denom_loss,
+ &dso->dcd.denom_loss,
amount_with_fee);
dso->report_emergency = true;
}
else
{
- dso->denom_balance = tmp;
+ dso->dcd.denom_balance = tmp;
}
- if (-1 == TALER_amount_cmp (&total_escrow_balance,
+ if (-1 == TALER_amount_cmp (&TALER_ARL_USE_AB (total_escrowed),
amount_with_fee))
{
/* This can theoretically happen if for example the exchange
@@ -1238,20 +1212,20 @@ reduce_denom_balance (struct DenominationSummary *dso,
report_amount_arithmetic_inconsistency (
"subtracting amount from escrow balance",
rowid,
- &total_escrow_balance,
+ &TALER_ARL_USE_AB (total_escrowed),
amount_with_fee,
0);
}
else
{
- TALER_ARL_amount_subtract (&total_escrow_balance,
- &total_escrow_balance,
+ TALER_ARL_amount_subtract (&TALER_ARL_USE_AB (total_escrowed),
+ &TALER_ARL_USE_AB (total_escrowed),
amount_with_fee);
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"New balance of denomination `%s' is %s\n",
GNUNET_h2s (&dso->issue->denom_hash.hash),
- TALER_amount2s (&dso->denom_balance));
+ TALER_amount2s (&dso->dcd.denom_balance));
}
@@ -1291,8 +1265,9 @@ refresh_session_cb (void *cls,
enum GNUNET_DB_QueryStatus qs;
(void) noreveal_index;
- GNUNET_assert (rowid >= ppc.last_melt_serial_id); /* should be monotonically increasing */
- ppc.last_melt_serial_id = rowid + 1;
+ GNUNET_assert (rowid >=
+ TALER_ARL_USE_PP (coins_melt_serial_id)); /* should be monotonically increasing */
+ TALER_ARL_USE_PP (coins_melt_serial_id) = rowid + 1;
qs = TALER_ARL_get_denomination_info (denom_pub,
&issue,
@@ -1351,8 +1326,8 @@ refresh_session_cb (void *cls,
amount_with_fee),
GNUNET_JSON_pack_data_auto ("coin_pub",
coin_pub)));
- TALER_ARL_amount_add (&total_bad_sig_loss,
- &total_bad_sig_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_irregular_loss),
+ &TALER_ARL_USE_AB (coin_irregular_loss),
amount_with_fee);
}
}
@@ -1385,7 +1360,7 @@ refresh_session_cb (void *cls,
/* This can legitimately happen if reveal was not yet called or only
with invalid data, even if the exchange is correctly operating. We
still report it. */
- TALER_ARL_report (report_refreshs_hanging,
+ TALER_ARL_report (report_refreshes_hanging,
GNUNET_JSON_PACK (
GNUNET_JSON_pack_uint64 ("row",
rowid),
@@ -1487,22 +1462,22 @@ refresh_session_cb (void *cls,
"Created fresh coin in denomination `%s' of value %s\n",
GNUNET_h2s (&ni->denom_hash.hash),
TALER_amount2s (&ni->value));
- dsi->num_issued++;
- TALER_ARL_amount_add (&dsi->denom_balance,
- &dsi->denom_balance,
+ dsi->dcd.num_issued++;
+ TALER_ARL_amount_add (&dsi->dcd.denom_balance,
+ &dsi->dcd.denom_balance,
&ni->value);
- TALER_ARL_amount_add (&dsi->denom_risk,
- &dsi->denom_risk,
+ TALER_ARL_amount_add (&dsi->dcd.denom_risk,
+ &dsi->dcd.denom_risk,
&ni->value);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"New balance of denomination `%s' is %s\n",
GNUNET_h2s (&ni->denom_hash.hash),
- TALER_amount2s (&dsi->denom_balance));
- TALER_ARL_amount_add (&total_escrow_balance,
- &total_escrow_balance,
+ TALER_amount2s (&dsi->dcd.denom_balance));
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_escrowed),
+ &TALER_ARL_USE_AB (total_escrowed),
&ni->value);
- TALER_ARL_amount_add (&total_risk,
- &total_risk,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_balance_risk),
+ &TALER_ARL_USE_AB (coin_balance_risk),
&ni->value);
}
}
@@ -1527,8 +1502,8 @@ refresh_session_cb (void *cls,
}
/* update global melt fees */
- TALER_ARL_amount_add (&total_melt_fee_income,
- &total_melt_fee_income,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_melt_fee_revenue),
+ &TALER_ARL_USE_AB (coin_melt_fee_revenue),
&issue->fees.refresh);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
@@ -1563,8 +1538,9 @@ deposit_cb (void *cls,
(void) done;
(void) exchange_timestamp;
- GNUNET_assert (rowid >= ppc.last_deposit_serial_id); /* should be monotonically increasing */
- ppc.last_deposit_serial_id = rowid + 1;
+ GNUNET_assert (rowid >=
+ TALER_ARL_USE_PP (coins_deposit_serial_id)); /* should be monotonically increasing */
+ TALER_ARL_USE_PP (coins_deposit_serial_id) = rowid + 1;
qs = TALER_ARL_get_denomination_info (denom_pub,
&issue,
@@ -1624,8 +1600,11 @@ deposit_cb (void *cls,
&issue->fees.deposit,
&h_wire,
&deposit->h_contract_terms,
+ deposit->no_wallet_data_hash
+ ? NULL
+ : &deposit->wallet_data_hash,
&deposit->coin.h_age_commitment,
- NULL /* FIXME-Oec: #7270: h_extensions! */,
+ &deposit->h_policy,
&h_denom_pub,
deposit->timestamp,
&deposit->merchant_pub,
@@ -1643,8 +1622,8 @@ deposit_cb (void *cls,
&deposit->amount_with_fee),
GNUNET_JSON_pack_data_auto ("coin_pub",
&deposit->coin.coin_pub)));
- TALER_ARL_amount_add (&total_bad_sig_loss,
- &total_bad_sig_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_irregular_loss),
+ &TALER_ARL_USE_AB (coin_irregular_loss),
&deposit->amount_with_fee);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
@@ -1675,8 +1654,8 @@ deposit_cb (void *cls,
}
/* update global deposit fees */
- TALER_ARL_amount_add (&total_deposit_fee_income,
- &total_deposit_fee_income,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_deposit_fee_revenue),
+ &TALER_ARL_USE_AB (coin_deposit_fee_revenue),
&issue->fees.deposit);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
@@ -1720,8 +1699,8 @@ refund_cb (void *cls,
struct TALER_Amount amount_without_fee;
enum GNUNET_DB_QueryStatus qs;
- GNUNET_assert (rowid >= ppc.last_refund_serial_id); /* should be monotonically increasing */
- ppc.last_refund_serial_id = rowid + 1;
+ GNUNET_assert (rowid >= TALER_ARL_USE_PP (coins_refund_serial_id)); /* should be monotonically increasing */
+ TALER_ARL_USE_PP (coins_refund_serial_id) = rowid + 1;
qs = TALER_ARL_get_denomination_info (denom_pub,
&issue,
@@ -1760,8 +1739,8 @@ refund_cb (void *cls,
amount_with_fee),
GNUNET_JSON_pack_data_auto ("coin_pub",
coin_pub)));
- TALER_ARL_amount_add (&total_bad_sig_loss,
- &total_bad_sig_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_irregular_loss),
+ &TALER_ARL_USE_AB (coin_irregular_loss),
amount_with_fee);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
@@ -1801,31 +1780,31 @@ refund_cb (void *cls,
}
else
{
- TALER_ARL_amount_add (&ds->denom_balance,
- &ds->denom_balance,
+ TALER_ARL_amount_add (&ds->dcd.denom_balance,
+ &ds->dcd.denom_balance,
&amount_without_fee);
- TALER_ARL_amount_add (&ds->denom_risk,
- &ds->denom_risk,
+ TALER_ARL_amount_add (&ds->dcd.denom_risk,
+ &ds->dcd.denom_risk,
&amount_without_fee);
- TALER_ARL_amount_add (&total_escrow_balance,
- &total_escrow_balance,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_escrowed),
+ &TALER_ARL_USE_AB (total_escrowed),
&amount_without_fee);
- TALER_ARL_amount_add (&total_risk,
- &total_risk,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_balance_risk),
+ &TALER_ARL_USE_AB (coin_balance_risk),
&amount_without_fee);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"New balance of denomination `%s' after refund is %s\n",
GNUNET_h2s (&issue->denom_hash.hash),
- TALER_amount2s (&ds->denom_balance));
+ TALER_amount2s (&ds->dcd.denom_balance));
}
/* update total refund fee balance */
- TALER_ARL_amount_add (&total_refund_fee_income,
- &total_refund_fee_income,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_refund_fee_revenue),
+ &TALER_ARL_USE_AB (coin_refund_fee_revenue),
&issue->fees.refund);
if (full_refund)
{
- TALER_ARL_amount_subtract (&total_deposit_fee_income,
- &total_deposit_fee_income,
+ TALER_ARL_amount_subtract (&TALER_ARL_USE_AB (coin_deposit_fee_revenue),
+ &TALER_ARL_USE_AB (coin_deposit_fee_revenue),
&issue->fees.deposit);
}
if (TALER_ARL_do_abort ())
@@ -1893,26 +1872,26 @@ purse_refund_coin_cb (
}
else
{
- TALER_ARL_amount_add (&ds->denom_balance,
- &ds->denom_balance,
+ TALER_ARL_amount_add (&ds->dcd.denom_balance,
+ &ds->dcd.denom_balance,
amount_with_fee);
- TALER_ARL_amount_add (&ds->denom_risk,
- &ds->denom_risk,
+ TALER_ARL_amount_add (&ds->dcd.denom_risk,
+ &ds->dcd.denom_risk,
amount_with_fee);
- TALER_ARL_amount_add (&total_escrow_balance,
- &total_escrow_balance,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_escrowed),
+ &TALER_ARL_USE_AB (total_escrowed),
amount_with_fee);
- TALER_ARL_amount_add (&total_risk,
- &total_risk,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_balance_risk),
+ &TALER_ARL_USE_AB (coin_balance_risk),
amount_with_fee);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"New balance of denomination `%s' after purse-refund is %s\n",
GNUNET_h2s (&issue->denom_hash.hash),
- TALER_amount2s (&ds->denom_balance));
+ TALER_amount2s (&ds->dcd.denom_balance));
}
/* update total deposit fee balance */
- TALER_ARL_amount_subtract (&total_deposit_fee_income,
- &total_deposit_fee_income,
+ TALER_ARL_amount_subtract (&TALER_ARL_USE_AB (coin_deposit_fee_revenue),
+ &TALER_ARL_USE_AB (coin_deposit_fee_revenue),
&issue->fees.deposit);
return GNUNET_OK;
@@ -1927,18 +1906,25 @@ purse_refund_coin_cb (
* @param cls closure
* @param rowid unique serial ID for the refund in our DB
* @param purse_pub public key of the purse
+ * @param reserve_pub public key of the targeted reserve (ignored)
+ * @param val targeted amount to be in the reserve (ignored)
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
*/
static enum GNUNET_GenericReturnValue
purse_refund_cb (void *cls,
uint64_t rowid,
- const struct TALER_PurseContractPublicKeyP *purse_pub)
+ const struct TALER_PurseContractPublicKeyP *purse_pub,
+ const struct TALER_ReservePublicKeyP *reserve_pub,
+ const struct TALER_Amount *val)
{
struct CoinContext *cc = cls;
enum GNUNET_DB_QueryStatus qs;
- GNUNET_assert (rowid >= ppc.last_purse_refunds_serial_id); /* should be monotonically increasing */
- ppc.last_purse_refunds_serial_id = rowid + 1;
+ (void) val; /* irrelevant on refund */
+ (void) reserve_pub; /* irrelevant, may even be NULL */
+ GNUNET_assert (rowid >=
+ TALER_ARL_USE_PP (coins_purse_refunds_serial_id)); /* should be monotonically increasing */
+ TALER_ARL_USE_PP (coins_purse_refunds_serial_id) = rowid + 1;
qs = TALER_ARL_edb->select_purse_deposits_by_purse (TALER_ARL_edb->cls,
purse_pub,
&purse_refund_coin_cb,
@@ -1976,13 +1962,23 @@ check_recoup (struct CoinContext *cc,
const struct TALER_CoinPublicInfo *coin,
const struct TALER_DenominationPublicKey *denom_pub,
const struct TALER_CoinSpendSignatureP *coin_sig,
- const union TALER_DenominationBlindingKeyP *coin_blind)
+ const union GNUNET_CRYPTO_BlindingSecretP *coin_blind)
{
struct DenominationSummary *ds;
enum GNUNET_DB_QueryStatus qs;
const struct TALER_EXCHANGEDB_DenominationKeyInformation *issue;
if (GNUNET_OK !=
+ TALER_wallet_recoup_verify (&coin->denom_pub_hash,
+ coin_blind,
+ &coin->coin_pub,
+ coin_sig))
+ {
+ report_row_inconsistency (operation,
+ rowid,
+ "recoup signature invalid");
+ }
+ if (GNUNET_OK !=
TALER_test_coin_valid (coin,
denom_pub))
{
@@ -1996,8 +1992,8 @@ check_recoup (struct CoinContext *cc,
amount),
GNUNET_JSON_pack_data_auto ("coin_pub",
&coin->denom_pub_hash)));
- TALER_ARL_amount_add (&total_bad_sig_loss,
- &total_bad_sig_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_irregular_loss),
+ &TALER_ARL_USE_AB (coin_irregular_loss),
amount);
}
qs = TALER_ARL_get_denomination_info_by_hash (&coin->denom_pub_hash,
@@ -2057,15 +2053,15 @@ check_recoup (struct CoinContext *cc,
amount),
GNUNET_JSON_pack_data_auto ("coin_pub",
&coin->coin_pub)));
- TALER_ARL_amount_add (&total_bad_sig_loss,
- &total_bad_sig_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_irregular_loss),
+ &TALER_ARL_USE_AB (coin_irregular_loss),
amount);
}
- TALER_ARL_amount_add (&ds->denom_recoup,
- &ds->denom_recoup,
+ TALER_ARL_amount_add (&ds->dcd.recoup_loss,
+ &ds->dcd.recoup_loss,
amount);
- TALER_ARL_amount_add (&total_recoup_loss,
- &total_recoup_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_recoup_loss),
+ &TALER_ARL_USE_AB (total_recoup_loss),
amount);
}
if (TALER_ARL_do_abort ())
@@ -2097,12 +2093,12 @@ recoup_cb (void *cls,
const struct TALER_CoinPublicInfo *coin,
const struct TALER_DenominationPublicKey *denom_pub,
const struct TALER_CoinSpendSignatureP *coin_sig,
- const union TALER_DenominationBlindingKeyP *coin_blind)
+ const union GNUNET_CRYPTO_BlindingSecretP *coin_blind)
{
struct CoinContext *cc = cls;
- GNUNET_assert (rowid >= ppc.last_recoup_serial_id); /* should be monotonically increasing */
- ppc.last_recoup_serial_id = rowid + 1;
+ GNUNET_assert (rowid >= TALER_ARL_USE_PP (coins_recoup_serial_id)); /* should be monotonically increasing */
+ TALER_ARL_USE_PP (coins_recoup_serial_id) = rowid + 1;
(void) timestamp;
(void) reserve_pub;
if (GNUNET_OK !=
@@ -2121,8 +2117,8 @@ recoup_cb (void *cls,
amount),
GNUNET_JSON_pack_data_auto ("coin_pub",
&coin->coin_pub)));
- TALER_ARL_amount_add (&total_bad_sig_loss,
- &total_bad_sig_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_irregular_loss),
+ &TALER_ARL_USE_AB (coin_irregular_loss),
amount);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
@@ -2165,7 +2161,7 @@ recoup_refresh_cb (void *cls,
const struct TALER_CoinPublicInfo *coin,
const struct TALER_DenominationPublicKey *denom_pub,
const struct TALER_CoinSpendSignatureP *coin_sig,
- const union TALER_DenominationBlindingKeyP *coin_blind)
+ const union GNUNET_CRYPTO_BlindingSecretP *coin_blind)
{
struct CoinContext *cc = cls;
const struct TALER_EXCHANGEDB_DenominationKeyInformation *issue;
@@ -2173,8 +2169,8 @@ recoup_refresh_cb (void *cls,
(void) timestamp;
(void) old_coin_pub;
- GNUNET_assert (rowid >= ppc.last_recoup_refresh_serial_id); /* should be monotonically increasing */
- ppc.last_recoup_refresh_serial_id = rowid + 1;
+ GNUNET_assert (rowid >= TALER_ARL_USE_PP (coins_recoup_refresh_serial_id)); /* should be monotonically increasing */
+ TALER_ARL_USE_PP (coins_recoup_refresh_serial_id) = rowid + 1;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Recoup-refresh amount is %s\n",
TALER_amount2s (amount));
@@ -2209,13 +2205,13 @@ recoup_refresh_cb (void *cls,
}
else
{
- TALER_ARL_amount_add (&dso->denom_balance,
- &dso->denom_balance,
+ TALER_ARL_amount_add (&dso->dcd.denom_balance,
+ &dso->dcd.denom_balance,
amount);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"New balance of denomination `%s' after refresh-recoup is %s\n",
GNUNET_h2s (&issue->denom_hash.hash),
- TALER_amount2s (&dso->denom_balance));
+ TALER_amount2s (&dso->dcd.denom_balance));
}
}
@@ -2235,8 +2231,8 @@ recoup_refresh_cb (void *cls,
amount),
GNUNET_JSON_pack_data_auto ("coin_pub",
&coin->coin_pub)));
- TALER_ARL_amount_add (&total_bad_sig_loss,
- &total_bad_sig_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_irregular_loss),
+ &TALER_ARL_USE_AB (coin_irregular_loss),
amount);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
@@ -2359,8 +2355,9 @@ purse_deposit_cb (
(void) auditor_balance;
(void) purse_total;
(void) reserve_pub;
- GNUNET_assert (rowid >= ppc.last_purse_deposits_serial_id);
- ppc.last_purse_deposits_serial_id = rowid + 1;
+ GNUNET_assert (rowid >=
+ TALER_ARL_USE_PP (coins_purse_deposits_serial_id));
+ TALER_ARL_USE_PP (coins_purse_deposits_serial_id) = rowid + 1;
qs = TALER_ARL_get_denomination_info (denom_pub,
&issue,
&dh);
@@ -2408,8 +2405,8 @@ purse_deposit_cb (
&deposit->amount),
GNUNET_JSON_pack_data_auto ("coin_pub",
&deposit->coin_pub)));
- TALER_ARL_amount_add (&total_bad_sig_loss,
- &total_bad_sig_loss,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_irregular_loss),
+ &TALER_ARL_USE_AB (coin_irregular_loss),
&deposit->amount);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
@@ -2434,8 +2431,8 @@ purse_deposit_cb (
}
/* update global deposit fees */
- TALER_ARL_amount_add (&total_deposit_fee_income,
- &total_deposit_fee_income,
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_deposit_fee_revenue),
+ &TALER_ARL_USE_AB (coin_deposit_fee_revenue),
&issue->fees.deposit);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
@@ -2470,9 +2467,17 @@ analyze_coins (void *cls)
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Analyzing coins\n");
- qsp = TALER_ARL_adb->get_auditor_progress_coin (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &ppc);
+ qsp = TALER_ARL_adb->get_auditor_progress (
+ TALER_ARL_adb->cls,
+ TALER_ARL_GET_PP (coins_withdraw_serial_id),
+ TALER_ARL_GET_PP (coins_deposit_serial_id),
+ TALER_ARL_GET_PP (coins_melt_serial_id),
+ TALER_ARL_GET_PP (coins_refund_serial_id),
+ TALER_ARL_GET_PP (coins_recoup_serial_id),
+ TALER_ARL_GET_PP (coins_recoup_refresh_serial_id),
+ TALER_ARL_GET_PP (coins_purse_deposits_serial_id),
+ TALER_ARL_GET_PP (coins_purse_refunds_serial_id),
+ NULL);
if (0 > qsp)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsp);
@@ -2485,30 +2490,39 @@ analyze_coins (void *cls)
}
else
{
- ppc_start = ppc;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Resuming coin audit at %llu/%llu/%llu/%llu/%llu/%llu\n",
- (unsigned long long) ppc.last_deposit_serial_id,
- (unsigned long long) ppc.last_melt_serial_id,
- (unsigned long long) ppc.last_refund_serial_id,
- (unsigned long long) ppc.last_withdraw_serial_id,
- (unsigned long long) ppc.last_recoup_refresh_serial_id,
- (unsigned long long) ppc.last_purse_deposits_serial_id);
+ GNUNET_log (
+ GNUNET_ERROR_TYPE_INFO,
+ "Resuming coin audit at %llu/%llu/%llu/%llu/%llu/%llu/%llu\n",
+ (unsigned long long) TALER_ARL_USE_PP (
+ coins_deposit_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ coins_melt_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ coins_refund_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ coins_withdraw_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ coins_recoup_refresh_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ coins_purse_deposits_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ coins_purse_refunds_serial_id));
}
/* setup 'cc' */
cc.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
cc.denom_summaries = GNUNET_CONTAINER_multihashmap_create (256,
GNUNET_NO);
- qsx = TALER_ARL_adb->get_balance_summary (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &total_escrow_balance,
- &total_deposit_fee_income,
- &total_melt_fee_income,
- &total_refund_fee_income,
- &total_risk,
- &total_recoup_loss,
- &total_irregular_recoups);
+ qsx = TALER_ARL_adb->get_balance (
+ TALER_ARL_adb->cls,
+ TALER_ARL_GET_AB (coin_balance_risk),
+ TALER_ARL_GET_AB (total_escrowed),
+ TALER_ARL_GET_AB (coin_irregular_loss),
+ TALER_ARL_GET_AB (coin_melt_fee_revenue),
+ TALER_ARL_GET_AB (coin_deposit_fee_revenue),
+ TALER_ARL_GET_AB (coin_refund_fee_revenue),
+ TALER_ARL_GET_AB (total_recoup_loss),
+ NULL);
if (0 > qsx)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx);
@@ -2519,7 +2533,7 @@ analyze_coins (void *cls)
if (0 >
(qs = TALER_ARL_edb->select_withdrawals_above_serial_id (
TALER_ARL_edb->cls,
- ppc.last_withdraw_serial_id,
+ TALER_ARL_USE_PP (coins_withdraw_serial_id),
&withdraw_cb,
&cc)) )
{
@@ -2533,7 +2547,7 @@ analyze_coins (void *cls)
if (0 >
(qs = TALER_ARL_edb->select_refunds_above_serial_id (
TALER_ARL_edb->cls,
- ppc.last_refund_serial_id,
+ TALER_ARL_USE_PP (coins_refund_serial_id),
&refund_cb,
&cc)))
{
@@ -2545,9 +2559,10 @@ analyze_coins (void *cls)
/* process purse_refunds */
if (0 >
- (qs = TALER_ARL_edb->select_purse_refunds_above_serial_id (
+ (qs = TALER_ARL_edb->select_purse_decisions_above_serial_id (
TALER_ARL_edb->cls,
- ppc.last_purse_refunds_serial_id,
+ TALER_ARL_USE_PP (coins_purse_refunds_serial_id),
+ true, /* only go for refunds! */
&purse_refund_cb,
&cc)))
{
@@ -2561,7 +2576,7 @@ analyze_coins (void *cls)
if (0 >
(qs = TALER_ARL_edb->select_recoup_refresh_above_serial_id (
TALER_ARL_edb->cls,
- ppc.last_recoup_refresh_serial_id,
+ TALER_ARL_USE_PP (coins_recoup_refresh_serial_id),
&recoup_refresh_cb,
&cc)))
{
@@ -2573,7 +2588,7 @@ analyze_coins (void *cls)
if (0 >
(qs = TALER_ARL_edb->select_recoup_above_serial_id (
TALER_ARL_edb->cls,
- ppc.last_recoup_serial_id,
+ TALER_ARL_USE_PP (coins_recoup_serial_id),
&recoup_cb,
&cc)))
{
@@ -2583,11 +2598,11 @@ analyze_coins (void *cls)
if (0 > cc.qs)
return cc.qs;
- /* process refreshs */
+ /* process refreshes */
if (0 >
(qs = TALER_ARL_edb->select_refreshes_above_serial_id (
TALER_ARL_edb->cls,
- ppc.last_melt_serial_id,
+ TALER_ARL_USE_PP (coins_melt_serial_id),
&refresh_session_cb,
&cc)))
{
@@ -2599,9 +2614,9 @@ analyze_coins (void *cls)
/* process deposits */
if (0 >
- (qs = TALER_ARL_edb->select_deposits_above_serial_id (
+ (qs = TALER_ARL_edb->select_coin_deposits_above_serial_id (
TALER_ARL_edb->cls,
- ppc.last_deposit_serial_id,
+ TALER_ARL_USE_PP (coins_deposit_serial_id),
&deposit_cb,
&cc)))
{
@@ -2615,7 +2630,7 @@ analyze_coins (void *cls)
if (0 >
(qs = TALER_ARL_edb->select_purse_deposits_above_serial_id (
TALER_ARL_edb->cls,
- ppc.last_purse_deposits_serial_id,
+ TALER_ARL_USE_PP (coins_purse_deposits_serial_id),
&purse_deposit_cb,
&cc)))
{
@@ -2637,25 +2652,27 @@ analyze_coins (void *cls)
return cc.qs;
}
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx)
- qs = TALER_ARL_adb->update_balance_summary (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &total_escrow_balance,
- &total_deposit_fee_income,
- &total_melt_fee_income,
- &total_refund_fee_income,
- &total_risk,
- &total_recoup_loss,
- &total_irregular_recoups);
+ qs = TALER_ARL_adb->update_balance (
+ TALER_ARL_adb->cls,
+ TALER_ARL_SET_AB (coin_balance_risk),
+ TALER_ARL_SET_AB (total_escrowed),
+ TALER_ARL_SET_AB (coin_irregular_loss),
+ TALER_ARL_SET_AB (coin_melt_fee_revenue),
+ TALER_ARL_SET_AB (coin_deposit_fee_revenue),
+ TALER_ARL_SET_AB (coin_refund_fee_revenue),
+ TALER_ARL_SET_AB (total_recoup_loss),
+ NULL);
else
- qs = TALER_ARL_adb->insert_balance_summary (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &total_escrow_balance,
- &total_deposit_fee_income,
- &total_melt_fee_income,
- &total_refund_fee_income,
- &total_risk,
- &total_recoup_loss,
- &total_irregular_recoups);
+ qs = TALER_ARL_adb->insert_balance (
+ TALER_ARL_adb->cls,
+ TALER_ARL_SET_AB (coin_balance_risk),
+ TALER_ARL_SET_AB (total_escrowed),
+ TALER_ARL_SET_AB (coin_irregular_loss),
+ TALER_ARL_SET_AB (coin_melt_fee_revenue),
+ TALER_ARL_SET_AB (coin_deposit_fee_revenue),
+ TALER_ARL_SET_AB (coin_refund_fee_revenue),
+ TALER_ARL_SET_AB (total_recoup_loss),
+ NULL);
if (0 >= qs)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
@@ -2663,13 +2680,29 @@ analyze_coins (void *cls)
}
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsp)
- qs = TALER_ARL_adb->update_auditor_progress_coin (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &ppc);
+ qs = TALER_ARL_adb->update_auditor_progress (
+ TALER_ARL_adb->cls,
+ TALER_ARL_SET_PP (coins_withdraw_serial_id),
+ TALER_ARL_SET_PP (coins_deposit_serial_id),
+ TALER_ARL_SET_PP (coins_melt_serial_id),
+ TALER_ARL_SET_PP (coins_refund_serial_id),
+ TALER_ARL_SET_PP (coins_recoup_serial_id),
+ TALER_ARL_SET_PP (coins_recoup_refresh_serial_id),
+ TALER_ARL_SET_PP (coins_purse_deposits_serial_id),
+ TALER_ARL_SET_PP (coins_purse_refunds_serial_id),
+ NULL);
else
- qs = TALER_ARL_adb->insert_auditor_progress_coin (TALER_ARL_adb->cls,
- &TALER_ARL_master_pub,
- &ppc);
+ qs = TALER_ARL_adb->insert_auditor_progress (
+ TALER_ARL_adb->cls,
+ TALER_ARL_SET_PP (coins_withdraw_serial_id),
+ TALER_ARL_SET_PP (coins_deposit_serial_id),
+ TALER_ARL_SET_PP (coins_melt_serial_id),
+ TALER_ARL_SET_PP (coins_refund_serial_id),
+ TALER_ARL_SET_PP (coins_recoup_serial_id),
+ TALER_ARL_SET_PP (coins_recoup_refresh_serial_id),
+ TALER_ARL_SET_PP (coins_purse_deposits_serial_id),
+ TALER_ARL_SET_PP (coins_purse_refunds_serial_id),
+ NULL);
if (0 >= qs)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -2678,13 +2711,17 @@ analyze_coins (void *cls)
return qs;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Concluded coin audit step at %llu/%llu/%llu/%llu/%llu/%llu\n",
- (unsigned long long) ppc.last_deposit_serial_id,
- (unsigned long long) ppc.last_melt_serial_id,
- (unsigned long long) ppc.last_refund_serial_id,
- (unsigned long long) ppc.last_withdraw_serial_id,
- (unsigned long long) ppc.last_recoup_refresh_serial_id,
- (unsigned long long) ppc.last_purse_deposits_serial_id);
+ "Concluded coin audit step at %llu/%llu/%llu/%llu/%llu/%llu/%llu\n",
+ (unsigned long long) TALER_ARL_USE_PP (coins_deposit_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (coins_melt_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (coins_refund_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (coins_withdraw_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ coins_recoup_refresh_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ coins_purse_deposits_serial_id),
+ (unsigned long long) TALER_ARL_USE_PP (
+ coins_purse_refunds_serial_id));
return qs;
}
@@ -2730,25 +2767,29 @@ run (void *cls,
&reported_emergency_loss_by_count));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &total_escrow_balance));
+ &TALER_ARL_USE_AB (total_escrowed)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &total_risk));
+ &TALER_ARL_USE_AB (
+ coin_deposit_fee_revenue)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &total_recoup_loss));
+ &TALER_ARL_USE_AB (
+ coin_melt_fee_revenue)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &total_irregular_recoups));
+ &TALER_ARL_USE_AB (
+ coin_refund_fee_revenue)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &total_deposit_fee_income));
+ &TALER_ARL_USE_AB (coin_balance_risk)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &total_melt_fee_income));
+ &TALER_ARL_USE_AB (total_recoup_loss)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &total_refund_fee_income));
+ &TALER_ARL_USE_AB (
+ coin_irregular_loss)));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
&total_arithmetic_delta_plus));
@@ -2757,9 +2798,6 @@ run (void *cls,
&total_arithmetic_delta_minus));
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (TALER_ARL_currency,
- &total_bad_sig_loss));
- GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (TALER_ARL_currency,
&total_refresh_hanging));
GNUNET_assert (NULL !=
(report_emergencies = json_array ()));
@@ -2775,7 +2813,7 @@ run (void *cls,
GNUNET_assert (NULL !=
(report_bad_sig_losses = json_array ()));
GNUNET_assert (NULL !=
- (report_refreshs_hanging = json_array ()));
+ (report_refreshes_hanging = json_array ()));
if (GNUNET_OK !=
TALER_ARL_setup_sessions_and_run (&analyze_coins,
NULL))
@@ -2788,27 +2826,26 @@ run (void *cls,
TALER_ARL_done (
GNUNET_JSON_PACK (
TALER_JSON_pack_amount ("total_escrow_balance",
- &total_escrow_balance),
- TALER_JSON_pack_amount ("total_active_risk",
- &total_risk),
+ &TALER_ARL_USE_AB (total_escrowed)),
TALER_JSON_pack_amount ("total_deposit_fee_income",
- &total_deposit_fee_income),
+ &TALER_ARL_USE_AB (coin_deposit_fee_revenue)),
TALER_JSON_pack_amount ("total_melt_fee_income",
- &total_melt_fee_income),
+ &TALER_ARL_USE_AB (coin_melt_fee_revenue)),
TALER_JSON_pack_amount ("total_refund_fee_income",
- &total_refund_fee_income),
+ &TALER_ARL_USE_AB (coin_refund_fee_revenue)),
+ TALER_JSON_pack_amount ("total_active_risk",
+ &TALER_ARL_USE_AB (coin_balance_risk)),
+ TALER_JSON_pack_amount ("total_recoup_loss",
+ &TALER_ARL_USE_AB (total_recoup_loss)),
+ /* Tested in test-auditor.sh #4/#5/#6/#13/#26 */
+ TALER_JSON_pack_amount ("irregular_loss",
+ &TALER_ARL_USE_AB (coin_irregular_loss)),
/* Tested in test-auditor.sh #18 */
GNUNET_JSON_pack_array_steal ("emergencies",
report_emergencies),
/* Tested in test-auditor.sh #18 */
TALER_JSON_pack_amount ("emergencies_risk_by_amount",
&reported_emergency_risk_by_amount),
- /* Tested in test-auditor.sh #4/#5/#6/#13/#26 */
- GNUNET_JSON_pack_array_steal ("bad_sig_losses",
- report_bad_sig_losses),
- /* Tested in test-auditor.sh #4/#5/#6/#13/#26 */
- TALER_JSON_pack_amount ("total_bad_sig_loss",
- &total_bad_sig_loss),
/* Tested in test-auditor.sh #31 */
GNUNET_JSON_pack_array_steal ("row_inconsistencies",
report_row_inconsistencies),
@@ -2821,11 +2858,11 @@ run (void *cls,
&total_arithmetic_delta_minus),
TALER_JSON_pack_amount ("total_refresh_hanging",
&total_refresh_hanging),
+ GNUNET_JSON_pack_array_steal ("bad_sig_losses",
+ report_bad_sig_losses),
/* Tested in test-auditor.sh #12 */
GNUNET_JSON_pack_array_steal ("refresh_hanging",
- report_refreshs_hanging),
- TALER_JSON_pack_amount ("total_recoup_loss",
- &total_recoup_loss),
+ report_refreshes_hanging),
/* Tested in test-auditor.sh #18 */
GNUNET_JSON_pack_array_steal ("emergencies_by_count",
report_emergencies_by_count),
@@ -2839,45 +2876,48 @@ run (void *cls,
TALER_JSON_pack_amount ("emergencies_loss_by_count",
&reported_emergency_loss_by_count),
GNUNET_JSON_pack_uint64 ("start_ppc_withdraw_serial_id",
- ppc_start.last_withdraw_serial_id),
+ 0 /* not implemented */),
GNUNET_JSON_pack_uint64 ("start_ppc_deposit_serial_id",
- ppc_start.last_deposit_serial_id),
+ 0 /* not implemented */),
GNUNET_JSON_pack_uint64 ("start_ppc_melt_serial_id",
- ppc_start.last_melt_serial_id),
+ 0 /* not implemented */),
GNUNET_JSON_pack_uint64 ("start_ppc_refund_serial_id",
- ppc_start.last_refund_serial_id),
+ 0 /* not implemented */),
GNUNET_JSON_pack_uint64 ("start_ppc_recoup_serial_id",
- ppc_start.last_recoup_serial_id),
+ 0 /* not implemented */),
GNUNET_JSON_pack_uint64 ("start_ppc_recoup_refresh_serial_id",
- ppc_start.last_recoup_refresh_serial_id),
+ 0 /* not implemented */),
GNUNET_JSON_pack_uint64 ("start_ppc_purse_deposits_serial_id",
- ppc_start.last_purse_deposits_serial_id),
+ 0 /* not implemented */),
GNUNET_JSON_pack_uint64 ("start_ppc_purse_refunds_serial_id",
- ppc_start.last_purse_refunds_serial_id),
+ 0 /* not implemented */),
GNUNET_JSON_pack_uint64 ("end_ppc_withdraw_serial_id",
- ppc.last_withdraw_serial_id),
+ TALER_ARL_USE_PP (coins_withdraw_serial_id)),
GNUNET_JSON_pack_uint64 ("end_ppc_deposit_serial_id",
- ppc.last_deposit_serial_id),
+ TALER_ARL_USE_PP (coins_deposit_serial_id)),
GNUNET_JSON_pack_uint64 ("end_ppc_melt_serial_id",
- ppc.last_melt_serial_id),
+ TALER_ARL_USE_PP (coins_melt_serial_id)),
GNUNET_JSON_pack_uint64 ("end_ppc_refund_serial_id",
- ppc.last_refund_serial_id),
+ TALER_ARL_USE_PP (coins_refund_serial_id)),
GNUNET_JSON_pack_uint64 ("end_ppc_recoup_serial_id",
- ppc.last_recoup_serial_id),
+ TALER_ARL_USE_PP (coins_recoup_serial_id)),
GNUNET_JSON_pack_uint64 ("end_ppc_recoup_refresh_serial_id",
- ppc.last_recoup_refresh_serial_id),
+ TALER_ARL_USE_PP (
+ coins_recoup_refresh_serial_id)),
GNUNET_JSON_pack_uint64 ("end_ppc_purse_deposits_serial_id",
- ppc.last_purse_deposits_serial_id),
+ TALER_ARL_USE_PP (
+ coins_purse_deposits_serial_id)),
GNUNET_JSON_pack_uint64 ("end_ppc_purse_refunds_serial_id",
- ppc.last_purse_refunds_serial_id),
- TALER_JSON_pack_time_abs_human ("auditor_start_time",
- start_time),
+ TALER_ARL_USE_PP (
+ coins_purse_refunds_serial_id)),
+ TALER_JSON_pack_time_abs_human (
+ "auditor_start_time",
+ start_time),
TALER_JSON_pack_time_abs_human ("auditor_end_time",
GNUNET_TIME_absolute_get ()),
- TALER_JSON_pack_amount ("total_irregular_recoups",
- &total_irregular_recoups),
- GNUNET_JSON_pack_array_steal ("unsigned_denominations",
- report_denominations_without_sigs)));
+ GNUNET_JSON_pack_array_steal (
+ "unsigned_denominations",
+ report_denominations_without_sigs)));
}
@@ -2897,11 +2937,10 @@ main (int argc,
"internal",
"perform checks only applicable for exchange-internal audits",
&internal_checks),
- GNUNET_GETOPT_option_base32_auto ('m',
- "exchange-key",
- "KEY",
- "public key of the exchange (Crockford base32 encoded)",
- &TALER_ARL_master_pub),
+ GNUNET_GETOPT_option_flag ('t',
+ "test",
+ "run in test mode and exit when idle",
+ &test_mode),
GNUNET_GETOPT_option_timetravel ('T',
"timetravel"),
GNUNET_GETOPT_OPTION_END