first pass at auditor-coins, also reviewing checks around amount arithmetic, can and should be made harsher

This commit is contained in:
Christian Grothoff 2020-03-22 23:32:06 +01:00
parent 488f759a2d
commit 3480146a66
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
4 changed files with 355 additions and 433 deletions

View File

@ -145,7 +145,7 @@ report_amount_arithmetic_inconsistency (
auditor)) auditor))
{ {
/* exchange > auditor */ /* exchange > auditor */
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_subtract (&delta, TALER_amount_subtract (&delta,
exchange, exchange,
auditor)); auditor));
@ -154,7 +154,7 @@ report_amount_arithmetic_inconsistency (
{ {
/* auditor < exchange */ /* auditor < exchange */
profitable = -profitable; profitable = -profitable;
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_subtract (&delta, TALER_amount_subtract (&delta,
auditor, auditor,
exchange)); exchange));
@ -171,7 +171,7 @@ report_amount_arithmetic_inconsistency (
target = (1 == profitable) target = (1 == profitable)
? &total_arithmetic_delta_plus ? &total_arithmetic_delta_plus
: &total_arithmetic_delta_minus; : &total_arithmetic_delta_minus;
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (target, TALER_amount_add (target,
target, target,
&delta)); &delta));
@ -207,7 +207,7 @@ report_coin_arithmetic_inconsistency (
auditor)) auditor))
{ {
/* exchange > auditor */ /* exchange > auditor */
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_subtract (&delta, TALER_amount_subtract (&delta,
exchange, exchange,
auditor)); auditor));
@ -216,7 +216,7 @@ report_coin_arithmetic_inconsistency (
{ {
/* auditor < exchange */ /* auditor < exchange */
profitable = -profitable; profitable = -profitable;
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_subtract (&delta, TALER_amount_subtract (&delta,
auditor, auditor,
exchange)); exchange));
@ -234,7 +234,7 @@ report_coin_arithmetic_inconsistency (
target = (1 == profitable) target = (1 == profitable)
? &total_coin_delta_plus ? &total_coin_delta_plus
: &total_coin_delta_minus; : &total_coin_delta_minus;
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (target, TALER_amount_add (target,
target, target,
&delta)); &delta));
@ -856,7 +856,7 @@ wire_transfer_information_cb (
"loss", TALER_JSON_from_amount (coin_value), "loss", TALER_JSON_from_amount (coin_value),
"key_pub", GNUNET_JSON_from_data_auto ( "key_pub", GNUNET_JSON_from_data_auto (
&issue->denom_hash))); &issue->denom_hash)));
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_bad_sig_loss, TALER_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss, &total_bad_sig_loss,
coin_value)); coin_value));

View File

