gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-donau] branch master updated (cb7b395 -> 473216a)


From: gnunet
Subject: [taler-donau] branch master updated (cb7b395 -> 473216a)
Date: Thu, 12 Oct 2023 12:12:31 +0200

This is an automated email from the git hooks/post-receive script.

lukas-matyja pushed a change to branch master
in repository donau.

    from cb7b395  [db] Some edits and added comments
     new ec6c7ee  [header] add amount header
     new 473216a  [header] remove swp file

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/include/taler_amount_lib.h    | 456 ++++++++++++++++++++++++++++++++++++++
 src/include/taler_crypto_lib.h    | 359 +-----------------------------
 src/include/taler_donau_service.h |   8 +-
 src/include/taler_util.h          |  96 +++++++-
 4 files changed, 563 insertions(+), 356 deletions(-)
 create mode 100644 src/include/taler_amount_lib.h

diff --git a/src/include/taler_amount_lib.h b/src/include/taler_amount_lib.h
new file mode 100644
index 0000000..c9a35a2
--- /dev/null
+++ b/src/include/taler_amount_lib.h
@@ -0,0 +1,456 @@
+/*
+  This file is part of TALER
+  Copyright (C) 2014, 2015, 2020 Taler Systems SA
+
+  TALER is free software; you can redistribute it and/or modify it under the
+  terms of the GNU General Public License as published by the Free Software
+  Foundation; either version 3, or (at your option) any later version.
+
+  TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+  A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License along with
+  TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/taler_amount_lib.h
+ * @brief amount-representation utility functions
+ * @author Sree Harsha Totakura <sreeharsha@totakura.in>
+ */
+#if ! defined (__TALER_UTIL_LIB_H_INSIDE__)
+#error "Only <taler_util.h> can be included directly."
+#endif
+
+#ifndef TALER_AMOUNT_LIB_H
+#define TALER_AMOUNT_LIB_H
+
+#include <stdint.h>
+#include "gnunet/gnunet_common.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#if 0                           /* keep Emacsens' auto-indent happy */
+}
+#endif
+#endif
+
+
+/**
+ * @brief Number of characters (plus 1 for 0-termination) we use to
+ * represent currency names (i.e. EUR, USD, etc.).  We use 8+4 for
+ * alignment in the `struct TALER_Amount`.  The amount is typically an
+ * ISO 4217 currency code when an alphanumeric 3-digit code is used.
+ * For regional currencies, the first character should be a "*" followed
+ * by a region-specific name (i.e. "*BRETAGNEFR").
+ */
+#define TALER_CURRENCY_LEN 12
+
+/**
+ * Taler currency length as a string.
+ */
+#define TALER_CURRENCY_LEN_STR "12"
+
+/**
+ * @brief The "fraction" value in a `struct TALER_Amount` represents which
+ * fraction of the "main" value?
+ *
+ * Note that we need sub-cent precision here as transaction fees might
+ * be that low, and as we want to support microdonations.
+ *
+ * An actual `struct Amount a` thus represents
+ * "a.value + (a.fraction / #TALER_AMOUNT_FRAC_BASE)" units of "a.currency".
+ */
+#define TALER_AMOUNT_FRAC_BASE 100000000
+
+/**
+ * @brief How many digits behind the comma are required to represent the
+ * fractional value in human readable decimal format?  Must match
+ * lg(#TALER_AMOUNT_FRAC_BASE).
+ */
+#define TALER_AMOUNT_FRAC_LEN 8
+
+/**
+ * Maximum legal 'value' for an amount, based on IEEE double (for JavaScript 
compatibility).
+ */
+#define TALER_AMOUNT_MAX_VALUE (1LLU << 52)
+
+
+GNUNET_NETWORK_STRUCT_BEGIN
+
+
+/**
+ * @brief Amount, encoded for network transmission.
+ */
+struct TALER_AmountNBO
+{
+  /**
+   * Value in the main currency, in NBO.
+   */
+  uint64_t value GNUNET_PACKED;
+
+  /**
+   * Fraction (integer multiples of #TALER_AMOUNT_FRAC_BASE), in NBO.
+   */
+  uint32_t fraction GNUNET_PACKED;
+
+  /**
+   * Type of the currency being represented.
+   */
+  char currency[TALER_CURRENCY_LEN];
+};
+
+GNUNET_NETWORK_STRUCT_END
+
+
+/**
+ * @brief Representation of monetary value in a given currency.
+ */
+struct TALER_Amount
+{
+  /**
+   * Value (numerator of fraction)
+   */
+  uint64_t value;
+
+  /**
+   * Fraction (integer multiples of #TALER_AMOUNT_FRAC_BASE).
+   */
+  uint32_t fraction;
+
+  /**
+   * Currency string, left adjusted and padded with zeros.  All zeros
+   * for "invalid" values.
+   */
+  char currency[TALER_CURRENCY_LEN];
+};
+
+
+/**
+ * Parse monetary amount, in the format "T:V.F".
+ *
+ * @param str amount string
+ * @param[out] amount amount to write the result to
+ * @return #GNUNET_OK if the string is a valid monetary amount specification,
+ *         #GNUNET_SYSERR if it is invalid.
+ */
+enum GNUNET_GenericReturnValue
+TALER_string_to_amount (const char *str,
+                        struct TALER_Amount *amount);
+
+
+/**
+ * Parse monetary amount, in the format "T:V.F".
+ * The result is stored in network byte order (NBO).
+ *
+ * @param str amount string
+ * @param[out] amount_nbo amount to write the result to
+ * @return #GNUNET_OK if the string is a valid amount specification,
+ *         #GNUNET_SYSERR if it is invalid.
+ */
+enum GNUNET_GenericReturnValue
+TALER_string_to_amount_nbo (const char *str,
+                            struct TALER_AmountNBO *amount_nbo);
+
+
+/**
+ * Get the value of "zero" in a particular currency.
+ *
+ * @param cur currency description
+ * @param[out] amount amount to write the result to
+ * @return #GNUNET_OK if @a cur is a valid currency specification,
+ *         #GNUNET_SYSERR if it is invalid.
+ */
+enum GNUNET_GenericReturnValue
+TALER_amount_set_zero (const char *cur,
+                       struct TALER_Amount *amount);
+
+
+/**
+ * Test if the given @a amount is zero.
+ *
+ * @param amount amount to compare to zero
+ * @return true if the amount is zero,
+ *         false if it is non-zero or invalid
+ */
+bool
+TALER_amount_is_zero (const struct TALER_Amount *amount);
+
+
+/**
+ * Test if the given amount is valid.
+ *
+ * @param amount amount to check
+ * @return #GNUNET_OK if @a amount is valid
+ */
+enum GNUNET_GenericReturnValue
+TALER_amount_is_valid (const struct TALER_Amount *amount);
+
+
+/**
+ * Test if the given amount is in the given currency
+ *
+ * @param amount amount to check
+ * @param currency currency to check for
+ * @return #GNUNET_OK if @a amount is in @a currency
+ */
+enum GNUNET_GenericReturnValue
+TALER_amount_is_currency (const struct TALER_Amount *amount,
+                          const char *currency);
+
+
+/**
+ * Convert amount from host to network representation.
+ *
+ * @param[out] res where to store amount in network representation
+ * @param d amount in host representation
+ */
+void
+TALER_amount_hton (struct TALER_AmountNBO *res,
+                   const struct TALER_Amount *d);
+
+
+/**
+ * Convert amount from network to host representation.
+ *
+ * @param[out] res where to store amount in host representation
+ * @param dn amount in network representation
+ */
+void
+TALER_amount_ntoh (struct TALER_Amount *res,
+                   const struct TALER_AmountNBO *dn);
+
+
+/**
+ * Compare the value/fraction of two amounts.  Does not compare the currency.
+ * Comparing amounts of different currencies will cause the program to abort().
+ * If unsure, check with #TALER_amount_cmp_currency() first to be sure that
+ * the currencies of the two amounts are identical.
+ *
+ * @param a1 first amount
+ * @param a2 second amount
+ * @return result of the comparison
+ *         -1 if `a1 < a2`
+ *          1 if `a1 > a2`
+ *          0 if `a1 == a2`.
+ */
+int
+TALER_amount_cmp (const struct TALER_Amount *a1,
+                  const struct TALER_Amount *a2);
+
+
+/**
+ * Compare the value/fraction of two amounts.  Does not compare the currency.
+ * Comparing amounts of different currencies will cause the program to abort().
+ * If unsure, check with #TALER_amount_cmp_currency() first to be sure that
+ * the currencies of the two amounts are identical. NBO variant.
+ *
+ * @param a1 first amount
+ * @param a2 second amount
+ * @return result of the comparison
+ *         -1 if `a1 < a2`
+ *          1 if `a1 > a2`
+ *          0 if `a1 == a2`.
+ */
+int
+TALER_amount_cmp_nbo (const struct TALER_AmountNBO *a1,
+                      const struct TALER_AmountNBO *a2);
+
+
+/**
+ * Test if @a a1 and @a a2 are the same currency.
+ *
+ * @param a1 amount to test
+ * @param a2 amount to test
+ * @return #GNUNET_YES if @a a1 and @a a2 are the same currency
+ *         #GNUNET_NO if the currencies are different
+ *         #GNUNET_SYSERR if either amount is invalid
+ */
+enum GNUNET_GenericReturnValue
+TALER_amount_cmp_currency (const struct TALER_Amount *a1,
+                           const struct TALER_Amount *a2);
+
+
+/**
+ * Test if @a a1 and @a a2 are the same currency, NBO variant.
+ *
+ * @param a1 amount to test
+ * @param a2 amount to test
+ * @return #GNUNET_YES if @a a1 and @a a2 are the same currency
+ *         #GNUNET_NO if the currencies are different
+ *         #GNUNET_SYSERR if either amount is invalid
+ */
+enum GNUNET_GenericReturnValue
+TALER_amount_cmp_currency_nbo (const struct TALER_AmountNBO *a1,
+                               const struct TALER_AmountNBO *a2);
+
+
+/**
+ * Possible results from calling #TALER_amount_subtract() and
+ * possibly other arithmetic operations. Negative values
+ * indicate that the operation did not generate a result.
+ */
+enum TALER_AmountArithmeticResult
+{
+
+  /**
+   * Operation succeeded, result is positive.
+   */
+  TALER_AAR_RESULT_POSITIVE = 1,
+
+  /**
+   * Operation succeeded, result is exactly zero.
+   */
+  TALER_AAR_RESULT_ZERO = 0,
+
+  /**
+   * Operation failed, the result would have been negative.
+   */
+  TALER_AAR_INVALID_NEGATIVE_RESULT = -1,
+
+  /**
+   * Operation failed, result outside of the representable range.
+   */
+  TALER_AAR_INVALID_RESULT_OVERFLOW = -2,
+
+  /**
+   * Operation failed, inputs could not be normalized.
+   */
+  TALER_AAR_INVALID_NORMALIZATION_FAILED = -3,
+
+  /**
+   * Operation failed, input currencies were not identical.
+   */
+  TALER_AAR_INVALID_CURRENCIES_INCOMPATIBLE = -4
+
+};
+
+/**
+ * Perform saturating subtraction of amounts.
+ *
+ * @param[out] diff where to store (@a a1 - @a a2), or invalid if @a a2 > @a a1
+ * @param a1 amount to subtract from
+ * @param a2 amount to subtract
+ * @return operation status, negative on failures
+ */
+enum TALER_AmountArithmeticResult
+TALER_amount_subtract (struct TALER_Amount *diff,
+                       const struct TALER_Amount *a1,
+                       const struct TALER_Amount *a2);
+
+
+/**
+ * Perform addition of amounts.
+ *
+ * @param[out] sum where to store @a a1 + @a a2, set to "invalid" on overflow
+ * @param a1 first amount to add
+ * @param a2 second amount to add
+ * @return operation status, negative on failures
+ */
+enum TALER_AmountArithmeticResult
+TALER_amount_add (struct TALER_Amount *sum,
+                  const struct TALER_Amount *a1,
+                  const struct TALER_Amount *a2);
+
+
+/**
+ * Divide an amount by a @ divisor.  Note that this function
+ * may introduce a rounding error!
+ *
+ * @param[out] result where to store @a dividend / @a divisor
+ * @param dividend amount to divide
+ * @param divisor by what to divide, must be positive
+ */
+void
+TALER_amount_divide (struct TALER_Amount *result,
+                     const struct TALER_Amount *dividend,
+                     uint32_t divisor);
+
+/**
+ * Divide one amount by another.  Note that this function
+ * may introduce a rounding error. It rounds down.
+ *
+ * @param dividend amount to divide
+ * @param divisor by what to divide, must be positive
+ * @return @a dividend / @a divisor, rounded down. -1 on currency mismatch,
+ *         INT_MAX for division by zero
+ */
+int
+TALER_amount_divide2 (const struct TALER_Amount *dividend,
+                      const struct TALER_Amount *divisor);
+
+
+/**
+ * Multiply an @a amount by a @ factor.
+ *
+ * @param[out] result where to store @a amount * @a factor
+ * @param amount amount to multiply
+ * @param factor factor by which to multiply
+ */
+enum TALER_AmountArithmeticResult
+TALER_amount_multiply (struct TALER_Amount *result,
+                       const struct TALER_Amount *amount,
+                       uint32_t factor);
+
+
+/**
+ * Normalize the given amount.
+ *
+ * @param[in,out] amount amount to normalize
+ * @return #GNUNET_OK if normalization worked
+ *         #GNUNET_NO if value was already normalized
+ *         #GNUNET_SYSERR if value was invalid or could not be normalized
+ */
+enum GNUNET_GenericReturnValue
+TALER_amount_normalize (struct TALER_Amount *amount);
+
+
+/**
+ * Convert amount to string.
+ *
+ * @param amount amount to convert to string
+ * @return freshly allocated string representation,
+ *         NULL if the @a amount was invalid
+ */
+char *
+TALER_amount_to_string (const struct TALER_Amount *amount);
+
+
+/**
+ * Convert amount to string.
+ *
+ * @param amount amount to convert to string
+ * @return statically allocated buffer with string representation,
+ *         NULL if the @a amount was invalid
+ */
+const char *
+TALER_amount2s (const struct TALER_Amount *amount);
+
+
+/**
+ * Round the amount to something that can be transferred on the wire.
+ * The rounding mode is specified via the smallest transferable unit,
+ * which must only have a fractional part *or* only a value (either
+ * of the two must be zero!).
+ *
+ * @param[in,out] amount amount to round down
+ * @param[in] round_unit unit that should be rounded down to, and
+ *            either value part or the faction must be zero (but not both)
+ * @return #GNUNET_OK on success, #GNUNET_NO if rounding was unnecessary,
+ *         #GNUNET_SYSERR if the amount or currency or @a round_unit was 
invalid
+ */
+enum GNUNET_GenericReturnValue
+TALER_amount_round_down (struct TALER_Amount *amount,
+                         const struct TALER_Amount *round_unit);
+
+
+#if 0                           /* keep Emacsens' auto-indent happy */
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h
index bc6ab67..f979fe0 100644
--- a/src/include/taler_crypto_lib.h
+++ b/src/include/taler_crypto_lib.h
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  Copyright (C) 2014-2023 Taler Systems SA
+  Copyright (C) 2023 Taler Systems SA
 
   TALER is free software; you can redistribute it and/or modify it under the
   terms of the GNU General Public License as published by the Free Software
