exchange

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

commit 68025fa02da821f8b952f7d4e71021aa265c8f73
parent 0b1d892f601cbdfcaf1bf326d2a9921fad6ab0a2
Author: Christian Grothoff <christian@grothoff.org>
Date:   Mon, 29 Jun 2026 20:30:01 +0200

bugfixes

Diffstat:
Msrc/auditor/taler-helper-auditor-reserves.c | 61+++++++++++++++++++++++++++++++++----------------------------
Msrc/exchange-tools/taler-exchange-offline.c | 10++++++----
Msrc/exchange/taler-exchange-expire.c | 1+
Msrc/kyclogic/kyclogic_api.c | 71+++++++++++++++++++++++++++++++++++++++++++++--------------------------
4 files changed, 85 insertions(+), 58 deletions(-)

diff --git a/src/auditor/taler-helper-auditor-reserves.c b/src/auditor/taler-helper-auditor-reserves.c @@ -587,13 +587,22 @@ handle_withdrawals ( GNUNET_assert (rowid >= TALER_ARL_USE_PP (reserves_withdraw_serial_id)); TALER_ARL_USE_PP (reserves_withdraw_serial_id) = rowid + 1; - GNUNET_assert (GNUNET_OK == TALER_amount_set_zero (TALER_ARL_currency, - &auditor_amount)); - GNUNET_assert (GNUNET_OK == TALER_amount_set_zero (TALER_ARL_currency, - &auditor_fee)); - GNUNET_assert (GNUNET_OK == TALER_amount_set_zero (TALER_ARL_currency, - &auditor_amount_with_fee)); - + GNUNET_assert (GNUNET_OK == + TALER_amount_set_zero (TALER_ARL_currency, + &auditor_amount)); + GNUNET_assert (GNUNET_OK == + TALER_amount_set_zero (TALER_ARL_currency, + &auditor_fee)); + GNUNET_assert (GNUNET_OK == + TALER_amount_set_zero (TALER_ARL_currency, + &auditor_amount_with_fee)); + rs = setup_reserve (rc, + reserve_pub); + if (NULL == rs) + { + GNUNET_break (0); + return GNUNET_SYSERR; + } for (size_t i = 0; i < num_denom_serials; i++) { /* lookup denomination pub data (make sure denom_pub is valid, establish fees); @@ -629,12 +638,12 @@ handle_withdrawals ( TALER_amount2s (&issue->value)); /* check that execution date is within withdraw range for denom_pub */ - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Checking withdraw timing: %llu, expire: %llu, timing: %llu\n", - (unsigned long long) issue->start.abs_time.abs_value_us, - (unsigned long - long) issue->expire_withdraw.abs_time.abs_value_us, - (unsigned long long) execution_date.abs_time.abs_value_us); + GNUNET_log ( + GNUNET_ERROR_TYPE_DEBUG, + "Checking withdraw timing: %llu, expire: %llu, timing: %llu\n", + (unsigned long long) issue->start.abs_time.abs_value_us, + (unsigned long long) issue->expire_withdraw.abs_time.abs_value_us, + (unsigned long long) execution_date.abs_time.abs_value_us); if (GNUNET_TIME_timestamp_cmp (issue->start, >, execution_date) || @@ -643,7 +652,7 @@ handle_withdrawals ( execution_date)) { struct TALER_AUDITORDB_DenominationKeyValidityWithdrawInconsistency - dkvwi ={ + dkvwi = { .problem_row_id = rowid, .execution_date = execution_date.abs_time, .denompub_h = issue->denom_hash, @@ -685,7 +694,13 @@ handle_withdrawals ( &auditor_amount_with_fee, &issue_amount_with_fee); } - } + TALER_ARL_amount_add (&rs->curr_balance.withdraw_fee_balance, + &rs->curr_balance.withdraw_fee_balance, + &issue->fees.withdraw); + TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_withdraw_fee_revenue), + &TALER_ARL_USE_AB (reserves_withdraw_fee_revenue), + &issue->fees.withdraw); + } /* end for all coins in batch */ /* check reserve_sig (first: setup remaining members of wsrd) */ if (GNUNET_OK != @@ -739,14 +754,10 @@ handle_withdrawals ( rowid, "amount with fee from exchange does not match denomination value plus fee"); if (global_qs < 0) + { + GNUNET_break (0); return GNUNET_SYSERR; - } - rs = setup_reserve (rc, - reserve_pub); - if (NULL == rs) - { - GNUNET_break (0); - return GNUNET_SYSERR; + } } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Reserve `%s' reduced by %s from withdraw\n", @@ -755,12 +766,6 @@ handle_withdrawals ( GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Increasing withdraw profits by fee %s\n", TALER_amount2s (&issue->fees.withdraw)); - TALER_ARL_amount_add (&rs->curr_balance.withdraw_fee_balance, - &rs->curr_balance.withdraw_fee_balance, - &issue->fees.withdraw); - TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_withdraw_fee_revenue), - &TALER_ARL_USE_AB (reserves_withdraw_fee_revenue), - &issue->fees.withdraw); TALER_ARL_amount_add (&rs->total_out, &rs->total_out, &auditor_amount_with_fee); diff --git a/src/exchange-tools/taler-exchange-offline.c b/src/exchange-tools/taler-exchange-offline.c @@ -4084,7 +4084,8 @@ tofu_check (const struct TALER_SecurityModulePublicKeySetP *secmset) &secmset->eddsa)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "ESIGN security module key does not match SECM_ESIGN_PUBKEY in configuration\n"); + "ESIGN security module key does not match SECM_ESIGN_PUBKEY in configuration\n") + ; GNUNET_free (fn); return GNUNET_SYSERR; } @@ -4117,7 +4118,8 @@ tofu_check (const struct TALER_SecurityModulePublicKeySetP *secmset) &secmset->rsa)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "DENOM security module key does not match SECM_DENOM_PUBKEY in configuration\n"); + "DENOM security module key does not match SECM_DENOM_PUBKEY in configuration\n") + ; GNUNET_free (fn); return GNUNET_SYSERR; } @@ -4566,7 +4568,7 @@ do_show (char *const *args) "Invalid input to 'show': %s #%u (skipping)\n", err_name, err_line); - json_dumpf (in, + json_dumpf (keys, stderr, JSON_INDENT (2)); global_ret = EXIT_FAILURE; @@ -4986,7 +4988,7 @@ do_sign (char *const *args) "Invalid input to 'sign' : %s #%u (skipping)\n", err_name, err_line); - json_dumpf (in, + json_dumpf (keys, stderr, JSON_INDENT (2)); global_ret = EXIT_FAILURE; diff --git a/src/exchange/taler-exchange-expire.c b/src/exchange/taler-exchange-expire.c @@ -200,6 +200,7 @@ release_shard (struct Shard *s) case GNUNET_DB_STATUS_SOFT_ERROR: GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs); GNUNET_break (0); + global_ret = EXIT_FAILURE; GNUNET_SCHEDULER_shutdown (); return; case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: diff --git a/src/kyclogic/kyclogic_api.c b/src/kyclogic/kyclogic_api.c @@ -1067,8 +1067,13 @@ cleanup: } -void -TALER_KYCLOGIC_rules_free (struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs) +/** + * Free rules in @a lrs but not @a lrs itself. + * + * @param[in,out] lrs rule set to free + */ +static void +free_rules (struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs) { if (NULL == lrs) return; @@ -1079,9 +1084,14 @@ TALER_KYCLOGIC_rules_free (struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs) for (unsigned int j = 0; j<rule->num_measures; j++) GNUNET_free (rule->next_measures[j]); - GNUNET_free (rule->next_measures); + GNUNET_array_grow (rule->next_measures, + rule->num_measures, + 0); GNUNET_free (rule->rule_name); } + GNUNET_array_grow (lrs->kyc_rules, + lrs->num_kyc_rules, + 0); for (unsigned int i = 0; i<lrs->num_custom_measures; i++) { struct TALER_KYCLOGIC_Measure *measure @@ -1092,9 +1102,19 @@ TALER_KYCLOGIC_rules_free (struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs) GNUNET_free (measure->prog_name); json_decref (measure->context); } - GNUNET_free (lrs->kyc_rules); - GNUNET_free (lrs->custom_measures); + GNUNET_array_grow (lrs->custom_measures, + lrs->num_custom_measures, + 0); GNUNET_free (lrs->successor_measure); +} + + +void +TALER_KYCLOGIC_rules_free (struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs) +{ + if (NULL == lrs) + return; + free_rules (lrs); GNUNET_free (lrs); } @@ -2561,6 +2581,16 @@ add_rule (const struct GNUNET_CONFIGURATION_Handle *cfg, "amount required"); return GNUNET_SYSERR; } + if (0 != + strcasecmp (threshold.currency, + my_currency)) + { + GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, + section, + "THRESHOLD", + "currency mismatch"); + return GNUNET_SYSERR; + } exposed = (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (cfg, section, @@ -3460,21 +3490,10 @@ TALER_KYCLOGIC_kyc_init ( void TALER_KYCLOGIC_kyc_done (void) { - for (unsigned int i = 0; i<default_rules.num_kyc_rules; i++) - { - struct TALER_KYCLOGIC_KycRule *kt - = &default_rules.kyc_rules[i]; - - for (unsigned int j = 0; j<kt->num_measures; j++) - GNUNET_free (kt->next_measures[j]); - GNUNET_array_grow (kt->next_measures, - kt->num_measures, - 0); - GNUNET_free (kt->rule_name); - } - GNUNET_array_grow (default_rules.kyc_rules, - default_rules.num_kyc_rules, - 0); + free_rules (&default_rules); + memset (&default_rules, + 0, + sizeof (default_rules)); for (unsigned int i = 0; i<num_kyc_providers; i++) { struct TALER_KYCLOGIC_KycProvider *kp = kyc_providers[i]; @@ -3633,6 +3652,12 @@ TALER_KYCLOGIC_requirements_to_check ( } if (NULL != kyc_rule) { + if (kyc_rule->verboten) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Rule says operation is categorically is verboten, cannot take measures\n"); + return GNUNET_SYSERR; + } for (unsigned int i = 0; i<kyc_rule->num_measures; i++) { if (0 != strcasecmp (measure_name, @@ -3649,12 +3674,6 @@ TALER_KYCLOGIC_requirements_to_check ( kyc_rule->rule_name); return GNUNET_SYSERR; } - if (kyc_rule->verboten) - { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Rule says operation is categorically is verboten, cannot take measures\n"); - return GNUNET_SYSERR; - } } measure = find_measure (lrs, measure_name);