@ -302,7 +302,7 @@ report_amount_arithmetic_inconsistency (
auditor)) auditor))
{ {
/* exchange > auditor */ /* exchange > auditor */
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_subtract (&delta, TALER_amount_subtract (&delta,
exchange, exchange,
auditor)); auditor));
@ -311,7 +311,7 @@ report_amount_arithmetic_inconsistency (
{ {
/* auditor < exchange */ /* auditor < exchange */
profitable = -profitable; profitable = -profitable;
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_subtract (&delta, TALER_amount_subtract (&delta,
auditor, auditor,
exchange)); exchange));
@ -328,7 +328,7 @@ report_amount_arithmetic_inconsistency (
target = (1 == profitable) target = (1 == profitable)
? &total_arithmetic_delta_plus ? &total_arithmetic_delta_plus
: &total_arithmetic_delta_minus; : &total_arithmetic_delta_minus;
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (target, TALER_amount_add (target,
target, target,
&delta)); &delta));
@ -494,12 +494,13 @@ init_denomination (const struct GNUNET_HashCode *denom_hash,
if (0 < qs) if (0 < qs)
{ {
/* check revocation signature */ /* check revocation signature */
struct TALER_MasterDenominationKeyRevocationPS rm; struct TALER_MasterDenominationKeyRevocationPS rm = {
.purpose.purpose = htonl (
TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED),
.purpose.size = htonl (sizeof (rm)),
.h_denom_pub = *denom_hash
};
rm.purpose.purpose = htonl (
TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED);
rm.purpose.size = htonl (sizeof (rm));
rm.h_denom_pub = *denom_hash;
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_verify ( GNUNET_CRYPTO_eddsa_verify (
TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED, TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED,
@ -642,8 +643,7 @@ sync_denomination (void *cls,
(qs = TALER_ARL_adb->insert_historic_denom_revenue ( (qs = TALER_ARL_adb->insert_historic_denom_revenue (
TALER_ARL_adb->cls, TALER_ARL_adb->cls,
TALER_ARL_asession, TALER_ARL_asession,
& &TALER_ARL_master_pub,
TALER_ARL_master_pub,
denom_hash, denom_hash,
expire_deposit, expire_deposit,
&ds->denom_balance, &ds->denom_balance,
@ -801,46 +801,26 @@ withdraw_cb (void *cls,
GNUNET_h2s (&dh), GNUNET_h2s (&dh),
TALER_amount2s (&value)); TALER_amount2s (&value));
ds->num_issued++; ds->num_issued++;
if (GNUNET_OK != GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&ds->denom_balance, TALER_amount_add (&ds->denom_balance,
&ds->denom_balance, &ds->denom_balance,
&value)) &value));
{
GNUNET_break (0);
cc->qs = GNUNET_DB_STATUS_HARD_ERROR;
return GNUNET_SYSERR;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"New balance of denomination `%s' is %s\n", "New balance of denomination `%s' is %s\n",
GNUNET_h2s (&dh), GNUNET_h2s (&dh),
TALER_amount2s (&ds->denom_balance)); TALER_amount2s (&ds->denom_balance));
if (GNUNET_OK != GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_escrow_balance, TALER_amount_add (&total_escrow_balance,
&total_escrow_balance, &total_escrow_balance,
&value)) &value));
{ GNUNET_assert (GNUNET_OK ==
GNUNET_break (0);
cc->qs = GNUNET_DB_STATUS_HARD_ERROR;
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
TALER_amount_add (&total_risk, TALER_amount_add (&total_risk,
&total_risk, &total_risk,
&value)) &value));
{ GNUNET_assert (GNUNET_OK ==
GNUNET_break (0);
cc->qs = GNUNET_DB_STATUS_HARD_ERROR;
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
TALER_amount_add (&ds->denom_risk, TALER_amount_add (&ds->denom_risk,
&ds->denom_risk, &ds->denom_risk,
&value)) &value));
{
GNUNET_break (0);
cc->qs = GNUNET_DB_STATUS_HARD_ERROR;
return GNUNET_SYSERR;
}
return GNUNET_OK; return GNUNET_OK;
} }
@ -939,7 +919,7 @@ check_known_coin (const struct TALER_CoinSpendPublicKeyP *coin_pub,
loss_potential), loss_potential),
"key_pub", GNUNET_JSON_from_data_auto ( "key_pub", GNUNET_JSON_from_data_auto (
coin_pub))); coin_pub)));
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_bad_sig_loss, TALER_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss, &total_bad_sig_loss,
loss_potential)); loss_potential));
@ -978,7 +958,6 @@ refresh_session_cb (void *cls,
const struct TALER_RefreshCommitmentP *rc) const struct TALER_RefreshCommitmentP *rc)
{ {
struct CoinContext *cc = cls; struct CoinContext *cc = cls;
struct TALER_RefreshMeltCoinAffirmationPS rmc;
const struct TALER_DenominationKeyValidityPS *issue; const struct TALER_DenominationKeyValidityPS *issue;
struct DenominationSummary *dso; struct DenominationSummary *dso;
struct TALER_Amount amount_without_fee; struct TALER_Amount amount_without_fee;
@ -1016,13 +995,17 @@ refresh_session_cb (void *cls,
} }
/* verify melt signature */ /* verify melt signature */
rmc.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT); {
rmc.purpose.size = htonl (sizeof (rmc)); struct TALER_RefreshMeltCoinAffirmationPS rmc = {
rmc.rc = *rc; .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT),
.purpose.size = htonl (sizeof (rmc)),
.rc = *rc,
.melt_fee = issue->fee_refresh,
.coin_pub = *coin_pub
};
TALER_amount_hton (&rmc.amount_with_fee, TALER_amount_hton (&rmc.amount_with_fee,
amount_with_fee); amount_with_fee);
rmc.melt_fee = issue->fee_refresh;
rmc.coin_pub = *coin_pub;
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_COIN_MELT, GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_COIN_MELT,
&rmc.purpose, &rmc.purpose,
@ -1037,12 +1020,13 @@ refresh_session_cb (void *cls,
amount_with_fee), amount_with_fee),
"key_pub", GNUNET_JSON_from_data_auto ( "key_pub", GNUNET_JSON_from_data_auto (
coin_pub))); coin_pub)));
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_bad_sig_loss, TALER_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss, &total_bad_sig_loss,
amount_with_fee)); amount_with_fee));
return GNUNET_OK; return GNUNET_OK;
} }
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Melting coin %s in denomination `%s' of value %s\n", "Melting coin %s in denomination `%s' of value %s\n",
TALER_B2S (coin_pub), TALER_B2S (coin_pub),
@ -1084,7 +1068,7 @@ refresh_session_cb (void *cls,
amount_with_fee), amount_with_fee),
"coin_pub", GNUNET_JSON_from_data_auto ( "coin_pub", GNUNET_JSON_from_data_auto (
coin_pub))); coin_pub)));
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_refresh_hanging, TALER_amount_add (&total_refresh_hanging,
&total_refresh_hanging, &total_refresh_hanging,
amount_with_fee)); amount_with_fee));
@ -1138,19 +1122,14 @@ refresh_session_cb (void *cls,
&new_issues[i]->fee_withdraw); &new_issues[i]->fee_withdraw);
TALER_amount_ntoh (&value, TALER_amount_ntoh (&value,
&new_issues[i]->value); &new_issues[i]->value);
if ( (GNUNET_OK != GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&refresh_cost, TALER_amount_add (&refresh_cost,
&refresh_cost, &refresh_cost,
&fee)) || &fee));
(GNUNET_OK != GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&refresh_cost, TALER_amount_add (&refresh_cost,
&refresh_cost, &refresh_cost,
&value)) ) &value));
{
GNUNET_break (0);
cc->qs = GNUNET_DB_STATUS_HARD_ERROR;
return GNUNET_SYSERR;
}
} }
/* compute contribution of old coin */ /* compute contribution of old coin */
@ -1164,6 +1143,7 @@ refresh_session_cb (void *cls,
amount_with_fee, amount_with_fee,
&melt_fee)) &melt_fee))
{ {
// FIXME: handle properly!
GNUNET_break (0); GNUNET_break (0);
cc->qs = GNUNET_DB_STATUS_HARD_ERROR; cc->qs = GNUNET_DB_STATUS_HARD_ERROR;
return GNUNET_SYSERR; return GNUNET_SYSERR;
@ -1204,46 +1184,26 @@ refresh_session_cb (void *cls,
GNUNET_h2s (&new_issues[i]->denom_hash), GNUNET_h2s (&new_issues[i]->denom_hash),
TALER_amount2s (&value)); TALER_amount2s (&value));
dsi->num_issued++; dsi->num_issued++;
if (GNUNET_OK != GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&dsi->denom_balance, TALER_amount_add (&dsi->denom_balance,
&dsi->denom_balance, &dsi->denom_balance,
&value)) &value));
{ GNUNET_assert (GNUNET_OK ==
GNUNET_break (0);
cc->qs = GNUNET_DB_STATUS_HARD_ERROR;
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
TALER_amount_add (&dsi->denom_risk, TALER_amount_add (&dsi->denom_risk,
&dsi->denom_risk, &dsi->denom_risk,
&value)) &value));
{
GNUNET_break (0);
cc->qs = GNUNET_DB_STATUS_HARD_ERROR;
return GNUNET_SYSERR;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"New balance of denomination `%s' is %s\n", "New balance of denomination `%s' is %s\n",
GNUNET_h2s (&new_issues[i]->denom_hash), GNUNET_h2s (&new_issues[i]->denom_hash),
TALER_amount2s (&dsi->denom_balance)); TALER_amount2s (&dsi->denom_balance));
if (GNUNET_OK != GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_escrow_balance, TALER_amount_add (&total_escrow_balance,
&total_escrow_balance, &total_escrow_balance,
&value)) &value));
{ GNUNET_assert (GNUNET_OK ==
GNUNET_break (0);
cc->qs = GNUNET_DB_STATUS_HARD_ERROR;
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
TALER_amount_add (&total_risk, TALER_amount_add (&total_risk,
&total_risk, &total_risk,
&value)) &value));
{
GNUNET_break (0);
cc->qs = GNUNET_DB_STATUS_HARD_ERROR;
return GNUNET_SYSERR;
}
} }
} }
} }
@ -1306,18 +1266,11 @@ refresh_session_cb (void *cls,
TALER_amount_ntoh (&rfee, TALER_amount_ntoh (&rfee,
&issue->fee_refresh); &issue->fee_refresh);
if (GNUNET_OK != GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_melt_fee_income, TALER_amount_add (&total_melt_fee_income,
&total_melt_fee_income, &total_melt_fee_income,
&rfee)) &rfee));
{
GNUNET_break (0);
cc->qs = GNUNET_DB_STATUS_HARD_ERROR;
return GNUNET_SYSERR;
} }
}
/* We're good! */
return GNUNET_OK; return GNUNET_OK;
} }
@ -1361,7 +1314,6 @@ deposit_cb (void *cls,
struct CoinContext *cc = cls; struct CoinContext *cc = cls;
const struct TALER_DenominationKeyValidityPS *issue; const struct TALER_DenominationKeyValidityPS *issue;
struct DenominationSummary *ds; struct DenominationSummary *ds;
struct TALER_DepositRequestPS dr;
struct TALER_Amount tmp; struct TALER_Amount tmp;
enum GNUNET_DB_QueryStatus qs; enum GNUNET_DB_QueryStatus qs;
@ -1398,9 +1350,18 @@ deposit_cb (void *cls,
} }
/* Verify deposit signature */ /* Verify deposit signature */
dr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_DEPOSIT); {
dr.purpose.size = htonl (sizeof (dr)); struct TALER_DepositRequestPS dr = {
dr.h_contract_terms = *h_contract_terms; .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_DEPOSIT),
.purpose.size = htonl (sizeof (dr)),
.h_contract_terms = *h_contract_terms,
.timestamp = GNUNET_TIME_absolute_hton (timestamp),
.refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline),
.deposit_fee = issue->fee_deposit,
.merchant = *merchant_pub,
.coin_pub = *coin_pub
};
if (GNUNET_OK != if (GNUNET_OK !=
TALER_JSON_merchant_wire_signature_hash (receiver_wire_account, TALER_JSON_merchant_wire_signature_hash (receiver_wire_account,
&dr.h_wire)) &dr.h_wire))
@ -1413,19 +1374,14 @@ deposit_cb (void *cls,
amount_with_fee), amount_with_fee),
"key_pub", GNUNET_JSON_from_data_auto ( "key_pub", GNUNET_JSON_from_data_auto (
coin_pub))); coin_pub)));
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_bad_sig_loss, TALER_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss, &total_bad_sig_loss,
amount_with_fee)); amount_with_fee));
return GNUNET_OK; return GNUNET_OK;
} }
dr.timestamp = GNUNET_TIME_absolute_hton (timestamp);
dr.refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline);
TALER_amount_hton (&dr.amount_with_fee, TALER_amount_hton (&dr.amount_with_fee,
amount_with_fee); amount_with_fee);
dr.deposit_fee = issue->fee_deposit;
dr.merchant = *merchant_pub;
dr.coin_pub = *coin_pub;
/* NOTE: This is one of the operations we might eventually /* NOTE: This is one of the operations we might eventually
want to do in parallel in the background to improve want to do in parallel in the background to improve
auditor performance! */ auditor performance! */
@ -1443,12 +1399,13 @@ deposit_cb (void *cls,
amount_with_fee), amount_with_fee),
"key_pub", GNUNET_JSON_from_data_auto ( "key_pub", GNUNET_JSON_from_data_auto (
coin_pub))); coin_pub)));
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_bad_sig_loss, TALER_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss, &total_bad_sig_loss,
amount_with_fee)); amount_with_fee));
return GNUNET_OK; return GNUNET_OK;
} }
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Deposited coin %s in denomination `%s' of value %s\n", "Deposited coin %s in denomination `%s' of value %s\n",
TALER_B2S (coin_pub), TALER_B2S (coin_pub),
@ -1488,7 +1445,8 @@ deposit_cb (void *cls,
accepted a forged coin (i.e. emergency situation after accepted a forged coin (i.e. emergency situation after
private key compromise). In that case, we cannot even private key compromise). In that case, we cannot even
subtract the profit we make from the fee from the escrow subtract the profit we make from the fee from the escrow
balance. Tested as part of test-auditor.sh, case #18 */report_amount_arithmetic_inconsistency ( balance. Tested as part of test-auditor.sh, case #18 *///
report_amount_arithmetic_inconsistency (
"subtracting deposit fee from escrow balance", "subtracting deposit fee from escrow balance",
rowid, rowid,
&total_escrow_balance, &total_escrow_balance,
@ -1508,21 +1466,16 @@ deposit_cb (void *cls,
GNUNET_h2s (&issue->denom_hash), GNUNET_h2s (&issue->denom_hash),
TALER_amount2s (&ds->denom_balance)); TALER_amount2s (&ds->denom_balance));
/* update global up melt fees */ /* update global deposit fees */
{ {
struct TALER_Amount dfee; struct TALER_Amount dfee;
TALER_amount_ntoh (&dfee, TALER_amount_ntoh (&dfee,
&issue->fee_deposit); &issue->fee_deposit);
if (GNUNET_OK != GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_deposit_fee_income, TALER_amount_add (&total_deposit_fee_income,
&total_deposit_fee_income, &total_deposit_fee_income,
&dfee)) &dfee));
{
GNUNET_break (0);
cc->qs = GNUNET_DB_STATUS_HARD_ERROR;
return GNUNET_SYSERR;
}
} }
return GNUNET_OK; return GNUNET_OK;
@ -1608,7 +1561,7 @@ refund_cb (void *cls,
amount_with_fee), amount_with_fee),
"key_pub", GNUNET_JSON_from_data_auto ( "key_pub", GNUNET_JSON_from_data_auto (
merchant_pub))); merchant_pub)));
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_bad_sig_loss, TALER_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss, &total_bad_sig_loss,
amount_with_fee)); amount_with_fee));
@ -1645,59 +1598,32 @@ refund_cb (void *cls,
GNUNET_break (0); GNUNET_break (0);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (GNUNET_OK != GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&ds->denom_balance, TALER_amount_add (&ds->denom_balance,
&ds->denom_balance, &ds->denom_balance,
&amount_without_fee)) &amount_without_fee));
{ GNUNET_assert (GNUNET_OK ==
GNUNET_break (0);
cc->qs = GNUNET_DB_STATUS_HARD_ERROR;
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
TALER_amount_add (&ds->denom_risk, TALER_amount_add (&ds->denom_risk,
&ds->denom_risk, &ds->denom_risk,
&amount_without_fee)) &amount_without_fee));
{ GNUNET_assert (GNUNET_OK ==
GNUNET_break (0);
cc->qs = GNUNET_DB_STATUS_HARD_ERROR;
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
TALER_amount_add (&total_escrow_balance, TALER_amount_add (&total_escrow_balance,
&total_escrow_balance, &total_escrow_balance,
&amount_without_fee)) &amount_without_fee));
{ GNUNET_assert (GNUNET_OK ==
GNUNET_break (0);
cc->qs = GNUNET_DB_STATUS_HARD_ERROR;
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
TALER_amount_add (&total_risk, TALER_amount_add (&total_risk,
&total_risk, &total_risk,
&amount_without_fee)) &amount_without_fee));
{
GNUNET_break (0);
cc->qs = GNUNET_DB_STATUS_HARD_ERROR;
return GNUNET_SYSERR;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"New balance of denomination `%s' after refund is %s\n", "New balance of denomination `%s' after refund is %s\n",
GNUNET_h2s (&issue->denom_hash), GNUNET_h2s (&issue->denom_hash),
TALER_amount2s (&ds->denom_balance)); TALER_amount2s (&ds->denom_balance));
/* update total refund fee balance */ /* update total refund fee balance */
if (GNUNET_OK != GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_refund_fee_income, TALER_amount_add (&total_refund_fee_income,
&total_refund_fee_income, &total_refund_fee_income,
&refund_fee)) &refund_fee));
{
GNUNET_break (0);
cc->qs = GNUNET_DB_STATUS_HARD_ERROR;
return GNUNET_SYSERR;
}
return GNUNET_OK; return GNUNET_OK;
} }
@ -1740,7 +1666,7 @@ check_recoup (struct CoinContext *cc,
"loss", TALER_JSON_from_amount (amount), "loss", TALER_JSON_from_amount (amount),
"key_pub", GNUNET_JSON_from_data_auto ( "key_pub", GNUNET_JSON_from_data_auto (
&pr.h_denom_pub))); &pr.h_denom_pub)));
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_bad_sig_loss, TALER_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss, &total_bad_sig_loss,
amount)); amount));
@ -1780,7 +1706,7 @@ check_recoup (struct CoinContext *cc,
"loss", TALER_JSON_from_amount (amount), "loss", TALER_JSON_from_amount (amount),
"coin_pub", GNUNET_JSON_from_data_auto ( "coin_pub", GNUNET_JSON_from_data_auto (
&coin->coin_pub))); &coin->coin_pub)));
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_bad_sig_loss, TALER_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss, &total_bad_sig_loss,
amount)); amount));
@ -1801,11 +1727,11 @@ check_recoup (struct CoinContext *cc,
"coin_pub", GNUNET_JSON_from_data_auto ( "coin_pub", GNUNET_JSON_from_data_auto (
&coin->coin_pub))); &coin->coin_pub)));
} }
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&ds->denom_recoup, TALER_amount_add (&ds->denom_recoup,
&ds->denom_recoup, &ds->denom_recoup,
amount)); amount));
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_recoup_loss, TALER_amount_add (&total_recoup_loss,
&total_recoup_loss, &total_recoup_loss,
amount)); amount));
@ -1960,8 +1886,7 @@ analyze_coins (void *cls)
(qs = TALER_ARL_edb->select_withdrawals_above_serial_id ( (qs = TALER_ARL_edb->select_withdrawals_above_serial_id (
TALER_ARL_edb->cls, TALER_ARL_edb->cls,
TALER_ARL_esession, TALER_ARL_esession,
ppc. ppc.last_withdraw_serial_id,
last_withdraw_serial_id,
&withdraw_cb, &withdraw_cb,
&cc)) ) &cc)) )
{ {
@ -1973,10 +1898,10 @@ analyze_coins (void *cls)
/* process refunds */ /* process refunds */
if (0 > if (0 >
(qs = TALER_ARL_edb->select_refunds_above_serial_id (TALER_ARL_edb->cls, (qs = TALER_ARL_edb->select_refunds_above_serial_id (
TALER_ARL_edb->cls,
TALER_ARL_esession, TALER_ARL_esession,
ppc. ppc.last_refund_serial_id,
last_refund_serial_id,
&refund_cb, &refund_cb,
&cc))) &cc)))
{ {
@ -1988,10 +1913,10 @@ analyze_coins (void *cls)
/* process refreshs */ /* process refreshs */
if (0 > if (0 >
(qs = TALER_ARL_edb->select_refreshes_above_serial_id (TALER_ARL_edb->cls, (qs = TALER_ARL_edb->select_refreshes_above_serial_id (
TALER_ARL_edb->cls,
TALER_ARL_esession, TALER_ARL_esession,
ppc. ppc.last_melt_serial_id,
last_melt_serial_id,
&refresh_session_cb, &refresh_session_cb,
&cc))) &cc)))
{ {
@ -2003,10 +1928,10 @@ analyze_coins (void *cls)
/* process deposits */ /* process deposits */
if (0 > if (0 >
(qs = TALER_ARL_edb->select_deposits_above_serial_id (TALER_ARL_edb->cls, (qs = TALER_ARL_edb->select_deposits_above_serial_id (
TALER_ARL_edb->cls,
TALER_ARL_esession, TALER_ARL_esession,
ppc. ppc.last_deposit_serial_id,
last_deposit_serial_id,
&deposit_cb, &deposit_cb,
&cc))) &cc)))
{ {
@ -2018,10 +1943,10 @@ analyze_coins (void *cls)
/* process recoups */ /* process recoups */
if (0 > if (0 >
(qs = TALER_ARL_edb->select_recoup_above_serial_id (TALER_ARL_edb->cls, (qs = TALER_ARL_edb->select_recoup_above_serial_id (
TALER_ARL_edb->cls,
TALER_ARL_esession, TALER_ARL_esession,
ppc. ppc.last_recoup_serial_id,
last_recoup_serial_id,
&recoup_cb, &recoup_cb,
&cc))) &cc)))
{ {
@ -2145,16 +2070,13 @@ run (void *cls,
&reported_emergency_loss)); &reported_emergency_loss));
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_get_zero (TALER_ARL_currency, TALER_amount_get_zero (TALER_ARL_currency,
& &reported_emergency_risk_by_amount));
reported_emergency_risk_by_amount));
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_get_zero (TALER_ARL_currency, TALER_amount_get_zero (TALER_ARL_currency,
& &reported_emergency_risk_by_count));
reported_emergency_risk_by_count));
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_get_zero (TALER_ARL_currency, TALER_amount_get_zero (TALER_ARL_currency,
& &reported_emergency_loss_by_count));
reported_emergency_loss_by_count));
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_get_zero (TALER_ARL_currency, TALER_amount_get_zero (TALER_ARL_currency,
&total_escrow_balance)); &total_escrow_balance));