@@ -34,21 +34,9 @@
 
 
 /**
- * Maximum number of coins we allow per operation.
+ * Maximum number of donation units we allow per operation.
  */
-#define TALER_MAX_FRESH_COINS 256
-
-/**
- * Cut-and-choose size for refreshing.  Client looses the gamble (of
- * unaccountable transfers) with probability 1/TALER_CNC_KAPPA.  Refresh cost
- * increases linearly with TALER_CNC_KAPPA, and 3 is sufficient up to a
- * income/sales tax of 66% of total transaction value.  As there is
- * no good reason to change this security parameter, we declare it
- * fixed and part of the protocol.
- */
-#define TALER_CNC_KAPPA 3
-#define TALER_CNC_KAPPA_MINUS_ONE_STR "2"
-
+#define TALER_MAX_FRESH_DONATION_UNITS 256
 
 /* ****************** Coin crypto primitives ************* */
 
@@ -148,18 +136,6 @@ struct TALER_ReserveSignatureP
 };
 
 
-/**
- * (Symmetric) key used to encrypt KYC attribute data in the database.
- */
-struct TALER_AttributeKeyP
-{
-  /**
-   * Actual key material.
-   */
-  struct GNUNET_HashCode key;
-};
-
-
 /**
  * @brief Type of public keys to for charity authorizations.
  * Charities can issue refunds using the corresponding
@@ -400,55 +376,6 @@ struct TALER_CoinSpendSignatureP
 };
 
 
-/**
- * @brief Type of private keys for age commitment in coins.
- */
-struct TALER_AgeCommitmentPrivateKeyP
-{
-#ifdef AGE_RESTRICTION_WITH_ECDSA
-  /**
-   * Taler uses EcDSA for coins when signing age verification attestation.
-   */
-  struct GNUNET_CRYPTO_EcdsaPrivateKey priv;
-#else
-  /**
-   * Taler uses Edx25519 for coins when signing age verification attestation.
-   */
-  struct GNUNET_CRYPTO_Edx25519PrivateKey priv;
-#endif
-};
-
-
-/**
- * @brief Type of public keys for age commitment in coins.
- */
-struct TALER_AgeCommitmentPublicKeyP
-{
-#ifdef AGE_RESTRICTION_WITH_ECDSA
-  /**
-   * Taler uses EcDSA for coins when signing age verification attestation.
-   */
-  struct GNUNET_CRYPTO_EcdsaPublicKey pub;
-#else
-  /**
-   * Taler uses Edx25519 for coins when signing age verification attestation.
-   */
-  struct GNUNET_CRYPTO_Edx25519PublicKey pub;
-#endif
-};
-
-
-/*
- * @brief Hash to represent the commitment to n*kappa blinded keys during a
- * age-withdrawal. It is the running SHA512 hash over the hashes of the blinded
- * envelopes of n*kappa coins.
- */
-struct TALER_AgeWithdrawCommitmentHashP
-{
-  struct GNUNET_HashCode hash;
-};
-
-
 /**
  * @brief Type of online public keys used by the wallet to establish a purse 
and the associated contract meta data.
  */
