diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-01-29 19:01:29 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-01-29 19:01:29 +0100 |
commit | 8ca555500f01ebb2f7286961588b81b4ee5ac4fe (patch) | |
tree | 8dafde6e87d5f89576350cb28ce19eb99245ff9a /src/mint/taler-mint-httpd_refresh.c | |
parent | 2b663f33c0b939ad463c71ffb52a95ec9325f011 (diff) |
more notes about issues in bug tracker
Diffstat (limited to 'src/mint/taler-mint-httpd_refresh.c')
-rw-r--r-- | src/mint/taler-mint-httpd_refresh.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/mint/taler-mint-httpd_refresh.c b/src/mint/taler-mint-httpd_refresh.c index 8bc8e7783..e7497327b 100644 --- a/src/mint/taler-mint-httpd_refresh.c +++ b/src/mint/taler-mint-httpd_refresh.c @@ -167,6 +167,12 @@ handle_refresh_melt_binary (struct MHD_Connection *connection, struct RefreshMeltSignatureBody body; char *buf; size_t buf_size; + struct MintKeyState *key_state; + struct TALER_MINT_DenomKeyIssue *dki; + struct TALER_Amount cost; + struct TALER_Amount total_cost; + struct TALER_Amount melt; + struct TALER_Amount total_melt; /* check that signature from the session public key is ok */ hash_context = GNUNET_CRYPTO_hash_context_start (); @@ -197,6 +203,45 @@ handle_refresh_melt_binary (struct MHD_Connection *connection, &body.purpose))) return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; + // FIXME: badness, use proper way to set to zero... + key_state = TALER_MINT_key_state_acquire (); + memset (&total_cost, 0, sizeof (struct TALER_Amount)); + for (i=0;i<num_new_denoms;i++) + { + dki = &TALER_MINT_get_denom_key (key_state, + denom_pubs[i])->issue; + cost = TALER_amount_add (TALER_amount_ntoh (dki->value), + TALER_amount_ntoh (dki->fee_withdraw)); + // FIXME: #3637 + total_cost = TALER_amount_add (cost, + total_cost); + } + + // FIXME: badness, use proper way to set to zero... + memset (&total_melt, 0, sizeof (struct TALER_Amount)); + for (i=0;i<coin_count;i++) + { + memset (&melt, 0, sizeof (struct TALER_Amount)); + // FIXME: reduce coin value by melting fee! + // melt = coin_values[i]; // FIXME: #3636! + + // FIXME: #3637 + total_melt = TALER_amount_add (melt, + total_melt); + } + TALER_MINT_key_state_release (key_state); + if (0 != + TALER_amount_cmp (total_cost, + total_melt) ) + { + /* We require total value of coins being melted and + total value of coins being generated to match! */ + return TALER_MINT_reply_json_pack (connection, + MHD_HTTP_BAD_REQUEST, + "{s:s}", + "error", "value mismatch"); + } + return TALER_MINT_db_execute_refresh_melt (connection, refresh_session_pub, num_new_denoms, |