[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] branch master updated: introduce sets for wire fees and
From: |
gnunet |
Subject: |
[taler-exchange] branch master updated: introduce sets for wire fees and global fees |
Date: |
Sat, 05 Mar 2022 11:57:01 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository exchange.
The following commit(s) were added to refs/heads/master by this push:
new 4835ddf6 introduce sets for wire fees and global fees
4835ddf6 is described below
commit 4835ddf60b80a720657d42e2de57a79f258328cd
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Mar 5 11:56:58 2022 +0100
introduce sets for wire fees and global fees
---
src/include/taler_crypto_lib.h | 146 +++++++++++++++++++++++++++++++++++++++++
src/util/config.c | 15 ++++-
src/util/util.c | 48 ++++++++++++++
3 files changed, 208 insertions(+), 1 deletion(-)
diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h
index c23de357..d81f5a71 100644
--- a/src/include/taler_crypto_lib.h
+++ b/src/include/taler_crypto_lib.h
@@ -647,6 +647,57 @@ struct TALER_DenomFeeSetNBOP
};
+/**
+ * Set of the fees applying for a given
+ * time-range and wire method.
+ */
+struct TALER_WireFeeSetNBOP
+{
+
+ /**
+ * The fee the exchange charges for wiring funds
+ * to a merchant.
+ */
+ struct TALER_AmountNBO wire;
+
+ /**
+ * The fee the exchange charges for closing a reserve
+ * and wiring the funds back to the origin account.
+ */
+ struct TALER_AmountNBO closing;
+
+ /**
+ * The fee the exchange charges for cross-exchange
+ * P2P payments.
+ */
+ struct TALER_AmountNBO wad;
+
+};
+
+
+/**
+ * Set of the fees applying globally for a given
+ * time-range.
+ */
+struct TALER_GlobalFeeSetNBOP
+{
+
+ /**
+ * The fee the exchange charges for returning the
+ * history of a reserve or account.
+ */
+ struct TALER_AmountNBO history;
+
+ /**
+ * The fee the exchange charges for performing a
+ * KYC check on a reserve to turn it into an account
+ * that can be used for P2P payments.
+ */
+ struct TALER_AmountNBO kyc;
+
+};
+
+
GNUNET_NETWORK_STRUCT_END
@@ -684,6 +735,57 @@ struct TALER_DenomFeeSet
};
+/**
+ * Set of the fees applying for a given
+ * time-range and wire method.
+ */
+struct TALER_WireFeeSet
+{
+
+ /**
+ * The fee the exchange charges for wiring funds
+ * to a merchant.
+ */
+ struct TALER_Amount wire;
+
+ /**
+ * The fee the exchange charges for closing a reserve
+ * and wiring the funds back to the origin account.
+ */
+ struct TALER_Amount closing;
+
+ /**
+ * The fee the exchange charges for cross-exchange
+ * P2P payments.
+ */
+ struct TALER_Amount wad;
+
+};
+
+
+/**
+ * Set of the fees applying globally for a given
+ * time-range.
+ */
+struct TALER_GlobalFeeSet
+{
+
+ /**
+ * The fee the exchange charges for returning the
+ * history of a reserve or account.
+ */
+ struct TALER_Amount history;
+
+ /**
+ * The fee the exchange charges for performing a
+ * KYC check on a reserve to turn it into an account
+ * that can be used for P2P payments.
+ */
+ struct TALER_Amount kyc;
+
+};
+
+
/**
* Convert fee set from host to network byte order.
*
@@ -706,6 +808,50 @@ TALER_denom_fee_set_ntoh (struct TALER_DenomFeeSet *fees,
const struct TALER_DenomFeeSetNBOP *nbo);
+/**
+ * Convert global fee set from host to network byte order.
+ *
+ * @param[out] nbo where to write the result
+ * @param fees fee set to convert
+ */
+void
+TALER_global_fee_set_hton (struct TALER_GlobalFeeSetNBOP *nbo,
+ const struct TALER_GlobalFeeSet *fees);
+
+
+/**
+ * Convert global fee set from network to host network byte order.
+ *
+ * @param[out] fees where to write the result
+ * @param nbo fee set to convert
+ */
+void
+TALER_global_fee_set_ntoh (struct TALER_GlobalFeeSet *fees,
+ const struct TALER_GlobalFeeSetNBOP *nbo);
+
+
+/**
+ * Convert wire fee set from host to network byte order.
+ *
+ * @param[out] nbo where to write the result
+ * @param fees fee set to convert
+ */
+void
+TALER_wire_fee_set_hton (struct TALER_WireFeeSetNBOP *nbo,
+ const struct TALER_WireFeeSet *fees);
+
+
+/**
+ * Convert wire fee set from network to host network byte order.
+ *
+ * @param[out] fees where to write the result
+ * @param nbo fee set to convert
+ */
+void
+TALER_wire_fee_set_ntoh (struct TALER_WireFeeSet *fees,
+ const struct TALER_WireFeeSetNBOP *nbo);
+
+
/**
* Hash @a rsa.
*
diff --git a/src/util/config.c b/src/util/config.c
index dc342fdc..c0079246 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 5b7181a1..6dfd6557 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,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-exchange] branch master updated: introduce sets for wire fees and global fees,
gnunet <=