@@ -851,103 +778,6 @@ struct TALER_PickupIdentifierP
   struct GNUNET_HashCode hash;
 };
 
-
-/**
- * @brief Salted hash over the JSON object representing the manifests of
- * extensions.
- */
-struct TALER_ExtensionManifestsHashP
-{
-  /**
-   * Actual hash value.
-   */
-  struct GNUNET_HashCode hash;
-};
-
-
-/**
- * Set of the fees applying to a denomination.
- */
-struct TALER_DenomFeeSetNBOP
-{
-
-  /**
-   * The fee the donau charges when a coin of this type is withdrawn.
-   * (can be zero).
-   */
-  struct TALER_AmountNBO withdraw;
-
-  /**
-   * The fee the donau charges when a coin of this type is deposited.
-   * (can be zero).
-   */
-  struct TALER_AmountNBO deposit;
-
-  /**
-   * The fee the donau charges when a coin of this type is refreshed.
-   * (can be zero).
-   */
-  struct TALER_AmountNBO refresh;
-
-  /**
-   * The fee the donau charges when a coin of this type is refunded.
-   * (can be zero).  Note that refund fees are charged to the donor;
-   * if a refund is given, the deposit fee is also refunded.
-   */
-  struct TALER_AmountNBO refund;
-
-};
-
-
-/**
- * Set of the fees applying for a given
- * time-range and wire method.
- */
-struct TALER_WireFeeSetNBOP
-{
-
-  /**
-   * The fee the donau charges for wiring funds
-   * to a charity.
-   */
-  struct TALER_AmountNBO wire;
-
-  /**
-   * The fee the donau charges for closing a reserve
-   * and wiring the funds back to the origin account.
-   */
-  struct TALER_AmountNBO closing;
-
-};
-
-
-/**
- * Set of the fees applying globally for a given
- * time-range.
- */
-struct TALER_GlobalFeeSetNBOP
-{
-
-  /**
-   * The fee the donau charges for returning the history of a reserve or
-   * account.
-   */
-  struct TALER_AmountNBO history;
-
-  /**
-   * The fee the donau charges for keeping an account or reserve open for a
-   * year.
-   */
-  struct TALER_AmountNBO account;
-
-  /**
-   * The fee the donau charges if a purse is abandoned and this was not
-   * covered by the account limit.
-   */
-  struct TALER_AmountNBO purse;
-};
-
-
 GNUNET_NETWORK_STRUCT_END
 
 
