From 7d62fa065bba408860a79fe121a62ef8f515159c Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 14 Oct 2021 14:45:10 +0200 Subject: start with KYC support in DB --- src/exchange/taler-exchange-httpd.c | 48 ++++++++++++++++ src/exchange/taler-exchange-httpd.h | 14 +++++ src/exchange/taler-exchange-httpd_withdraw.c | 13 ++++- src/exchangedb/Makefile.am | 4 +- src/exchangedb/drop0001.sql | 22 ++++++- src/exchangedb/drop0002.sql | 31 ---------- src/exchangedb/drop0003.sql | 26 --------- src/exchangedb/plugin_exchangedb_postgres.c | 76 +++++++++++++++++++++--- src/exchangedb/test_exchangedb.c | 18 ++++-- src/include/taler_exchangedb_plugin.h | 86 ++++++++++++++++++++++++---- src/include/taler_util.h | 4 +- src/util/config.c | 14 ++--- 12 files changed, 259 insertions(+), 97 deletions(-) delete mode 100644 src/exchangedb/drop0002.sql delete mode 100644 src/exchangedb/drop0003.sql diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index b7845f5aa..9f0abb0e3 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c @@ -1075,6 +1075,48 @@ handle_mhd_request (void *cls, } +/** + * Load general KYC configuration parameters for the exchange server into the + * #TEH_kyc_config variable. + * + * @return #GNUNET_OK on success + */ +static enum GNUNET_GenericReturnValue +parse_kyc_settings (void) +{ + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_time (TEH_cfg, + "exchange", + "KYC_WITHDRAW_PERIOD", + &TEH_kyc_config.withdraw_period)) + { + GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, + "exchange", + "KYC_WITHDRAW_PERIOD", + "valid relative time expected"); + return GNUNET_SYSERR; + } + if (GNUNET_TIME_relative_is_zero (TEH_kyc_config.withdraw_period)) + return GNUNET_OK; + if (GNUNET_OK != + TALER_config_get_amount (TEH_cfg, + "exchange", + "KYC_WITHDRAW_LIMIT", + &TEH_kyc_config.withdraw_limit)) + return GNUNET_SYSERR; + if (0 != strcasecmp (TEH_kyc_config.withdraw_limit.currency, + TEH_currency)) + { + GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, + "exchange", + "KYC_WITHDRAW_LIMIT", + "currency mismatch"); + return GNUNET_SYSERR; + } + return GNUNET_OK; +} + + /** * Load OAuth2.0 configuration parameters for the exchange server into the * #TEH_kyc_config variable. @@ -1265,6 +1307,12 @@ exchange_serve_process_config (void) } GNUNET_free (master_public_key_str); } + if (TEH_KYC_NONE != TEH_kyc_config.mode) + { + if (GNUNET_OK != + parse_kyc_settings ()) + return GNUNET_SYSERR; + } GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Launching exchange with public key `%s'...\n", GNUNET_p2s (&TEH_master_public_key.eddsa_pub)); diff --git a/src/exchange/taler-exchange-httpd.h b/src/exchange/taler-exchange-httpd.h index bf41d227d..7c95c9dc0 100644 --- a/src/exchange/taler-exchange-httpd.h +++ b/src/exchange/taler-exchange-httpd.h @@ -56,6 +56,20 @@ struct TEH_KycOptions */ enum TEH_KycMode mode; + /** + * Maximum amount that can be withdrawn in @e withdraw_period without + * needing KYC. + * Only valid if @e mode is not #TEH_KYC_NONE and + * if @e withdraw_period is non-zero. + */ + struct TALER_Amount withdraw_limit; + + /** + * Time period over which @e withdraw_limit applies. + * Only valid if @e mode is not #TEH_KYC_NONE. + */ + struct GNUNET_TIME_Relative withdraw_period; + /** * Details depending on @e mode. */ diff --git a/src/exchange/taler-exchange-httpd_withdraw.c b/src/exchange/taler-exchange-httpd_withdraw.c index d9cba045c..ca5618af6 100644 --- a/src/exchange/taler-exchange-httpd_withdraw.c +++ b/src/exchange/taler-exchange-httpd_withdraw.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2019 Taler Systems SA + Copyright (C) 2014-2021 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -165,6 +165,7 @@ withdraw_transaction (void *cls, struct TALER_EXCHANGEDB_Reserve r; enum GNUNET_DB_QueryStatus qs; struct TALER_DenominationSignature denom_sig; + struct TALER_EXCHANGEDB_KycStatus kyc; #if OPTIMISTIC_SIGN /* store away optimistic signature to protect @@ -209,7 +210,8 @@ withdraw_transaction (void *cls, "Trying to withdraw from reserve: %s\n", TALER_B2S (&r.pub)); qs = TEH_plugin->reserves_get (TEH_plugin->cls, - &r); + &r, + &kyc); if (0 > qs) { if (GNUNET_DB_STATUS_HARD_ERROR == qs) @@ -268,6 +270,13 @@ withdraw_transaction (void *cls, return GNUNET_DB_STATUS_HARD_ERROR; } + if ( (! kyc.ok) && + (TEH_KYC_NONE != TEH_kyc_config.mode) ) + { + // FIXME: check if we are above the limit + // for KYC, and if so, deny the transaction! + } + /* Balance is good, sign the coin! */ #if ! OPTIMISTIC_SIGN if (NULL == wc->collectable.sig.rsa_signature) diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am index eae037267..37b5f015a 100644 --- a/src/exchangedb/Makefile.am +++ b/src/exchangedb/Makefile.am @@ -19,9 +19,7 @@ sql_DATA = \ exchange-0001.sql \ exchange-0002.sql \ exchange-0003.sql \ - drop0001.sql \ - drop0002.sql \ - drop0003.sql + drop0001.sql EXTRA_DIST = \ exchangedb.conf \ diff --git a/src/exchangedb/drop0001.sql b/src/exchangedb/drop0001.sql index f5a28192f..507393e57 100644 --- a/src/exchangedb/drop0001.sql +++ b/src/exchangedb/drop0001.sql @@ -22,6 +22,19 @@ BEGIN; -- Unlike the other SQL files, it SHOULD be updated to reflect the -- latest requirements for dropping tables. + +-- Drops for exchange-0003.sql +DROP TABLE IF EXISTS revolving_work_shards CASCADE; + + +-- Drops for exchange-0002.sql +DROP TABLE IF EXISTS auditors CASCADE; +DROP TABLE IF EXISTS auditor_denom_sigs CASCADE; +DROP TABLE IF EXISTS exchange_sign_keys CASCADE; +DROP TABLE IF EXISTS wire_accounts CASCADE; +DROP TABLE IF EXISTS signkey_revocations CASCADE; +DROP TABLE IF EXISTS work_shards CASCADE; + -- Drops for 0001.sql DROP TABLE IF EXISTS prewire CASCADE; DROP TABLE IF EXISTS recoup CASCADE; @@ -42,8 +55,15 @@ DROP TABLE IF EXISTS reserves CASCADE; DROP TABLE IF EXISTS denomination_revocations CASCADE; DROP TABLE IF EXISTS denominations CASCADE; --- Unregister patch (0001.sql) + +-- Unregister patch (exchange-0001.sql) SELECT _v.unregister_patch('exchange-0001'); +-- Unregister patch (exchange-0002.sql) +SELECT _v.unregister_patch('exchange-0002'); + +-- Unregister patch (exchange-0003.sql) +SELECT _v.unregister_patch('exchange-0003'); + -- And we're out of here... COMMIT; diff --git a/src/exchangedb/drop0002.sql b/src/exchangedb/drop0002.sql deleted file mode 100644 index 12db64c54..000000000 --- a/src/exchangedb/drop0002.sql +++ /dev/null @@ -1,31 +0,0 @@ --- --- This file is part of TALER --- Copyright (C) 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 --- - --- Everything in one big transaction -BEGIN; - --- Unregister patch (0002.sql) -SELECT _v.unregister_patch('exchange-0002'); - -DROP TABLE IF EXISTS auditors CASCADE; -DROP TABLE IF EXISTS auditor_denom_sigs CASCADE; -DROP TABLE IF EXISTS exchange_sign_keys CASCADE; -DROP TABLE IF EXISTS wire_accounts CASCADE; -DROP TABLE IF EXISTS signkey_revocations CASCADE; -DROP TABLE IF EXISTS work_shards CASCADE; - --- And we're out of here... -COMMIT; diff --git a/src/exchangedb/drop0003.sql b/src/exchangedb/drop0003.sql deleted file mode 100644 index fbdab04c6..000000000 --- a/src/exchangedb/drop0003.sql +++ /dev/null @@ -1,26 +0,0 @@ --- --- This file is part of TALER --- Copyright (C) 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 --- - --- Everything in one big transaction -BEGIN; - --- Unregister patch (0003.sql) -SELECT _v.unregister_patch('exchange-0003'); - -DROP TABLE IF EXISTS revolving_work_shards CASCADE; - --- And we're out of here... -COMMIT; diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index 74dc8779b..34b785e7f 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -347,6 +347,19 @@ prepare_statements (struct PostgresClosure *pg) " WHERE denom_pub_hash=$1);", 1), /* Used in #postgres_reserves_get() */ + GNUNET_PQ_make_prepare ("reserves_get_with_kyc", + "SELECT" + " current_balance_val" + ",current_balance_frac" + ",expiration_date" + ",gc_date" + ",FALSE AS kyc_ok" // FIXME + ",CAST (0 AS INT8) AS payment_target_uuid" // FIXME + " FROM reserves" + " WHERE reserve_pub=$1" + " LIMIT 1;", + 1), + /* Used in #reserves_get() */ GNUNET_PQ_make_prepare ("reserves_get", "SELECT" " current_balance_val" @@ -3464,10 +3477,56 @@ postgres_iterate_auditor_denominations ( * @param[in,out] reserve the reserve data. The public key of the reserve should be * set in this structure; it is used to query the database. The balance * and expiration are then filled accordingly. + * @param[out] kyc set to the KYC status of the reserve * @return transaction status */ static enum GNUNET_DB_QueryStatus postgres_reserves_get (void *cls, + struct TALER_EXCHANGEDB_Reserve *reserve, + struct TALER_EXCHANGEDB_KycStatus *kyc) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_auto_from_type (&reserve->pub), + GNUNET_PQ_query_param_end + }; + uint8_t ok8; + struct GNUNET_PQ_ResultSpec rs[] = { + TALER_PQ_RESULT_SPEC_AMOUNT ("current_balance", + &reserve->balance), + TALER_PQ_result_spec_absolute_time ("expiration_date", + &reserve->expiry), + TALER_PQ_result_spec_absolute_time ("gc_date", + &reserve->gc), + GNUNET_PQ_result_spec_uint64 ("payment_target_uuid", + &kyc->payment_target_uuid), + GNUNET_PQ_result_spec_auto_from_type ("kyc_ok", + &ok8), + GNUNET_PQ_result_spec_end + }; + enum GNUNET_DB_QueryStatus qs; + + qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn, + "reserves_get_with_kyc", + params, + rs); + kyc->type = TALER_EXCHANGEDB_KYC_WITHDRAW; + kyc->ok = (0 != ok8); + return qs; +} + + +/** + * Get the summary of a reserve. + * + * @param cls the `struct PostgresClosure` with the plugin-specific state + * @param[in,out] reserve the reserve data. The public key of the reserve should be + * set in this structure; it is used to query the database. The balance + * and expiration are then filled accordingly. + * @return transaction status + */ +static enum GNUNET_DB_QueryStatus +reserves_get_internal (void *cls, struct TALER_EXCHANGEDB_Reserve *reserve) { struct PostgresClosure *pg = cls; @@ -3476,9 +3535,12 @@ postgres_reserves_get (void *cls, GNUNET_PQ_query_param_end }; struct GNUNET_PQ_ResultSpec rs[] = { - TALER_PQ_RESULT_SPEC_AMOUNT ("current_balance", &reserve->balance), - TALER_PQ_result_spec_absolute_time ("expiration_date", &reserve->expiry), - TALER_PQ_result_spec_absolute_time ("gc_date", &reserve->gc), + TALER_PQ_RESULT_SPEC_AMOUNT ("current_balance", + &reserve->balance), + TALER_PQ_result_spec_absolute_time ("expiration_date", + &reserve->expiry), + TALER_PQ_result_spec_absolute_time ("gc_date", + &reserve->gc), GNUNET_PQ_result_spec_end }; @@ -3699,7 +3761,7 @@ postgres_reserves_in_insert (void *cls, { enum GNUNET_DB_QueryStatus reserve_exists; - reserve_exists = postgres_reserves_get (pg, + reserve_exists = reserves_get_internal (pg, &reserve); switch (reserve_exists) { @@ -3916,7 +3978,7 @@ postgres_insert_withdraw_info ( /* update reserve balance */ reserve.pub = collectable->reserve_pub; if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - (qs = postgres_reserves_get (pg, + (qs = reserves_get_internal (pg, &reserve))) { /* Should have been checked before we got here... */ @@ -6875,7 +6937,7 @@ postgres_insert_reserve_closed ( /* update reserve balance */ reserve.pub = *reserve_pub; if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - (qs = postgres_reserves_get (cls, + (qs = reserves_get_internal (cls, &reserve))) { /* Existence should have been checked before we got here... */ @@ -8667,7 +8729,7 @@ postgres_insert_recoup_request ( /* Update reserve balance */ reserve.pub = *reserve_pub; - qs = postgres_reserves_get (pg, + qs = reserves_get_internal (pg, &reserve); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) { diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index 655d2f53e..bfe131639 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c @@ -154,22 +154,25 @@ drop: * @return #GNUNET_OK if the given reserve has the same balance and expiration * as the given parameters; #GNUNET_SYSERR if not */ -static int +static enum GNUNET_GenericReturnValue check_reserve (const struct TALER_ReservePublicKeyP *pub, uint64_t value, uint32_t fraction, const char *currency) { struct TALER_EXCHANGEDB_Reserve reserve; + struct TALER_EXCHANGEDB_KycStatus kyc; reserve.pub = *pub; FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->reserves_get (plugin->cls, - &reserve)); + &reserve, + &kyc)); FAILIF (value != reserve.balance.value); FAILIF (fraction != reserve.balance.fraction); - FAILIF (0 != strcmp (currency, reserve.balance.currency)); - + FAILIF (0 != strcmp (currency, + reserve.balance.currency)); + FAILIF (kyc.ok); return GNUNET_OK; drop: return GNUNET_SYSERR; @@ -1692,11 +1695,13 @@ run (void *cls) struct TALER_EXCHANGEDB_Reserve pre_reserve; struct TALER_EXCHANGEDB_Reserve post_reserve; struct TALER_Amount delta; + struct TALER_EXCHANGEDB_KycStatus kyc; pre_reserve.pub = reserve_pub; FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->reserves_get (plugin->cls, - &pre_reserve)); + &pre_reserve, + &kyc)); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->insert_recoup_request (plugin->cls, &reserve_pub, @@ -1709,7 +1714,8 @@ run (void *cls) post_reserve.pub = reserve_pub; FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->reserves_get (plugin->cls, - &post_reserve)); + &post_reserve, + &kyc)); FAILIF (0 >= TALER_amount_subtract (&delta, &post_reserve.balance, diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h index 03e0b64c3..d94a985d8 100644 --- a/src/include/taler_exchangedb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -1533,7 +1533,7 @@ typedef void * @param done flag set if the deposit was already executed (or not) * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop */ -typedef int +typedef enum GNUNET_GenericReturnValue (*TALER_EXCHANGEDB_DepositCallback)( void *cls, uint64_t rowid, @@ -1565,7 +1565,7 @@ typedef int * @param rc what is the commitment * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop */ -typedef int +typedef enum GNUNET_GenericReturnValue (*TALER_EXCHANGEDB_RefreshesCallback)( void *cls, uint64_t rowid, @@ -1585,7 +1585,7 @@ typedef int * @param amount_with_fee amount being refunded * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop */ -typedef int +typedef enum GNUNET_GenericReturnValue (*TALER_EXCHANGEDB_RefundCoinCallback)( void *cls, const struct TALER_Amount *amount_with_fee); @@ -1625,6 +1625,66 @@ struct TALER_EXCHANGEDB_RefreshRevealedCoin }; +/** + * Types of operations that require KYC checks. + */ +enum TALER_EXCHANGEDB_KycType +{ + /** + * KYC to be applied for simple withdraws without + * the involvement of wallet-to-wallet payments. + * Tied to the payto:// of the debited account. + */ + TALER_EXCHANGEDB_KYC_WITHDRAW = 1, + + /** + * KYC to be applied for simple deposits to a + * merchant's bank account. Tied to the payto:// + * of the credited account. + */ + TALER_EXCHANGEDB_KYC_DEPOSIT = 2, + + /** + * KYC that is self-applied by a wallet that is exceeding the amount + * threshold. Tied to the reserve-account public key that identifies the + * funds-holding wallet. + */ + TALER_EXCHANGEDB_KYC_BALANCE = 3, + + /** + * KYC that is triggered upon wallet-to-wallet + * payments for the recipient of funds. Tied to the + * reserve public key that identifies the receiving + * wallet. + */ + TALER_EXCHANGEDB_KYC_W2W = 4 +}; + + +/** + * Generic KYC status for some operation. + */ +struct TALER_EXCHANGEDB_KycStatus +{ + /** + * Number that identifies the KYC target the operation + * was about. + */ + uint64_t payment_target_uuid; + + /** + * What kind of KYC operation is this? + */ + enum TALER_EXCHANGEDB_KycType type; + + /** + * True if the KYC status is "satisfied". + */ + bool ok; + +}; + + /** * Function called with information about a refresh order. * @@ -1660,7 +1720,7 @@ typedef void * @param amount_with_fee amount that was deposited including fee * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop */ -typedef int +typedef enum GNUNET_GenericReturnValue (*TALER_EXCHANGEDB_RefundCallback)( void *cls, uint64_t rowid, @@ -1685,7 +1745,7 @@ typedef int * @param execution_date when did we receive the funds * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop */ -typedef int +typedef enum GNUNET_GenericReturnValue (*TALER_EXCHANGEDB_ReserveInCallback)( void *cls, uint64_t rowid, @@ -1745,7 +1805,7 @@ typedef void * @param amount_with_fee amount that was withdrawn * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop */ -typedef int +typedef enum GNUNET_GenericReturnValue (*TALER_EXCHANGEDB_WithdrawCallback)( void *cls, uint64_t rowid, @@ -1838,7 +1898,7 @@ typedef void * @param amount amount that was wired * @return #GNUNET_OK to continue, #GNUNET_SYSERR to stop iteration */ -typedef int +typedef enum GNUNET_GenericReturnValue (*TALER_EXCHANGEDB_WireTransferOutCallback)( void *cls, uint64_t rowid, @@ -1859,7 +1919,7 @@ typedef int * @param finished did we complete the transfer yet? * @return #GNUNET_OK to continue, #GNUNET_SYSERR to stop iteration */ -typedef int +typedef enum GNUNET_GenericReturnValue (*TALER_EXCHANGEDB_WirePreparationCallback)(void *cls, uint64_t rowid, const char *wire_method, @@ -1882,7 +1942,7 @@ typedef int * @param coin_blind blinding factor used to blind the coin * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop */ -typedef int +typedef enum GNUNET_GenericReturnValue (*TALER_EXCHANGEDB_RecoupCallback)( void *cls, uint64_t rowid, @@ -1911,7 +1971,7 @@ typedef int * @param coin_blind blinding factor used to blind the coin * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop */ -typedef int +typedef enum GNUNET_GenericReturnValue (*TALER_EXCHANGEDB_RecoupRefreshCallback)( void *cls, uint64_t rowid, @@ -1939,7 +1999,7 @@ typedef int * @param wtid identifier used for the wire transfer * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop */ -typedef int +typedef enum GNUNET_GenericReturnValue (*TALER_EXCHANGEDB_ReserveClosedCallback)( void *cls, uint64_t rowid, @@ -2295,11 +2355,13 @@ struct TALER_EXCHANGEDB_Plugin * @param[in,out] reserve the reserve data. The public key of the reserve should be set * in this structure; it is used to query the database. The balance * and expiration are then filled accordingly. + * @param[out] kyc set to the KYC status of the reserve * @return transaction status */ enum GNUNET_DB_QueryStatus (*reserves_get)(void *cls, - struct TALER_EXCHANGEDB_Reserve *reserve); + struct TALER_EXCHANGEDB_Reserve *reserve, + struct TALER_EXCHANGEDB_KycStatus *kyc); /** diff --git a/src/include/taler_util.h b/src/include/taler_util.h index 68c4b52de..2c556be27 100644 --- a/src/include/taler_util.h +++ b/src/include/taler_util.h @@ -136,7 +136,7 @@ TALER_b2s (const void *buf, * @param[out] denom set to the amount found in configuration * @return #GNUNET_OK on success, #GNUNET_SYSERR on error */ -int +enum GNUNET_GenericReturnValue TALER_config_get_amount (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, @@ -151,7 +151,7 @@ TALER_config_get_amount (const struct GNUNET_CONFIGURATION_Handle *cfg, * @param[out] currency where to write the result * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure */ -int +enum GNUNET_GenericReturnValue TALER_config_get_currency (const struct GNUNET_CONFIGURATION_Handle *cfg, char **currency); diff --git a/src/util/config.c b/src/util/config.c index e533a4ec3..d368d346e 100644 --- a/src/util/config.c +++ b/src/util/config.c @@ -32,7 +32,7 @@ * @param[out] denom set to the amount found in configuration * @return #GNUNET_OK on success, #GNUNET_SYSERR on error */ -int +enum GNUNET_GenericReturnValue TALER_config_get_amount (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, @@ -59,7 +59,7 @@ TALER_config_get_amount (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, section, option, - "valid amount"); + "invalid amount"); return GNUNET_SYSERR; } GNUNET_free (str); @@ -75,7 +75,7 @@ TALER_config_get_amount (const struct GNUNET_CONFIGURATION_Handle *cfg, * @param[out] currency where to write the result * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure */ -int +enum GNUNET_GenericReturnValue TALER_config_get_currency (const struct GNUNET_CONFIGURATION_Handle *cfg, char **currency) { @@ -92,10 +92,10 @@ TALER_config_get_currency (const struct GNUNET_CONFIGURATION_Handle *cfg, } if (strlen (*currency) >= TALER_CURRENCY_LEN) { - fprintf (stderr, - "Currency `%s' longer than the allowed limit of %u characters.", - *currency, - (unsigned int) TALER_CURRENCY_LEN); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Currency `%s' longer than the allowed limit of %u characters.", + *currency, + (unsigned int) TALER_CURRENCY_LEN); GNUNET_free (*currency); *currency = NULL; return GNUNET_SYSERR; -- cgit v1.2.3