View File

@ -174,7 +174,7 @@ report_amount_arithmetic_inconsistency (
auditor)) auditor))
{ {
/* exchange > auditor */ /* exchange > auditor */
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_subtract (&delta, TALER_amount_subtract (&delta,
exchange, exchange,
auditor)); auditor));
@ -183,7 +183,7 @@ report_amount_arithmetic_inconsistency (
{ {
/* auditor < exchange */ /* auditor < exchange */
profitable = -profitable; profitable = -profitable;
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_subtract (&delta, TALER_amount_subtract (&delta,
auditor, auditor,
exchange)); exchange));
@ -200,7 +200,7 @@ report_amount_arithmetic_inconsistency (
target = (1 == profitable) target = (1 == profitable)
? &total_arithmetic_delta_plus ? &total_arithmetic_delta_plus
: &total_arithmetic_delta_minus; : &total_arithmetic_delta_minus;
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (target, TALER_amount_add (target,
target, target,
&delta)); &delta));
@ -725,7 +725,7 @@ handle_recoup_by_reserve (
report_row_inconsistency ("recoup", report_row_inconsistency ("recoup",
rowid, rowid,
"denomination key not in revocation set"); "denomination key not in revocation set");
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_irregular_recoups, TALER_amount_add (&total_irregular_recoups,
&total_irregular_recoups, &total_irregular_recoups,
amount)); amount));
@ -774,7 +774,7 @@ handle_recoup_by_reserve (
"loss", TALER_JSON_from_amount (amount), "loss", TALER_JSON_from_amount (amount),
"key_pub", GNUNET_JSON_from_data_auto ( "key_pub", GNUNET_JSON_from_data_auto (
&TALER_ARL_master_pub))); &TALER_ARL_master_pub)));
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_bad_sig_loss, TALER_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss, &total_bad_sig_loss,
amount)); amount));