@@ -966,179 +796,6 @@ TALER_build_pos_confirmation (const char *pos_key,
                               const struct TALER_Amount *total,
                               struct GNUNET_TIME_Timestamp ts);
 
-
-/**
- * Set of the fees applying to a denomination.
- */
-struct TALER_DenomFeeSet
-{
-
-  /**
-   * The fee the donau charges when a coin of this type is withdrawn.
-   * (can be zero).
-   */
-  struct TALER_Amount withdraw;
-
-  /**
-   * The fee the donau charges when a coin of this type is deposited.
-   * (can be zero).
-   */
-  struct TALER_Amount deposit;
-
-  /**
-   * The fee the donau charges when a coin of this type is refreshed.
-   * (can be zero).
-   */
-  struct TALER_Amount refresh;
-
-  /**
-   * The fee the donau charges when a coin of this type is refunded.
-   * (can be zero).  Note that refund fees are charged to the donor;
-   * if a refund is given, the deposit fee is also refunded.
-   */
-  struct TALER_Amount refund;
-
-};
-
-
-/**
- * Set of the fees applying for a given time-range and wire method.
- */
-struct TALER_WireFeeSet
-{
-
-  /**
-   * The fee the donau charges for wiring funds to a charity.
-   */
-  struct TALER_Amount wire;
-
-  /**
-   * The fee the donau charges for closing a reserve
-   * and wiring the funds back to the origin account.
-   */
-  struct TALER_Amount closing;
-
-};
-
-
-/**
- * Set of the fees applying globally for a given
- * time-range.
- */
-struct TALER_GlobalFeeSet
-{
-
-  /**
-   * The fee the donau charges for returning the
-   * history of a reserve or account.
-   */
-  struct TALER_Amount history;
-
-  /**
-   * The fee the donau charges for keeping
-   * an account or reserve open for a year.
-   */
-  struct TALER_Amount account;
-
-  /**
-   * The fee the donau charges if a purse
-   * is abandoned and this was not covered by
-   * the account limit.
-   */
-  struct TALER_Amount purse;
-};
-
-
-/**
- * Convert fee set from host to network byte order.
- *
- * @param[out] nbo where to write the result
- * @param fees fee set to convert
- */
-void
-TALER_denom_fee_set_hton (struct TALER_DenomFeeSetNBOP *nbo,
-                          const struct TALER_DenomFeeSet *fees);
-
-
-/**
- * Convert 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_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);
-
-
-/**
- * Compare global fee sets.
- *
- * @param f1 first set to compare
- * @param f2 second set to compare
- * @return 0 if sets are equal
- */
-int
-TALER_global_fee_set_cmp (const struct TALER_GlobalFeeSet *f1,
-                          const struct TALER_GlobalFeeSet *f2);
-
-
-/**
- * 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);
-
-
-/**
- * Compare wire fee sets.
- *
- * @param f1 first set to compare
- * @param f2 second set to compare
- * @return 0 if sets are equal
- */
-int
-TALER_wire_fee_set_cmp (const struct TALER_WireFeeSet *f1,
-                        const struct TALER_WireFeeSet *f2);
-
-
 /**
  * Hash @a rsa.
  *
@@ -1151,7 +808,7 @@ TALER_rsa_pub_hash (const struct 
GNUNET_CRYPTO_RsaPublicKey *rsa,
 
 /**
  * Hash @a cs.
- *
+ *DENOMINATION
  * @param cs key to hash
  * @param[out] h_cs where to write the result
  */
