add asset_type to /keys response

This commit is contained in:
Christian Grothoff 2022-12-11 13:48:44 +01:00
parent e682f4213e
commit 58983d7455
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
4 changed files with 41 additions and 0 deletions

View File

@ -47,6 +47,14 @@ BASE_URL = http://localhost:8081/
# How long should the aggregator sleep if it has nothing to do?
AGGREGATOR_IDLE_SLEEP_INTERVAL = 60 s
# What type of asset is the exchange managing? Used to adjust
# the user-interface of the wallet.
# Possibilities include: "fiat", "regional" and "crypto".
# In the future (and already permitted but not yet supported by wallets)
# we also expect to have "stock" and "future" (and more).
# Default is "fiat".
ASSET_TYPE = "fiat"
# FIXME: document!
ROUTER_IDLE_SLEEP_INTERVAL = 60 s

View File

@ -456,6 +456,11 @@ static struct GNUNET_SCHEDULER_Task *keys_tt;
*/
static struct GNUNET_TIME_Relative signkey_legal_duration;
/**
* What type of asset are we dealing with here?
*/
static char *asset_type;
/**
* RSA security module public key, all zero if not known.
*/
@ -1279,6 +1284,17 @@ TEH_keys_init ()
"SIGNKEY_LEGAL_DURATION");
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (TEH_cfg,
"exchange",
"ASSET_TYPE",
&asset_type))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
"exchange",
"ASSET_TYPE");
asset_type = GNUNET_strdup ("fiat");
}
keys_eh = TEH_plugin->event_listen (TEH_plugin->cls,
GNUNET_TIME_UNIT_FOREVER_REL,
&es,
@ -1856,6 +1872,8 @@ create_krd (struct TEH_KeyStateHandle *ksh,
TEH_base_url),
GNUNET_JSON_pack_string ("currency",
TEH_currency),
GNUNET_JSON_pack_string ("asset_type",
asset_type),
GNUNET_JSON_pack_data_auto ("master_public_key",
&TEH_master_public_key),
GNUNET_JSON_pack_time_rel ("reserve_closing_delay",

View File

@ -358,6 +358,14 @@ struct TALER_EXCHANGE_Keys
*/
unsigned int denom_keys_size;
/**
* Asset type used by the exchange. Typical values
* are "fiat" or "crypto" or "regional" or "stock".
* Wallets should adjust their UI/UX based on this
* value.
*/
char *asset_type;
};

View File

@ -732,6 +732,7 @@ decode_keys_json (const json_t *resp_obj,
struct GNUNET_HashCode hash_xor = {0};
struct TALER_ExchangePublicKeyP pub;
const char *currency;
const char *asset_type;
json_t *wblwk = NULL;
struct GNUNET_JSON_Specification mspec[] = {
GNUNET_JSON_spec_fixed_auto ("denominations_sig",
@ -746,6 +747,8 @@ decode_keys_json (const json_t *resp_obj,
&key_data->reserve_closing_delay),
GNUNET_JSON_spec_string ("currency",
&currency),
GNUNET_JSON_spec_string ("asset_type",
&asset_type),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_json ("wallet_balance_limit_without_kyc",
&wblwk),
@ -815,6 +818,7 @@ decode_keys_json (const json_t *resp_obj,
(check_sig) ? mspec : &mspec[2],
NULL, NULL));
key_data->currency = GNUNET_strdup (currency);
key_data->asset_type = GNUNET_strdup (asset_type);
/* parse the global fees */
{
@ -1233,6 +1237,7 @@ free_key_data (struct TALER_EXCHANGE_Keys *key_data)
GNUNET_free (key_data->wallet_balance_limit_without_kyc);
GNUNET_free (key_data->version);
GNUNET_free (key_data->currency);
GNUNET_free (key_data->asset_type);
GNUNET_free (key_data->global_fees);
}
@ -1917,6 +1922,8 @@ TALER_EXCHANGE_serialize_data (struct TALER_EXCHANGE_Handle *exchange)
kd->version),
GNUNET_JSON_pack_string ("currency",
kd->currency),
GNUNET_JSON_pack_string ("asset_type",
kd->asset_type),
GNUNET_JSON_pack_data_auto ("master_public_key",
&kd->master_pub),
GNUNET_JSON_pack_time_rel ("reserve_closing_delay",