From 427417b8352c2036dc6f5c0ca6bd20c0b7edd225 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 20 Mar 2022 13:20:45 +0100 Subject: towards support for new reserve history/status APIs --- src/lib/exchange_api_common.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src/lib/exchange_api_common.c') diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c index 160f62dc..c9bff71f 100644 --- a/src/lib/exchange_api_common.c +++ b/src/lib/exchange_api_common.c @@ -34,7 +34,7 @@ TALER_EXCHANGE_parse_reserve_history ( const char *currency, struct TALER_Amount *balance, unsigned int history_length, - struct TALER_EXCHANGE_ReserveHistory *rhistory) + struct TALER_EXCHANGE_ReserveHistoryEntry *rhistory) { struct GNUNET_HashCode uuid[history_length]; unsigned int uuid_off; @@ -50,7 +50,7 @@ TALER_EXCHANGE_parse_reserve_history ( uuid_off = 0; for (unsigned int off = 0; off - TALER_amount_subtract (balance, - &total_in, - &total_out)) + if (NULL != balance) { - /* total_in < total_out, why did the exchange ever allow this!? */ - GNUNET_break_op (0); - return GNUNET_SYSERR; + /* if balance is NULL, we may have a partial history + in which case the subtraction may fail, so we do + not even check that invariant in this case. */ + if (0 > + TALER_amount_subtract (balance, + &total_in, + &total_out)) + { + /* total_in < total_out, why did the exchange ever allow this!? */ + GNUNET_break_op (0); + return GNUNET_SYSERR; + } } return GNUNET_OK; } @@ -383,7 +389,7 @@ TALER_EXCHANGE_parse_reserve_history ( void TALER_EXCHANGE_free_reserve_history ( - struct TALER_EXCHANGE_ReserveHistory *rhistory, + struct TALER_EXCHANGE_ReserveHistoryEntry *rhistory, unsigned int len) { for (unsigned int i = 0; i