@@ -1163,23 +820,23 @@ TALER_cs_pub_hash (const struct 
GNUNET_CRYPTO_CsPublicKey *cs,
 /**
  * Types of public keys used for denominations in Taler.
  */
-enum TALER_DenominationCipher
+enum TALER_DonationUnitCipher
 {
 
   /**
    * Invalid type of signature.
    */
-  TALER_DENOMINATION_INVALID = 0,
+  TALER_DONATION_UNIT_INVALID = 0,
 
   /**
    * RSA blind signature.
    */
-  TALER_DENOMINATION_RSA = 1,
+  TALER_DONATION_UNIT_RSA = 1,
 
   /**
    * Clause Blind Schnorr signature.
    */
-  TALER_DENOMINATION_CS = 2
+  TALER_DONATION_UNIT_CS = 2
 };
 
 
diff --git a/src/include/taler_donau_service.h 
b/src/include/taler_donau_service.h
index 9238447..71d3a87 100644
--- a/src/include/taler_donau_service.h
+++ b/src/include/taler_donau_service.h
@@ -73,7 +73,7 @@ struct TALER_DonationUnitPublicKey
   /**
    * Type of the public key (RSA or CS).
    */
-  enum TALER_DenominationCipher cipher;
+  enum TALER_DonationUnitCipher cipher;
 
   /**
    * Details, depending on @e cipher.
@@ -81,14 +81,14 @@ struct TALER_DonationUnitPublicKey
   union
   {
     /**
-     * If we use #TALER_DENOMINATION_CS in @a cipher.
+     * If we use #TALER_DONATION_UNIT_CS in @a cipher.
      */
     struct GNUNET_CRYPTO_CsPublicKey cs_public_key;
 
     /**
-     * If we use #TALER_DENOMINATION_RSA in @a cipher.
+     * If we use #TALER_DONATION_UNIT_RSA in @a cipher.
      */
-    struct GNUNET_CRYPTO_RsaPublicKey *rsa_public_key;
+    struct GNUNET_CRYPTO_RsaPublicKey rsa_public_key;
 
   } details;
 };
