summaryrefslogtreecommitdiff
path: root/src/exchange
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-08-11 16:30:32 +0200
committerChristian Grothoff <christian@grothoff.org>2023-08-11 16:30:32 +0200
commit1b37347422f00edb648dfa78cd83083a2f80a9e8 (patch)
tree56a8c34ae3864ec25aa5c1d0e40e2e845f324998 /src/exchange
parent8d3934c7fa6224092781a2400d68e9efa94a497d (diff)
downloadexchange-1b37347422f00edb648dfa78cd83083a2f80a9e8.tar.gz
exchange-1b37347422f00edb648dfa78cd83083a2f80a9e8.tar.bz2
exchange-1b37347422f00edb648dfa78cd83083a2f80a9e8.zip
add STEFAN support to exchange
Diffstat (limited to 'src/exchange')
-rw-r--r--src/exchange/taler-exchange-httpd.c71
-rw-r--r--src/exchange/taler-exchange-httpd.h21
-rw-r--r--src/exchange/taler-exchange-httpd_keys.c8
3 files changed, 100 insertions, 0 deletions
diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c
index 7d5992935..194ec6dae 100644
--- a/src/exchange/taler-exchange-httpd.c
+++ b/src/exchange/taler-exchange-httpd.c
@@ -150,6 +150,27 @@ struct TALER_AttributeEncryptionKeyP TEH_attribute_key;
struct TALER_EXCHANGEDB_Plugin *TEH_plugin;
/**
+ * Absolute STEFAN parameter.
+ */
+struct TALER_Amount TEH_stefan_abs;
+
+/**
+ * Logarithmic STEFAN parameter.
+ */
+struct TALER_Amount TEH_stefan_log;
+
+/**
+ * Linear STEFAN parameter.
+ */
+struct TALER_Amount TEH_stefan_lin;
+
+/**
+ * Default number of fractional digits to render
+ * amounts with.
+ */
+unsigned int TEH_currency_fraction_digits;
+
+/**
* Our currency.
*/
char *TEH_currency;
@@ -1925,6 +1946,25 @@ exchange_serve_process_config (void)
"CURRENCY");
return GNUNET_SYSERR;
}
+ {
+ unsigned long long cfd;
+
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (TEH_cfg,
+ "exchange",
+ "CURRENCY_FRACTION_DIGITS",
+ &cfd))
+ cfd = 0;
+ if (cfd > 8)
+ {
+ GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
+ "taler",
+ "CURRENCY_FRACTION_DIGITS",
+ "Value must be below 8");
+ return GNUNET_SYSERR;
+ }
+ TEH_currency_fraction_digits = (unsigned int) cfd;
+ }
if (GNUNET_OK !=
TALER_config_get_amount (TEH_cfg,
"exchange",
@@ -1935,6 +1975,37 @@ exchange_serve_process_config (void)
"Need amount in section `exchange' under `AML_THRESHOLD'\n");
return GNUNET_SYSERR;
}
+ if (GNUNET_OK !=
+ TALER_config_get_amount (TEH_cfg,
+ "exchange",
+ "STEFAN_ABS",
+ &TEH_stefan_abs))
+ {
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TEH_currency,
+ &TEH_stefan_abs));
+ }
+ if (GNUNET_OK !=
+ TALER_config_get_amount (TEH_cfg,
+ "exchange",
+ "STEFAN_LOG",
+ &TEH_stefan_log))
+ {
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TEH_currency,
+ &TEH_stefan_log));
+ }
+ if (GNUNET_OK !=
+ TALER_config_get_amount (TEH_cfg,
+ "exchange",
+ "STEFAN_LIN",
+ &TEH_stefan_lin))
+ {
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TEH_currency,
+ &TEH_stefan_lin));
+ }
+
if (0 != strcmp (TEH_currency,
TEH_aml_threshold.currency))
{
diff --git a/src/exchange/taler-exchange-httpd.h b/src/exchange/taler-exchange-httpd.h
index 9fcfcd6c1..9e18f9e69 100644
--- a/src/exchange/taler-exchange-httpd.h
+++ b/src/exchange/taler-exchange-httpd.h
@@ -98,6 +98,27 @@ extern struct TALER_AttributeEncryptionKeyP TEH_attribute_key;
extern struct TALER_EXCHANGEDB_Plugin *TEH_plugin;
/**
+ * Absolute STEFAN parameter.
+ */
+extern struct TALER_Amount TEH_stefan_abs;
+
+/**
+ * Logarithmic STEFAN parameter.
+ */
+extern struct TALER_Amount TEH_stefan_log;
+
+/**
+ * Linear STEFAN parameter.
+ */
+extern struct TALER_Amount TEH_stefan_lin;
+
+/**
+ * Default number of fractional digits to render
+ * amounts with.
+ */
+extern unsigned int TEH_currency_fraction_digits;
+
+/**
* Our currency.
*/
extern char *TEH_currency;
diff --git a/src/exchange/taler-exchange-httpd_keys.c b/src/exchange/taler-exchange-httpd_keys.c
index 9623a5a30..0bb5c8138 100644
--- a/src/exchange/taler-exchange-httpd_keys.c
+++ b/src/exchange/taler-exchange-httpd_keys.c
@@ -2525,6 +2525,14 @@ create_krd (struct TEH_KeyStateHandle *ksh,
TEH_base_url),
GNUNET_JSON_pack_string ("currency",
TEH_currency),
+ GNUNET_JSON_pack_uint64 ("currency_fraction_digits",
+ TEH_currency_fraction_digits),
+ TALER_JSON_pack_amount ("stefan_abs",
+ &TEH_stefan_abs),
+ TALER_JSON_pack_amount ("stefan_log",
+ &TEH_stefan_log),
+ TALER_JSON_pack_amount ("stefan_lin",
+ &TEH_stefan_lin),
GNUNET_JSON_pack_string ("asset_type",
asset_type),
// FIXME: legacy, remove soon!