summaryrefslogtreecommitdiff
path: root/src/lib/exchange_api_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/exchange_api_common.c')
-rw-r--r--src/lib/exchange_api_common.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c
index 160f62dc6..c9bff71f1 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<history_length; off++)
{
- struct TALER_EXCHANGE_ReserveHistory *rh = &rhistory[off];
+ struct TALER_EXCHANGE_ReserveHistoryEntry *rh = &rhistory[off];
json_t *transaction;
struct TALER_Amount amount;
const char *type;
@@ -368,14 +368,20 @@ TALER_EXCHANGE_parse_reserve_history (
}
/* check balance = total_in - total_out < withdraw-amount */
- if (0 >
- 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<len; i++)