From 3480146a6658f16d8a12d9653cb2e8b358c595c8 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 22 Mar 2020 23:32:06 +0100 Subject: first pass at auditor-coins, also reviewing checks around amount arithmetic, can and should be made harsher --- src/auditor/taler-helper-auditor-aggregation.c | 56 +-- src/auditor/taler-helper-auditor-coins.c | 540 +++++++++++-------------- src/auditor/taler-helper-auditor-reserves.c | 40 +- src/auditor/taler-helper-auditor-wire.c | 152 +++---- 4 files changed, 355 insertions(+), 433 deletions(-) diff --git a/src/auditor/taler-helper-auditor-aggregation.c b/src/auditor/taler-helper-auditor-aggregation.c index 74476a766..9982612e0 100644 --- a/src/auditor/taler-helper-auditor-aggregation.c +++ b/src/auditor/taler-helper-auditor-aggregation.c @@ -145,19 +145,19 @@ report_amount_arithmetic_inconsistency ( auditor)) { /* exchange > auditor */ - GNUNET_break (GNUNET_OK == - TALER_amount_subtract (&delta, - exchange, - auditor)); + GNUNET_assert (GNUNET_OK == + TALER_amount_subtract (&delta, + exchange, + auditor)); } else { /* auditor < exchange */ profitable = -profitable; - GNUNET_break (GNUNET_OK == - TALER_amount_subtract (&delta, - auditor, - exchange)); + GNUNET_assert (GNUNET_OK == + TALER_amount_subtract (&delta, + auditor, + exchange)); } TALER_ARL_report (report_amount_arithmetic_inconsistencies, json_pack ("{s:s, s:I, s:o, s:o, s:I}", @@ -171,10 +171,10 @@ report_amount_arithmetic_inconsistency ( target = (1 == profitable) ? &total_arithmetic_delta_plus : &total_arithmetic_delta_minus; - GNUNET_break (GNUNET_OK == - TALER_amount_add (target, - target, - &delta)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (target, + target, + &delta)); } } @@ -207,19 +207,19 @@ report_coin_arithmetic_inconsistency ( auditor)) { /* exchange > auditor */ - GNUNET_break (GNUNET_OK == - TALER_amount_subtract (&delta, - exchange, - auditor)); + GNUNET_assert (GNUNET_OK == + TALER_amount_subtract (&delta, + exchange, + auditor)); } else { /* auditor < exchange */ profitable = -profitable; - GNUNET_break (GNUNET_OK == - TALER_amount_subtract (&delta, - auditor, - exchange)); + GNUNET_assert (GNUNET_OK == + TALER_amount_subtract (&delta, + auditor, + exchange)); } TALER_ARL_report (report_coin_inconsistencies, json_pack ("{s:s, s:o, s:o, s:o, s:I}", @@ -234,10 +234,10 @@ report_coin_arithmetic_inconsistency ( target = (1 == profitable) ? &total_coin_delta_plus : &total_coin_delta_minus; - GNUNET_break (GNUNET_OK == - TALER_amount_add (target, - target, - &delta)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (target, + target, + &delta)); } } @@ -856,10 +856,10 @@ wire_transfer_information_cb ( "loss", TALER_JSON_from_amount (coin_value), "key_pub", GNUNET_JSON_from_data_auto ( &issue->denom_hash))); - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_bad_sig_loss, - &total_bad_sig_loss, - coin_value)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_bad_sig_loss, + &total_bad_sig_loss, + coin_value)); GNUNET_CRYPTO_rsa_signature_free (coin.denom_sig.rsa_signature); TALER_ARL_edb->free_coin_transaction_list (TALER_ARL_edb->cls, tl); diff --git a/src/auditor/taler-helper-auditor-coins.c b/src/auditor/taler-helper-auditor-coins.c index f35aa0fcf..c58dbc721 100644 --- a/src/auditor/taler-helper-auditor-coins.c +++ b/src/auditor/taler-helper-auditor-coins.c @@ -302,19 +302,19 @@ report_amount_arithmetic_inconsistency ( auditor)) { /* exchange > auditor */ - GNUNET_break (GNUNET_OK == - TALER_amount_subtract (&delta, - exchange, - auditor)); + GNUNET_assert (GNUNET_OK == + TALER_amount_subtract (&delta, + exchange, + auditor)); } else { /* auditor < exchange */ profitable = -profitable; - GNUNET_break (GNUNET_OK == - TALER_amount_subtract (&delta, - auditor, - exchange)); + GNUNET_assert (GNUNET_OK == + TALER_amount_subtract (&delta, + auditor, + exchange)); } TALER_ARL_report (report_amount_arithmetic_inconsistencies, json_pack ("{s:s, s:I, s:o, s:o, s:I}", @@ -328,10 +328,10 @@ report_amount_arithmetic_inconsistency ( target = (1 == profitable) ? &total_arithmetic_delta_plus : &total_arithmetic_delta_minus; - GNUNET_break (GNUNET_OK == - TALER_amount_add (target, - target, - &delta)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (target, + target, + &delta)); } } @@ -494,12 +494,13 @@ init_denomination (const struct GNUNET_HashCode *denom_hash, if (0 < qs) { /* 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 != GNUNET_CRYPTO_eddsa_verify ( TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED, @@ -642,8 +643,7 @@ sync_denomination (void *cls, (qs = TALER_ARL_adb->insert_historic_denom_revenue ( TALER_ARL_adb->cls, TALER_ARL_asession, - & - TALER_ARL_master_pub, + &TALER_ARL_master_pub, denom_hash, expire_deposit, &ds->denom_balance, @@ -801,46 +801,26 @@ withdraw_cb (void *cls, GNUNET_h2s (&dh), TALER_amount2s (&value)); ds->num_issued++; - if (GNUNET_OK != - TALER_amount_add (&ds->denom_balance, - &ds->denom_balance, - &value)) - { - GNUNET_break (0); - cc->qs = GNUNET_DB_STATUS_HARD_ERROR; - return GNUNET_SYSERR; - } + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&ds->denom_balance, + &ds->denom_balance, + &value)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New balance of denomination `%s' is %s\n", GNUNET_h2s (&dh), TALER_amount2s (&ds->denom_balance)); - if (GNUNET_OK != - TALER_amount_add (&total_escrow_balance, - &total_escrow_balance, - &value)) - { - GNUNET_break (0); - cc->qs = GNUNET_DB_STATUS_HARD_ERROR; - return GNUNET_SYSERR; - } - if (GNUNET_OK != - TALER_amount_add (&total_risk, - &total_risk, - &value)) - { - GNUNET_break (0); - cc->qs = GNUNET_DB_STATUS_HARD_ERROR; - return GNUNET_SYSERR; - } - if (GNUNET_OK != - TALER_amount_add (&ds->denom_risk, - &ds->denom_risk, - &value)) - { - GNUNET_break (0); - cc->qs = GNUNET_DB_STATUS_HARD_ERROR; - return GNUNET_SYSERR; - } + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_escrow_balance, + &total_escrow_balance, + &value)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_risk, + &total_risk, + &value)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&ds->denom_risk, + &ds->denom_risk, + &value)); return GNUNET_OK; } @@ -939,10 +919,10 @@ check_known_coin (const struct TALER_CoinSpendPublicKeyP *coin_pub, loss_potential), "key_pub", GNUNET_JSON_from_data_auto ( coin_pub))); - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_bad_sig_loss, - &total_bad_sig_loss, - loss_potential)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_bad_sig_loss, + &total_bad_sig_loss, + loss_potential)); } GNUNET_CRYPTO_rsa_signature_free (ci.denom_sig.rsa_signature); @@ -978,7 +958,6 @@ refresh_session_cb (void *cls, const struct TALER_RefreshCommitmentP *rc) { struct CoinContext *cc = cls; - struct TALER_RefreshMeltCoinAffirmationPS rmc; const struct TALER_DenominationKeyValidityPS *issue; struct DenominationSummary *dso; struct TALER_Amount amount_without_fee; @@ -1016,32 +995,37 @@ refresh_session_cb (void *cls, } /* verify melt signature */ - rmc.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT); - rmc.purpose.size = htonl (sizeof (rmc)); - rmc.rc = *rc; - TALER_amount_hton (&rmc.amount_with_fee, - amount_with_fee); - rmc.melt_fee = issue->fee_refresh; - rmc.coin_pub = *coin_pub; - if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_COIN_MELT, - &rmc.purpose, - &coin_sig->eddsa_signature, - &coin_pub->eddsa_pub)) { - TALER_ARL_report (report_bad_sig_losses, - json_pack ("{s:s, s:I, s:o, s:o}", - "operation", "melt", - "row", (json_int_t) rowid, - "loss", TALER_JSON_from_amount ( - amount_with_fee), - "key_pub", GNUNET_JSON_from_data_auto ( - coin_pub))); - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_bad_sig_loss, - &total_bad_sig_loss, - amount_with_fee)); - return GNUNET_OK; + struct TALER_RefreshMeltCoinAffirmationPS rmc = { + .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, + amount_with_fee); + if (GNUNET_OK != + GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_COIN_MELT, + &rmc.purpose, + &coin_sig->eddsa_signature, + &coin_pub->eddsa_pub)) + { + TALER_ARL_report (report_bad_sig_losses, + json_pack ("{s:s, s:I, s:o, s:o}", + "operation", "melt", + "row", (json_int_t) rowid, + "loss", TALER_JSON_from_amount ( + amount_with_fee), + "key_pub", GNUNET_JSON_from_data_auto ( + coin_pub))); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_bad_sig_loss, + &total_bad_sig_loss, + amount_with_fee)); + return GNUNET_OK; + } } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Melting coin %s in denomination `%s' of value %s\n", @@ -1084,10 +1068,10 @@ refresh_session_cb (void *cls, amount_with_fee), "coin_pub", GNUNET_JSON_from_data_auto ( coin_pub))); - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_refresh_hanging, - &total_refresh_hanging, - amount_with_fee)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_refresh_hanging, + &total_refresh_hanging, + amount_with_fee)); return GNUNET_OK; } @@ -1138,19 +1122,14 @@ refresh_session_cb (void *cls, &new_issues[i]->fee_withdraw); TALER_amount_ntoh (&value, &new_issues[i]->value); - if ( (GNUNET_OK != - TALER_amount_add (&refresh_cost, - &refresh_cost, - &fee)) || - (GNUNET_OK != - TALER_amount_add (&refresh_cost, - &refresh_cost, - &value)) ) - { - GNUNET_break (0); - cc->qs = GNUNET_DB_STATUS_HARD_ERROR; - return GNUNET_SYSERR; - } + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&refresh_cost, + &refresh_cost, + &fee)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&refresh_cost, + &refresh_cost, + &value)); } /* compute contribution of old coin */ @@ -1164,6 +1143,7 @@ refresh_session_cb (void *cls, amount_with_fee, &melt_fee)) { + // FIXME: handle properly! GNUNET_break (0); cc->qs = GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_SYSERR; @@ -1204,46 +1184,26 @@ refresh_session_cb (void *cls, GNUNET_h2s (&new_issues[i]->denom_hash), TALER_amount2s (&value)); dsi->num_issued++; - if (GNUNET_OK != - TALER_amount_add (&dsi->denom_balance, - &dsi->denom_balance, - &value)) - { - GNUNET_break (0); - cc->qs = GNUNET_DB_STATUS_HARD_ERROR; - return GNUNET_SYSERR; - } - if (GNUNET_OK != - TALER_amount_add (&dsi->denom_risk, - &dsi->denom_risk, - &value)) - { - GNUNET_break (0); - cc->qs = GNUNET_DB_STATUS_HARD_ERROR; - return GNUNET_SYSERR; - } + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&dsi->denom_balance, + &dsi->denom_balance, + &value)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&dsi->denom_risk, + &dsi->denom_risk, + &value)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New balance of denomination `%s' is %s\n", GNUNET_h2s (&new_issues[i]->denom_hash), TALER_amount2s (&dsi->denom_balance)); - if (GNUNET_OK != - TALER_amount_add (&total_escrow_balance, - &total_escrow_balance, - &value)) - { - GNUNET_break (0); - cc->qs = GNUNET_DB_STATUS_HARD_ERROR; - return GNUNET_SYSERR; - } - if (GNUNET_OK != - TALER_amount_add (&total_risk, - &total_risk, - &value)) - { - GNUNET_break (0); - cc->qs = GNUNET_DB_STATUS_HARD_ERROR; - return GNUNET_SYSERR; - } + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_escrow_balance, + &total_escrow_balance, + &value)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_risk, + &total_risk, + &value)); } } } @@ -1306,18 +1266,11 @@ refresh_session_cb (void *cls, TALER_amount_ntoh (&rfee, &issue->fee_refresh); - if (GNUNET_OK != - TALER_amount_add (&total_melt_fee_income, - &total_melt_fee_income, - &rfee)) - { - GNUNET_break (0); - cc->qs = GNUNET_DB_STATUS_HARD_ERROR; - return GNUNET_SYSERR; - } + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_melt_fee_income, + &total_melt_fee_income, + &rfee)); } - - /* We're good! */ return GNUNET_OK; } @@ -1361,7 +1314,6 @@ deposit_cb (void *cls, struct CoinContext *cc = cls; const struct TALER_DenominationKeyValidityPS *issue; struct DenominationSummary *ds; - struct TALER_DepositRequestPS dr; struct TALER_Amount tmp; enum GNUNET_DB_QueryStatus qs; @@ -1398,56 +1350,61 @@ deposit_cb (void *cls, } /* Verify deposit signature */ - dr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_DEPOSIT); - dr.purpose.size = htonl (sizeof (dr)); - dr.h_contract_terms = *h_contract_terms; - if (GNUNET_OK != - TALER_JSON_merchant_wire_signature_hash (receiver_wire_account, - &dr.h_wire)) { - TALER_ARL_report (report_bad_sig_losses, - json_pack ("{s:s, s:I, s:o, s:o}", - "operation", "deposit", - "row", (json_int_t) rowid, - "loss", TALER_JSON_from_amount ( - amount_with_fee), - "key_pub", GNUNET_JSON_from_data_auto ( - coin_pub))); - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_bad_sig_loss, - &total_bad_sig_loss, - amount_with_fee)); - 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, - 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 - want to do in parallel in the background to improve - auditor performance! */ - if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_COIN_DEPOSIT, - &dr.purpose, - &coin_sig->eddsa_signature, - &coin_pub->eddsa_pub)) - { - TALER_ARL_report (report_bad_sig_losses, - json_pack ("{s:s, s:I, s:o, s:o}", - "operation", "deposit", - "row", (json_int_t) rowid, - "loss", TALER_JSON_from_amount ( - amount_with_fee), - "key_pub", GNUNET_JSON_from_data_auto ( - coin_pub))); - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_bad_sig_loss, - &total_bad_sig_loss, - amount_with_fee)); - return GNUNET_OK; + struct TALER_DepositRequestPS dr = { + .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 != + TALER_JSON_merchant_wire_signature_hash (receiver_wire_account, + &dr.h_wire)) + { + TALER_ARL_report (report_bad_sig_losses, + json_pack ("{s:s, s:I, s:o, s:o}", + "operation", "deposit", + "row", (json_int_t) rowid, + "loss", TALER_JSON_from_amount ( + amount_with_fee), + "key_pub", GNUNET_JSON_from_data_auto ( + coin_pub))); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_bad_sig_loss, + &total_bad_sig_loss, + amount_with_fee)); + return GNUNET_OK; + } + TALER_amount_hton (&dr.amount_with_fee, + amount_with_fee); + /* NOTE: This is one of the operations we might eventually + want to do in parallel in the background to improve + auditor performance! */ + if (GNUNET_OK != + GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_COIN_DEPOSIT, + &dr.purpose, + &coin_sig->eddsa_signature, + &coin_pub->eddsa_pub)) + { + TALER_ARL_report (report_bad_sig_losses, + json_pack ("{s:s, s:I, s:o, s:o}", + "operation", "deposit", + "row", (json_int_t) rowid, + "loss", TALER_JSON_from_amount ( + amount_with_fee), + "key_pub", GNUNET_JSON_from_data_auto ( + coin_pub))); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_bad_sig_loss, + &total_bad_sig_loss, + amount_with_fee)); + return GNUNET_OK; + } } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deposited coin %s in denomination `%s' of value %s\n", @@ -1488,7 +1445,8 @@ deposit_cb (void *cls, accepted a forged coin (i.e. emergency situation after private key compromise). In that case, we cannot even 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", rowid, &total_escrow_balance, @@ -1508,21 +1466,16 @@ deposit_cb (void *cls, GNUNET_h2s (&issue->denom_hash), TALER_amount2s (&ds->denom_balance)); - /* update global up melt fees */ + /* update global deposit fees */ { struct TALER_Amount dfee; TALER_amount_ntoh (&dfee, &issue->fee_deposit); - if (GNUNET_OK != - TALER_amount_add (&total_deposit_fee_income, - &total_deposit_fee_income, - &dfee)) - { - GNUNET_break (0); - cc->qs = GNUNET_DB_STATUS_HARD_ERROR; - return GNUNET_SYSERR; - } + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_deposit_fee_income, + &total_deposit_fee_income, + &dfee)); } return GNUNET_OK; @@ -1608,10 +1561,10 @@ refund_cb (void *cls, amount_with_fee), "key_pub", GNUNET_JSON_from_data_auto ( merchant_pub))); - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_bad_sig_loss, - &total_bad_sig_loss, - amount_with_fee)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_bad_sig_loss, + &total_bad_sig_loss, + amount_with_fee)); return GNUNET_OK; } @@ -1645,59 +1598,32 @@ refund_cb (void *cls, GNUNET_break (0); return GNUNET_SYSERR; } - if (GNUNET_OK != - TALER_amount_add (&ds->denom_balance, - &ds->denom_balance, - &amount_without_fee)) - { - GNUNET_break (0); - cc->qs = GNUNET_DB_STATUS_HARD_ERROR; - return GNUNET_SYSERR; - } - if (GNUNET_OK != - TALER_amount_add (&ds->denom_risk, - &ds->denom_risk, - &amount_without_fee)) - { - GNUNET_break (0); - cc->qs = GNUNET_DB_STATUS_HARD_ERROR; - return GNUNET_SYSERR; - } - if (GNUNET_OK != - TALER_amount_add (&total_escrow_balance, - &total_escrow_balance, - &amount_without_fee)) - { - GNUNET_break (0); - cc->qs = GNUNET_DB_STATUS_HARD_ERROR; - return GNUNET_SYSERR; - } - if (GNUNET_OK != - TALER_amount_add (&total_risk, - &total_risk, - &amount_without_fee)) - { - GNUNET_break (0); - cc->qs = GNUNET_DB_STATUS_HARD_ERROR; - return GNUNET_SYSERR; - } - + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&ds->denom_balance, + &ds->denom_balance, + &amount_without_fee)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&ds->denom_risk, + &ds->denom_risk, + &amount_without_fee)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_escrow_balance, + &total_escrow_balance, + &amount_without_fee)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_risk, + &total_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), TALER_amount2s (&ds->denom_balance)); /* update total refund fee balance */ - if (GNUNET_OK != - TALER_amount_add (&total_refund_fee_income, - &total_refund_fee_income, - &refund_fee)) - { - GNUNET_break (0); - cc->qs = GNUNET_DB_STATUS_HARD_ERROR; - return GNUNET_SYSERR; - } - + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_refund_fee_income, + &total_refund_fee_income, + &refund_fee)); return GNUNET_OK; } @@ -1740,10 +1666,10 @@ check_recoup (struct CoinContext *cc, "loss", TALER_JSON_from_amount (amount), "key_pub", GNUNET_JSON_from_data_auto ( &pr.h_denom_pub))); - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_bad_sig_loss, - &total_bad_sig_loss, - amount)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_bad_sig_loss, + &total_bad_sig_loss, + amount)); } qs = TALER_ARL_get_denomination_info (denom_pub, &issue, @@ -1780,10 +1706,10 @@ check_recoup (struct CoinContext *cc, "loss", TALER_JSON_from_amount (amount), "coin_pub", GNUNET_JSON_from_data_auto ( &coin->coin_pub))); - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_bad_sig_loss, - &total_bad_sig_loss, - amount)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_bad_sig_loss, + &total_bad_sig_loss, + amount)); return GNUNET_OK; } ds = get_denomination_summary (cc, @@ -1801,14 +1727,14 @@ check_recoup (struct CoinContext *cc, "coin_pub", GNUNET_JSON_from_data_auto ( &coin->coin_pub))); } - GNUNET_break (GNUNET_OK == - TALER_amount_add (&ds->denom_recoup, - &ds->denom_recoup, - amount)); - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_recoup_loss, - &total_recoup_loss, - amount)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&ds->denom_recoup, + &ds->denom_recoup, + amount)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_recoup_loss, + &total_recoup_loss, + amount)); return GNUNET_OK; } @@ -1960,8 +1886,7 @@ analyze_coins (void *cls) (qs = TALER_ARL_edb->select_withdrawals_above_serial_id ( TALER_ARL_edb->cls, TALER_ARL_esession, - ppc. - last_withdraw_serial_id, + ppc.last_withdraw_serial_id, &withdraw_cb, &cc)) ) { @@ -1973,12 +1898,12 @@ analyze_coins (void *cls) /* process refunds */ if (0 > - (qs = TALER_ARL_edb->select_refunds_above_serial_id (TALER_ARL_edb->cls, - TALER_ARL_esession, - ppc. - last_refund_serial_id, - &refund_cb, - &cc))) + (qs = TALER_ARL_edb->select_refunds_above_serial_id ( + TALER_ARL_edb->cls, + TALER_ARL_esession, + ppc.last_refund_serial_id, + &refund_cb, + &cc))) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; @@ -1988,12 +1913,12 @@ analyze_coins (void *cls) /* process refreshs */ if (0 > - (qs = TALER_ARL_edb->select_refreshes_above_serial_id (TALER_ARL_edb->cls, - TALER_ARL_esession, - ppc. - last_melt_serial_id, - &refresh_session_cb, - &cc))) + (qs = TALER_ARL_edb->select_refreshes_above_serial_id ( + TALER_ARL_edb->cls, + TALER_ARL_esession, + ppc.last_melt_serial_id, + &refresh_session_cb, + &cc))) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; @@ -2003,12 +1928,12 @@ analyze_coins (void *cls) /* process deposits */ if (0 > - (qs = TALER_ARL_edb->select_deposits_above_serial_id (TALER_ARL_edb->cls, - TALER_ARL_esession, - ppc. - last_deposit_serial_id, - &deposit_cb, - &cc))) + (qs = TALER_ARL_edb->select_deposits_above_serial_id ( + TALER_ARL_edb->cls, + TALER_ARL_esession, + ppc.last_deposit_serial_id, + &deposit_cb, + &cc))) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; @@ -2018,12 +1943,12 @@ analyze_coins (void *cls) /* process recoups */ if (0 > - (qs = TALER_ARL_edb->select_recoup_above_serial_id (TALER_ARL_edb->cls, - TALER_ARL_esession, - ppc. - last_recoup_serial_id, - &recoup_cb, - &cc))) + (qs = TALER_ARL_edb->select_recoup_above_serial_id ( + TALER_ARL_edb->cls, + TALER_ARL_esession, + ppc.last_recoup_serial_id, + &recoup_cb, + &cc))) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; @@ -2145,16 +2070,13 @@ run (void *cls, &reported_emergency_loss)); GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (TALER_ARL_currency, - & - reported_emergency_risk_by_amount)); + &reported_emergency_risk_by_amount)); GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (TALER_ARL_currency, - & - reported_emergency_risk_by_count)); + &reported_emergency_risk_by_count)); GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (TALER_ARL_currency, - & - reported_emergency_loss_by_count)); + &reported_emergency_loss_by_count)); GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (TALER_ARL_currency, &total_escrow_balance)); diff --git a/src/auditor/taler-helper-auditor-reserves.c b/src/auditor/taler-helper-auditor-reserves.c index ccc6df55e..79439e01f 100644 --- a/src/auditor/taler-helper-auditor-reserves.c +++ b/src/auditor/taler-helper-auditor-reserves.c @@ -174,19 +174,19 @@ report_amount_arithmetic_inconsistency ( auditor)) { /* exchange > auditor */ - GNUNET_break (GNUNET_OK == - TALER_amount_subtract (&delta, - exchange, - auditor)); + GNUNET_assert (GNUNET_OK == + TALER_amount_subtract (&delta, + exchange, + auditor)); } else { /* auditor < exchange */ profitable = -profitable; - GNUNET_break (GNUNET_OK == - TALER_amount_subtract (&delta, - auditor, - exchange)); + GNUNET_assert (GNUNET_OK == + TALER_amount_subtract (&delta, + auditor, + exchange)); } TALER_ARL_report (report_amount_arithmetic_inconsistencies, json_pack ("{s:s, s:I, s:o, s:o, s:I}", @@ -200,10 +200,10 @@ report_amount_arithmetic_inconsistency ( target = (1 == profitable) ? &total_arithmetic_delta_plus : &total_arithmetic_delta_minus; - GNUNET_break (GNUNET_OK == - TALER_amount_add (target, - target, - &delta)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (target, + target, + &delta)); } } @@ -725,10 +725,10 @@ handle_recoup_by_reserve ( report_row_inconsistency ("recoup", rowid, "denomination key not in revocation set"); - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_irregular_recoups, - &total_irregular_recoups, - amount)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_irregular_recoups, + &total_irregular_recoups, + amount)); } else { @@ -774,10 +774,10 @@ handle_recoup_by_reserve ( "loss", TALER_JSON_from_amount (amount), "key_pub", GNUNET_JSON_from_data_auto ( &TALER_ARL_master_pub))); - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_bad_sig_loss, - &total_bad_sig_loss, - amount)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_bad_sig_loss, + &total_bad_sig_loss, + amount)); } GNUNET_CRYPTO_hash (reserve_pub, diff --git a/src/auditor/taler-helper-auditor-wire.c b/src/auditor/taler-helper-auditor-wire.c index faf65a52f..4808ed74e 100644 --- a/src/auditor/taler-helper-auditor-wire.c +++ b/src/auditor/taler-helper-auditor-wire.c @@ -629,10 +629,10 @@ check_pending_rc (void *cls, (void) cls; (void) key; - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_closure_amount_lag, - &total_closure_amount_lag, - &rc->amount)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_closure_amount_lag, + &total_closure_amount_lag, + &rc->amount)); if ( (0 != rc->amount.value) || (0 != rc->amount.fraction) ) TALER_ARL_report (report_closure_lags, @@ -835,10 +835,10 @@ wire_missing_cb (void *cls, /* bool? */ int done) { (void) cls; - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_amount_lag, - &total_amount_lag, - amount)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_amount_lag, + &total_amount_lag, + amount)); if ( (GNUNET_YES == tiny) && (0 > TALER_amount_cmp (amount, &tiny_amount)) ) @@ -1001,10 +1001,10 @@ wire_out_cb (void *cls, date), "diagnostic", "wire transfer not made (yet?)", "account_section", wa->section_name)); - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_bad_amount_out_minus, - &total_bad_amount_out_minus, - amount)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_bad_amount_out_minus, + &total_bad_amount_out_minus, + amount)); return GNUNET_OK; } { @@ -1029,10 +1029,10 @@ wire_out_cb (void *cls, date), "diagnostic", "recevier account mismatch", "account_section", wa->section_name)); - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_bad_amount_out_plus, - &total_bad_amount_out_plus, - &roi->details.amount)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_bad_amount_out_plus, + &total_bad_amount_out_plus, + &roi->details.amount)); TALER_ARL_report (report_wire_out_inconsistencies, json_pack ("{s:I, s:o, s:o, s:o, s:o, s:s, s:s}", "row", (json_int_t) rowid, @@ -1045,10 +1045,10 @@ wire_out_cb (void *cls, date), "diagnostic", "receiver account mismatch", "account_section", wa->section_name)); - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_bad_amount_out_minus, - &total_bad_amount_out_minus, - amount)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_bad_amount_out_minus, + &total_bad_amount_out_minus, + amount)); GNUNET_free (payto_uri); goto cleanup; } @@ -1075,28 +1075,28 @@ wire_out_cb (void *cls, /* amount > roi->details.amount: wire transfer was smaller than it should have been */ struct TALER_Amount delta; - GNUNET_break (GNUNET_OK == - TALER_amount_subtract (&delta, - amount, - &roi->details.amount)); - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_bad_amount_out_minus, - &total_bad_amount_out_minus, - &delta)); + GNUNET_assert (GNUNET_OK == + TALER_amount_subtract (&delta, + amount, + &roi->details.amount)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_bad_amount_out_minus, + &total_bad_amount_out_minus, + &delta)); } else { /* roi->details.amount < amount: wire transfer was larger than it should have been */ struct TALER_Amount delta; - GNUNET_break (GNUNET_OK == - TALER_amount_subtract (&delta, - &roi->details.amount, - amount)); - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_bad_amount_out_plus, - &total_bad_amount_out_plus, - &delta)); + GNUNET_assert (GNUNET_OK == + TALER_amount_subtract (&delta, + &roi->details.amount, + amount)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_bad_amount_out_plus, + &total_bad_amount_out_plus, + &delta)); } goto cleanup; } @@ -1217,10 +1217,10 @@ complain_out_not_found (void *cls, wa->section_name, "diagnostic", "justification for wire transfer not found")); - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_bad_amount_out_plus, - &total_bad_amount_out_plus, - &roi->details.amount)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_bad_amount_out_plus, + &total_bad_amount_out_plus, + &roi->details.amount)); return GNUNET_OK; } @@ -1350,10 +1350,10 @@ history_debit_cb (void *cls, GNUNET_asprintf (&diagnostic, "duplicate subject hash `%s'", TALER_B2S (&roi->subject_hash)); - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_wire_format_amount, - &total_wire_format_amount, - &details->amount)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_wire_format_amount, + &total_wire_format_amount, + &details->amount)); TALER_ARL_report (report_wire_format_inconsistencies, json_pack ("{s:o, s:I, s:s}", "amount", TALER_JSON_from_amount ( @@ -1540,10 +1540,10 @@ complain_in_not_found (void *cls, "account", wa->section_name, "diagnostic", "incoming wire transfer claimed by exchange not found")); - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_bad_amount_in_minus, - &total_bad_amount_in_minus, - &rii->details.amount)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_bad_amount_in_minus, + &total_bad_amount_in_minus, + &rii->details.amount)); return GNUNET_OK; } @@ -1653,10 +1653,10 @@ history_credit_cb (void *cls, "timestamp", TALER_ARL_json_from_time_abs ( rii->details.execution_date), "diagnostic", "wire subject does not match")); - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_bad_amount_in_minus, - &total_bad_amount_in_minus, - &rii->details.amount)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_bad_amount_in_minus, + &total_bad_amount_in_minus, + &rii->details.amount)); TALER_ARL_report (report_reserve_in_inconsistencies, json_pack ("{s:I, s:I, s:o, s:o, s:o, s:o, s:s}", "row", (json_int_t) rii->rowid, @@ -1672,10 +1672,10 @@ history_credit_cb (void *cls, details->execution_date), "diagnostic", "wire subject does not match")); - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_bad_amount_in_plus, - &total_bad_amount_in_plus, - &details->amount)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_bad_amount_in_plus, + &total_bad_amount_in_plus, + &details->amount)); goto cleanup; } if (0 != TALER_amount_cmp (&rii->details.amount, @@ -1701,28 +1701,28 @@ history_credit_cb (void *cls, /* details->amount > rii->details.amount: wire transfer was larger than it should have been */ struct TALER_Amount delta; - GNUNET_break (GNUNET_OK == - TALER_amount_subtract (&delta, - &details->amount, - &rii->details.amount)); - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_bad_amount_in_plus, - &total_bad_amount_in_plus, - &delta)); + GNUNET_assert (GNUNET_OK == + TALER_amount_subtract (&delta, + &details->amount, + &rii->details.amount)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_bad_amount_in_plus, + &total_bad_amount_in_plus, + &delta)); } else { /* rii->details.amount < details->amount: wire transfer was smaller than it should have been */ struct TALER_Amount delta; - GNUNET_break (GNUNET_OK == - TALER_amount_subtract (&delta, - &rii->details.amount, - &details->amount)); - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_bad_amount_in_minus, - &total_bad_amount_in_minus, - &delta)); + GNUNET_assert (GNUNET_OK == + TALER_amount_subtract (&delta, + &rii->details.amount, + &details->amount)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_bad_amount_in_minus, + &total_bad_amount_in_minus, + &delta)); } goto cleanup; } @@ -1737,10 +1737,10 @@ history_credit_cb (void *cls, "bank_row", (json_int_t) row_off, "reserve_pub", GNUNET_JSON_from_data_auto ( &rii->details.reserve_pub))); - GNUNET_break (GNUNET_OK == - TALER_amount_add (&total_missattribution_in, - &total_missattribution_in, - &rii->details.amount)); + GNUNET_assert (GNUNET_OK == + TALER_amount_add (&total_missattribution_in, + &total_missattribution_in, + &rii->details.amount)); } if (details->execution_date.abs_value_us != rii->details.execution_date.abs_value_us) -- cgit v1.2.3