commit 57c9bcf54e4dc98b6a16344d28c306ad9e5ef8b8
parent 08ce214e695e73a79e8344eed0e648a870121f61
Author: bohdan-potuzhnyi <bohdan.potuzhnyi@gmail.com>
Date: Tue, 15 Jul 2025 18:49:51 +0200
all warnings fixed
Diffstat:
10 files changed, 249 insertions(+), 251 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
@@ -1975,10 +1975,9 @@ merchant_donau_issue_receipt_cb (void *cls,
pc->donau_receipt.sigs,
pc->donau_receipt.donau_sigs_json);
- struct TALER_Amount total_issued = resp->details.ok.issued_amount;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Donau accepted donation receipts with total_issued=%s\n",
- TALER_amount2s (&total_issued));
+ TALER_amount2s (&resp->details.ok.issued_amount));
}
else
{
@@ -2043,63 +2042,18 @@ phase_generate_donation_receipt (struct PayContext *pc)
pc->phase = PP_PAYMENT_NOTIFICATION;
return;
#else
- /* 1) Parse the BUDIs array from JSON into an array of
- * DONAU_BlindedUniqueDonorIdentifierKeyPair. */
- const json_t *budikeypairs = pc->parse_wallet_data.donau.budikeypairs;
- size_t num_bkps = 0;
- struct DONAU_BlindedUniqueDonorIdentifierKeyPair *bkps = NULL;
-
- if ((NULL == budikeypairs) || (! json_is_array (budikeypairs)))
- {
- /* Missing or invalid budikeypairs array */
- resume_pay_with_error (pc,
- TALER_EC_GENERIC_PARAMETER_MALFORMED,
- "Missing or invalid 'budikeypairs' array");
- return;
- }
-
- num_bkps = json_array_size (budikeypairs);
- /* Looks strange, but theoretically must work, at least donau uses it*/
- pc->donau_receipt.num_sigs = num_bkps;
- if (0 == num_bkps)
- {
- /* Theoretically is part is never reached, how do we behave? */
- resume_pay_with_error (pc,
- TALER_EC_GENERIC_PARAMETER_MALFORMED,
- "No budikeypairs provided");
- return;
- }
-
- bkps = GNUNET_new_array (num_bkps,
- struct DONAU_BlindedUniqueDonorIdentifierKeyPair);
-
- /* Parse each BUDI object */
- for (size_t i = 0; i < num_bkps; i++)
- {
- const json_t *bkp_obj = json_array_get (budikeypairs, i);
- if (GNUNET_SYSERR == merchant_parse_json_bkp (&bkps[i], bkp_obj))
- {
- GNUNET_break_op (0);
- GNUNET_free (bkps);
- resume_pay_with_error (pc,
- TALER_EC_GENERIC_PARAMETER_MALFORMED,
- "Failed to parse budikeypairs");
- return;
- }
- }
-
- /* 2) Call DONAU_charity_issue_receipt() asynchronously. */
- struct DONAU_BatchIssueReceiptHandle *birh =
+ /* Call DONAU_charity_issue_receipt() asynchronously. */
+ pc->donau_handler.birh =
DONAU_charity_issue_receipt (TMH_curl_ctx,
pc->parse_wallet_data.donau.donau_url,
pc->charity.charity_priv,
pc->charity.charity_id,
pc->parse_wallet_data.donau.donation_year,
- num_bkps,
- bkps,
+ pc->donau_handler.num_bkps,
+ pc->donau_handler.bkps,
&merchant_donau_issue_receipt_cb,
pc);
- if (NULL == birh)
+ if (NULL == pc->donau_handler.birh)
{
/* The request was invalid from the library’s perspective. */
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -2107,7 +2061,6 @@ phase_generate_donation_receipt (struct PayContext *pc)
resume_pay_with_error (pc,
TALER_EC_GENERIC_CLIENT_INTERNAL_ERROR,
"Donau error");
- GNUNET_free (bkps);
return;
}
@@ -2722,65 +2675,75 @@ phase_execute_pay_transaction (struct PayContext *pc)
/* Store signed output tokens in database. */
for (size_t i = 0; i<pc->validate_tokens.output_tokens_len; i++)
{
- const struct TALER_MERCHANT_ContractChoice *choice =
- &pc->check_contract.contract_terms->details.v1
- .choices[pc->parse_wallet_data.choice_index];
-
- /* If the matching contract-output is a donation-receipt, we skip it. */
- if (i < choice->outputs_len &&
- TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_DONATION_RECEIPT ==
- choice->outputs[i].type)
- continue;
+ /* Checking that the output is not donau,
+ * donau tokens sigs received from donau and saved later */
+ {
+ const struct TALER_MERCHANT_ContractChoice *choice =
+ &pc->check_contract.contract_terms->details.v1
+ .choices[pc->parse_wallet_data.choice_index];
- struct SignedOutputToken *output = &pc->validate_tokens.output_tokens[i];
+ /* If the matching contract-output is a donation-receipt, we skip it. */
+ if (i < choice->outputs_len &&
+ TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_DONATION_RECEIPT ==
+ choice->outputs[i].type)
+ continue;
+ }
- enum GNUNET_DB_QueryStatus qs;
+ /* Non-donau tokens processing */
+ {
+ struct SignedOutputToken *output = &pc->validate_tokens.output_tokens[i];
- qs = TMH_db->insert_issued_token (TMH_db->cls,
- &pc->check_contract.h_contract_terms,
- &output->h_issue,
- &output->sig);
+ enum GNUNET_DB_QueryStatus qs;
- if (0 >= qs)
- {
- TMH_db->rollback (TMH_db->cls);
- if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
- return; /* do it again */
- /* Always report on hard error as well to enable diagnostics */
- GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
- pay_end (pc,
- TALER_MHD_reply_with_error (pc->connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_DB_STORE_FAILED,
- "insert output token"));
- return;
+ qs = TMH_db->insert_issued_token (TMH_db->cls,
+ &pc->check_contract.h_contract_terms,
+ &output->h_issue,
+ &output->sig);
+
+ if (0 >= qs)
+ {
+ TMH_db->rollback (TMH_db->cls);
+ if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
+ return; /* do it again */
+ /* Always report on hard error as well to enable diagnostics */
+ GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
+ pay_end (pc,
+ TALER_MHD_reply_with_error (pc->connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_STORE_FAILED,
+ "insert output token"));
+ return;
+ }
}
}
- // REVIEW: insert donau blinded inputs (into DB here!)
+ // REVIEW: Do we really need to save the BUDIs? and what is the point of it?
if (NULL != pc->parse_wallet_data.donau.budikeypairs)
{
enum GNUNET_DB_QueryStatus qs;
qs = TMH_db->insert_order_budis (TMH_db->cls,
pc->order_id,
pc->parse_wallet_data.donau.budikeypairs);
- if (0 >= qs)
+ switch (qs)
{
- if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Order BUDIs already present, ignoring.\n");
- }
- else
- {
- TMH_db->rollback (TMH_db->cls);
- pay_end (pc,
- TALER_MHD_reply_with_error (pc->connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_DB_STORE_FAILED,
- "insert_order_budis"));
- return;
- }
+ case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
+ /* Case we are looking for */
+ break;
+ case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
+ // REVIEW: Do we really want to ignore, or to fetch the ones from the DB?
+ // Maybe we even want to do it in the parse_wallet_data part...
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Order BUDIs already present, ignoring.\n");
+ break;
+ case GNUNET_DB_STATUS_SOFT_ERROR:
+ case GNUNET_DB_STATUS_HARD_ERROR:
+ TMH_db->rollback (TMH_db->cls);
+ pay_end (pc,
+ TALER_MHD_reply_with_error (pc->connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_STORE_FAILED,
+ "insert_order_budis"));
+ return;
}
}
@@ -3950,7 +3913,7 @@ phase_parse_wallet_data (struct PayContext *pc)
uint64_t donation_year_tmp = 0;
const json_t *budikeypairs = NULL;
- /* All three fields inside the object are required together. */
+ /* Fetching and checking that all 3 are present in some way */
struct GNUNET_JSON_Specification dspec[] = {
GNUNET_JSON_spec_string ("url",
&donau_url_tmp),
@@ -3983,7 +3946,7 @@ phase_parse_wallet_data (struct PayContext *pc)
return;
}
- // Fetchning the charity information from the database based on the selected donau_url
+ // Check if the needed data is present for the given donau URL
{
enum GNUNET_DB_QueryStatus qs;
pc->charity.charity_priv = GNUNET_new (struct DONAU_CharityPrivateKeyP);
@@ -3995,31 +3958,29 @@ phase_parse_wallet_data (struct PayContext *pc)
&pc->charity.charity_id,
pc->charity.charity_priv);
- // TODO: Change to switch
- if (0 > qs)
+ switch (qs)
{
+ case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
+ /* We found the charity, continue */
+ break;
+ case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
TMH_db->rollback (TMH_db->cls);
-
- /* just fail. */
pay_end (pc,
TALER_MHD_reply_with_error (
pc->connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_DB_FETCH_FAILED,
- "lookup_order_charity"));
+ MHD_HTTP_NOT_FOUND,
+ TALER_EC_GENERIC_PARAMETER_MALFORMED,
+ "No matching Donau charity found for the given URL"));
return;
- }
- else if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
- {
- /* The given donau_url was not found in merchant_donau_instances
- or the corresponding merchant_keys for the private key. */
+ default:
+ /* SOFT or HARD errors, MULTIPLE is also here(but select single)? ask C about it */
TMH_db->rollback (TMH_db->cls);
pay_end (pc,
TALER_MHD_reply_with_error (
pc->connection,
- MHD_HTTP_BAD_REQUEST,
- TALER_EC_GENERIC_PARAMETER_MALFORMED,
- "No matching Donau charity found for the given URL"));
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ "lookup_order_charity"));
return;
}
}
@@ -4431,6 +4392,7 @@ pay_context_cleanup (void *cls)
pc_tail,
pc);
GNUNET_free (pc->check_contract.pos_key);
+ // TODO: add donau cleanup here
GNUNET_free (pc);
}
diff --git a/src/backend/taler-merchant-httpd_private-post-donau-instance.c b/src/backend/taler-merchant-httpd_private-post-donau-instance.c
@@ -45,19 +45,28 @@ TMH_private_post_donau_instance (const struct TMH_RequestHandler *rh,
const char *donau_url = NULL;
uint64_t charity_id = 0;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_string ("donau_url", &donau_url),
- GNUNET_JSON_spec_string ("charity_name", (const char **) &charity.name),
- GNUNET_JSON_spec_fixed_auto ("charity_pub_key", &charity.charity_pub),
- GNUNET_JSON_spec_uint64 ("charity_id", &charity_id),
- TALER_JSON_spec_amount_any ("max_per_year", &charity.max_per_year),
- TALER_JSON_spec_amount_any ("receipts_to_date", &charity.receipts_to_date),
- GNUNET_JSON_spec_uint64 ("current_year", &charity.current_year),
+ GNUNET_JSON_spec_string ("donau_url",
+ &donau_url),
+ GNUNET_JSON_spec_string ("charity_name",
+ (const char **) &charity.name),
+ GNUNET_JSON_spec_fixed_auto ("charity_pub_key",
+ &charity.charity_pub),
+ GNUNET_JSON_spec_uint64 ("charity_id",
+ &charity_id),
+ TALER_JSON_spec_amount_any ("max_per_year",
+ &charity.max_per_year),
+ TALER_JSON_spec_amount_any ("receipts_to_date",
+ &charity.receipts_to_date),
+ GNUNET_JSON_spec_uint64 ("current_year",
+ &charity.current_year),
GNUNET_JSON_spec_end ()
};
// Parse JSON body of the request
- if (GNUNET_OK != TALER_MHD_parse_json_data (connection, hc->request_body,
- spec))
+ if (GNUNET_OK != TALER_MHD_parse_json_data (connection,
+ hc->request_body,
+ spec)
+ )
{
return MHD_NO;
}
@@ -72,38 +81,48 @@ TMH_private_post_donau_instance (const struct TMH_RequestHandler *rh,
}
// Try to insert the new Donau instance into the database
- enum GNUNET_DB_QueryStatus qs = TMH_db->insert_donau_instance (TMH_db->cls,
- donau_url,
- &charity,
- charity_id);
- switch (qs)
{
- case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
- struct GNUNET_DB_EventHeaderP es = {
- .size = ntohs (sizeof (es)),
- .type = ntohs (TALER_DBEVENT_MERCHANT_DONAU_KEYS)
- };
+ enum GNUNET_DB_QueryStatus qs =
+ TMH_db->insert_donau_instance (TMH_db->cls,
+ donau_url,
+ &charity,
+ charity_id);
+ switch (qs)
+ {
+ case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
+ /* Everything fine we can finish with throwing
+ * the event_notify in the next part */
+ break;
+ case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
+ case GNUNET_DB_STATUS_SOFT_ERROR:
+ default:
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_COMMIT_FAILED,
+ "Database operation failed");
+ case GNUNET_DB_STATUS_HARD_ERROR:
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_STORE_FAILED,
+ "Failed to insert Donau instance");
+ }
- TMH_db->event_notify (TMH_db->cls,
- &es,
- donau_url,
- strlen (donau_url) + 1);
+ /* Notify the event system about the new Donau instance */
+ {
+ struct GNUNET_DB_EventHeaderP es = {
+ .size = ntohs (sizeof (es)),
+ .type = ntohs (TALER_DBEVENT_MERCHANT_DONAU_KEYS)
+ };
- return TALER_MHD_reply_static (connection,
- MHD_HTTP_NO_CONTENT,
- NULL, NULL,
- 0);
- case GNUNET_DB_STATUS_HARD_ERROR:
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_DB_STORE_FAILED,
- "Failed to insert Donau instance");
- case GNUNET_DB_STATUS_SOFT_ERROR:
- case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
- default:
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_DB_COMMIT_FAILED,
- "Database operation failed");
+ TMH_db->event_notify (TMH_db->cls,
+ &es,
+ donau_url,
+ strlen (donau_url) + 1);
+
+ return TALER_MHD_reply_static (connection,
+ MHD_HTTP_NO_CONTENT,
+ NULL, NULL,
+ 0);
+ }
}
}
diff --git a/src/include/taler_merchant_donau.h b/src/include/taler_merchant_donau.h
@@ -35,12 +35,12 @@ struct TALER_MERCHANT_DONAU_Charity
/**
* name of the charity
*/
- char *name;
+ const char *name;
/**
* charity url
*/
- char *charity_url;
+ const char *charity_url;
/**
* public key of the charity
diff --git a/src/lib/merchant_api_delete_donau_instance.c b/src/lib/merchant_api_delete_donau_instance.c
@@ -138,6 +138,7 @@ TALER_MERCHANT_donau_instance_delete (struct GNUNET_CURL_Context *ctx,
{
struct TALER_MERCHANT_DonauInstanceDeleteHandle *ddh;
char *charity_id_str;
+ CURL *eh;
GNUNET_asprintf (&charity_id_str, "private/donau/%ld", charity_id);
if (NULL == charity_id_str)
@@ -160,7 +161,7 @@ TALER_MERCHANT_donau_instance_delete (struct GNUNET_CURL_Context *ctx,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requesting URL '%s'\n", ddh->url);
- CURL *eh = TALER_MERCHANT_curl_easy_get_ (ddh->url);
+ eh = TALER_MERCHANT_curl_easy_get_ (ddh->url);
GNUNET_assert (CURLE_OK == curl_easy_setopt (eh, CURLOPT_CUSTOMREQUEST,
"DELETE"));
ddh->job = GNUNET_CURL_job_add (ctx, eh,
diff --git a/src/lib/merchant_api_get_donau_instance.c b/src/lib/merchant_api_get_donau_instance.c
@@ -79,6 +79,10 @@ 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)];
+ size_t index;
+ json_t *value;
if ((json_array_size (ia) != (size_t) instances_len))
{
@@ -86,14 +90,11 @@ parse_donau_instances (const json_t *ia,
return GNUNET_SYSERR;
}
- struct TALER_MERCHANT_DonauInstanceEntry instances[GNUNET_NZL (
- instances_len)];
- size_t index;
- json_t *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[] = {
@@ -114,22 +115,27 @@ parse_donau_instances (const json_t *ia,
GNUNET_JSON_spec_end ()
};
- if (GNUNET_OK != GNUNET_JSON_parse (value, spec, NULL, NULL))
+ if (GNUNET_OK != GNUNET_JSON_parse (value,
+ spec,
+ NULL, NULL))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
/* Parse the Donau keys */
- const json_t *donau_keys_json = json_object_get (value, "donau_keys_json");
+
+ donau_keys_json = json_object_get (value,
+ "donau_keys_json");
if (NULL == donau_keys_json)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to parse donau keys JSON\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to parse donau keys JSON\n");
return GNUNET_SYSERR;
}
/* Convert donau_keys_json to donau_keys struct */
- struct DONAU_Keys *donau_keys_ptr = DONAU_keys_from_json (donau_keys_json);
+ donau_keys_ptr = DONAU_keys_from_json (donau_keys_json);
if (NULL == donau_keys_ptr)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -144,8 +150,7 @@ parse_donau_instances (const json_t *ia,
igr->details.ok.donau_instances_length = instances_len;
igr->details.ok.donau_instances = instances;
dgh->cb (dgh->cb_cls, igr);
- dgh->cb = NULL; /* just to be sure */
-
+ dgh->cb = NULL;
return GNUNET_OK;
}
diff --git a/src/lib/taler_merchant_pay_service.c b/src/lib/taler_merchant_pay_service.c
@@ -728,6 +728,7 @@ TALER_MERCHANT_order_pay_start (struct TALER_MERCHANT_OrderPayHandle *ph)
{
const struct TALER_MERCHANT_PayCoin *c = &ph->coins.coins[i];
struct TALER_MERCHANT_PaidCoin pc;
+ json_t *je;
/* sign ------------------------------------------------------------ */
struct TALER_Amount fee;
@@ -765,18 +766,19 @@ TALER_MERCHANT_order_pay_start (struct TALER_MERCHANT_OrderPayHandle *ph)
&pc.coin_pub.eddsa_pub);
/* JSON ------------------------------------------------------------ */
- json_t *je = GNUNET_JSON_PACK (TALER_JSON_pack_amount ("contribution",
- &pc.amount_with_fee),
- GNUNET_JSON_pack_data_auto ("coin_pub",
- &pc.coin_pub),
- GNUNET_JSON_pack_string ("exchange_url",
- pc.exchange_url),
- GNUNET_JSON_pack_data_auto ("h_denom",
- &h_denom_pub),
- TALER_JSON_pack_denom_sig ("ub_sig",
- &pc.denom_sig),
- GNUNET_JSON_pack_data_auto ("coin_sig",
- &pc.coin_sig));
+
+ je = GNUNET_JSON_PACK (TALER_JSON_pack_amount ("contribution",
+ &pc.amount_with_fee),
+ GNUNET_JSON_pack_data_auto ("coin_pub",
+ &pc.coin_pub),
+ GNUNET_JSON_pack_string ("exchange_url",
+ pc.exchange_url),
+ GNUNET_JSON_pack_data_auto ("h_denom",
+ &h_denom_pub),
+ TALER_JSON_pack_denom_sig ("ub_sig",
+ &pc.denom_sig),
+ GNUNET_JSON_pack_data_auto ("coin_sig",
+ &pc.coin_sig));
json_array_append_new (arr, je);
/* optional totals if you need them later
@@ -802,15 +804,18 @@ TALER_MERCHANT_order_pay_start (struct TALER_MERCHANT_OrderPayHandle *ph)
}
}
- enum TALER_MERCHANT_OrderPayOptionErrorCode ec =
- store_json_option (ph,
- TALER_MERCHANT_OrderPayOptionType_COINS,
- GNUNET_JSON_PACK (
- GNUNET_JSON_pack_array_steal ("coins", arr)
- ));
- if (TALER_MERCHANT_OPOEC_OK != ec)
+ /* Putting coins to the body*/
{
- return ec;
+ enum TALER_MERCHANT_OrderPayOptionErrorCode ec =
+ store_json_option (ph,
+ TALER_MERCHANT_OrderPayOptionType_COINS,
+ GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_array_steal ("coins", arr)
+ ));
+ if (TALER_MERCHANT_OPOEC_OK != ec)
+ {
+ return ec;
+ }
}
}
@@ -821,7 +826,7 @@ TALER_MERCHANT_order_pay_start (struct TALER_MERCHANT_OrderPayHandle *ph)
json_t *arr = json_array ();
for (unsigned i = 0; i < ph->input_tokens.num_tokens; i++)
{
-
+ json_t *je;
const struct TALER_MERCHANT_UseToken *in = &ph->input_tokens.tokens[i];
struct TALER_MERCHANT_UsedToken *t = &ut[i];
@@ -836,7 +841,7 @@ TALER_MERCHANT_order_pay_start (struct TALER_MERCHANT_OrderPayHandle *ph)
GNUNET_CRYPTO_eddsa_key_get_public (&in->token_priv.private_key,
&t->token_pub.public_key);
- json_t *je = GNUNET_JSON_PACK (
+ 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 ("h_issue",
@@ -858,6 +863,7 @@ TALER_MERCHANT_order_pay_start (struct TALER_MERCHANT_OrderPayHandle *ph)
/* --- post the request --------------------------------------------------- */
{
char *path;
+ CURL *eh;
GNUNET_asprintf (&path,
"orders/%s/pay",
ph->order_id);
@@ -875,7 +881,7 @@ TALER_MERCHANT_order_pay_start (struct TALER_MERCHANT_OrderPayHandle *ph)
return TALER_MERCHANT_OPOEC_INVALID_VALUE;
}
- CURL *eh = TALER_MERCHANT_curl_easy_get_ (ph->url);
+ eh = TALER_MERCHANT_curl_easy_get_ (ph->url);
if (GNUNET_OK !=
TALER_curl_easy_post (&ph->post_ctx,
eh,
diff --git a/src/testing/testing_api_cmd_delete_donau_instances.c b/src/testing/testing_api_cmd_delete_donau_instances.c
@@ -181,12 +181,15 @@ TALER_TESTING_cmd_merchant_delete_donau_instance (const char *label,
dds->charity_id = charity_id;
dds->expected_http_status = expected_http_status;
- struct TALER_TESTING_Command cmd = {
- .cls = dds,
- .label = label,
- .run = &delete_donau_run,
- .cleanup = &delete_donau_cleanup
- };
-
- return cmd;
+ {
+ struct TALER_TESTING_Command cmd = {
+ .cls = dds,
+ .label = label,
+ .run = &delete_donau_run,
+ .cleanup = &delete_donau_cleanup
+ };
+
+ return cmd;
+ }
+
}
diff --git a/src/testing/testing_api_cmd_get_donau_instances.c b/src/testing/testing_api_cmd_get_donau_instances.c
@@ -171,22 +171,25 @@ TALER_TESTING_cmd_merchant_get_donau_instances (const char *label,
...)
{
struct GetDonauInstancesState *gis;
+ va_list ap;
gis = GNUNET_new (struct GetDonauInstancesState);
gis->url = url;
gis->expected_http_status = expected_http_status;
gis->instances_length = instance_count;
- va_list ap;
va_start (ap, expected_http_status);
va_end (ap);
- struct TALER_TESTING_Command cmd = {
- .cls = gis,
- .label = label,
- .run = &get_donau_instances_run,
- .cleanup = &get_donau_instances_cleanup
- };
+ {
+ struct TALER_TESTING_Command cmd = {
+ .cls = gis,
+ .label = label,
+ .run = &get_donau_instances_run,
+ .cleanup = &get_donau_instances_cleanup
+ };
+
+ return cmd;
+ }
- return cmd;
}
diff --git a/src/testing/testing_api_cmd_pay_order.c b/src/testing/testing_api_cmd_pay_order.c
@@ -209,17 +209,21 @@ prepare_donau_data (struct TALER_TESTING_Interpreter *is,
for (size_t cnt = 0; cnt < ss->num_bkps; cnt++)
{
+ struct DONAU_UniqueDonorIdentifierNonce *udi_nonce;
+ struct DONAU_BudiMasterSecretP ps;
+ const struct DONAU_BatchIssueValues *alg_values;
+ struct DONAU_BlindedUniqueDonorIdentifier *blinded_udi;
+ struct DONAU_UniqueDonorIdentifierHashP *udi_hash;
+
DONAU_donation_unit_pub_hash (&ss->keys->donation_unit_keys[0].key,
&ss->bkps[cnt].h_donation_unit_pub);
ss->receipts[cnt].h_donation_unit_pub = ss->bkps[cnt].h_donation_unit_pub;
- struct DONAU_UniqueDonorIdentifierNonce *udi_nonce =
+ udi_nonce =
&ss->receipts[cnt].nonce;
- struct DONAU_BudiMasterSecretP ps;
- const struct DONAU_BatchIssueValues *alg_values;
- struct DONAU_BlindedUniqueDonorIdentifier *blinded_udi =
+ blinded_udi =
&ss->bkps[cnt].blinded_udi;
- struct DONAU_UniqueDonorIdentifierHashP *udi_hash = &ss->h_udis[cnt];
+ udi_hash = &ss->h_udis[cnt];
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG,
&ps,
@@ -1329,6 +1333,8 @@ pay_run (void *cls,
{
struct GNUNET_CURL_Context *ctx =
TALER_TESTING_interpreter_get_context (is);
+ struct TALER_MERCHANT_OrderPayOption opts[32];
+ size_t oi = 0;
ps->oph = TALER_MERCHANT_order_pay_create (ctx,
&pay_cb,
@@ -1337,11 +1343,7 @@ pay_run (void *cls,
if (NULL == ps->oph)
TALER_TESTING_FAIL (is);
- /* build the option array ------------------------------------------------ */
- struct TALER_MERCHANT_OrderPayOption opts[32];
- size_t oi = 0;
-
- #define ADD(_opt) opts[oi++] = (_opt)
+#define ADD(_opt) opts[oi++] = (_opt)
ADD (TALER_MERCHANT_ORDER_PAY_OPTION_MERCHANT_URL (ps->merchant_url));
ADD (TALER_MERCHANT_ORDER_PAY_OPTION_ORDER_ID (order_id));
if (NULL != ps->session_id)
@@ -1377,7 +1379,8 @@ pay_run (void *cls,
#endif
ADD (TALER_MERCHANT_ORDER_PAY_OPTION_TERMINATE ());
- #undef ADD
+#undef ADD
+
if (TALER_MERCHANT_OPOEC_OK !=
TALER_MERCHANT_order_pay_set_options (ps->oph,
@@ -1575,19 +1578,10 @@ TALER_TESTING_cmd_merchant_pay_order_donau (const char *label,
const char *donor_tax_id,
const char *salt)
{
- struct TALER_TESTING_Command cmd;
struct PayState *ps;
struct MerchantDonauPayData *mdpd;
-#if NO_LEAK_NO_COPY_NO_DUPLICATION
- cmd = TALER_TESTING_cmd_merchant_pay_order_choices (...);
- ps = cmd.cls;
- mdpd = &pd.donau_data;
-#else
mdpd = GNUNET_new (struct MerchantDonauPayData);
-#endif
-
-
mdpd->year = year;
mdpd->num_bkps = 3;
mdpd->charity_reference = charity_reference;
diff --git a/src/testing/testing_api_cmd_post_donau_instances.c b/src/testing/testing_api_cmd_post_donau_instances.c
@@ -233,28 +233,33 @@ TALER_TESTING_cmd_merchant_post_donau_instance (const char *label,
TALER_string_to_amount (damount,
&date_amount));
- struct TALER_MERCHANT_DONAU_Charity charity = {
- .charity_url = "http://replaced.in.post_donau_run/",
- .name = "example",
- .charity_pub = *charity_pub,
- .charity_id = 1,
- .max_per_year = max_amount,
- .receipts_to_date = date_amount,
- .current_year = 2025
- };
-
- pds->merchant_reference = merchant_reference;
- pds->merchant_url = merchant_url;
- pds->charity = charity;
- pds->http_status = http_status;
- pds->auth_token = NULL;
-
- struct TALER_TESTING_Command cmd = {
- .cls = pds,
- .label = label,
- .run = &post_donau_run,
- .cleanup = &post_donau_cleanup
- };
-
- return cmd;
+ {
+ struct TALER_MERCHANT_DONAU_Charity charity = {
+ .charity_url = "http://replaced.in.post_donau_run/",
+ .name = "example",
+ .charity_pub = *charity_pub,
+ .charity_id = 1,
+ .max_per_year = max_amount,
+ .receipts_to_date = date_amount,
+ .current_year = 2025
+ };
+
+ pds->merchant_reference = merchant_reference;
+ pds->merchant_url = merchant_url;
+ pds->charity = charity;
+ pds->http_status = http_status;
+ pds->auth_token = NULL;
+
+ {
+ struct TALER_TESTING_Command cmd = {
+ .cls = pds,
+ .label = label,
+ .run = &post_donau_run,
+ .cleanup = &post_donau_cleanup
+ };
+
+ return cmd;
+ }
+
+ }
}
\ No newline at end of file