exchange

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

commit 5d6b4317d8f87874a098b8e5e1c513e68d7b40f3
parent 872de5769e6f699b59e438d9b04032580a1f3c99
Author: Christian Grothoff <grothoff@gnunet.org>
Date:   Mon, 17 Aug 2026 16:57:23 +0200

amount is not present in open/close reserve operations

Diffstat:
Msrc/lib/exchange_api_get-reserves-RESERVE_PUB-history.c | 37++++++++++++++++++++++++++++++-------
1 file changed, 30 insertions(+), 7 deletions(-)

diff --git a/src/lib/exchange_api_get-reserves-RESERVE_PUB-history.c b/src/lib/exchange_api_get-reserves-RESERVE_PUB-history.c @@ -701,9 +701,12 @@ parse_open (struct TALER_EXCHANGE_ReserveHistoryEntry *rh, GNUNET_break_op (0); return GNUNET_SYSERR; } + /* the entry has no "amount" of its own; the amount debited from + the reserve is the reserve payment for the open request */ + rh->amount = rh->details.open_request.reserve_payment; if (GNUNET_OK != TALER_wallet_reserve_open_verify ( - &rh->amount, + &rh->details.open_request.reserve_payment, rh->details.open_request.request_timestamp, rh->details.open_request.reserve_expiration, rh->details.open_request.purse_limit, @@ -716,7 +719,7 @@ parse_open (struct TALER_EXCHANGE_ReserveHistoryEntry *rh, if (0 > TALER_amount_add (uc->total_out, uc->total_out, - &rh->amount)) + &rh->details.open_request.reserve_payment)) { /* overflow in history already!? inconceivable! Bad exchange! */ GNUNET_break_op (0); @@ -876,11 +879,15 @@ parse_reserve_history ( struct TALER_EXCHANGE_ReserveHistoryEntry *rh = &rhistory[off]; json_t *transaction; const char *type; + bool no_amount = false; struct GNUNET_JSON_Specification hist_spec[] = { GNUNET_JSON_spec_string ("type", &type), - TALER_JSON_spec_amount_any ("amount", - &rh->amount), + /* 'OPEN' and 'CLOSE' entries have no 'amount'! */ + GNUNET_JSON_spec_mark_optional ( + TALER_JSON_spec_amount_any ("amount", + &rh->amount), + &no_amount), GNUNET_JSON_spec_uint64 ("history_offset", &rh->history_offset), /* 'wire' and 'signature' are optional depending on 'type'! */ @@ -904,9 +911,25 @@ parse_reserve_history ( GNUNET_free (uuid); return GNUNET_SYSERR; } - if (GNUNET_YES != - TALER_amount_cmp_currency (&rh->amount, - total_in)) + if (no_amount) + { + /* only 'OPEN' and 'CLOSE' entries may omit the amount */ + if ( (0 != strcasecmp ("OPEN", + type)) && + (0 != strcasecmp ("CLOSE", + type)) ) + { + GNUNET_break_op (0); + GNUNET_free (uuid); + return GNUNET_SYSERR; + } + memset (&rh->amount, + 0, + sizeof (rh->amount)); + } + else if (GNUNET_YES != + TALER_amount_cmp_currency (&rh->amount, + total_in)) { GNUNET_break_op (0); GNUNET_free (uuid);