aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-03-05 11:56:58 +0100
committerChristian Grothoff <christian@grothoff.org>2022-03-05 11:56:58 +0100
commit4835ddf60b80a720657d42e2de57a79f258328cd (patch)
tree0126bd1a22c1732090922a7932c3180a29e655a7 /src/util
parent3a1f4186038783844bca225fd3892d91714b9b5f (diff)
downloadexchange-4835ddf60b80a720657d42e2de57a79f258328cd.tar.xz
introduce sets for wire fees and global fees
Diffstat (limited to 'src/util')
-rw-r--r--src/util/config.c15
-rw-r--r--src/util/util.c48
2 files changed, 62 insertions, 1 deletions
diff --git a/src/util/config.c b/src/util/config.c
index dc342fdcf..c00792469 100644
--- a/src/util/config.c
+++ b/src/util/config.c
@@ -130,6 +130,8 @@ enum GNUNET_GenericReturnValue
TALER_config_get_currency (const struct GNUNET_CONFIGURATION_Handle *cfg,
char **currency)
{
+ size_t slen;
+
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
"taler",
@@ -141,7 +143,8 @@ TALER_config_get_currency (const struct GNUNET_CONFIGURATION_Handle *cfg,
"CURRENCY");
return GNUNET_SYSERR;
}
- if (strlen (*currency) >= TALER_CURRENCY_LEN)
+ slen = strlen (*currency);
+ if (slen >= TALER_CURRENCY_LEN)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Currency `%s' longer than the allowed limit of %u characters.",
@@ -151,5 +154,15 @@ TALER_config_get_currency (const struct GNUNET_CONFIGURATION_Handle *cfg,
*currency = NULL;
return GNUNET_SYSERR;
}
+ for (size_t i = 0; i<slen; i++)
+ if (! isalpha ((unsigned char) (*currency)[i]))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Currency `%s' must only use characters from the A-Z range.",
+ *currency);
+ GNUNET_free (*currency);
+ *currency = NULL;
+ return GNUNET_SYSERR;
+ }
return GNUNET_OK;
}
diff --git a/src/util/util.c b/src/util/util.c
index 5b7181a13..6dfd65574 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -76,6 +76,54 @@ TALER_denom_fee_set_ntoh (struct TALER_DenomFeeSet *fees,
}
+void
+TALER_global_fee_set_hton (struct TALER_GlobalFeeSetNBOP *nbo,
+ const struct TALER_GlobalFeeSet *fees)
+{
+ TALER_amount_hton (&nbo->history,
+ &fees->history);
+ TALER_amount_hton (&nbo->kyc,
+ &fees->kyc);
+}
+
+
+void
+TALER_global_fee_set_ntoh (struct TALER_GlobalFeeSet *fees,
+ const struct TALER_GlobalFeeSetNBOP *nbo)
+{
+ TALER_amount_ntoh (&fees->history,
+ &nbo->history);
+ TALER_amount_ntoh (&fees->kyc,
+ &nbo->kyc);
+}
+
+
+void
+TALER_wire_fee_set_hton (struct TALER_WireFeeSetNBOP *nbo,
+ const struct TALER_WireFeeSet *fees)
+{
+ TALER_amount_hton (&nbo->wire,
+ &fees->wire);
+ TALER_amount_hton (&nbo->closing,
+ &fees->closing);
+ TALER_amount_hton (&nbo->wad,
+ &fees->wad);
+}
+
+
+void
+TALER_wire_fee_set_ntoh (struct TALER_WireFeeSet *fees,
+ const struct TALER_WireFeeSetNBOP *nbo)
+{
+ TALER_amount_ntoh (&fees->wire,
+ &nbo->wire);
+ TALER_amount_ntoh (&fees->closing,
+ &nbo->closing);
+ TALER_amount_ntoh (&fees->wad,
+ &nbo->wad);
+}
+
+
enum GNUNET_GenericReturnValue
TALER_denom_fee_check_currency (
const char *currency,