commit fd8519d7cb869a5574cec6e686ef9c56505a73d4
parent 23ecdf47b2d6c1031a1d0383d677c4c786bdb1fd
Author: Christian Grothoff <grothoff@gnunet.org>
Date: Sat, 15 Aug 2026 21:14:06 +0200
log loss if deposited coin is unknown
Diffstat:
1 file changed, 45 insertions(+), 4 deletions(-)
diff --git a/src/auditor/taler-helper-auditor-coins.c b/src/auditor/taler-helper-auditor-coins.c
@@ -1131,8 +1131,10 @@ withdraw_cb (
* @param denom_pub expected denomination of the coin
* @param loss_potential how big could the loss be if the coin is
* not properly signed
- * @return database transaction status, on success
- * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT
+ * @return database transaction status; on success
+ * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT, or
+ * #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if the coin is not known to
+ * the exchange at all (which was reported to the auditor database)
*/
static enum GNUNET_DB_QueryStatus
check_known_coin (
@@ -1166,11 +1168,50 @@ check_known_coin (
qs = TALER_EXCHANGEDB_get_known_coin (TALER_ARL_edb,
coin_pub,
&ci);
- if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
+ if (0 > qs)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
return qs;
}
+ if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
+ {
+ /* The exchange has no denomination signature on file for this
+ coin at all; that is the strongest evidence of a forged coin
+ and must be persisted, not merely logged. */
+ struct TALER_AUDITORDB_BadSigLosses bsl = {
+ .problem_row_id = rowid,
+ .operation = (char *) operation,
+ .loss = *loss_potential,
+ .operation_specific_pub = coin_pub->eddsa_pub
+ };
+ enum GNUNET_DB_QueryStatus rqs;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Coin %s used in %s in row %llu is not known to the exchange\n",
+ TALER_B2S (coin_pub),
+ operation,
+ (unsigned long long) rowid);
+ rqs = report_row_inconsistency ("known_coins",
+ rowid,
+ "coin not known to exchange");
+ if (0 > rqs)
+ {
+ GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == rqs);
+ return rqs;
+ }
+ rqs = TALER_AUDITORDB_insert_bad_sig_losses (
+ TALER_ARL_adb,
+ &bsl);
+ if (0 > rqs)
+ {
+ GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == rqs);
+ return rqs;
+ }
+ TALER_ARL_amount_add (&TALER_ARL_USE_AB (coin_irregular_loss),
+ &TALER_ARL_USE_AB (coin_irregular_loss),
+ loss_potential);
+ return qs;
+ }
if (GNUNET_YES !=
TALER_test_coin_valid (&ci,
denom_pub))
@@ -1620,7 +1661,7 @@ deposit_cb (struct CoinContext *cc,
&deposit->coin.coin_pub,
denom_pub,
&deposit->amount_with_fee);
- if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
+ if (0 > qs)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
cc->qs = qs;