merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit 00b3c5e0bbcfa0f4b78525601dc4ca7807f3efdc
parent 6a792c799ff158e41ec98e2fd1a8ad4db56d6a05
Author: bohdan-potuzhnyi <bohdan.potuzhnyi@gmail.com>
Date:   Fri,  1 Aug 2025 15:58:04 +0200

more cleanup of donau

Diffstat:
Msrc/lib/merchant_api_delete_donau_instance.c | 45+++++++++++++++++++++++++++------------------
Msrc/lib/merchant_api_get_donau_instance.c | 32+++++++++++---------------------
Msrc/lib/merchant_api_post_donau_instance.c | 8+++-----
Msrc/lib/taler_merchant_pay_service.c | 61++++++++++++++++++++++++++++++++++---------------------------
Msrc/testing/test_merchant_api.c | 1-
Msrc/testing/testing_api_cmd_delete_donau_instances.c | 7++++---
Msrc/testing/testing_api_cmd_get_donau_instances.c | 10++--------
Msrc/testing/testing_api_cmd_pay_order.c | 150++++++++++++++++++++++++++++++-------------------------------------------------
Msrc/testing/testing_api_cmd_post_donau_instances.c | 10+---------
9 files changed, 138 insertions(+), 186 deletions(-)

diff --git a/src/lib/merchant_api_delete_donau_instance.c b/src/lib/merchant_api_delete_donau_instance.c @@ -96,7 +96,6 @@ handle_delete_donau_instance_finished (void *cls, switch (response_code) { case MHD_HTTP_NO_CONTENT: - /* Successful deletion */ break; case MHD_HTTP_NOT_FOUND: case MHD_HTTP_UNAUTHORIZED: @@ -113,7 +112,8 @@ handle_delete_donau_instance_finished (void *cls, (int) hr.ec); break; } - ddh->cb (ddh->cb_cls, &hr); + ddh->cb (ddh->cb_cls, + &hr); TALER_MERCHANT_donau_instance_delete_cancel (ddh); } @@ -129,18 +129,20 @@ handle_delete_donau_instance_finished (void *cls, * @return the handle for the operation, or NULL on error */ struct TALER_MERCHANT_DonauInstanceDeleteHandle * -TALER_MERCHANT_donau_instance_delete (struct GNUNET_CURL_Context *ctx, - const char *backend_url, - uint64_t charity_id, - TALER_MERCHANT_DonauInstanceDeleteCallback - cb, - void *cb_cls) +TALER_MERCHANT_donau_instance_delete ( + struct GNUNET_CURL_Context *ctx, + const char *backend_url, + uint64_t charity_id, + TALER_MERCHANT_DonauInstanceDeleteCallback cb, + void *cb_cls) { struct TALER_MERCHANT_DonauInstanceDeleteHandle *ddh; char *charity_id_str; CURL *eh; - GNUNET_asprintf (&charity_id_str, "private/donau/%ld", charity_id); + GNUNET_asprintf (&charity_id_str, + "private/donau/%ld", + charity_id); if (NULL == charity_id_str) return NULL; @@ -149,23 +151,31 @@ TALER_MERCHANT_donau_instance_delete (struct GNUNET_CURL_Context *ctx, ddh->cb = cb; ddh->cb_cls = cb_cls; - ddh->url = TALER_url_join (backend_url, charity_id_str, NULL); + ddh->url = TALER_url_join (backend_url, + charity_id_str, + NULL); GNUNET_free (charity_id_str); if (NULL == ddh->url) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not construct request URL.\n"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Could not construct request URL.\n"); GNUNET_free (ddh); return NULL; } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requesting URL '%s'\n", ddh->url); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Requesting URL '%s'\n", + ddh->url); eh = TALER_MERCHANT_curl_easy_get_ (ddh->url); - GNUNET_assert (CURLE_OK == curl_easy_setopt (eh, CURLOPT_CUSTOMREQUEST, + GNUNET_assert (CURLE_OK == curl_easy_setopt (eh, + CURLOPT_CUSTOMREQUEST, "DELETE")); - ddh->job = GNUNET_CURL_job_add (ctx, eh, - &handle_delete_donau_instance_finished, ddh); + ddh->job = GNUNET_CURL_job_add (ctx, + eh, + &handle_delete_donau_instance_finished, + ddh); return ddh; } @@ -177,9 +187,8 @@ TALER_MERCHANT_donau_instance_delete (struct GNUNET_CURL_Context *ctx, * @param ddh Handle for the operation to cancel. */ void -TALER_MERCHANT_donau_instance_delete_cancel (struct - TALER_MERCHANT_DonauInstanceDeleteHandle - *ddh) +TALER_MERCHANT_donau_instance_delete_cancel ( + struct TALER_MERCHANT_DonauInstanceDeleteHandle *ddh) { if (NULL != ddh->job) GNUNET_CURL_job_cancel (ddh->job); diff --git a/src/lib/merchant_api_get_donau_instance.c b/src/lib/merchant_api_get_donau_instance.c @@ -79,8 +79,8 @@ parse_donau_instances (const json_t *ia, struct TALER_MERCHANT_DonauInstanceGetHandle *dgh) { unsigned int instances_len = (unsigned int) json_array_size (ia); - struct TALER_MERCHANT_DonauInstanceEntry instances[GNUNET_NZL ( - instances_len)]; + struct TALER_MERCHANT_DonauInstanceEntry + instances[GNUNET_NZL (instances_len)]; size_t index; json_t *value; @@ -90,13 +90,14 @@ parse_donau_instances (const json_t *ia, return GNUNET_SYSERR; } - json_array_foreach (ia, index, value) + json_array_foreach (ia, + index, + value) { struct TALER_MERCHANT_DonauInstanceEntry *instance = &instances[index]; const json_t *donau_keys_json; struct DONAU_Keys *donau_keys_ptr; - /* Specification for parsing each instance */ struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_string ("donau_url", &instance->donau_url), @@ -117,14 +118,14 @@ parse_donau_instances (const json_t *ia, if (GNUNET_OK != GNUNET_JSON_parse (value, spec, - NULL, NULL)) + NULL, + NULL)) { GNUNET_break_op (0); return GNUNET_SYSERR; } /* Parse the Donau keys */ - donau_keys_json = json_object_get (value, "donau_keys_json"); if (NULL == donau_keys_json) @@ -133,8 +134,6 @@ parse_donau_instances (const json_t *ia, "Failed to parse donau keys JSON\n"); return GNUNET_SYSERR; } - - /* Convert donau_keys_json to donau_keys struct */ donau_keys_ptr = DONAU_keys_from_json (donau_keys_json); if (NULL == donau_keys_ptr) { @@ -143,7 +142,6 @@ parse_donau_instances (const json_t *ia, return GNUNET_SYSERR; } - /* Assign donau_keys to the instance details */ instance->donau_keys = *donau_keys_ptr; } @@ -209,15 +207,7 @@ handle_get_donau_instances_finished (void *cls, } case MHD_HTTP_UNAUTHORIZED: - igr.hr.ec = TALER_JSON_get_error_code (json); - igr.hr.hint = TALER_JSON_get_error_hint (json); - break; - case MHD_HTTP_NOT_FOUND: - igr.hr.ec = TALER_JSON_get_error_code (json); - igr.hr.hint = TALER_JSON_get_error_hint (json); - break; - default: igr.hr.ec = TALER_JSON_get_error_code (json); igr.hr.hint = TALER_JSON_get_error_hint (json); @@ -228,7 +218,8 @@ handle_get_donau_instances_finished (void *cls, break; } - dgh->cb (dgh->cb_cls, &igr); + dgh->cb (dgh->cb_cls, + &igr); TALER_MERCHANT_donau_instances_get_cancel (dgh); } @@ -282,9 +273,8 @@ TALER_MERCHANT_donau_instances_get (struct GNUNET_CURL_Context *ctx, * @param dgh request to cancel. */ void -TALER_MERCHANT_donau_instances_get_cancel (struct - TALER_MERCHANT_DonauInstanceGetHandle - *dgh) +TALER_MERCHANT_donau_instances_get_cancel ( + struct TALER_MERCHANT_DonauInstanceGetHandle *dgh) { if (NULL != dgh->job) GNUNET_CURL_job_cancel (dgh->job); diff --git a/src/lib/merchant_api_post_donau_instance.c b/src/lib/merchant_api_post_donau_instance.c @@ -97,7 +97,6 @@ handle_post_donau_finished (void *cls, }; dph->job = NULL; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "POST /donau completed with response code %u\n", (unsigned int) response_code); @@ -111,9 +110,6 @@ handle_post_donau_finished (void *cls, break; case MHD_HTTP_BAD_REQUEST: case MHD_HTTP_INTERNAL_SERVER_ERROR: - hr.ec = TALER_JSON_get_error_code (json); - hr.hint = TALER_JSON_get_error_hint (json); - break; default: TALER_MERCHANT_parse_error_details_ (json, response_code, @@ -210,7 +206,9 @@ TALER_MERCHANT_donau_instances_post ( CURL *eh; eh = TALER_MERCHANT_curl_easy_get_ (dph->url); - if (GNUNET_OK != TALER_curl_easy_post (&dph->post_ctx, eh, req_obj)) + if (GNUNET_OK != TALER_curl_easy_post (&dph->post_ctx, + eh, + req_obj)) { GNUNET_break (0); curl_easy_cleanup (eh); diff --git a/src/lib/taler_merchant_pay_service.c b/src/lib/taler_merchant_pay_service.c @@ -25,7 +25,7 @@ #include <gnunet/gnunet_common.h> #include <gnunet/gnunet_json_lib.h> #include <jansson.h> -#include <microhttpd.h> /* just for HTTP status codes */ +#include <microhttpd.h> #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_curl_lib.h> #include "taler_merchant_service.h" @@ -620,7 +620,8 @@ store_json_option (struct TALER_MERCHANT_OrderPayHandle *ph, return TALER_MERCHANT_OPOEC_DUPLICATE_OPTION; } ph->field_seen[ot] = true; - GNUNET_assert (0 == json_object_update (ph->body, snippet)); + GNUNET_assert (0 == json_object_update (ph->body, + snippet)); json_decref (snippet); return TALER_MERCHANT_OPOEC_OK; } @@ -656,10 +657,10 @@ TALER_MERCHANT_order_pay_set_options (struct TALER_MERCHANT_OrderPayHandle *ph, json_t *js = GNUNET_JSON_PACK (GNUNET_JSON_pack_string ("session_id", o->details. session_id)); - enum TALER_MERCHANT_OrderPayOptionErrorCode ec = store_json_option (ph, - o-> - ot, - js); + enum TALER_MERCHANT_OrderPayOptionErrorCode ec = + store_json_option (ph, + o->ot, + js); if (TALER_MERCHANT_OPOEC_OK != ec) return ec; break; @@ -718,8 +719,8 @@ TALER_MERCHANT_order_pay_set_options (struct TALER_MERCHANT_OrderPayHandle *ph, case TALER_MERCHANT_OrderPayOptionType_PAY_DEADLINE: { - // FIXME: This one comes from the merchant_api_post_order_pay - // no idea do we still need it or not? + /* FIXME: This one comes from the merchant_api_post_order_pay + no idea do we still need it or not? */ break; } @@ -736,7 +737,6 @@ TALER_MERCHANT_order_pay_set_options (struct TALER_MERCHANT_OrderPayHandle *ph, GNUNET_assert (o->details.coins.num_coins >= 0); ph->coins.num_coins = o->details.coins.num_coins; ph->coins.coins = o->details.coins.coins; - // ph->field_seen[o->ot] = true; break; case TALER_MERCHANT_OrderPayOptionType_INPUT_TOKENS: @@ -782,7 +782,6 @@ TALER_MERCHANT_order_pay_set_options (struct TALER_MERCHANT_OrderPayHandle *ph, case TALER_MERCHANT_OrderPayOptionType_DONAU_YEAR: { - // TODO: As the donau_year is part of the donau object, we can already put it inside the json_t donau_data if (ph->donau_data == NULL) ph->donau_data = json_object (); GNUNET_assert (0 == json_object_set_new ( @@ -835,17 +834,19 @@ TALER_MERCHANT_order_pay_start (struct TALER_MERCHANT_OrderPayHandle *ph) return TALER_MERCHANT_OPOEC_INVALID_VALUE; } - /* --- build wallet_data hash for signing coins & tokens --- */ + /* build wallet_data hash for signing coins & tokens */ if (ph->has_choice_index) { /* base fields */ json_t *wd = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_int64 ("choice_index", ph->choice_index), + GNUNET_JSON_pack_int64 ("choice_index", + ph->choice_index), GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_array_incref ("tokens_evs", ph->tokens_evs)) + GNUNET_JSON_pack_array_incref ("tokens_evs", + ph->tokens_evs)) ); - // Putting prepared donau_data into the wallet_data + /* Putting prepared donau_data into the wallet_data */ if (ph->donau_data) GNUNET_assert (0 == json_object_set_new ( wd, @@ -864,7 +865,7 @@ TALER_MERCHANT_order_pay_start (struct TALER_MERCHANT_OrderPayHandle *ph) ph->wallet_data))); } - /* --- sign coins AND build the “coins” JSON in one pass --------------- */ + /* sign coins AND build the “coins” JSON in one pass */ { json_t *arr = json_array (); struct TALER_Amount total_fee, total_amount; @@ -875,12 +876,14 @@ TALER_MERCHANT_order_pay_start (struct TALER_MERCHANT_OrderPayHandle *ph) struct TALER_MERCHANT_PaidCoin pc; json_t *je; - /* sign ------------------------------------------------------------ */ + /* sign */ struct TALER_Amount fee; struct TALER_DenominationHashP h_denom_pub; - TALER_denom_pub_hash (&c->denom_pub, &h_denom_pub); - if (0 > TALER_amount_subtract (&fee, &c->amount_with_fee, + TALER_denom_pub_hash (&c->denom_pub, + &h_denom_pub); + if (0 > TALER_amount_subtract (&fee, + &c->amount_with_fee, &c->amount_without_fee)) return TALER_MERCHANT_OPOEC_INVALID_VALUE; @@ -910,8 +913,7 @@ TALER_MERCHANT_order_pay_start (struct TALER_MERCHANT_OrderPayHandle *ph) GNUNET_CRYPTO_eddsa_key_get_public (&c->coin_priv.eddsa_priv, &pc.coin_pub.eddsa_pub); - /* JSON ------------------------------------------------------------ */ - + /* JSON */ je = GNUNET_JSON_PACK (TALER_JSON_pack_amount ("contribution", &pc.amount_with_fee), GNUNET_JSON_pack_data_auto ("coin_pub", @@ -924,7 +926,8 @@ TALER_MERCHANT_order_pay_start (struct TALER_MERCHANT_OrderPayHandle *ph) &pc.denom_sig), GNUNET_JSON_pack_data_auto ("coin_sig", &pc.coin_sig)); - json_array_append_new (arr, je); + json_array_append_new (arr, + je); /* optional totals if you need them later (kept here because they existed in the legacy code) */ @@ -964,7 +967,7 @@ TALER_MERCHANT_order_pay_start (struct TALER_MERCHANT_OrderPayHandle *ph) } } - /* --- sign & pack input_tokens into used_tokens array in body --- */ + /* sign & pack input_tokens into used_tokens array in body */ if (ph->input_tokens.num_tokens > 0) { struct TALER_MERCHANT_UsedToken ut[ph->input_tokens.num_tokens]; @@ -987,13 +990,17 @@ TALER_MERCHANT_order_pay_start (struct TALER_MERCHANT_OrderPayHandle *ph) &t->token_pub.public_key); je = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_data_auto ("token_sig", &t->token_sig), - TALER_JSON_pack_token_issue_sig ("ub_sig", &t->ub_sig), + GNUNET_JSON_pack_data_auto ("token_sig", + &t->token_sig), + TALER_JSON_pack_token_issue_sig ("ub_sig", + &t->ub_sig), GNUNET_JSON_pack_data_auto ("h_issue", &t->issue_pub.public_key->pub_key_hash), - GNUNET_JSON_pack_data_auto ("token_pub", &t->token_pub) + GNUNET_JSON_pack_data_auto ("token_pub", + &t->token_pub) ); - json_array_append_new (arr, je); + json_array_append_new (arr, + je); } store_json_option (ph, @@ -1005,7 +1012,7 @@ TALER_MERCHANT_order_pay_start (struct TALER_MERCHANT_OrderPayHandle *ph) } - /* --- post the request --------------------------------------------------- */ + /* post the request */ { char *path; CURL *eh; diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c @@ -2267,7 +2267,6 @@ run (void *cls, tokens), #ifdef HAVE_DONAU_DONAU_SERVICE_H - // TALER_TESTING_cmd_sleep("dream", 30), TALER_TESTING_cmd_batch ("donau", donau), #endif diff --git a/src/testing/testing_api_cmd_delete_donau_instances.c b/src/testing/testing_api_cmd_delete_donau_instances.c @@ -13,7 +13,6 @@ You should have received a copy of the GNU Lesser General Public License along with TALER; see the file COPYING.LGPL. If not, see <http://www.gnu.org/licenses/> */ - /** * @file testing_api_cmd_delete_donau_instances.c * @brief Command to test DELETE /donau/$charity_id request @@ -86,7 +85,8 @@ delete_donau_cb (void *cls, switch (hr->http_status) { case MHD_HTTP_NO_CONTENT: - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DELETE /donau succeeded\n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "DELETE /donau succeeded\n"); break; case MHD_HTTP_NOT_FOUND: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -97,7 +97,8 @@ delete_donau_cb (void *cls, "DELETE /donau: Unauthorized access\n"); break; default: - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unhandled HTTP status %u\n", + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Unhandled HTTP status %u\n", hr->http_status); } diff --git a/src/testing/testing_api_cmd_get_donau_instances.c b/src/testing/testing_api_cmd_get_donau_instances.c @@ -86,7 +86,6 @@ get_donau_instances_cb (void *cls, return; } - // Process successful response if the status is 200 OK if (MHD_HTTP_OK == response->hr.http_status) { unsigned int instance_count = response->details.ok.donau_instances_length; @@ -99,8 +98,6 @@ get_donau_instances_cb (void *cls, return; } } - - // Continue to the next test command TALER_TESTING_interpreter_next (gis->is); } @@ -126,7 +123,7 @@ get_donau_instances_run (void *cls, &get_donau_instances_cb, gis); - GNUNET_assert (NULL != gis->dgh); // Ensure the request handle is valid + GNUNET_assert (NULL != gis->dgh); } @@ -150,7 +147,7 @@ get_donau_instances_cleanup (void *cls, TALER_MERCHANT_donau_instances_get_cancel (gis->dgh); } - GNUNET_free (gis); // Free the state + GNUNET_free (gis); } @@ -175,7 +172,6 @@ TALER_TESTING_cmd_merchant_get_donau_instances (const char *label, va_start (ap, expected_http_status); va_end (ap); - { struct TALER_TESTING_Command cmd = { .cls = gis, @@ -183,8 +179,6 @@ TALER_TESTING_cmd_merchant_get_donau_instances (const char *label, .run = &get_donau_instances_run, .cleanup = &get_donau_instances_cleanup }; - return cmd; } - } diff --git a/src/testing/testing_api_cmd_pay_order.c b/src/testing/testing_api_cmd_pay_order.c @@ -43,6 +43,9 @@ #endif /* HAVE_DONAU_DONAU_SERVICE_H */ #ifdef HAVE_DONAU_DONAU_SERVICE_H +/** + * Struct for handling the CS approach in signing of the bkps + */ struct CSR_Data { /** @@ -66,6 +69,9 @@ struct CSR_Data size_t position; }; +/** + * Handling all data needed for the /pay DONAU CMD. + */ struct MerchantDonauPayData { /** @@ -89,11 +95,6 @@ struct MerchantDonauPayData uint64_t charity_id; /** - * Charity private key - */ - // struct DONAU_CharityPrivateKeyP charity_priv; - - /** * Number of BUDIs to create or fetch. Example only. */ size_t num_bkps; @@ -145,23 +146,28 @@ struct MerchantDonauPayData json_t *budis_json; }; - +/** + * Prepares the donau data for the /pay CMD. + * + * @param is interpreter state + * @param ss donau data to prepare + */ static enum GNUNET_GenericReturnValue prepare_donau_data (struct TALER_TESTING_Interpreter *is, struct MerchantDonauPayData *ss) { - /* Get charity id and the charity private key from trait */ { const struct TALER_TESTING_Command *charity_post_cmd; const unsigned long long *charity_id; - charity_post_cmd = TALER_TESTING_interpreter_lookup_command (is, - ss-> - charity_reference); + charity_post_cmd = TALER_TESTING_interpreter_lookup_command ( + is, + ss->charity_reference); if (GNUNET_OK != - TALER_TESTING_get_trait_charity_id (charity_post_cmd, &charity_id)) + TALER_TESTING_get_trait_charity_id (charity_post_cmd, + &charity_id)) { GNUNET_break (0); return GNUNET_SYSERR; @@ -189,7 +195,6 @@ prepare_donau_data (struct TALER_TESTING_Interpreter *is, /* Get BUDIsKP */ { - // FIXME: Define me pleeeease ss->bkps = GNUNET_new_array (ss->num_bkps, struct DONAU_BlindedUniqueDonorIdentifierKeyPair); @@ -206,7 +211,6 @@ prepare_donau_data (struct TALER_TESTING_Interpreter *is, = GNUNET_new_array (ss->num_bkps, struct DONAU_UniqueDonorIdentifierHashP); - for (size_t cnt = 0; cnt < ss->num_bkps; cnt++) { struct DONAU_UniqueDonorIdentifierNonce *udi_nonce; @@ -254,26 +258,26 @@ prepare_donau_data (struct TALER_TESTING_Interpreter *is, GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "CS donation-unit key not yet supported – skip"); return GNUNET_NO; -// FIXME: BUG-#### Cs support missing/broken for donau -// struct CSR_Data *csr_data = GNUNET_new (struct CSR_Data); -// TALER_cs_withdraw_nonce_derive ( // FIXME: write new method -// (struct TALER_PlanchetMasterSecretP *) &ps, -// &csr_data->nonce.cs_nonce); -// csr_data->ss = is; -// csr_data->position = cnt; -// -// csr_data->csr_handle = DONAU_csr_issue ( -// TALER_TESTING_interpreter_get_context (is), -// TALER_TESTING_get_donau_url (is), -// &ss->keys->donation_unit_keys[0].key, -// &csr_data->nonce.cs_nonce, -// &cs_stage_two_callback, -// csr_data); -// if (NULL == csr_data->csr_handle) -// { -// GNUNET_break (0); -// } -// ss->cs_pending++; + /* FIXME: BUG-#### Cs support missing/broken for donau + struct CSR_Data *csr_data = GNUNET_new (struct CSR_Data); + TALER_cs_withdraw_nonce_derive ( // FIXME: write new method + (struct TALER_PlanchetMasterSecretP *) &ps, + &csr_data->nonce.cs_nonce); + csr_data->ss = is; + csr_data->position = cnt; + + csr_data->csr_handle = DONAU_csr_issue ( + TALER_TESTING_interpreter_get_context (is), + TALER_TESTING_get_donau_url (is), + &ss->keys->donation_unit_keys[0].key, + &csr_data->nonce.cs_nonce, + &cs_stage_two_callback, + csr_data); + if (NULL == csr_data->csr_handle) + { + GNUNET_break (0); + } + ss->cs_pending++; */ break; default: GNUNET_break (0); @@ -286,25 +290,20 @@ prepare_donau_data (struct TALER_TESTING_Interpreter *is, GNUNET_assert (NULL != budikeypairs); for (size_t i = 0; i < ss->num_bkps; i++) { - /* One object per BKP, identical layout to parse_json_bkp() */ json_t *budikeypair = GNUNET_JSON_PACK ( - /* donation-unit hash (binary) */ GNUNET_JSON_pack_data_auto ("h_donation_unit_pub", &ss->bkps[i].h_donation_unit_pub), - /* blinded UDI structure (cipher-aware helper does the heavy lifting) */ DONAU_JSON_pack_blinded_donation_identifier ("blinded_udi", &ss->bkps[i].blinded_udi) ); /* steal the reference into the array */ - GNUNET_assert (0 == json_array_append_new (budikeypairs, budikeypair)); + GNUNET_assert (0 == json_array_append_new (budikeypairs, + budikeypair)); } - ss->budis_json = budikeypairs; } - } - return GNUNET_OK; }; #endif /* HAVE_DONAU_DONAU_SERVICE_H */ @@ -1099,7 +1098,8 @@ pay_run (void *cls, TALER_TESTING_FAIL (is); } - donau_url_str = json_string_value (json_array_get (donau_urls, 0)); + donau_url_str = json_string_value (json_array_get (donau_urls, + 0)); if (NULL == donau_url_str) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -1111,7 +1111,8 @@ pay_run (void *cls, if (ps->donau_data.charity_reference != NULL) { - switch (prepare_donau_data (is, &ps->donau_data)) + switch (prepare_donau_data (is, + &ps->donau_data)) { case GNUNET_OK: break; @@ -1125,8 +1126,7 @@ pay_run (void *cls, ps->num_donau_tokens++; } #else /* HAVE_DONAU_DONAU_SERVICE_H */ - // Theoretically we have thought about paying without donau_url being selected, so could proceed... - // or maybe not + /* SIMPLY NOTHING */ #endif /* HAVE_DONAU_DONAU_SERVICE_H */ } @@ -1164,10 +1164,10 @@ pay_run (void *cls, continue; } - GNUNET_array_grow (ps->issued_tokens, - ps->num_issued_tokens, - ps->num_issued_tokens + count - + ps->num_donau_tokens); + GNUNET_array_grow ( + ps->issued_tokens, + ps->num_issued_tokens, + ps->num_issued_tokens + count + ps->num_donau_tokens); for (unsigned int k = 0; k < count; k++) { @@ -1200,11 +1200,9 @@ pay_run (void *cls, &details->blinding_inputs, &details->blinding_secret) ; - GNUNET_CRYPTO_eddsa_key_get_public (&details->token_priv. - private_key - , - &details->token_pub.public_key - ); + GNUNET_CRYPTO_eddsa_key_get_public ( + &details->token_priv.private_key, + &details->token_pub.public_key); GNUNET_CRYPTO_hash (&details->token_pub.public_key, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), &details->h_token_pub.hash); @@ -1232,8 +1230,6 @@ pay_run (void *cls, default: TALER_TESTING_FAIL (is); } - - } { @@ -1298,38 +1294,7 @@ pay_run (void *cls, TALER_TESTING_FAIL (is); ps->h_contract_terms = *h_proposal; - // old logic -// { -// ps->oph = TALER_MERCHANT_order_pay ( -// TALER_TESTING_interpreter_get_context (is), -// ps->merchant_url, -// ps->session_id, -// h_proposal, -// ps->choice_index, -// &ps->total_amount, -// &max_fee, -// &merchant_pub, -// merchant_sig, -// timestamp, -// refund_deadline, -// pay_deadline, -// &h_wire, -// order_id, -// npay_coins, -// pay_coins, -// len_use_tokens, -// use_tokens, -// len_output_tokens, -// output_tokens, -// &pay_cb, -// ps); -// -// if (NULL == ps->oph) -// TALER_TESTING_FAIL (is); -// -// } - - // New logic of setting params + /* New logic of setting pay params */ { struct GNUNET_CURL_Context *ctx = TALER_TESTING_interpreter_get_context (is); @@ -1370,18 +1335,16 @@ pay_run (void *cls, #ifdef HAVE_DONAU_DONAU_SERVICE_H if (ps->donau_data.charity_reference) { - ADD (TALER_MERCHANT_ORDER_PAY_OPTION_DONAU_URL (ps->donau_data.donau_url) - ); + ADD ( + TALER_MERCHANT_ORDER_PAY_OPTION_DONAU_URL (ps->donau_data.donau_url)); ADD (TALER_MERCHANT_ORDER_PAY_OPTION_DONAU_YEAR (ps->donau_data.year)); - ADD (TALER_MERCHANT_ORDER_PAY_OPTION_DONAU_BUDIS (ps->donau_data. - budis_json)); + ADD (TALER_MERCHANT_ORDER_PAY_OPTION_DONAU_BUDIS ( + ps->donau_data.budis_json)); } #endif - ADD (TALER_MERCHANT_ORDER_PAY_OPTION_TERMINATE ()); #undef ADD - if (TALER_MERCHANT_OPOEC_OK != TALER_MERCHANT_order_pay_set_options (ps->oph, opts, @@ -1425,7 +1388,6 @@ pay_cleanup (void *cls, "Command `%s' did not complete.\n", TALER_TESTING_interpreter_get_current_label ( ps->is)); - // TALER_MERCHANT_order_pay_cancel (ps->oph); TALER_MERCHANT_order_pay_cancel1 (ps->oph); } diff --git a/src/testing/testing_api_cmd_post_donau_instances.c b/src/testing/testing_api_cmd_post_donau_instances.c @@ -99,7 +99,7 @@ post_donau_cb (void *cls, switch (hr->http_status) { case MHD_HTTP_NO_CONTENT: - break; /* Test passes */ + break; case MHD_HTTP_BAD_REQUEST: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "POST /donau returned BAD REQUEST: %s\n", @@ -137,11 +137,7 @@ post_donau_run (void *cls, struct PostDonauState *pds = cls; pds->is = is; - - // Replacing the url of the charity pds->charity.charity_url = TALER_TESTING_get_donau_url (is); - - // Fetching the publick key of the merchant if (NULL != pds->merchant_reference) { const struct TALER_TESTING_Command *mc; @@ -153,8 +149,6 @@ post_donau_run (void *cls, GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_merchant_pub (mc, &merchant_pub)); - - /* shallow copy of the actual EdDSA key */ pds->charity.charity_pub.eddsa_pub = merchant_pub->eddsa_pub; } @@ -210,8 +204,6 @@ TALER_TESTING_cmd_merchant_post_donau_instance (const char *label, ...) { struct PostDonauState *pds = GNUNET_new (struct PostDonauState); - - // FIXME: I need to steal the charity_pub->eddsa_pub from the merchant_pub->eddsa_pub struct DONAU_CharityPublicKeyP *charity_pub = GNUNET_new (struct DONAU_CharityPublicKeyP);