diff --git a/src/include/taler_util.h b/src/include/taler_util.h
index c82d449..f2851b3 100644
--- a/src/include/taler_util.h
+++ b/src/include/taler_util.h
@@ -198,6 +198,100 @@ enum GNUNET_GenericReturnValue
 TALER_config_get_currency (const struct GNUNET_CONFIGURATION_Handle *cfg,
                            char **currency);
 
+/**
+ * Details about how to render a currency.
+ */
+struct TALER_CurrencySpecification
+{
+  /**
+   * Name of the currency.
+   */
+  char currency[TALER_CURRENCY_LEN];
+
+  /**
+   * Human-readable long name of the currency, e.g.
+   * "Japanese Yen".
+   */
+  char *name;
+
+  /**
+   * Character used to separate decimals.  String as
+   * multi-byte sequences may be required (UTF-8!).
+   */
+  char *decimal_separator;
+
+  /**
+   * how many digits the user may enter at most after the @e decimal_separator
+   */
+  unsigned int num_fractional_input_digits;
+
+  /**
+   * how many digits we render in normal scale after the @e decimal_separator
+   */
+  unsigned int num_fractional_normal_digits;
+
+  /**
+   * how many digits we render in after the @e decimal_separator even if all
+   * remaining digits are zero.
+   */
+  unsigned int num_fractional_trailing_zero_digits;
+
+  /**
+   * True to put the currency symbol before the number,
+   * false to put the currency symbol after the number.
+   */
+  bool is_currency_name_leading;
+
+  /**
+   * Mapping of powers of 10 to alternative currency names or symbols.
+   * Keys are the decimal powers, values the currency symbol to use.
+   * Map MUST contain an entry for "0" to the default currency symbol.
+   */
+  json_t *map_alt_unit_names;
+
+};
+
+
+/**
+ * Parse information about supported currencies from
+ * our configuration.
+ *
+ * @param cfg configuration to parse
+ * @param[out] num_currencies set to number of enabled currencies, length of 
@e cspecs
+ * @param[out] cspecs set to currency specification array
+ * @return #GNUNET_OK on success, #GNUNET_NO if zero
+ *  currency specifications were enabled,
+ *  #GNUNET_SYSERR if the configuration was malformed
+ */
+enum GNUNET_GenericReturnValue
+TALER_CONFIG_parse_currencies (const struct GNUNET_CONFIGURATION_Handle *cfg,
+                               unsigned int *num_currencies,
+                               struct TALER_CurrencySpecification **cspecs);
+
+
+/**
+ * Free @a cspecs array.
+ *
+ * @param num_currencies length of @a cspecs array
+ * @param[in] cspecs array to free
+ */
+void
+TALER_CONFIG_free_currencies (
+  unsigned int num_currencies,
+  struct TALER_CurrencySpecification cspecs[static num_currencies]);
+
+
+/**
+ * Convert a currency specification to the
+ * respective JSON object.
+ *
+ * @param cspec currency specification
+ * @return JSON object encoding @a cspec for `/config`.
+ */
+json_t *
+TALER_CONFIG_currency_specs_to_json (
+  const struct TALER_CurrencySpecification *cspec);
+
 
 /**
  * Allow user to specify an amount on the command line.
@@ -686,4 +780,4 @@ TALER_JSON_external_conversion_stop (
 
 #undef __TALER_UTIL_LIB_H_INSIDE__
 
-#endif
+#endifTALER_CURRENCY_LEN

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]