View File

@ -629,7 +629,7 @@ check_pending_rc (void *cls,
(void) cls; (void) cls;
(void) key; (void) key;
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_closure_amount_lag, TALER_amount_add (&total_closure_amount_lag,
&total_closure_amount_lag, &total_closure_amount_lag,
&rc->amount)); &rc->amount));
@ -835,7 +835,7 @@ wire_missing_cb (void *cls,
/* bool? */ int done) /* bool? */ int done)
{ {
(void) cls; (void) cls;
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_amount_lag, TALER_amount_add (&total_amount_lag,
&total_amount_lag, &total_amount_lag,
amount)); amount));
@ -1001,7 +1001,7 @@ wire_out_cb (void *cls,
date), date),
"diagnostic", "wire transfer not made (yet?)", "diagnostic", "wire transfer not made (yet?)",
"account_section", wa->section_name)); "account_section", wa->section_name));
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_bad_amount_out_minus, TALER_amount_add (&total_bad_amount_out_minus,
&total_bad_amount_out_minus, &total_bad_amount_out_minus,
amount)); amount));
@ -1029,7 +1029,7 @@ wire_out_cb (void *cls,
date), date),
"diagnostic", "recevier account mismatch", "diagnostic", "recevier account mismatch",
"account_section", wa->section_name)); "account_section", wa->section_name));
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_bad_amount_out_plus, TALER_amount_add (&total_bad_amount_out_plus,
&total_bad_amount_out_plus, &total_bad_amount_out_plus,
&roi->details.amount)); &roi->details.amount));
@ -1045,7 +1045,7 @@ wire_out_cb (void *cls,
date), date),
"diagnostic", "receiver account mismatch", "diagnostic", "receiver account mismatch",
"account_section", wa->section_name)); "account_section", wa->section_name));
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_bad_amount_out_minus, TALER_amount_add (&total_bad_amount_out_minus,
&total_bad_amount_out_minus, &total_bad_amount_out_minus,
amount)); amount));
@ -1075,11 +1075,11 @@ wire_out_cb (void *cls,
/* amount > roi->details.amount: wire transfer was smaller than it should have been */ /* amount > roi->details.amount: wire transfer was smaller than it should have been */
struct TALER_Amount delta; struct TALER_Amount delta;
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_subtract (&delta, TALER_amount_subtract (&delta,
amount, amount,
&roi->details.amount)); &roi->details.amount));
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_bad_amount_out_minus, TALER_amount_add (&total_bad_amount_out_minus,
&total_bad_amount_out_minus, &total_bad_amount_out_minus,
&delta)); &delta));
@ -1089,11 +1089,11 @@ wire_out_cb (void *cls,
/* roi->details.amount < amount: wire transfer was larger than it should have been */ /* roi->details.amount < amount: wire transfer was larger than it should have been */
struct TALER_Amount delta; struct TALER_Amount delta;
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_subtract (&delta, TALER_amount_subtract (&delta,
&roi->details.amount, &roi->details.amount,
amount)); amount));
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_bad_amount_out_plus, TALER_amount_add (&total_bad_amount_out_plus,
&total_bad_amount_out_plus, &total_bad_amount_out_plus,
&delta)); &delta));
@ -1217,7 +1217,7 @@ complain_out_not_found (void *cls,
wa->section_name, wa->section_name,
"diagnostic", "diagnostic",
"justification for wire transfer not found")); "justification for wire transfer not found"));
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_bad_amount_out_plus, TALER_amount_add (&total_bad_amount_out_plus,
&total_bad_amount_out_plus, &total_bad_amount_out_plus,
&roi->details.amount)); &roi->details.amount));
@ -1350,7 +1350,7 @@ history_debit_cb (void *cls,
GNUNET_asprintf (&diagnostic, GNUNET_asprintf (&diagnostic,
"duplicate subject hash `%s'", "duplicate subject hash `%s'",
TALER_B2S (&roi->subject_hash)); TALER_B2S (&roi->subject_hash));
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_wire_format_amount, TALER_amount_add (&total_wire_format_amount,
&total_wire_format_amount, &total_wire_format_amount,
&details->amount)); &details->amount));
@ -1540,7 +1540,7 @@ complain_in_not_found (void *cls,
"account", wa->section_name, "account", wa->section_name,
"diagnostic", "diagnostic",
"incoming wire transfer claimed by exchange not found")); "incoming wire transfer claimed by exchange not found"));
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_bad_amount_in_minus, TALER_amount_add (&total_bad_amount_in_minus,
&total_bad_amount_in_minus, &total_bad_amount_in_minus,
&rii->details.amount)); &rii->details.amount));
@ -1653,7 +1653,7 @@ history_credit_cb (void *cls,
"timestamp", TALER_ARL_json_from_time_abs ( "timestamp", TALER_ARL_json_from_time_abs (
rii->details.execution_date), rii->details.execution_date),
"diagnostic", "wire subject does not match")); "diagnostic", "wire subject does not match"));
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_bad_amount_in_minus, TALER_amount_add (&total_bad_amount_in_minus,
&total_bad_amount_in_minus, &total_bad_amount_in_minus,
&rii->details.amount)); &rii->details.amount));
@ -1672,7 +1672,7 @@ history_credit_cb (void *cls,
details->execution_date), details->execution_date),
"diagnostic", "wire subject does not match")); "diagnostic", "wire subject does not match"));
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_bad_amount_in_plus, TALER_amount_add (&total_bad_amount_in_plus,
&total_bad_amount_in_plus, &total_bad_amount_in_plus,
&details->amount)); &details->amount));
@ -1701,11 +1701,11 @@ history_credit_cb (void *cls,
/* details->amount > rii->details.amount: wire transfer was larger than it should have been */ /* details->amount > rii->details.amount: wire transfer was larger than it should have been */
struct TALER_Amount delta; struct TALER_Amount delta;
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_subtract (&delta, TALER_amount_subtract (&delta,
&details->amount, &details->amount,
&rii->details.amount)); &rii->details.amount));
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_bad_amount_in_plus, TALER_amount_add (&total_bad_amount_in_plus,
&total_bad_amount_in_plus, &total_bad_amount_in_plus,
&delta)); &delta));
@ -1715,11 +1715,11 @@ history_credit_cb (void *cls,
/* rii->details.amount < details->amount: wire transfer was smaller than it should have been */ /* rii->details.amount < details->amount: wire transfer was smaller than it should have been */
struct TALER_Amount delta; struct TALER_Amount delta;
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_subtract (&delta, TALER_amount_subtract (&delta,
&rii->details.amount, &rii->details.amount,
&details->amount)); &details->amount));
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_bad_amount_in_minus, TALER_amount_add (&total_bad_amount_in_minus,
&total_bad_amount_in_minus, &total_bad_amount_in_minus,
&delta)); &delta));
@ -1737,7 +1737,7 @@ history_credit_cb (void *cls,
"bank_row", (json_int_t) row_off, "bank_row", (json_int_t) row_off,
"reserve_pub", GNUNET_JSON_from_data_auto ( "reserve_pub", GNUNET_JSON_from_data_auto (
&rii->details.reserve_pub))); &rii->details.reserve_pub)));
GNUNET_break (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_add (&total_missattribution_in, TALER_amount_add (&total_missattribution_in,
&total_missattribution_in, &total_missattribution_in,
&rii->details.amount)); &rii->details.amount));