exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit e5358fdfc031b8bb7f17dcf37dd3f4ce5fe4c409
parent ace816572e8ae465b168db9214c2c7f895f76b88
Author: Özgür Kesim <oec@codeblau.de>
Date:   Mon, 31 Mar 2025 20:21:30 +0200

[auditor] adjusting withdraw callback in taler-helper-auditor-coins

Diffstat:
Msrc/auditor/taler-helper-auditor-coins.c | 112+++++++++++++++++++++++++++++++++++++++++++++----------------------------------
1 file changed, 64 insertions(+), 48 deletions(-)

diff --git a/src/auditor/taler-helper-auditor-coins.c b/src/auditor/taler-helper-auditor-coins.c @@ -971,10 +971,15 @@ cleanup_denomination (void *cls, * @param cls our `struct CoinContext` * @param rowid unique serial ID for the refresh session in our DB * @param num_evs number of elements in @e h_blind_evs - * @param h_blind_evs array @e num_evs of blinded hash of the coin's public keys - * @param denom_pub public denomination key of the deposited coin + * @param h_blind_evs array @e num_evs of blinded hashes of the coin's public keys + * @param denom_serials array @e num_evs of serial ID's of denominations in our DB + * @param h_commitment hash of the commitment of the withdraw + * @param h_planchets running hash over all hashes of blinded planchets in the original withdraw request + * @param age_proof_required true if the withdraw request required an age proof. + * @param max_age if @e age_proof_required is true, the maximum age that was set on the coins. + * @param noreveal_index if @e age_proof_required is true, the index that was returned by the exchange for the reveal phase. * @param reserve_pub public key of the reserve - * @param reserve_sig signature over the withdraw operation (verified elsewhere) + * @param reserve_sig signature over the withdraw operation * @param execution_date when did the wallet withdraw the coin * @param amount_with_fee amount that was withdrawn * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop @@ -984,7 +989,12 @@ withdraw_cb (void *cls, uint64_t rowid, size_t num_evs, const struct TALER_BlindedCoinHashP *h_blind_evs, - const struct TALER_DenominationPublicKey *denom_pub, + const uint64_t *denom_serials, + const struct TALER_WithdrawCommitmentHashP *h_commitment, + const struct TALER_HashBlindedPlanchetsP *h_planchets, + bool age_proof_required, + uint8_t max_age, + uint8_t noreveal_index, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_ReserveSignatureP *reserve_sig, struct GNUNET_TIME_Timestamp execution_date, @@ -999,6 +1009,8 @@ withdraw_cb (void *cls, /* Note: some optimization potential here: lots of fields we could avoid fetching from the database with a custom function. */ (void) h_blind_evs; + (void) h_commitment; + (void) h_planchets; (void) reserve_pub; (void) reserve_sig; (void) execution_date; @@ -1008,58 +1020,60 @@ withdraw_cb (void *cls, 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, - &dh); - if (0 > qs) - { - GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); - cc->qs = qs; - return GNUNET_SYSERR; - } - if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) + for (size_t i=0; i < num_evs; i++) { - qs = report_row_inconsistency ("withdraw", - rowid, - "denomination key not found"); + qs = TALER_ARL_get_denomination_info_by_serial (denom_serials[i], + &issue); if (0 > qs) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); cc->qs = qs; return GNUNET_SYSERR; } - return GNUNET_OK; - } - ds = get_denomination_summary (cc, - issue, - &dh); - if (NULL == ds) - { - /* cc->qs is set by #get_denomination_summary() */ - GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == cc->qs); - return GNUNET_SYSERR; + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) + { + qs = report_row_inconsistency ("withdraw", + rowid, + "denomination key not found"); + if (0 > qs) + { + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + cc->qs = qs; + return GNUNET_SYSERR; + } + return GNUNET_OK; + } + ds = get_denomination_summary (cc, + issue, + &dh); + if (NULL == ds) + { + /* cc->qs is set by #get_denomination_summary() */ + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == cc->qs); + return GNUNET_SYSERR; + } + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Issued coin in denomination `%s' of total value %s\n", + GNUNET_h2s (&dh.hash), + TALER_amount2s (&issue->value)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "New balance of denomination `%s' is %s\n", + GNUNET_h2s (&dh.hash), + 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 (&TALER_ARL_USE_AB (coin_balance_risk), + &TALER_ARL_USE_AB (coin_balance_risk), + &issue->value); + 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); } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Issued coin in denomination `%s' of total value %s\n", - GNUNET_h2s (&dh.hash), - TALER_amount2s (&issue->value)); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "New balance of denomination `%s' is %s\n", - GNUNET_h2s (&dh.hash), - 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 (&TALER_ARL_USE_AB (coin_balance_risk), - &TALER_ARL_USE_AB (coin_balance_risk), - &issue->value); - 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); return GNUNET_OK; } @@ -2461,12 +2475,14 @@ recoup_refresh_cb (void *cls, * by this auditor. * * @param cls closure, pointer to `enum GNUNET_DB_QueryStatus` + * @param denom_serial row ID of the denominations table of the exchange DB * @param denom_pub public key, sometimes NULL (!) * @param issue issuing information with value, fees and other info about the denomination. */ static void check_denomination ( void *cls, + uint64_t denom_serial, const struct TALER_DenominationPublicKey *denom_pub, const struct TALER_EXCHANGEDB_DenominationKeyInformation *issue) {