exchange

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

commit 7f43c9292900a4e6c1b6efe056e24498899eec58
parent a2be9458fcae890f3b05804e70b8aba7383abdfa
Author: Florian Dold <dold@taler.net>
Date:   Fri, 20 Nov 2026 19:12:33 +0100

exchange: report purse refunds in full with a zero refund fee

Diffstat:
Msrc/auditor/taler-helper-auditor-aggregation.c | 47++++++++---------------------------------------
Msrc/auditor/taler-helper-auditor-coins.c | 4----
Msrc/exchange/taler-exchange-httpd_get-coins-COIN_PUB-history.c | 14++------------
Msrc/exchangedb/exchangedb_transactions.c | 12+-----------
Msrc/exchangedb/get_coin_transactions.c | 10+++-------
Msrc/include/exchange-database/free_coin_transaction_list.h | 5++---
Msrc/include/taler/taler_crypto_lib.h | 12++++++------
Msrc/util/exchange_signatures.c | 12++++++------
8 files changed, 28 insertions(+), 88 deletions(-)

diff --git a/src/auditor/taler-helper-auditor-aggregation.c b/src/auditor/taler-helper-auditor-aggregation.c @@ -646,46 +646,15 @@ check_transaction_history_for_deposit ( break; } case TALER_EXCHANGEDB_TT_PURSE_DEPOSIT: - { - const struct TALER_Amount *amount_with_fee; - - amount_with_fee = &tl->details.purse_deposit->amount; - if (! tl->details.purse_deposit->refunded) - TALER_ARL_amount_add (&expenditures, - &expenditures, - amount_with_fee); - break; - } - + TALER_ARL_amount_add (&expenditures, + &expenditures, + &tl->details.purse_deposit->amount); + break; case TALER_EXCHANGEDB_TT_PURSE_REFUND: - { - const struct TALER_Amount *amount_with_fee; - - amount_with_fee = &tl->details.purse_refund->refund_amount; - fee_claimed = &tl->details.purse_refund->refund_fee; - TALER_ARL_amount_add (&refunds, - &refunds, - amount_with_fee); - TALER_ARL_amount_add (&expenditures, - &expenditures, - fee_claimed); - /* Check that the fees given in the transaction list and in dki match */ - if (0 != - TALER_amount_cmp (&issue->fees.refund, - fee_claimed)) - { - /* Disagreement in fee structure between exchange and auditor! */ - qs = report_amount_arithmetic_inconsistency ("refund fee", - 0, - fee_claimed, - &issue->fees.refund, - 1); - if (0 > qs) - return qs; - } - break; - } - + TALER_ARL_amount_add (&refunds, + &refunds, + &tl->details.purse_refund->refund_amount); + break; case TALER_EXCHANGEDB_TT_RESERVE_OPEN: { const struct TALER_Amount *amount_with_fee; diff --git a/src/auditor/taler-helper-auditor-coins.c b/src/auditor/taler-helper-auditor-coins.c @@ -646,10 +646,6 @@ check_coin_history (const struct TALER_CoinSpendPublicKeyP *coin_pub, TALER_ARL_amount_add (&refunded, &refunded, &pos->details.purse_refund->refund_amount); - TALER_ARL_amount_add (&spent, - &spent, - &pos->details.purse_refund->refund_fee); - have_refund = true; break; case TALER_EXCHANGEDB_TT_RESERVE_OPEN: TALER_ARL_amount_add (&spent, diff --git a/src/exchange/taler-exchange-httpd_get-coins-COIN_PUB-history.c b/src/exchange/taler-exchange-httpd_get-coins-COIN_PUB-history.c @@ -516,23 +516,13 @@ compile_transaction_history ( { const struct TALER_EXCHANGEDB_PurseRefundListEntry *prefund = pos->details.purse_refund; - struct TALER_Amount value; enum TALER_ErrorCode ec; struct TALER_ExchangePublicKeyP epub; struct TALER_ExchangeSignatureP esig; - if (0 > - TALER_amount_subtract (&value, - &prefund->refund_amount, - &prefund->refund_fee)) - { - GNUNET_break (0); - json_decref (history); - return NULL; - } ec = TALER_exchange_online_purse_refund_sign ( &TEH_keys_exchange_sign_, - &value, + &prefund->refund_amount, &prefund->refund_fee, coin_pub, &prefund->purse_pub, @@ -553,7 +543,7 @@ compile_transaction_history ( GNUNET_JSON_pack_uint64 ("history_offset", pos->coin_history_id), TALER_JSON_pack_amount ("amount", - &value), + &prefund->refund_amount), TALER_JSON_pack_amount ("refund_fee", &prefund->refund_fee), GNUNET_JSON_pack_data_auto ("exchange_sig", diff --git a/src/exchangedb/exchangedb_transactions.c b/src/exchangedb/exchangedb_transactions.c @@ -131,10 +131,9 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals ( GNUNET_break (0); return GNUNET_SYSERR; } - deposit_fee = pos->details.purse_deposit->deposit_fee; break; case TALER_EXCHANGEDB_TT_PURSE_REFUND: - /* refunded += pos->refund_amount - pos->refund_fee */ + /* refunded += pos->refund_amount */ if (0 > TALER_amount_add (&refunded, &refunded, @@ -143,15 +142,6 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals ( GNUNET_break (0); return GNUNET_SYSERR; } - if (0 > - TALER_amount_add (&spent, - &spent, - &pos->details.purse_refund->refund_fee)) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - have_refund = true; break; case TALER_EXCHANGEDB_TT_RESERVE_OPEN: /* spent += pos->amount_with_fee */ diff --git a/src/exchangedb/get_coin_transactions.c b/src/exchangedb/get_coin_transactions.c @@ -435,8 +435,6 @@ add_coin_purse_decision (void *cls, &prefund->purse_pub), TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee", &prefund->refund_amount), - TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refund", - &prefund->refund_fee), GNUNET_PQ_result_spec_uint64 ("purse_decision_serial_id", &serial_id), GNUNET_PQ_result_spec_end @@ -455,6 +453,9 @@ add_coin_purse_decision (void *cls, } tl = GNUNET_new (struct TALER_EXCHANGEDB_TransactionList); tl->next = chc->head; + GNUNET_assert (GNUNET_OK == + TALER_amount_set_zero (prefund->refund_amount.currency, + &prefund->refund_fee)); tl->type = TALER_EXCHANGEDB_TT_PURSE_REFUND; tl->details.purse_refund = prefund; tl->serial_id = serial_id; @@ -1024,15 +1025,10 @@ TALER_EXCHANGEDB_get_coin_transactions ( "SELECT" " pdes.purse_pub" ",pd.amount_with_fee" - ",denom.fee_refund" ",pdes.purse_decision_serial_id" " FROM purse_decision pdes" " JOIN purse_deposits pd" " USING (purse_pub)" - " JOIN known_coins kc" - " ON (pd.coin_pub = kc.coin_pub)" - " JOIN denominations denom" - " USING (denominations_serial)" " WHERE pd.coin_pub=$1" " AND pdes.purse_decision_serial_id=$2" " AND pdes.refunded;"); diff --git a/src/include/exchange-database/free_coin_transaction_list.h b/src/include/exchange-database/free_coin_transaction_list.h @@ -511,13 +511,12 @@ struct TALER_EXCHANGEDB_PurseRefundListEntry struct TALER_PurseContractPublicKeyP purse_pub; /** - * Fraction of the original deposit's value to be refunded, including - * refund fee (if any). The coin is identified by @e coin_pub. + * Full value restored to the coin, including the original deposit fee. */ struct TALER_Amount refund_amount; /** - * Refund fee to be covered by the customer. + * Always zero in the currency of the coin. */ struct TALER_Amount refund_fee; diff --git a/src/include/taler/taler_crypto_lib.h b/src/include/taler/taler_crypto_lib.h @@ -5572,8 +5572,8 @@ TALER_exchange_online_melt_confirmation_verify ( * Create exchange purse refund confirmation signature. * * @param scb function to call to create the signature - * @param amount_without_fee refunded amount - * @param refund_fee refund fee charged + * @param refunded_amount refunded amount + * @param refund_fee zero in the coin currency * @param coin_pub coin that was refunded * @param purse_pub public key of the expired purse * @param[out] pub where to write the public key @@ -5583,7 +5583,7 @@ TALER_exchange_online_melt_confirmation_verify ( enum TALER_ErrorCode TALER_exchange_online_purse_refund_sign ( TALER_ExchangeSignCallback scb, - const struct TALER_Amount *amount_without_fee, + const struct TALER_Amount *refunded_amount, const struct TALER_Amount *refund_fee, const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_PurseContractPublicKeyP *purse_pub, @@ -5595,8 +5595,8 @@ TALER_exchange_online_purse_refund_sign ( * Verify signature of exchange affirming purse refund * from purse expiration. * - * @param amount_without_fee refunded amount - * @param refund_fee refund fee charged + * @param refunded_amount refunded amount + * @param refund_fee fee field from the signed history entry * @param coin_pub coin that was refunded * @param purse_pub public key of the expired purse * @param pub public key to verify signature against @@ -5605,7 +5605,7 @@ TALER_exchange_online_purse_refund_sign ( */ enum GNUNET_GenericReturnValue TALER_exchange_online_purse_refund_verify ( - const struct TALER_Amount *amount_without_fee, + const struct TALER_Amount *refunded_amount, const struct TALER_Amount *refund_fee, const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_PurseContractPublicKeyP *purse_pub, diff --git a/src/util/exchange_signatures.c b/src/util/exchange_signatures.c @@ -1710,12 +1710,12 @@ struct TALER_CoinPurseRefundConfirmationPS struct TALER_CoinSpendPublicKeyP coin_pub; /** - * How much will be refunded to the purse. + * Amount restored to the coin (net amount in legacy confirmations). */ struct TALER_AmountNBO refunded_amount; /** - * How much was the refund fee. + * Zero in new confirmations. Legacy exchanges signed the denomination refund fee. */ struct TALER_AmountNBO refund_fee; @@ -1727,7 +1727,7 @@ GNUNET_NETWORK_STRUCT_END enum TALER_ErrorCode TALER_exchange_online_purse_refund_sign ( TALER_ExchangeSignCallback scb, - const struct TALER_Amount *amount_without_fee, + const struct TALER_Amount *refunded_amount, const struct TALER_Amount *refund_fee, const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_PurseContractPublicKeyP *purse_pub, @@ -1742,7 +1742,7 @@ TALER_exchange_online_purse_refund_sign ( }; TALER_amount_hton (&dc.refunded_amount, - amount_without_fee); + refunded_amount); TALER_amount_hton (&dc.refund_fee, refund_fee); return scb (&dc.purpose, @@ -1753,7 +1753,7 @@ TALER_exchange_online_purse_refund_sign ( enum GNUNET_GenericReturnValue TALER_exchange_online_purse_refund_verify ( - const struct TALER_Amount *amount_without_fee, + const struct TALER_Amount *refunded_amount, const struct TALER_Amount *refund_fee, const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_PurseContractPublicKeyP *purse_pub, @@ -1768,7 +1768,7 @@ TALER_exchange_online_purse_refund_verify ( }; TALER_amount_hton (&dc.refunded_amount, - amount_without_fee); + refunded_amount); TALER_amount_hton (&dc.refund_fee, refund_fee); return GNUNET_CRYPTO_eddsa_verify (