aboutsummaryrefslogtreecommitdiff
path: root/src/exchange-lib/exchange_api_refresh.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-06-20 10:19:58 +0200
committerChristian Grothoff <christian@grothoff.org>2016-06-20 10:19:58 +0200
commit029911c757b4557064608ac0e3f27ad7f7a4b82f (patch)
tree2c5aea0df74ba33939a8b6832bcb8c9524018f1b /src/exchange-lib/exchange_api_refresh.c
parent9fb17b3ca7b9360c1c32d45b180591a3220f9758 (diff)
parent17c8741e2049cde4099af3d1d132da3b48e427c5 (diff)
downloadexchange-029911c757b4557064608ac0e3f27ad7f7a4b82f.tar.xz
Merge branch 'master' of git+ssh://git.taler.net/var/git/exchange
Diffstat (limited to 'src/exchange-lib/exchange_api_refresh.c')
-rw-r--r--src/exchange-lib/exchange_api_refresh.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/exchange-lib/exchange_api_refresh.c b/src/exchange-lib/exchange_api_refresh.c
index 9a9c6b7eb..e32f73e21 100644
--- a/src/exchange-lib/exchange_api_refresh.c
+++ b/src/exchange-lib/exchange_api_refresh.c
@@ -764,6 +764,7 @@ TALER_EXCHANGE_refresh_prepare (const struct TALER_CoinSpendPrivateKeyP *melt_pr
unsigned int i;
unsigned int j;
struct GNUNET_HashContext *hash_context;
+ struct TALER_Amount total;
/* build up melt data structure */
for (i=0;i<TALER_CNC_KAPPA;i++)
@@ -799,10 +800,44 @@ TALER_EXCHANGE_refresh_prepare (const struct TALER_CoinSpendPrivateKeyP *melt_pr
md.fresh_coins[i] = GNUNET_new_array (fresh_pks_len,
struct FreshCoinP);
for (j=0;j<fresh_pks_len;j++)
+ {
setup_fresh_coin (&md.fresh_coins[i][j],
&fresh_pks[j]);
+ }
}
+ /* verify that melt_amount is above total cost */
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_get_zero (melt_amount->currency,
+ &total));
+ for (j=0;j<fresh_pks_len;j++)
+ {
+ if ( (GNUNET_OK !=
+ TALER_amount_add (&total,
+ &total,
+ &fresh_pks[j].value)) ||
+ (GNUNET_OK !=
+ TALER_amount_add (&total,
+ &total,
+ &fresh_pks[j].fee_withdraw)) )
+ {
+ GNUNET_break (0);
+ free_melt_data (&md);
+ return NULL;
+ }
+ }
+ if (1 ==
+ TALER_amount_cmp (&total,
+ melt_amount) )
+ {
+ /* Eh, this operation is more expensive than the
+ @a melt_amount. This is not OK. */
+ GNUNET_break (0);
+ free_melt_data (&md);
+ return NULL;
+ }
+
+
/* now compute melt session hash */
hash_context = GNUNET_CRYPTO_hash_context_start ();
for (i=0;i<fresh_pks_len;i++)