commit d1881c09978a43fc9da9e6f9041e8f1d31e4fa98
parent 994d4b37c06326f3e27a4d6300a16e7c3e7f0704
Author: bohdan-potuzhnyi <bohdan.potuzhnyi@gmail.com>
Date: Wed, 16 Jul 2025 21:15:48 +0200
small fixmes
Diffstat:
1 file changed, 69 insertions(+), 89 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
@@ -1959,17 +1959,7 @@ merchant_donau_issue_receipt_cb (void *cls,
}
}
- /*FIXME: Remove NULL check versus json_array alloc*/
pc->donau_receipt.donau_sigs_json = json_array ();
- if (NULL == pc->donau_receipt.donau_sigs_json)
- {
- GNUNET_break_op (0);
- resume_pay_with_error (pc,
- TALER_EC_GENERIC_CLIENT_INTERNAL_ERROR,
- "Failed to create Donau sigs JSON array");
- return;
- }
-
signature_to_json (pc->donau_receipt.num_sigs,
pc->donau_receipt.sigs,
pc->donau_receipt.donau_sigs_json);
@@ -2677,86 +2667,65 @@ phase_execute_pay_transaction (struct PayContext *pc)
}
}
- /*FIXME: Change to the switch, get out the choice
- * + assert output_len is the same as output_tokens_len */
- /* Store signed output tokens in database. */
- for (size_t i = 0; i<pc->validate_tokens.output_tokens_len; i++)
{
- /* 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];
+ 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;
- }
+ // GNUNET_assert (pc->validate_tokens.output_tokens_len ==
+ // choice->outputs_len);
- /* Non-donau tokens processing */
+ /*FIXME: Change to the switch,
+ * + check assert output_len is the same as output_tokens_len */
+ /* Store signed output tokens in database. */
+ for (size_t i = 0; i<pc->validate_tokens.output_tokens_len; i++)
{
- struct SignedOutputToken *output = &pc->validate_tokens.output_tokens[i];
-
- enum GNUNET_DB_QueryStatus qs;
-
- qs = TMH_db->insert_issued_token (TMH_db->cls,
- &pc->check_contract.h_contract_terms,
- &output->h_issue,
- &output->sig);
-
- if (0 >= qs)
+ switch (choice->outputs[i].type)
{
- 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);
+ case TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_INVALID:
+ /* Well, good luck getting here */
+ GNUNET_break (0);
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;
+ TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
+ "invalid output type"));
+ break;
+ case TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_DONATION_RECEIPT:
+ /* We skip outputs of donation receipts here, as they are handled in the
+ * phase_generate_donation_receipt() */
+ break;
+ case TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_TOKEN:
+ struct SignedOutputToken *output =
+ &pc->validate_tokens.output_tokens[i];
+
+ enum GNUNET_DB_QueryStatus qs;
+
+ 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;
+ }
+ break;
}
}
}
- // REVIEW: Do we really need to save the BUDIs? and what is the point of it?
- /* FIXME: Review this part */
-// 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);
-// switch (qs)
-// {
-// 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;
-// }
-// }
-
-
TMH_notify_order_change (hc->instance,
TMH_OSF_CLAIMED | TMH_OSF_PAID,
pc->check_contract.contract_terms->timestamp,
@@ -3148,7 +3117,7 @@ handle_output_token (struct PayContext *pc,
pc->check_contract.contract_terms->timestamp,
pc->check_contract.contract_terms->pay_deadline,
&details);
- /* FIXME: NO_RESPONSE 404, ERRORs */
+ /* FIXME: NO_RESPONSE 404, SOFT/HARD ERRORs 500 */
if (qs <= 0)
{
GNUNET_log (
@@ -3186,7 +3155,8 @@ handle_output_token (struct PayContext *pc,
output->details.token.count))
{
/* sign_token_envelopes() already queued up an error via pay_end() */
- /* FIXME: GNUNET_break(0); */
+ /* FIXME: fixed? GNUNET_break(0); */
+ GNUNET_break_op (0);
return GNUNET_NO;
}
@@ -3210,11 +3180,11 @@ handle_output_donation_receipt (
const struct TALER_MERCHANT_ContractOutput *output,
unsigned int output_index)
{
- // FIXME: Rethink this one, as most checks can be done immediately after receiving the wallet_data
/* FIXME: Implement this function.
* check donau outputs are good choices
* (allowed donau, total amount below max, correct year, ...)
*/
+ /* FIXME: Add helper function to donau, to get amount of the BKPS*/
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"handle_output_donation_receipt: ignoring donation output index %u\n",
output_index);
@@ -3407,7 +3377,17 @@ deposit_paid_check (
}
-/* FIXME: Add comment */
+/**
+ * Function called with information about a token that was spent.
+ *
+ * @param cls FIXME
+ * @param spent_token_serial
+ * @param h_contract_terms
+ * @param h_issue_pub
+ * @param use_pub
+ * @param use_sig
+ * @param issue_sig
+ */
static void
input_tokens_paid_check (
void *cls,
@@ -3919,7 +3899,6 @@ phase_parse_wallet_data (struct PayContext *pc)
if (NULL != donau_obj)
{
const char *donau_url_tmp;
- uint64_t donation_year_tmp;
const json_t *budikeypairs;
/* Fetching and checking that all 3 are present in some way */
@@ -3928,7 +3907,7 @@ phase_parse_wallet_data (struct PayContext *pc)
GNUNET_JSON_spec_string ("url",
&donau_url_tmp),
GNUNET_JSON_spec_uint64 ("year",
- &donation_year_tmp),
+ &pc->parse_wallet_data.donau.donation_year),
GNUNET_JSON_spec_array_const ("budikeypairs",
&budikeypairs),
GNUNET_JSON_spec_end ()
@@ -3998,7 +3977,6 @@ phase_parse_wallet_data (struct PayContext *pc)
}
pc->parse_wallet_data.donau.donau_url = GNUNET_strdup (donau_url_tmp);
- pc->parse_wallet_data.donau.donation_year = donation_year_tmp;
// Stage to parse the budikeypairs from json to struct
{
@@ -4010,8 +3988,10 @@ phase_parse_wallet_data (struct PayContext *pc)
/* Change to json for each*/
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))
+ 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);
@@ -4076,10 +4056,8 @@ phase_parse_pay (struct PayContext *pc)
GNUNET_JSON_spec_end ()
};
+#if DEBUG
{
- // TODO: Clean up this block when done
- // Print the request body for debugging purposes
- // FIXME: IF DEBUG
char *dump = json_dumps (pc->hc->request_body,
JSON_INDENT (2)
| JSON_ENCODE_ANY
@@ -4091,7 +4069,9 @@ phase_parse_pay (struct PayContext *pc)
dump);
free (dump);
+
}
+#endif /* DEBUG */
GNUNET_assert (PP_PARSE_PAY == pc->phase);
{