aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/taler-merchant-exchange.c42
-rw-r--r--src/backend/taler-merchant-httpd_contract.c108
-rw-r--r--src/backend/taler-merchant-httpd_exchanges.c5
-rw-r--r--src/backend/taler-merchant-httpd_get-orders-ID.c67
-rw-r--r--src/backend/taler-merchant-httpd_post-orders-ID-pay.c19
-rw-r--r--src/backend/taler-merchant-httpd_post-orders-ID-refund.c2
-rw-r--r--src/backend/taler-merchant-httpd_private-get-token-families-SLUG.c4
-rw-r--r--src/lib/merchant_api_common.c2
8 files changed, 129 insertions, 120 deletions
diff --git a/src/backend/taler-merchant-exchange.c b/src/backend/taler-merchant-exchange.c
index 72566e9b..d26786d5 100644
--- a/src/backend/taler-merchant-exchange.c
+++ b/src/backend/taler-merchant-exchange.c
@@ -784,7 +784,6 @@ wire_transfer_cb (void *cls,
{
struct Inquiry *w = cls;
struct Exchange *e = w->exchange;
- enum GNUNET_DB_QueryStatus qs;
const struct TALER_EXCHANGE_TransferData *td = NULL;
e->exchange_inquiries--;
@@ -845,25 +844,30 @@ wire_transfer_cb (void *cls,
return;
}
db_plugin->preflight (db_plugin->cls);
- qs = db_plugin->insert_transfer_details (db_plugin->cls,
- w->instance_id,
- w->exchange->exchange_url,
- w->payto_uri,
- &w->wtid,
- td);
- if (0 > qs)
- {
- /* Always report on DB error as well to enable diagnostics */
- GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
- global_ret = EXIT_FAILURE;
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
+
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Transfer already known. Ignoring duplicate.\n");
- return;
+ enum GNUNET_DB_QueryStatus qs;
+
+ qs = db_plugin->insert_transfer_details (db_plugin->cls,
+ w->instance_id,
+ w->exchange->exchange_url,
+ w->payto_uri,
+ &w->wtid,
+ td);
+ if (0 > qs)
+ {
+ /* Always report on DB error as well to enable diagnostics */
+ GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
+ global_ret = EXIT_FAILURE;
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Transfer already known. Ignoring duplicate.\n");
+ return;
+ }
}
{
diff --git a/src/backend/taler-merchant-httpd_contract.c b/src/backend/taler-merchant-httpd_contract.c
index 0783a30e..07db6a9d 100644
--- a/src/backend/taler-merchant-httpd_contract.c
+++ b/src/backend/taler-merchant-httpd_contract.c
@@ -87,15 +87,15 @@ TMH_string_from_contract_output_type (enum TALER_MerchantContractOutputType t)
*
* @param cls closure, pointer to array length
* @param root the json array representing the choices
- * @param[out] spec where to write the data
+ * @param[out] ospec where to write the data
* @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
*/
static enum GNUNET_GenericReturnValue
parse_choices (void *cls,
json_t *root,
- struct GNUNET_JSON_Specification *spec)
+ struct GNUNET_JSON_Specification *ospec)
{
- struct TALER_MerchantContractChoice **choices = spec->ptr;
+ struct TALER_MerchantContractChoice **choices = ospec->ptr;
unsigned int *choices_len = cls;
if (! json_is_array (root))
@@ -169,7 +169,7 @@ parse_choices (void *cls,
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Failed to parse %s at %u: %s\n",
- spec[ierror_line].field,
+ ispec[ierror_line].field,
ierror_line,
ierror_name);
GNUNET_break_op (0);
@@ -232,7 +232,7 @@ parse_choices (void *cls,
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Failed to parse %s at %u: %s\n",
- spec[ierror_line].field,
+ ispec[ierror_line].field,
ierror_line,
ierror_name);
GNUNET_break_op (0);
@@ -288,15 +288,15 @@ TALER_JSON_spec_choices (const char *name,
* @param cls closure, pointer to array length
* @param root the json object representing the token families. The keys are
* the token family slugs.
- * @param[out] spec where to write the data
+ * @param[out] ospec where to write the data
* @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
*/
static enum GNUNET_GenericReturnValue
parse_token_families (void *cls,
json_t *root,
- struct GNUNET_JSON_Specification *spec)
+ struct GNUNET_JSON_Specification *ospec)
{
- struct TALER_MerchantContractTokenFamily **families = spec->ptr;
+ struct TALER_MerchantContractTokenFamily **families = ospec->ptr;
unsigned int *families_len = cls;
json_t *jfamily;
const char *slug;
@@ -351,44 +351,51 @@ parse_token_families (void *cls,
{
/* TODO: Move this to TALER_JSON_spec_token_issue_key */
int64_t cipher;
- struct TALER_MerchantContractTokenFamilyKey *key;
- key = &family.keys[i];
+ struct TALER_MerchantContractTokenFamilyKey *key = &family.keys[i];
/* TODO: Free when not used anymore */
- key->pub.public_key = GNUNET_new (struct GNUNET_CRYPTO_BlindSignPublicKey)
- ;
- struct GNUNET_JSON_Specification key_spec[] = {
- GNUNET_JSON_spec_fixed_auto ("h_pub",
- &key->pub.public_key->pub_key_hash),
- GNUNET_JSON_spec_rsa_public_key ("rsa_pub",
- &key->pub.public_key->details.
- rsa_public_key),
- // GNUNET_JSON_spec_fixed_auto ("cs_pub",
- // &key.pub.public_key->details.cs_public_key)),
- GNUNET_JSON_spec_int64 ("cipher",
- &cipher),
- GNUNET_JSON_spec_timestamp ("valid_after",
- &key->valid_after),
- GNUNET_JSON_spec_timestamp ("valid_before",
- &key->valid_before),
- GNUNET_JSON_spec_end ()
- };
- const char *ierror_name;
- unsigned int ierror_line;
-
- if (GNUNET_OK !=
- GNUNET_JSON_parse (json_array_get (keys,
- i),
- key_spec,
- &ierror_name,
- &ierror_line))
+
+ key->pub.public_key
+ = GNUNET_new (struct GNUNET_CRYPTO_BlindSignPublicKey);
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Failed to parse %s at %u: %s\n",
- key_spec[ierror_line].field,
- ierror_line,
- ierror_name);
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
+ struct GNUNET_JSON_Specification key_spec[] = {
+ GNUNET_JSON_spec_fixed_auto (
+ "h_pub",
+ &key->pub.public_key->pub_key_hash),
+ GNUNET_JSON_spec_rsa_public_key (
+ "rsa_pub",
+ &key->pub.public_key->details.rsa_public_key),
+ // FIXME: sort out CS here!
+ // GNUNET_JSON_spec_fixed_auto ("cs_pub",
+ // &key.pub.public_key->details.cs_public_key)),
+ GNUNET_JSON_spec_int64 (
+ "cipher",
+ &cipher),
+ GNUNET_JSON_spec_timestamp (
+ "valid_after",
+ &key->valid_after),
+ GNUNET_JSON_spec_timestamp (
+ "valid_before",
+ &key->valid_before),
+ GNUNET_JSON_spec_end ()
+ };
+ const char *ierror_name;
+ unsigned int ierror_line;
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (json_array_get (keys,
+ i),
+ key_spec,
+ &ierror_name,
+ &ierror_line))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Failed to parse %s at %u: %s\n",
+ key_spec[ierror_line].field,
+ ierror_line,
+ ierror_name);
+ GNUNET_break_op (0);
+ return GNUNET_SYSERR;
+ }
}
switch (cipher)
@@ -407,8 +414,9 @@ parse_token_families (void *cls,
return GNUNET_SYSERR;
}
}
-
- GNUNET_array_append (*families, *families_len, family);
+ GNUNET_array_append (*families,
+ *families_len,
+ family);
}
return GNUNET_OK;
@@ -416,10 +424,10 @@ parse_token_families (void *cls,
struct GNUNET_JSON_Specification
-TALER_JSON_spec_token_families (const char *name,
- struct TALER_MerchantContractTokenFamily **
- families,
- unsigned int *families_len)
+TALER_JSON_spec_token_families (
+ const char *name,
+ struct TALER_MerchantContractTokenFamily **families,
+ unsigned int *families_len)
{
struct GNUNET_JSON_Specification ret = {
.cls = (void *) families_len,
diff --git a/src/backend/taler-merchant-httpd_exchanges.c b/src/backend/taler-merchant-httpd_exchanges.c
index 260a725a..918bc48f 100644
--- a/src/backend/taler-merchant-httpd_exchanges.c
+++ b/src/backend/taler-merchant-httpd_exchanges.c
@@ -35,7 +35,7 @@
* Threshold after which exponential backoff should not increase.
*/
#define RETRY_BACKOFF_THRESHOLD GNUNET_TIME_relative_multiply ( \
- GNUNET_TIME_UNIT_SECONDS, 60)
+ GNUNET_TIME_UNIT_SECONDS, 60)
/**
* This is how long /keys long-polls for, so we should
@@ -43,7 +43,7 @@
* answer. See exchange_api_handle.c.
*/
#define LONG_POLL_THRESHOLD GNUNET_TIME_relative_multiply ( \
- GNUNET_TIME_UNIT_SECONDS, 120)
+ GNUNET_TIME_UNIT_SECONDS, 120)
/**
@@ -1076,7 +1076,6 @@ insert_keys_data (const struct TALER_EXCHANGE_Keys *keys)
for (unsigned int i = 0; i<keys->num_sign_keys; i++)
{
struct TALER_EXCHANGE_SigningPublicKey *sign_key = &keys->sign_keys[i];
- enum GNUNET_DB_QueryStatus qs;
qs = TMH_db->insert_exchange_signkey (
TMH_db->cls,
diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.c b/src/backend/taler-merchant-httpd_get-orders-ID.c
index 53136628..e33093ec 100644
--- a/src/backend/taler-merchant-httpd_get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_get-orders-ID.c
@@ -472,9 +472,13 @@ resume_by_event (void *cls,
}
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Resuming (%d/%d) by event with argument `%.*s`\n",
- (int) GNUNET_TIME_absolute_is_future (god->sc.long_poll_timeout),
- god->sc.awaiting_refund,
+ "Resuming (%s/%s) by event with argument `%.*s`\n",
+ GNUNET_TIME_absolute_is_future (god->sc.long_poll_timeout)
+ ? "future"
+ : "past",
+ god->sc.awaiting_refund
+ ? "awaiting refund"
+ : "not waiting for refund",
(int) extra_size,
(const char *) extra);
god->suspended = GNUNET_NO;
@@ -566,37 +570,41 @@ phase_lookup_terms (struct GetOrderData *god)
{
uint64_t order_serial;
struct TALER_ClaimTokenP db_claim_token;
- enum GNUNET_DB_QueryStatus qs;
/* Convert order_id to h_contract_terms */
TMH_db->preflight (TMH_db->cls);
GNUNET_assert (NULL == god->contract_terms);
- qs = TMH_db->lookup_contract_terms (
- TMH_db->cls,
- god->hc->instance->settings.id,
- god->order_id,
- &god->contract_terms,
- &order_serial,
- &db_claim_token);
- if (0 > qs)
+
{
- /* single, read-only SQL statements should never cause
- serialization problems */
- GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs);
- /* Always report on hard error as well to enable diagnostics */
- GNUNET_break (0);
- phase_fail (god,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_DB_FETCH_FAILED,
- "lookup_contract_terms");
- return;
+ enum GNUNET_DB_QueryStatus qs;
+
+ qs = TMH_db->lookup_contract_terms (
+ TMH_db->cls,
+ god->hc->instance->settings.id,
+ god->order_id,
+ &god->contract_terms,
+ &order_serial,
+ &db_claim_token);
+ if (0 > qs)
+ {
+ /* single, read-only SQL statements should never cause
+ serialization problems */
+ GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs);
+ /* Always report on hard error as well to enable diagnostics */
+ GNUNET_break (0);
+ phase_fail (god,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ "lookup_contract_terms");
+ return;
+ }
+ /* Note: when "!ord.requireClaimToken" and the client does not provide
+ a claim token (all zeros!), then token_match==TRUE below: */
+ god->token_match
+ = (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
+ && (0 == GNUNET_memcmp (&db_claim_token,
+ &god->claim_token));
}
- /* Note: when "!ord.requireClaimToken" and the client does not provide
- a claim token (all zeros!), then token_match==TRUE below: */
- god->token_match
- = (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
- && (0 == GNUNET_memcmp (&db_claim_token,
- &god->claim_token));
/* Check if client provided the right hash code of the contract terms */
if (NULL != god->contract_terms)
@@ -653,7 +661,6 @@ phase_lookup_terms (struct GetOrderData *god)
}
else
{
- struct TALER_ClaimTokenP db_claim_token;
struct TALER_MerchantPostDataHashP unused;
enum GNUNET_DB_QueryStatus qs;
@@ -988,8 +995,6 @@ send_pay_request (struct GetOrderData *god,
MHD_HTTP_HEADER_LOCATION,
god->fulfillment_url));
{
- MHD_RESULT ret;
-
ret = MHD_queue_response (god->sc.con,
MHD_HTTP_FOUND,
reply);
diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
index 0370dedf..c9fbd34e 100644
--- a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
+++ b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
@@ -2521,6 +2521,7 @@ phase_validate_tokens (struct PayContext *pc)
{
struct TALER_MerchantContractChoice selected;
+ struct GNUNET_TIME_Timestamp now = GNUNET_TIME_timestamp_get ();
selected = pc->choices[pc->choice_index];
@@ -2559,8 +2560,6 @@ phase_validate_tokens (struct PayContext *pc)
return;
}
- struct GNUNET_TIME_Timestamp now = GNUNET_TIME_timestamp_get ();
-
/* Ensure tokens signed by this key are valid at the current time. */
if (GNUNET_TIME_timestamp_cmp (key.valid_after, >, now) ||
GNUNET_TIME_timestamp_cmp (key.valid_before, <=, now))
@@ -3135,16 +3134,7 @@ phase_check_contract (struct PayContext *pc)
static void
phase_parse_wallet_data (struct PayContext *pc)
{
- pc->choice_index = -1;
-
- if (NULL == pc->wallet_data)
- {
- pc->phase = PP_CHECK_CONTRACT;
- return;
- }
-
const json_t *tokens_evs;
-
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_int64 ("choice_index",
@@ -3156,9 +3146,14 @@ phase_parse_wallet_data (struct PayContext *pc)
NULL),
GNUNET_JSON_spec_end ()
};
-
enum GNUNET_GenericReturnValue res;
+ pc->choice_index = -1;
+ if (NULL == pc->wallet_data)
+ {
+ pc->phase = PP_CHECK_CONTRACT;
+ return;
+ }
res = TALER_MHD_parse_json_data (pc->connection,
pc->wallet_data,
spec);
diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-refund.c b/src/backend/taler-merchant-httpd_post-orders-ID-refund.c
index 134cd2ee..5fd81bef 100644
--- a/src/backend/taler-merchant-httpd_post-orders-ID-refund.c
+++ b/src/backend/taler-merchant-httpd_post-orders-ID-refund.c
@@ -691,8 +691,6 @@ TMH_post_orders_ID_refund (const struct TMH_RequestHandler *rh,
NULL != cr;
cr = cr->next)
{
- enum GNUNET_DB_QueryStatus qs;
-
qs = TMH_db->lookup_refund_proof (TMH_db->cls,
cr->refund_serial,
&cr->exchange_sig,
diff --git a/src/backend/taler-merchant-httpd_private-get-token-families-SLUG.c b/src/backend/taler-merchant-httpd_private-get-token-families-SLUG.c
index 92e1bb82..c2d3a58c 100644
--- a/src/backend/taler-merchant-httpd_private-get-token-families-SLUG.c
+++ b/src/backend/taler-merchant-httpd_private-get-token-families-SLUG.c
@@ -63,6 +63,8 @@ TMH_private_get_tokenfamilies_SLUG (const struct TMH_RequestHandler *rh,
}
{
char *kind = NULL;
+ MHD_RESULT result;
+
if (TALER_MERCHANTDB_TFK_Subscription == details.kind)
{
kind = GNUNET_strdup ("subscription");
@@ -80,8 +82,6 @@ TMH_private_get_tokenfamilies_SLUG (const struct TMH_RequestHandler *rh,
"invalid_token_family_kind");
}
- MHD_RESULT result;
-
result = TALER_MHD_REPLY_JSON_PACK (
connection,
MHD_HTTP_OK,
diff --git a/src/lib/merchant_api_common.c b/src/lib/merchant_api_common.c
index f5569ce3..d4f1c9c0 100644
--- a/src/lib/merchant_api_common.c
+++ b/src/lib/merchant_api_common.c
@@ -86,7 +86,7 @@ TALER_MERCHANT_parse_error_details_ (const json_t *response,
}
else
{
- hr->exchange_code = (enum TALER_ErrorCode) json_integer_value (jc);
+ hr->exchange_code = (enum TALER_ErrorCode) (int) json_integer_value (jc);
}
/* handle 'exchange-hint' */