summaryrefslogtreecommitdiff
path: root/src/exchange-lib
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
parent9fb17b3ca7b9360c1c32d45b180591a3220f9758 (diff)
parent17c8741e2049cde4099af3d1d132da3b48e427c5 (diff)
downloadexchange-029911c757b4557064608ac0e3f27ad7f7a4b82f.tar.gz
exchange-029911c757b4557064608ac0e3f27ad7f7a4b82f.tar.bz2
exchange-029911c757b4557064608ac0e3f27ad7f7a4b82f.zip
Merge branch 'master' of git+ssh://git.taler.net/var/git/exchange
Diffstat (limited to 'src/exchange-lib')
-rw-r--r--src/exchange-lib/exchange_api_refresh.c35
-rw-r--r--src/exchange-lib/exchange_api_refund.c3
-rw-r--r--src/exchange-lib/test_exchange_api.conf2
3 files changed, 38 insertions, 2 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++)
diff --git a/src/exchange-lib/exchange_api_refund.c b/src/exchange-lib/exchange_api_refund.c
index fff03acf9..26b960703 100644
--- a/src/exchange-lib/exchange_api_refund.c
+++ b/src/exchange-lib/exchange_api_refund.c
@@ -283,7 +283,8 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange,
"merchant_pub", GNUNET_JSON_from_data_auto (&rr.merchant),
"merchant_sig", GNUNET_JSON_from_data_auto (&merchant_sig)
);
-
+ GNUNET_assert (NULL != refund_obj);
+
rh = GNUNET_new (struct TALER_EXCHANGE_RefundHandle);
rh->exchange = exchange;
rh->cb = cb;
diff --git a/src/exchange-lib/test_exchange_api.conf b/src/exchange-lib/test_exchange_api.conf
index a8c690786..03dd6f992 100644
--- a/src/exchange-lib/test_exchange_api.conf
+++ b/src/exchange-lib/test_exchange_api.conf
@@ -43,7 +43,7 @@ TEST_RESPONSE_FILE = ${TALER_CONFIG_HOME}/test.json
[exchange-wire-outgoing-test]
# What is the main website of the bank?
BANK_URI = "http://localhost:8082/"
-# Into which account at the 'bank' should (incoming) wire transfers be made?
+# From which account at the 'bank' should outgoing wire transfers be made?
BANK_ACCOUNT_NUMBER = 2
[coin_eur_ct_1]