diff options
Diffstat (limited to 'src/exchange')
-rw-r--r-- | src/exchange/taler-exchange-httpd_batch-deposit.c | 14 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_deposit.c | 36 |
2 files changed, 20 insertions, 30 deletions
diff --git a/src/exchange/taler-exchange-httpd_batch-deposit.c b/src/exchange/taler-exchange-httpd_batch-deposit.c index 17bbb2c1..d4a9666e 100644 --- a/src/exchange/taler-exchange-httpd_batch-deposit.c +++ b/src/exchange/taler-exchange-httpd_batch-deposit.c @@ -91,7 +91,7 @@ struct BatchDepositContext * deposit operation, possibly NULL! */ json_t *policy_details; - bool no_policy_details; + bool has_policy_details; /** * Hash over @e policy_details, might be all zero; @@ -174,7 +174,7 @@ again: &TEH_keys_exchange_sign_, &bdc->h_contract_terms, &bdc->h_wire, - bdc->no_policy_details ? NULL : &bdc->h_policy, + bdc->has_policy_details ? &bdc->h_policy : NULL, bdc->exchange_timestamp, bdc->wire_deadline, bdc->refund_deadline, @@ -474,7 +474,8 @@ parse_coin (struct MHD_Connection *connection, &dc->h_wire, &dc->h_contract_terms, &deposit->coin.h_age_commitment, - dc->no_policy_details ? NULL : &dc->h_policy, + dc->has_policy_details ? &dc->h_policy : + NULL, &deposit->coin.denom_pub_hash, dc->timestamp, &dc->merchant_pub, @@ -517,6 +518,7 @@ TEH_handler_batch_deposit (struct TEH_RequestContext *rc, struct BatchDepositContext dc; json_t *coins; bool no_refund_deadline = true; + bool no_policy_details = true; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_string ("merchant_payto_uri", &dc.payto_uri), @@ -531,7 +533,7 @@ TEH_handler_batch_deposit (struct TEH_RequestContext *rc, GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_json ("policy", &dc.policy_details), - &dc.no_policy_details), + &no_policy_details), GNUNET_JSON_spec_timestamp ("timestamp", &dc.timestamp), GNUNET_JSON_spec_mark_optional ( @@ -562,6 +564,8 @@ TEH_handler_batch_deposit (struct TEH_RequestContext *rc, return MHD_YES; /* failure */ } + dc.has_policy_details = ! no_policy_details; + /* validate merchant's wire details (as far as we can) */ { char *emsg; @@ -606,7 +610,7 @@ TEH_handler_batch_deposit (struct TEH_RequestContext *rc, TALER_merchant_wire_signature_hash (dc.payto_uri, &dc.wire_salt, &dc.h_wire); - if (! dc.no_policy_details) + if (dc.has_policy_details) { TALER_deposit_policy_hash (dc.policy_details, &dc.h_policy); diff --git a/src/exchange/taler-exchange-httpd_deposit.c b/src/exchange/taler-exchange-httpd_deposit.c index 6e75dac5..fa6a3232 100644 --- a/src/exchange/taler-exchange-httpd_deposit.c +++ b/src/exchange/taler-exchange-httpd_deposit.c @@ -21,6 +21,7 @@ * @author Florian Dold * @author Benedikt Mueller * @author Christian Grothoff + * @author Özgür Kesim */ #include "platform.h" #include <gnunet/gnunet_util_lib.h> @@ -218,6 +219,7 @@ TEH_handler_deposit (struct MHD_Connection *connection, struct TALER_EXCHANGEDB_Deposit deposit; const char *payto_uri; struct TALER_ExtensionPolicyHashP *ph_policy = NULL; + bool no_policy_details; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_string ("merchant_payto_uri", &payto_uri), @@ -254,7 +256,7 @@ TEH_handler_deposit (struct MHD_Connection *connection, GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_json ("policy", &deposit.policy_details), - &deposit.no_policy_details), + &no_policy_details), GNUNET_JSON_spec_end () }; struct TALER_MerchantWireHashP h_wire; @@ -328,31 +330,15 @@ TEH_handler_deposit (struct MHD_Connection *connection, dc.deposit = &deposit; /* Check policy */ - if (! deposit.no_policy_details) + deposit.has_policy_details = ! no_policy_details; + if (! deposit.has_policy_details) { - enum GNUNET_GenericReturnValue ret; - const struct TALER_Extension *ext; const char *error_hint = NULL; - GNUNET_assert (ext->parse_policy_details); - - do { - ret = TALER_extensions_from_policy_details (deposit.policy_details, - &ext, - &error_hint); - - if (GNUNET_OK != ret) - break; - - deposit.policy_deadline = GNUNET_TIME_UNIT_FOREVER_TS; - - ret = ext->parse_policy_details (deposit.policy_details, - &deposit.policy_serial_id, - &deposit.policy_deadline, - &error_hint); - - } while(0); - - if (GNUNET_OK != ret) + if (GNUNET_OK != + TALER_extensions_serial_from_policy_details (deposit.policy_details, + &deposit.policy_serial_id, + &deposit.policy_deadline, + &error_hint)) return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, TALER_EC_EXCHANGE_DEPOSITS_POLICY_NOT_ACCEPTED, @@ -424,7 +410,7 @@ TEH_handler_deposit (struct MHD_Connection *connection, NULL); } - if (! deposit.no_policy_details) + if (deposit.has_policy_details) { TALER_deposit_policy_hash (deposit.policy_details, &deposit.h_policy); |