summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-04-14 18:59:31 +0200
committerChristian Grothoff <christian@grothoff.org>2022-04-14 18:59:38 +0200
commit37cad4c26b8c37ce12843965fcc9334e998923ab (patch)
treed8bf2f1a526fa6d061587e2b49d0c40c2b4233b5 /src
parentcfc7801cf630e4090c038269e63ef8742cfcc7e5 (diff)
downloadanastasis-37cad4c26b8c37ce12843965fcc9334e998923ab.tar.gz
anastasis-37cad4c26b8c37ce12843965fcc9334e998923ab.tar.bz2
anastasis-37cad4c26b8c37ce12843965fcc9334e998923ab.zip
-remove currency-based provider selection
Diffstat (limited to 'src')
-rw-r--r--src/backend/anastasis-httpd.c22
-rw-r--r--src/backend/anastasis-httpd.h5
-rw-r--r--src/backend/anastasis-httpd_config.c2
-rw-r--r--src/backend/anastasis-httpd_policy-upload.c5
-rw-r--r--src/backend/anastasis-httpd_truth-upload.c5
-rw-r--r--src/include/anastasis_service.h5
-rw-r--r--src/reducer/anastasis_api_redux.c77
-rw-r--r--src/restclient/anastasis_api_config.c15
8 files changed, 27 insertions, 109 deletions
diff --git a/src/backend/anastasis-httpd.c b/src/backend/anastasis-httpd.c
index 16e2a08..9b8c68e 100644
--- a/src/backend/anastasis-httpd.c
+++ b/src/backend/anastasis-httpd.c
@@ -73,11 +73,6 @@ const struct GNUNET_CONFIGURATION_Handle *AH_cfg;
char *AH_backend_url;
/**
- * Taler currency.
- */
-char *AH_currency;
-
-/**
* Our fulfillment URL.
*/
char *AH_fulfillment_url;
@@ -761,23 +756,6 @@ run (void *cls,
return;
}
if (GNUNET_OK !=
- TALER_config_get_currency (config,
- &AH_currency))
- {
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- if (0 != strcasecmp (AH_currency,
- AH_annual_fee.currency))
- {
- GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
- "anastasis",
- "ANNUAL_FEE",
- "currency mismatch");
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- if (GNUNET_OK !=
TALER_amount_cmp_currency (&AH_insurance,
&AH_annual_fee))
{
diff --git a/src/backend/anastasis-httpd.h b/src/backend/anastasis-httpd.h
index 8cc96b2..1a87921 100644
--- a/src/backend/anastasis-httpd.h
+++ b/src/backend/anastasis-httpd.h
@@ -175,11 +175,6 @@ extern struct TALER_Amount AH_question_cost;
extern char *AH_backend_url;
/**
- * Taler currency.
- */
-extern char *AH_currency;
-
-/**
* Heap for processing timeouts of requests.
*/
extern struct GNUNET_CONTAINER_Heap *AH_to_heap;
diff --git a/src/backend/anastasis-httpd_config.c b/src/backend/anastasis-httpd_config.c
index adabffb..015fd01 100644
--- a/src/backend/anastasis-httpd_config.c
+++ b/src/backend/anastasis-httpd_config.c
@@ -106,8 +106,6 @@ AH_handler_config (struct AH_RequestHandler *rh,
"0:0:0"),
GNUNET_JSON_pack_string ("business_name",
AH_business_name),
- GNUNET_JSON_pack_string ("currency",
- (char *) AH_currency),
GNUNET_JSON_pack_array_steal ("methods",
method_arr),
GNUNET_JSON_pack_uint64 ("storage_limit_in_megabytes",
diff --git a/src/backend/anastasis-httpd_policy-upload.c b/src/backend/anastasis-httpd_policy-upload.c
index 32f0266..94a38bc 100644
--- a/src/backend/anastasis-httpd_policy-upload.c
+++ b/src/backend/anastasis-httpd_policy-upload.c
@@ -435,9 +435,8 @@ check_payment_cb (void *cls,
const json_t *contract;
struct TALER_Amount amount;
struct GNUNET_JSON_Specification cspec[] = {
- TALER_JSON_spec_amount ("amount",
- AH_currency,
- &amount),
+ TALER_JSON_spec_amount_any ("amount",
+ &amount),
GNUNET_JSON_spec_end ()
};
diff --git a/src/backend/anastasis-httpd_truth-upload.c b/src/backend/anastasis-httpd_truth-upload.c
index 642f523..356dc36 100644
--- a/src/backend/anastasis-httpd_truth-upload.c
+++ b/src/backend/anastasis-httpd_truth-upload.c
@@ -321,9 +321,8 @@ check_payment_cb (void *cls,
const json_t *contract;
struct TALER_Amount amount;
struct GNUNET_JSON_Specification cspec[] = {
- TALER_JSON_spec_amount ("amount",
- AH_currency,
- &amount),
+ TALER_JSON_spec_amount_any ("amount",
+ &amount),
GNUNET_JSON_spec_end ()
};
diff --git a/src/include/anastasis_service.h b/src/include/anastasis_service.h
index 5e01aa5..ba55314 100644
--- a/src/include/anastasis_service.h
+++ b/src/include/anastasis_service.h
@@ -62,11 +62,6 @@ struct ANASTASIS_Config
const char *business_name;
/**
- * Currency used for payments by the server.
- */
- const char *currency;
-
- /**
* Array of authorization methods supported by the server.
*/
const struct ANASTASIS_AuthorizationMethodConfig *methods;
diff --git a/src/reducer/anastasis_api_redux.c b/src/reducer/anastasis_api_redux.c
index b9d18ab..5dde4c6 100644
--- a/src/reducer/anastasis_api_redux.c
+++ b/src/reducer/anastasis_api_redux.c
@@ -152,11 +152,6 @@ struct ConfigRequest
char *business_name;
/**
- * currency used by the anastasis backend.
- */
- char *currency;
-
- /**
* Array of authorization methods supported by the server.
*/
struct AuthorizationMethodConfig *methods;
@@ -366,7 +361,6 @@ free_config_request (struct ConfigRequest *cr)
ANASTASIS_config_cancel (cr->co);
if (NULL != cr->tt)
GNUNET_SCHEDULER_cancel (cr->tt);
- GNUNET_free (cr->currency);
GNUNET_free (cr->url);
GNUNET_free (cr->business_name);
for (unsigned int i = 0; i<cr->methods_length; i++)
@@ -533,8 +527,6 @@ notify_waiting (struct ConfigRequest *cr)
&cr->truth_upload_fee),
TALER_JSON_pack_amount ("liability_limit",
&cr->liability_limit),
- GNUNET_JSON_pack_string ("currency",
- cr->currency),
GNUNET_JSON_pack_string ("business_name",
cr->business_name),
GNUNET_JSON_pack_uint64 ("storage_limit_in_megabytes",
@@ -598,8 +590,6 @@ config_cb (void *cls,
else
{
cr->ec = TALER_EC_NONE;
- GNUNET_free (cr->currency);
- cr->currency = GNUNET_strdup (acfg->currency);
GNUNET_free (cr->business_name);
cr->business_name = GNUNET_strdup (acfg->business_name);
for (unsigned int i = 0; i<cr->methods_length; i++)
@@ -693,12 +683,12 @@ check_config (const char *url)
/**
* Begin asynchronous check for provider configurations.
*
- * @param currencies the currencies to initiate the provider checks for
+ * @param cc country code that was selected
* @param[in,out] state to set provider list for
* @return #TALER_EC_NONE on success
*/
static enum TALER_ErrorCode
-begin_provider_config_check (const json_t *currencies,
+begin_provider_config_check (const char *cc,
json_t *state)
{
if (NULL == provider_list)
@@ -746,12 +736,14 @@ begin_provider_config_check (const json_t *currencies,
json_array_foreach (provider_arr, index, provider)
{
const char *url;
- const char *cur;
+ const char *restricted = NULL;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("url",
&url),
- GNUNET_JSON_spec_string ("currency",
- &cur),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_string ("restricted",
+ &restricted),
+ NULL),
GNUNET_JSON_spec_end ()
};
json_t *prov;
@@ -765,27 +757,21 @@ begin_provider_config_check (const json_t *currencies,
json_decref (pl);
return TALER_EC_ANASTASIS_REDUCER_RESOURCE_MALFORMED;
}
-
+ if ( (NULL != restricted) &&
+ (0 != strcmp (restricted,
+ cc)) )
{
- bool found = false;
- json_t *cu;
- size_t off;
-
- json_array_foreach (currencies, off, cu)
- {
- const char *currency;
-
- currency = json_string_value (cu);
- if (NULL == currency)
- {
- json_decref (pl);
- return TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID;
- }
- found = (0 == strcasecmp (currency,
- cur));
- }
- if (! found)
- continue;
+ /* skip */
+ continue;
+ }
+ if ( (NULL == restricted) &&
+ (0 == strcmp (cc,
+ "xx")) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Running in demo mode, skipping unrestricted providers\n");
+ /* demo mode, skipping regular providers */
+ continue;
}
prov = GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("status",
@@ -1023,7 +1009,6 @@ select_country (json_t *state,
{
const json_t *required_attrs;
const json_t *country_code;
- const json_t *currencies;
const json_t *redux_id_attr;
if (NULL == arguments)
@@ -1073,23 +1058,11 @@ select_country (json_t *state,
}
}
- currencies = json_object_get (arguments,
- "currencies");
- if ( (NULL == currencies) ||
- (! json_is_array (currencies)) )
- {
- ANASTASIS_redux_fail_ (cb,
- cb_cls,
- TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
- "'currencies' missing");
- return NULL;
- }
- /* We now have an idea of the currency, begin fetching
- provider /configs (we likely need them later) */
+ /* Begin fetching provider /configs (we likely need them later) */
{
enum TALER_ErrorCode ec;
- ec = begin_provider_config_check (currencies,
+ ec = begin_provider_config_check (json_string_value (country_code),
state);
if (TALER_EC_NONE != ec)
{
@@ -1129,10 +1102,6 @@ select_country (json_t *state,
(json_t *) country_code));
GNUNET_assert (0 ==
json_object_set (state,
- "currencies",
- (json_t *) currencies));
- GNUNET_assert (0 ==
- json_object_set (state,
"required_attributes",
(json_t *) required_attrs));
cb (cb_cls,
diff --git a/src/restclient/anastasis_api_config.c b/src/restclient/anastasis_api_config.c
index 08b6952..dab63f7 100644
--- a/src/restclient/anastasis_api_config.c
+++ b/src/restclient/anastasis_api_config.c
@@ -108,8 +108,6 @@ handle_config_finished (void *cls,
&acfg.business_name),
GNUNET_JSON_spec_string ("version",
&acfg.version),
- GNUNET_JSON_spec_string ("currency",
- &acfg.currency),
GNUNET_JSON_spec_json ("methods",
&methods),
GNUNET_JSON_spec_uint32 ("storage_limit_in_megabytes",
@@ -179,19 +177,6 @@ handle_config_finished (void *cls,
break;
}
}
- if ( (GNUNET_OK !=
- TALER_amount_cmp_currency (&acfg.liability_limit,
- &acfg.annual_fee)) ||
- (0 !=
- strcasecmp (acfg.currency,
- acfg.annual_fee.currency)) )
- {
- GNUNET_break_op (0);
- GNUNET_JSON_parse_free (spec);
- response_code = 0;
- break;
- }
-
if (! json_is_array (methods))
{
GNUNET_break_op (0);