From 30959d1380ed79d71baee10ec547027b4911c760 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 9 Aug 2015 18:42:38 +0200 Subject: fix array dimensions to match server expecations, fix server to report location of parse errors more precisely --- src/mint/taler-mint-httpd_refresh.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/mint/taler-mint-httpd_refresh.c') diff --git a/src/mint/taler-mint-httpd_refresh.c b/src/mint/taler-mint-httpd_refresh.c index 687fb998..d870f3a3 100644 --- a/src/mint/taler-mint-httpd_refresh.c +++ b/src/mint/taler-mint-httpd_refresh.c @@ -700,6 +700,7 @@ TMH_REFRESH_handler_refresh_melt (struct TMH_RequestHandler *rh, JSON_ARRAY, &coin_detail); if (GNUNET_OK != res) { + GNUNET_break_op (0); TMH_PARSE_release_data (spec); return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; } @@ -711,6 +712,7 @@ TMH_REFRESH_handler_refresh_melt (struct TMH_RequestHandler *rh, JSON_ARRAY, &coin_detail); if (GNUNET_OK != res) { + GNUNET_break_op (0); TMH_PARSE_release_data (spec); return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; } -- cgit v1.2.3 From c489c391a8ad27b7fe55246b4a39f33944822846 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 9 Aug 2015 18:49:50 +0200 Subject: use correct TMH command code for JSON objects --- src/mint/taler-mint-httpd_refresh.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/mint/taler-mint-httpd_refresh.c') diff --git a/src/mint/taler-mint-httpd_refresh.c b/src/mint/taler-mint-httpd_refresh.c index d870f3a3..0a1ad2a0 100644 --- a/src/mint/taler-mint-httpd_refresh.c +++ b/src/mint/taler-mint-httpd_refresh.c @@ -694,9 +694,10 @@ TMH_REFRESH_handler_refresh_melt (struct TMH_RequestHandler *rh, return TMH_RESPONSE_reply_arg_invalid (connection, "transfer_pubs"); } - res = TMH_PARSE_navigate_json (connection, coin_evs, + res = TMH_PARSE_navigate_json (connection, + coin_evs, TMH_PARSE_JNC_INDEX, (int) 0, - TMH_PARSE_JNC_RET_DATA, + TMH_PARSE_JNC_RET_TYPED_JSON, JSON_ARRAY, &coin_detail); if (GNUNET_OK != res) { @@ -708,7 +709,7 @@ TMH_REFRESH_handler_refresh_melt (struct TMH_RequestHandler *rh, res = TMH_PARSE_navigate_json (connection, transfer_pubs, TMH_PARSE_JNC_INDEX, (int) 0, - TMH_PARSE_JNC_RET_DATA, + TMH_PARSE_JNC_RET_TYPED_JSON, JSON_ARRAY, &coin_detail); if (GNUNET_OK != res) { -- cgit v1.2.3 From 6453b72ef971bcd0697e5b6d2c4cc89ed4f41a90 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 9 Aug 2015 19:00:48 +0200 Subject: -some cosmetics --- src/mint-lib/test_mint_api.c | 5 ++++- src/mint/taler-mint-httpd_refresh.c | 7 +++---- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src/mint/taler-mint-httpd_refresh.c') diff --git a/src/mint-lib/test_mint_api.c b/src/mint-lib/test_mint_api.c index cc500987..fcc5db10 100644 --- a/src/mint-lib/test_mint_api.c +++ b/src/mint-lib/test_mint_api.c @@ -1932,6 +1932,10 @@ run (void *cls, .details.deposit.transaction_id = 42421 }, /* Melt the rest of the coin's value (EUR:4.00 = 3x EUR:1.03 + 7x EUR:0.13) */ + +#if TEST_REFRESH + + { .oc = OC_REFRESH_MELT, .label = "refresh-melt-1", .expected_response_code = MHD_HTTP_OK, @@ -1944,7 +1948,6 @@ run (void *cls, .expected_response_code = MHD_HTTP_OK, .details.refresh_reveal.melt_ref = "refresh-melt-1" }, -#if TEST_REFRESH_LINK /* Test that /refresh/link works */ { .oc = OC_REFRESH_LINK, diff --git a/src/mint/taler-mint-httpd_refresh.c b/src/mint/taler-mint-httpd_refresh.c index 0a1ad2a0..f952bec7 100644 --- a/src/mint/taler-mint-httpd_refresh.c +++ b/src/mint/taler-mint-httpd_refresh.c @@ -209,7 +209,7 @@ get_coin_public_info (struct MHD_Connection *connection, /** * Verify that the signature shows that this coin is to be melted into - * the given @a session_pub melting session, and that this is a valid + * the given @a session_hash melting session, and that this is a valid * coin (we know the denomination key and the signature on it is * valid). Essentially, this does all of the per-coin checks that can * be done before the transaction starts. @@ -361,7 +361,6 @@ handle_refresh_melt_json (struct MHD_Connection *connection, unsigned int num_newcoins, const json_t *coin_evs, const json_t *link_encs) - { int res; unsigned int i; @@ -407,8 +406,8 @@ handle_refresh_melt_json (struct MHD_Connection *connection, } coin_count = json_array_size (melt_coins); - coin_melt_details = GNUNET_malloc (coin_count * - sizeof (struct TMH_DB_MeltDetails)); + coin_melt_details = GNUNET_new_array (coin_count, + struct TMH_DB_MeltDetails); for (i=0;i Date: Sun, 9 Aug 2015 19:22:18 +0200 Subject: fix use-after-free, add log statements to report request parsing error lines more clearly --- src/mint/taler-mint-httpd_refresh.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/mint/taler-mint-httpd_refresh.c') diff --git a/src/mint/taler-mint-httpd_refresh.c b/src/mint/taler-mint-httpd_refresh.c index f952bec7..c6b79c47 100644 --- a/src/mint/taler-mint-httpd_refresh.c +++ b/src/mint/taler-mint-httpd_refresh.c @@ -185,13 +185,17 @@ get_coin_public_info (struct MHD_Connection *connection, coin_info, spec); if (GNUNET_OK != ret) + { + GNUNET_break_op (0); return ret; + } /* check mint signature on the coin */ r_melt_detail->coin_info.denom_sig = sig; r_melt_detail->coin_info.denom_pub = pk; if (GNUNET_OK != TALER_test_coin_valid (&r_melt_detail->coin_info)) { + GNUNET_break_op (0); TMH_PARSE_release_data (spec); r_melt_detail->coin_info.denom_sig.rsa_signature = NULL; r_melt_detail->coin_info.denom_pub.rsa_public_key = NULL; @@ -202,7 +206,6 @@ get_coin_public_info (struct MHD_Connection *connection, } r_melt_detail->melt_sig = melt_sig; r_melt_detail->melt_amount_with_fee = amount; - TMH_PARSE_release_data (spec); return GNUNET_OK; } @@ -257,6 +260,7 @@ verify_coin_public_info (struct MHD_Connection *connection, if (TALER_amount_cmp (&fee_refresh, &melt_detail->melt_amount_with_fee) < 0) { + GNUNET_break_op (0); TMH_KS_release (key_state); return (MHD_YES == TMH_RESPONSE_reply_external_error (connection, @@ -271,6 +275,7 @@ verify_coin_public_info (struct MHD_Connection *connection, &melt_detail->melt_sig.eddsa_signature, &melt_detail->coin_info.coin_pub.eddsa_pub)) { + GNUNET_break_op (0); if (MHD_YES != TMH_RESPONSE_reply_signature_invalid (connection, "confirm_sig")) @@ -418,6 +423,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection, &coin_melt_details[i]); if (GNUNET_OK != res) { + GNUNET_break_op (0); for (j=0;j Date: Sun, 9 Aug 2015 19:31:35 +0200 Subject: fix direction of cmp check, log session hash for diagnostics --- src/mint/taler-mint-httpd_refresh.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/mint/taler-mint-httpd_refresh.c') diff --git a/src/mint/taler-mint-httpd_refresh.c b/src/mint/taler-mint-httpd_refresh.c index c6b79c47..eb205ed1 100644 --- a/src/mint/taler-mint-httpd_refresh.c +++ b/src/mint/taler-mint-httpd_refresh.c @@ -252,13 +252,17 @@ verify_coin_public_info (struct MHD_Connection *connection, body.purpose.size = htonl (sizeof (struct TALER_RefreshMeltCoinAffirmationPS)); body.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT); body.session_hash = *session_hash; + fprintf (stderr, + "Verifying hash %s\n", + GNUNET_h2s (session_hash)); + TALER_amount_hton (&body.amount_with_fee, &melt_detail->melt_amount_with_fee); TALER_amount_hton (&body.melt_fee, &fee_refresh); body.coin_pub = melt_detail->coin_info.coin_pub; if (TALER_amount_cmp (&fee_refresh, - &melt_detail->melt_amount_with_fee) < 0) + &melt_detail->melt_amount_with_fee) > 0) { GNUNET_break_op (0); TMH_KS_release (key_state); -- cgit v1.2.3 From 3ead9d772a6850a7654e7e483ebfce5acac8da86 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 9 Aug 2015 21:25:02 +0200 Subject: move struct TALER_MINTDB_RefreshCommitLinkP to taler_signatures.h --- src/include/taler_mintdb_plugin.h | 27 --------------------------- src/include/taler_signatures.h | 25 +++++++++++++++++++++++++ src/mint-lib/test_mint_api.c | 5 ++--- src/mint/taler-mint-httpd_refresh.c | 3 --- 4 files changed, 27 insertions(+), 33 deletions(-) (limited to 'src/mint/taler-mint-httpd_refresh.c') diff --git a/src/include/taler_mintdb_plugin.h b/src/include/taler_mintdb_plugin.h index a7a73574..ba83c814 100644 --- a/src/include/taler_mintdb_plugin.h +++ b/src/include/taler_mintdb_plugin.h @@ -388,33 +388,6 @@ struct TALER_MINTDB_RefreshCommitCoin }; -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * @brief For each (old) coin being melted, we have a `struct - * RefreshCommitLinkP` that allows the user to find the shared secret - * to decrypt the respective refresh links for the new coins in the - * `struct TALER_MINTDB_RefreshCommitCoin`. - */ -struct TALER_MINTDB_RefreshCommitLinkP -{ - /** - * Transfer public key, used to decrypt the @e shared_secret_enc - * in combintation with the corresponding private key of the - * coin. - */ - struct TALER_TransferPublicKeyP transfer_pub; - - /** - * Encrypted shared secret to decrypt the link. - */ - struct TALER_EncryptedLinkSecretP shared_secret_enc; -}; - -GNUNET_NETWORK_STRUCT_END - - - /** * @brief Linked list of refresh information linked to a coin. */ diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h index 402e67fe..0b05bace 100644 --- a/src/include/taler_signatures.h +++ b/src/include/taler_signatures.h @@ -648,6 +648,31 @@ struct TALER_MintKeyValidityPS }; +/** + * @brief For each (old) coin being melted, we have a `struct + * RefreshCommitLinkP` that allows the user to find the shared secret + * to decrypt the respective refresh links for the new coins in the + * `struct TALER_MINTDB_RefreshCommitCoin`. + * + * Part of the construction of the refresh session's hash and + * thus of what is signed there. + */ +struct TALER_MINTDB_RefreshCommitLinkP +{ + /** + * Transfer public key, used to decrypt the @e shared_secret_enc + * in combintation with the corresponding private key of the + * coin. + */ + struct TALER_TransferPublicKeyP transfer_pub; + + /** + * Encrypted shared secret to decrypt the link. + */ + struct TALER_EncryptedLinkSecretP shared_secret_enc; +}; + + GNUNET_NETWORK_STRUCT_END #endif diff --git a/src/mint-lib/test_mint_api.c b/src/mint-lib/test_mint_api.c index fcc5db10..bae96dfb 100644 --- a/src/mint-lib/test_mint_api.c +++ b/src/mint-lib/test_mint_api.c @@ -1933,15 +1933,14 @@ run (void *cls, /* Melt the rest of the coin's value (EUR:4.00 = 3x EUR:1.03 + 7x EUR:0.13) */ -#if TEST_REFRESH - - { .oc = OC_REFRESH_MELT, .label = "refresh-melt-1", .expected_response_code = MHD_HTTP_OK, .details.refresh_melt.melted_coins = melt_coins_1, .details.refresh_melt.fresh_amounts = melt_fresh_amounts_1 }, +#if TEST_REFRESH + /* Complete (successful) melt operation, and withdraw the coins */ { .oc = OC_REFRESH_REVEAL, .label = "refresh-reveal-1", diff --git a/src/mint/taler-mint-httpd_refresh.c b/src/mint/taler-mint-httpd_refresh.c index eb205ed1..7bcaa799 100644 --- a/src/mint/taler-mint-httpd_refresh.c +++ b/src/mint/taler-mint-httpd_refresh.c @@ -252,9 +252,6 @@ verify_coin_public_info (struct MHD_Connection *connection, body.purpose.size = htonl (sizeof (struct TALER_RefreshMeltCoinAffirmationPS)); body.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT); body.session_hash = *session_hash; - fprintf (stderr, - "Verifying hash %s\n", - GNUNET_h2s (session_hash)); TALER_amount_hton (&body.amount_with_fee, &melt_detail->melt_amount_with_fee); -- cgit v1.2.3 From 6237981d9652889bbcc042e8b374c0addc65932f Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 9 Aug 2015 21:25:49 +0200 Subject: rename struct TALER_MINTDB_RefreshCommitLinkP to struct TALER_RefreshCommitLinkP --- src/include/taler_mintdb_plugin.h | 6 +++--- src/include/taler_signatures.h | 2 +- src/mint-lib/mint_api_refresh.c | 4 ++-- src/mint/taler-mint-httpd_db.c | 6 +++--- src/mint/taler-mint-httpd_db.h | 2 +- src/mint/taler-mint-httpd_refresh.c | 12 ++++++------ src/mint/taler-mint-httpd_responses.c | 2 +- src/mintdb/plugin_mintdb_postgres.c | 6 +++--- 8 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src/mint/taler-mint-httpd_refresh.c') diff --git a/src/include/taler_mintdb_plugin.h b/src/include/taler_mintdb_plugin.h index ba83c814..c5b9828d 100644 --- a/src/include/taler_mintdb_plugin.h +++ b/src/include/taler_mintdb_plugin.h @@ -539,7 +539,7 @@ struct TALER_MINTDB_MeltCommitment /** * 2D-Array of #TALER_CNC_KAPPA and @e new_oldcoins links. */ - struct TALER_MINTDB_RefreshCommitLinkP *commit_links[TALER_CNC_KAPPA]; + struct TALER_RefreshCommitLinkP *commit_links[TALER_CNC_KAPPA]; }; @@ -1002,7 +1002,7 @@ struct TALER_MINTDB_Plugin const struct GNUNET_HashCode *session_hash, uint16_t cnc_index, uint16_t num_links, - const struct TALER_MINTDB_RefreshCommitLinkP *commit_links); + const struct TALER_RefreshCommitLinkP *commit_links); /** * Obtain the commited (encrypted) refresh link data @@ -1024,7 +1024,7 @@ struct TALER_MINTDB_Plugin const struct GNUNET_HashCode *session_hash, uint16_t cnc_index, uint16_t num_links, - struct TALER_MINTDB_RefreshCommitLinkP *links); + struct TALER_RefreshCommitLinkP *links); /** diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h index 0b05bace..c5348eb5 100644 --- a/src/include/taler_signatures.h +++ b/src/include/taler_signatures.h @@ -657,7 +657,7 @@ struct TALER_MintKeyValidityPS * Part of the construction of the refresh session's hash and * thus of what is signed there. */ -struct TALER_MINTDB_RefreshCommitLinkP +struct TALER_RefreshCommitLinkP { /** * Transfer public key, used to decrypt the @e shared_secret_enc diff --git a/src/mint-lib/mint_api_refresh.c b/src/mint-lib/mint_api_refresh.c index 796eb23f..66e8ea83 100644 --- a/src/mint-lib/mint_api_refresh.c +++ b/src/mint-lib/mint_api_refresh.c @@ -990,7 +990,7 @@ TALER_MINT_refresh_prepare (unsigned int num_melts, { for (j = 0; j < num_melts; j++) { - struct TALER_MINTDB_RefreshCommitLinkP rcl; + struct TALER_RefreshCommitLinkP rcl; struct TALER_TransferSecretP trans_sec; GNUNET_CRYPTO_ecdhe_key_get_public (&md.melted_coins[j].transfer_priv[i].ecdhe_priv, @@ -1003,7 +1003,7 @@ TALER_MINT_refresh_prepare (unsigned int num_melts, &rcl.shared_secret_enc); GNUNET_CRYPTO_hash_context_read (hash_context, &rcl, - sizeof (struct TALER_MINTDB_RefreshCommitLinkP)); + sizeof (struct TALER_RefreshCommitLinkP)); } } diff --git a/src/mint/taler-mint-httpd_db.c b/src/mint/taler-mint-httpd_db.c index 4e91e7e7..e24102ea 100644 --- a/src/mint/taler-mint-httpd_db.c +++ b/src/mint/taler-mint-httpd_db.c @@ -623,7 +623,7 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection, unsigned int coin_count, const struct TMH_DB_MeltDetails *coin_melt_details, struct TALER_MINTDB_RefreshCommitCoin *const* commit_coin, - struct TALER_MINTDB_RefreshCommitLinkP *const* commit_link) + struct TALER_RefreshCommitLinkP *const* commit_link) { struct TMH_KS_StateHandle *key_state; struct TALER_MINTDB_RefreshSession refresh_session; @@ -839,11 +839,11 @@ check_commitment (struct MHD_Connection *connection, unsigned int j; struct TALER_LinkSecretP last_shared_secret; int secret_initialized = GNUNET_NO; - struct TALER_MINTDB_RefreshCommitLinkP *commit_links; + struct TALER_RefreshCommitLinkP *commit_links; struct TALER_MINTDB_RefreshCommitCoin *commit_coins; commit_links = GNUNET_malloc (num_oldcoins * - sizeof (struct TALER_MINTDB_RefreshCommitLinkP)); + sizeof (struct TALER_RefreshCommitLinkP)); if (GNUNET_OK != TMH_plugin->get_refresh_commit_links (TMH_plugin->cls, session, diff --git a/src/mint/taler-mint-httpd_db.h b/src/mint/taler-mint-httpd_db.h index 8a171153..c2f9a310 100644 --- a/src/mint/taler-mint-httpd_db.h +++ b/src/mint/taler-mint-httpd_db.h @@ -130,7 +130,7 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection, unsigned int coin_count, const struct TMH_DB_MeltDetails *coin_melt_details, struct TALER_MINTDB_RefreshCommitCoin *const* commit_coin, - struct TALER_MINTDB_RefreshCommitLinkP *const* commit_link); + struct TALER_RefreshCommitLinkP *const* commit_link); /** diff --git a/src/mint/taler-mint-httpd_refresh.c b/src/mint/taler-mint-httpd_refresh.c index 7bcaa799..954d8daf 100644 --- a/src/mint/taler-mint-httpd_refresh.c +++ b/src/mint/taler-mint-httpd_refresh.c @@ -57,7 +57,7 @@ handle_refresh_melt_binary (struct MHD_Connection *connection, const struct TMH_DB_MeltDetails *coin_melt_details, const struct GNUNET_HashCode *session_hash, struct TALER_MINTDB_RefreshCommitCoin *const* commit_coin, - struct TALER_MINTDB_RefreshCommitLinkP *const* commit_link) + struct TALER_RefreshCommitLinkP *const* commit_link) { unsigned int i; struct TMH_KS_StateHandle *key_state; @@ -324,7 +324,7 @@ free_commit_coins (struct TALER_MINTDB_RefreshCommitCoin **commit_coin, * @param num_old_coins size of 2nd dimension */ static void -free_commit_links (struct TALER_MINTDB_RefreshCommitLinkP **commit_link, +free_commit_links (struct TALER_RefreshCommitLinkP **commit_link, unsigned int kappa, unsigned int num_old_coins) { @@ -378,7 +378,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection, struct GNUNET_HashCode session_hash; struct GNUNET_HashContext *hash_context; struct TALER_MINTDB_RefreshCommitCoin *commit_coin[TALER_CNC_KAPPA]; - struct TALER_MINTDB_RefreshCommitLinkP *commit_link[TALER_CNC_KAPPA]; + struct TALER_RefreshCommitLinkP *commit_link[TALER_CNC_KAPPA]; /* For the signature check, we hash most of the inputs together (except for the signatures on the coins). */ @@ -532,10 +532,10 @@ handle_refresh_melt_json (struct MHD_Connection *connection, for (i = 0; i < TALER_CNC_KAPPA; i++) { commit_link[i] = GNUNET_malloc (num_oldcoins * - sizeof (struct TALER_MINTDB_RefreshCommitLinkP)); + sizeof (struct TALER_RefreshCommitLinkP)); for (j = 0; j < num_oldcoins; j++) { - struct TALER_MINTDB_RefreshCommitLinkP *rcl = &commit_link[i][j]; + struct TALER_RefreshCommitLinkP *rcl = &commit_link[i][j]; res = TMH_PARSE_navigate_json (connection, transfer_pubs, @@ -582,7 +582,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection, GNUNET_CRYPTO_hash_context_read (hash_context, rcl, - sizeof (struct TALER_MINTDB_RefreshCommitLinkP)); + sizeof (struct TALER_RefreshCommitLinkP)); } } diff --git a/src/mint/taler-mint-httpd_responses.c b/src/mint/taler-mint-httpd_responses.c index 0e2f9070..9a6813f1 100644 --- a/src/mint/taler-mint-httpd_responses.c +++ b/src/mint/taler-mint-httpd_responses.c @@ -900,7 +900,7 @@ TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection, info_link_k = json_array (); for (i=0;inum_newcoins;i++) { - const struct TALER_MINTDB_RefreshCommitLinkP *cl; + const struct TALER_RefreshCommitLinkP *cl; json_t *cl_json; cl = &mc->commit_links[k][i]; diff --git a/src/mintdb/plugin_mintdb_postgres.c b/src/mintdb/plugin_mintdb_postgres.c index 57455fcc..658d8dd9 100644 --- a/src/mintdb/plugin_mintdb_postgres.c +++ b/src/mintdb/plugin_mintdb_postgres.c @@ -2640,7 +2640,7 @@ postgres_insert_refresh_commit_links (void *cls, const struct GNUNET_HashCode *session_hash, uint16_t cnc_index, uint16_t num_links, - const struct TALER_MINTDB_RefreshCommitLinkP *links) + const struct TALER_RefreshCommitLinkP *links) { // FIXME: check logic! links is array! struct TALER_PQ_QueryParam params[] = { @@ -2693,7 +2693,7 @@ postgres_get_refresh_commit_links (void *cls, const struct GNUNET_HashCode *session_hash, uint16_t cnc_index, uint16_t num_links, - struct TALER_MINTDB_RefreshCommitLinkP *links) + struct TALER_RefreshCommitLinkP *links) { // FIXME: check logic: was written for a single link! struct TALER_PQ_QueryParam params[] = { @@ -2801,7 +2801,7 @@ postgres_get_melt_commitment (void *cls, goto cleanup; mc->commit_links[cnc_index] = GNUNET_malloc (mc->num_oldcoins * - sizeof (struct TALER_MINTDB_RefreshCommitLinkP)); + sizeof (struct TALER_RefreshCommitLinkP)); if (GNUNET_OK != postgres_get_refresh_commit_links (cls, session, -- cgit v1.2.3 From e08f479eb403cfbcb490dd0b07fd3d384136f446 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 9 Aug 2015 21:38:04 +0200 Subject: -fix testcase, more verbose logging of client protocol errors --- src/mint-lib/test_mint_api.c | 11 ++++++++++- src/mint/taler-mint-httpd_db.c | 8 ++++++-- src/mint/taler-mint-httpd_refresh.c | 4 ++++ 3 files changed, 20 insertions(+), 3 deletions(-) (limited to 'src/mint/taler-mint-httpd_refresh.c') diff --git a/src/mint-lib/test_mint_api.c b/src/mint-lib/test_mint_api.c index bae96dfb..4b1b0f22 100644 --- a/src/mint-lib/test_mint_api.c +++ b/src/mint-lib/test_mint_api.c @@ -1835,7 +1835,16 @@ run (void *cls, "EUR:0.1", "EUR:0.1", "EUR:0.1", - /* with 0.03 refresh fees each, this totals up to exactly 4 EUR */ + "EUR:0.1", + "EUR:0.01", + "EUR:0.01", + "EUR:0.01", + "EUR:0.01", + "EUR:0.01", + "EUR:0.01", + /* with 0.01 withdraw fees (except for 1ct coins), + this totals up to exactly EUR:3.97, and with + the 0.03 refresh fee, to EUR:4.0*/ NULL }; static struct Command commands[] = diff --git a/src/mint/taler-mint-httpd_db.c b/src/mint/taler-mint-httpd_db.c index e24102ea..04c2555e 100644 --- a/src/mint/taler-mint-httpd_db.c +++ b/src/mint/taler-mint-httpd_db.c @@ -550,7 +550,9 @@ refresh_accept_melts (struct MHD_Connection *connection, GNUNET_break (0); TMH_plugin->free_coin_transaction_list (TMH_plugin->cls, tl); - return TMH_RESPONSE_reply_internal_db_error (connection); + return (MHD_YES == + TMH_RESPONSE_reply_internal_db_error (connection)) + ? GNUNET_NO : GNUNET_SYSERR; } /* Refuse to refresh when the coin's value is insufficient for the cost of all transactions. */ @@ -587,7 +589,9 @@ refresh_accept_melts (struct MHD_Connection *connection, &melt)) { GNUNET_break (0); - return GNUNET_SYSERR; + return (MHD_YES == + TMH_RESPONSE_reply_internal_db_error (connection)) + ? GNUNET_NO : GNUNET_SYSERR; } return GNUNET_OK; } diff --git a/src/mint/taler-mint-httpd_refresh.c b/src/mint/taler-mint-httpd_refresh.c index 954d8daf..625fcc50 100644 --- a/src/mint/taler-mint-httpd_refresh.c +++ b/src/mint/taler-mint-httpd_refresh.c @@ -92,6 +92,7 @@ handle_refresh_melt_binary (struct MHD_Connection *connection, &cost, &total_cost)) ) { + GNUNET_break_op (0); TMH_KS_release (key_state); return TMH_RESPONSE_reply_internal_error (connection, "cost calculation failure"); @@ -115,6 +116,7 @@ handle_refresh_melt_binary (struct MHD_Connection *connection, &coin_melt_details->melt_amount_with_fee, &fee_melt)) { + GNUNET_break_op (0); TMH_KS_release (key_state); return TMH_RESPONSE_reply_external_error (connection, "Melt contribution below melting fee"); @@ -124,6 +126,7 @@ handle_refresh_melt_binary (struct MHD_Connection *connection, &melt, &total_melt)) { + GNUNET_break_op (0); TMH_KS_release (key_state); return TMH_RESPONSE_reply_internal_error (connection, "balance calculation failure"); @@ -134,6 +137,7 @@ handle_refresh_melt_binary (struct MHD_Connection *connection, TALER_amount_cmp (&total_cost, &total_melt)) { + GNUNET_break_op (0); /* We require total value of coins being melted and total value of coins being generated to match! */ return TMH_RESPONSE_reply_json_pack (connection, -- cgit v1.2.3 From cf3345a96f4e5c3fc1085052170e79adfaaff220 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 9 Aug 2015 21:50:23 +0200 Subject: initialize melt_fee in the TALER_MINT_RefreshMelt struct --- src/mint/taler-mint-httpd_db.c | 1 + src/mint/taler-mint-httpd_db.h | 6 ++++++ src/mint/taler-mint-httpd_refresh.c | 6 ++++-- 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src/mint/taler-mint-httpd_refresh.c') diff --git a/src/mint/taler-mint-httpd_db.c b/src/mint/taler-mint-httpd_db.c index 04c2555e..2a4c1674 100644 --- a/src/mint/taler-mint-httpd_db.c +++ b/src/mint/taler-mint-httpd_db.c @@ -582,6 +582,7 @@ refresh_accept_melts (struct MHD_Connection *connection, melt.coin_sig = coin_details->melt_sig; melt.session_hash = *session_hash; melt.amount_with_fee = coin_details->melt_amount_with_fee; + melt.melt_fee = coin_details->melt_fee; if (GNUNET_OK != TMH_plugin->insert_refresh_melt (TMH_plugin->cls, session, diff --git a/src/mint/taler-mint-httpd_db.h b/src/mint/taler-mint-httpd_db.h index c2f9a310..59976217 100644 --- a/src/mint/taler-mint-httpd_db.h +++ b/src/mint/taler-mint-httpd_db.h @@ -99,6 +99,12 @@ struct TMH_DB_MeltDetails * to the melt is this value minus the fee for melting the coin. */ struct TALER_Amount melt_amount_with_fee; + + /** + * What fee is earned by the mint? Set delayed during + * #verify_coin_public_info(). + */ + struct TALER_Amount melt_fee; }; diff --git a/src/mint/taler-mint-httpd_refresh.c b/src/mint/taler-mint-httpd_refresh.c index 625fcc50..fcd84308 100644 --- a/src/mint/taler-mint-httpd_refresh.c +++ b/src/mint/taler-mint-httpd_refresh.c @@ -223,7 +223,8 @@ get_coin_public_info (struct MHD_Connection *connection, * * @param connection the connection to send error responses to * @param session_hash hash over refresh session the coin is melted into - * @param melt_detail details about the coin's melting permission (if valid) + * @param[in,out] melt_detail details about the coin's melting permission, + * the `melt_fee` is updated * @return #GNUNET_YES if coin public info in JSON was valid * #GNUNET_NO JSON was invalid, response was generated * #GNUNET_SYSERR on internal error @@ -231,7 +232,7 @@ get_coin_public_info (struct MHD_Connection *connection, static int verify_coin_public_info (struct MHD_Connection *connection, const struct GNUNET_HashCode *session_hash, - const struct TMH_DB_MeltDetails *melt_detail) + struct TMH_DB_MeltDetails *melt_detail) { struct TALER_RefreshMeltCoinAffirmationPS body; struct TMH_KS_StateHandle *key_state; @@ -253,6 +254,7 @@ verify_coin_public_info (struct MHD_Connection *connection, valid for issuing! (#3634) */ TALER_amount_ntoh (&fee_refresh, &dki->issue.properties.fee_refresh); + melt_detail->melt_fee = fee_refresh; body.purpose.size = htonl (sizeof (struct TALER_RefreshMeltCoinAffirmationPS)); body.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT); body.session_hash = *session_hash; -- cgit v1.2.3