start with KYC support in DB
This commit is contained in:
parent
1b119edd62
commit
7d62fa065b
@ -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
|
* Load OAuth2.0 configuration parameters for the exchange server into the
|
||||||
* #TEH_kyc_config variable.
|
* #TEH_kyc_config variable.
|
||||||
@ -1265,6 +1307,12 @@ exchange_serve_process_config (void)
|
|||||||
}
|
}
|
||||||
GNUNET_free (master_public_key_str);
|
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,
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
"Launching exchange with public key `%s'...\n",
|
"Launching exchange with public key `%s'...\n",
|
||||||
GNUNET_p2s (&TEH_master_public_key.eddsa_pub));
|
GNUNET_p2s (&TEH_master_public_key.eddsa_pub));
|
||||||
|
@ -56,6 +56,20 @@ struct TEH_KycOptions
|
|||||||
*/
|
*/
|
||||||
enum TEH_KycMode mode;
|
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.
|
* Details depending on @e mode.
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
This file is part of TALER
|
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
|
TALER is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Affero General Public License as
|
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;
|
struct TALER_EXCHANGEDB_Reserve r;
|
||||||
enum GNUNET_DB_QueryStatus qs;
|
enum GNUNET_DB_QueryStatus qs;
|
||||||
struct TALER_DenominationSignature denom_sig;
|
struct TALER_DenominationSignature denom_sig;
|
||||||
|
struct TALER_EXCHANGEDB_KycStatus kyc;
|
||||||
|
|
||||||
#if OPTIMISTIC_SIGN
|
#if OPTIMISTIC_SIGN
|
||||||
/* store away optimistic signature to protect
|
/* store away optimistic signature to protect
|
||||||
@ -209,7 +210,8 @@ withdraw_transaction (void *cls,
|
|||||||
"Trying to withdraw from reserve: %s\n",
|
"Trying to withdraw from reserve: %s\n",
|
||||||
TALER_B2S (&r.pub));
|
TALER_B2S (&r.pub));
|
||||||
qs = TEH_plugin->reserves_get (TEH_plugin->cls,
|
qs = TEH_plugin->reserves_get (TEH_plugin->cls,
|
||||||
&r);
|
&r,
|
||||||
|
&kyc);
|
||||||
if (0 > qs)
|
if (0 > qs)
|
||||||
{
|
{
|
||||||
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
|
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
|
||||||
@ -268,6 +270,13 @@ withdraw_transaction (void *cls,
|
|||||||
return GNUNET_DB_STATUS_HARD_ERROR;
|
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! */
|
/* Balance is good, sign the coin! */
|
||||||
#if ! OPTIMISTIC_SIGN
|
#if ! OPTIMISTIC_SIGN
|
||||||
if (NULL == wc->collectable.sig.rsa_signature)
|
if (NULL == wc->collectable.sig.rsa_signature)
|
||||||
|
@ -19,9 +19,7 @@ sql_DATA = \
|
|||||||
exchange-0001.sql \
|
exchange-0001.sql \
|
||||||
exchange-0002.sql \
|
exchange-0002.sql \
|
||||||
exchange-0003.sql \
|
exchange-0003.sql \
|
||||||
drop0001.sql \
|
drop0001.sql
|
||||||
drop0002.sql \
|
|
||||||
drop0003.sql
|
|
||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
exchangedb.conf \
|
exchangedb.conf \
|
||||||
|
@ -22,6 +22,19 @@ BEGIN;
|
|||||||
-- Unlike the other SQL files, it SHOULD be updated to reflect the
|
-- Unlike the other SQL files, it SHOULD be updated to reflect the
|
||||||
-- latest requirements for dropping tables.
|
-- 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
|
-- Drops for 0001.sql
|
||||||
DROP TABLE IF EXISTS prewire CASCADE;
|
DROP TABLE IF EXISTS prewire CASCADE;
|
||||||
DROP TABLE IF EXISTS recoup 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 denomination_revocations CASCADE;
|
||||||
DROP TABLE IF EXISTS denominations CASCADE;
|
DROP TABLE IF EXISTS denominations CASCADE;
|
||||||
|
|
||||||
-- Unregister patch (0001.sql)
|
|
||||||
|
-- Unregister patch (exchange-0001.sql)
|
||||||
SELECT _v.unregister_patch('exchange-0001');
|
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...
|
-- And we're out of here...
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
@ -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 <http://www.gnu.org/licenses/>
|
|
||||||
--
|
|
||||||
|
|
||||||
-- 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;
|
|
@ -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 <http://www.gnu.org/licenses/>
|
|
||||||
--
|
|
||||||
|
|
||||||
-- 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;
|
|
@ -347,6 +347,19 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
" WHERE denom_pub_hash=$1);",
|
" WHERE denom_pub_hash=$1);",
|
||||||
1),
|
1),
|
||||||
/* Used in #postgres_reserves_get() */
|
/* 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",
|
GNUNET_PQ_make_prepare ("reserves_get",
|
||||||
"SELECT"
|
"SELECT"
|
||||||
" current_balance_val"
|
" 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
|
* @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
|
* set in this structure; it is used to query the database. The balance
|
||||||
* and expiration are then filled accordingly.
|
* and expiration are then filled accordingly.
|
||||||
|
* @param[out] kyc set to the KYC status of the reserve
|
||||||
* @return transaction status
|
* @return transaction status
|
||||||
*/
|
*/
|
||||||
static enum GNUNET_DB_QueryStatus
|
static enum GNUNET_DB_QueryStatus
|
||||||
postgres_reserves_get (void *cls,
|
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 TALER_EXCHANGEDB_Reserve *reserve)
|
||||||
{
|
{
|
||||||
struct PostgresClosure *pg = cls;
|
struct PostgresClosure *pg = cls;
|
||||||
@ -3476,9 +3535,12 @@ postgres_reserves_get (void *cls,
|
|||||||
GNUNET_PQ_query_param_end
|
GNUNET_PQ_query_param_end
|
||||||
};
|
};
|
||||||
struct GNUNET_PQ_ResultSpec rs[] = {
|
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||||
TALER_PQ_RESULT_SPEC_AMOUNT ("current_balance", &reserve->balance),
|
TALER_PQ_RESULT_SPEC_AMOUNT ("current_balance",
|
||||||
TALER_PQ_result_spec_absolute_time ("expiration_date", &reserve->expiry),
|
&reserve->balance),
|
||||||
TALER_PQ_result_spec_absolute_time ("gc_date", &reserve->gc),
|
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
|
GNUNET_PQ_result_spec_end
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -3699,7 +3761,7 @@ postgres_reserves_in_insert (void *cls,
|
|||||||
{
|
{
|
||||||
enum GNUNET_DB_QueryStatus reserve_exists;
|
enum GNUNET_DB_QueryStatus reserve_exists;
|
||||||
|
|
||||||
reserve_exists = postgres_reserves_get (pg,
|
reserve_exists = reserves_get_internal (pg,
|
||||||
&reserve);
|
&reserve);
|
||||||
switch (reserve_exists)
|
switch (reserve_exists)
|
||||||
{
|
{
|
||||||
@ -3916,7 +3978,7 @@ postgres_insert_withdraw_info (
|
|||||||
/* update reserve balance */
|
/* update reserve balance */
|
||||||
reserve.pub = collectable->reserve_pub;
|
reserve.pub = collectable->reserve_pub;
|
||||||
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
|
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
|
||||||
(qs = postgres_reserves_get (pg,
|
(qs = reserves_get_internal (pg,
|
||||||
&reserve)))
|
&reserve)))
|
||||||
{
|
{
|
||||||
/* Should have been checked before we got here... */
|
/* Should have been checked before we got here... */
|
||||||
@ -6875,7 +6937,7 @@ postgres_insert_reserve_closed (
|
|||||||
/* update reserve balance */
|
/* update reserve balance */
|
||||||
reserve.pub = *reserve_pub;
|
reserve.pub = *reserve_pub;
|
||||||
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
|
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
|
||||||
(qs = postgres_reserves_get (cls,
|
(qs = reserves_get_internal (cls,
|
||||||
&reserve)))
|
&reserve)))
|
||||||
{
|
{
|
||||||
/* Existence should have been checked before we got here... */
|
/* Existence should have been checked before we got here... */
|
||||||
@ -8667,7 +8729,7 @@ postgres_insert_recoup_request (
|
|||||||
|
|
||||||
/* Update reserve balance */
|
/* Update reserve balance */
|
||||||
reserve.pub = *reserve_pub;
|
reserve.pub = *reserve_pub;
|
||||||
qs = postgres_reserves_get (pg,
|
qs = reserves_get_internal (pg,
|
||||||
&reserve);
|
&reserve);
|
||||||
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
|
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
|
||||||
{
|
{
|
||||||
|
@ -154,22 +154,25 @@ drop:
|
|||||||
* @return #GNUNET_OK if the given reserve has the same balance and expiration
|
* @return #GNUNET_OK if the given reserve has the same balance and expiration
|
||||||
* as the given parameters; #GNUNET_SYSERR if not
|
* as the given parameters; #GNUNET_SYSERR if not
|
||||||
*/
|
*/
|
||||||
static int
|
static enum GNUNET_GenericReturnValue
|
||||||
check_reserve (const struct TALER_ReservePublicKeyP *pub,
|
check_reserve (const struct TALER_ReservePublicKeyP *pub,
|
||||||
uint64_t value,
|
uint64_t value,
|
||||||
uint32_t fraction,
|
uint32_t fraction,
|
||||||
const char *currency)
|
const char *currency)
|
||||||
{
|
{
|
||||||
struct TALER_EXCHANGEDB_Reserve reserve;
|
struct TALER_EXCHANGEDB_Reserve reserve;
|
||||||
|
struct TALER_EXCHANGEDB_KycStatus kyc;
|
||||||
|
|
||||||
reserve.pub = *pub;
|
reserve.pub = *pub;
|
||||||
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
|
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
|
||||||
plugin->reserves_get (plugin->cls,
|
plugin->reserves_get (plugin->cls,
|
||||||
&reserve));
|
&reserve,
|
||||||
|
&kyc));
|
||||||
FAILIF (value != reserve.balance.value);
|
FAILIF (value != reserve.balance.value);
|
||||||
FAILIF (fraction != reserve.balance.fraction);
|
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;
|
return GNUNET_OK;
|
||||||
drop:
|
drop:
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
@ -1692,11 +1695,13 @@ run (void *cls)
|
|||||||
struct TALER_EXCHANGEDB_Reserve pre_reserve;
|
struct TALER_EXCHANGEDB_Reserve pre_reserve;
|
||||||
struct TALER_EXCHANGEDB_Reserve post_reserve;
|
struct TALER_EXCHANGEDB_Reserve post_reserve;
|
||||||
struct TALER_Amount delta;
|
struct TALER_Amount delta;
|
||||||
|
struct TALER_EXCHANGEDB_KycStatus kyc;
|
||||||
|
|
||||||
pre_reserve.pub = reserve_pub;
|
pre_reserve.pub = reserve_pub;
|
||||||
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
|
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
|
||||||
plugin->reserves_get (plugin->cls,
|
plugin->reserves_get (plugin->cls,
|
||||||
&pre_reserve));
|
&pre_reserve,
|
||||||
|
&kyc));
|
||||||
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
|
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
|
||||||
plugin->insert_recoup_request (plugin->cls,
|
plugin->insert_recoup_request (plugin->cls,
|
||||||
&reserve_pub,
|
&reserve_pub,
|
||||||
@ -1709,7 +1714,8 @@ run (void *cls)
|
|||||||
post_reserve.pub = reserve_pub;
|
post_reserve.pub = reserve_pub;
|
||||||
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
|
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
|
||||||
plugin->reserves_get (plugin->cls,
|
plugin->reserves_get (plugin->cls,
|
||||||
&post_reserve));
|
&post_reserve,
|
||||||
|
&kyc));
|
||||||
FAILIF (0 >=
|
FAILIF (0 >=
|
||||||
TALER_amount_subtract (&delta,
|
TALER_amount_subtract (&delta,
|
||||||
&post_reserve.balance,
|
&post_reserve.balance,
|
||||||
|
@ -1533,7 +1533,7 @@ typedef void
|
|||||||
* @param done flag set if the deposit was already executed (or not)
|
* @param done flag set if the deposit was already executed (or not)
|
||||||
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
|
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
|
||||||
*/
|
*/
|
||||||
typedef int
|
typedef enum GNUNET_GenericReturnValue
|
||||||
(*TALER_EXCHANGEDB_DepositCallback)(
|
(*TALER_EXCHANGEDB_DepositCallback)(
|
||||||
void *cls,
|
void *cls,
|
||||||
uint64_t rowid,
|
uint64_t rowid,
|
||||||
@ -1565,7 +1565,7 @@ typedef int
|
|||||||
* @param rc what is the commitment
|
* @param rc what is the commitment
|
||||||
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
|
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
|
||||||
*/
|
*/
|
||||||
typedef int
|
typedef enum GNUNET_GenericReturnValue
|
||||||
(*TALER_EXCHANGEDB_RefreshesCallback)(
|
(*TALER_EXCHANGEDB_RefreshesCallback)(
|
||||||
void *cls,
|
void *cls,
|
||||||
uint64_t rowid,
|
uint64_t rowid,
|
||||||
@ -1585,7 +1585,7 @@ typedef int
|
|||||||
* @param amount_with_fee amount being refunded
|
* @param amount_with_fee amount being refunded
|
||||||
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
|
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
|
||||||
*/
|
*/
|
||||||
typedef int
|
typedef enum GNUNET_GenericReturnValue
|
||||||
(*TALER_EXCHANGEDB_RefundCoinCallback)(
|
(*TALER_EXCHANGEDB_RefundCoinCallback)(
|
||||||
void *cls,
|
void *cls,
|
||||||
const struct TALER_Amount *amount_with_fee);
|
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.
|
* Function called with information about a refresh order.
|
||||||
*
|
*
|
||||||
@ -1660,7 +1720,7 @@ typedef void
|
|||||||
* @param amount_with_fee amount that was deposited including fee
|
* @param amount_with_fee amount that was deposited including fee
|
||||||
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
|
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
|
||||||
*/
|
*/
|
||||||
typedef int
|
typedef enum GNUNET_GenericReturnValue
|
||||||
(*TALER_EXCHANGEDB_RefundCallback)(
|
(*TALER_EXCHANGEDB_RefundCallback)(
|
||||||
void *cls,
|
void *cls,
|
||||||
uint64_t rowid,
|
uint64_t rowid,
|
||||||
@ -1685,7 +1745,7 @@ typedef int
|
|||||||
* @param execution_date when did we receive the funds
|
* @param execution_date when did we receive the funds
|
||||||
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
|
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
|
||||||
*/
|
*/
|
||||||
typedef int
|
typedef enum GNUNET_GenericReturnValue
|
||||||
(*TALER_EXCHANGEDB_ReserveInCallback)(
|
(*TALER_EXCHANGEDB_ReserveInCallback)(
|
||||||
void *cls,
|
void *cls,
|
||||||
uint64_t rowid,
|
uint64_t rowid,
|
||||||
@ -1745,7 +1805,7 @@ typedef void
|
|||||||
* @param amount_with_fee amount that was withdrawn
|
* @param amount_with_fee amount that was withdrawn
|
||||||
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
|
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
|
||||||
*/
|
*/
|
||||||
typedef int
|
typedef enum GNUNET_GenericReturnValue
|
||||||
(*TALER_EXCHANGEDB_WithdrawCallback)(
|
(*TALER_EXCHANGEDB_WithdrawCallback)(
|
||||||
void *cls,
|
void *cls,
|
||||||
uint64_t rowid,
|
uint64_t rowid,
|
||||||
@ -1838,7 +1898,7 @@ typedef void
|
|||||||
* @param amount amount that was wired
|
* @param amount amount that was wired
|
||||||
* @return #GNUNET_OK to continue, #GNUNET_SYSERR to stop iteration
|
* @return #GNUNET_OK to continue, #GNUNET_SYSERR to stop iteration
|
||||||
*/
|
*/
|
||||||
typedef int
|
typedef enum GNUNET_GenericReturnValue
|
||||||
(*TALER_EXCHANGEDB_WireTransferOutCallback)(
|
(*TALER_EXCHANGEDB_WireTransferOutCallback)(
|
||||||
void *cls,
|
void *cls,
|
||||||
uint64_t rowid,
|
uint64_t rowid,
|
||||||
@ -1859,7 +1919,7 @@ typedef int
|
|||||||
* @param finished did we complete the transfer yet?
|
* @param finished did we complete the transfer yet?
|
||||||
* @return #GNUNET_OK to continue, #GNUNET_SYSERR to stop iteration
|
* @return #GNUNET_OK to continue, #GNUNET_SYSERR to stop iteration
|
||||||
*/
|
*/
|
||||||
typedef int
|
typedef enum GNUNET_GenericReturnValue
|
||||||
(*TALER_EXCHANGEDB_WirePreparationCallback)(void *cls,
|
(*TALER_EXCHANGEDB_WirePreparationCallback)(void *cls,
|
||||||
uint64_t rowid,
|
uint64_t rowid,
|
||||||
const char *wire_method,
|
const char *wire_method,
|
||||||
@ -1882,7 +1942,7 @@ typedef int
|
|||||||
* @param coin_blind blinding factor used to blind the coin
|
* @param coin_blind blinding factor used to blind the coin
|
||||||
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
|
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
|
||||||
*/
|
*/
|
||||||
typedef int
|
typedef enum GNUNET_GenericReturnValue
|
||||||
(*TALER_EXCHANGEDB_RecoupCallback)(
|
(*TALER_EXCHANGEDB_RecoupCallback)(
|
||||||
void *cls,
|
void *cls,
|
||||||
uint64_t rowid,
|
uint64_t rowid,
|
||||||
@ -1911,7 +1971,7 @@ typedef int
|
|||||||
* @param coin_blind blinding factor used to blind the coin
|
* @param coin_blind blinding factor used to blind the coin
|
||||||
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
|
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
|
||||||
*/
|
*/
|
||||||
typedef int
|
typedef enum GNUNET_GenericReturnValue
|
||||||
(*TALER_EXCHANGEDB_RecoupRefreshCallback)(
|
(*TALER_EXCHANGEDB_RecoupRefreshCallback)(
|
||||||
void *cls,
|
void *cls,
|
||||||
uint64_t rowid,
|
uint64_t rowid,
|
||||||
@ -1939,7 +1999,7 @@ typedef int
|
|||||||
* @param wtid identifier used for the wire transfer
|
* @param wtid identifier used for the wire transfer
|
||||||
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
|
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
|
||||||
*/
|
*/
|
||||||
typedef int
|
typedef enum GNUNET_GenericReturnValue
|
||||||
(*TALER_EXCHANGEDB_ReserveClosedCallback)(
|
(*TALER_EXCHANGEDB_ReserveClosedCallback)(
|
||||||
void *cls,
|
void *cls,
|
||||||
uint64_t rowid,
|
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
|
* @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
|
* in this structure; it is used to query the database. The balance
|
||||||
* and expiration are then filled accordingly.
|
* and expiration are then filled accordingly.
|
||||||
|
* @param[out] kyc set to the KYC status of the reserve
|
||||||
* @return transaction status
|
* @return transaction status
|
||||||
*/
|
*/
|
||||||
enum GNUNET_DB_QueryStatus
|
enum GNUNET_DB_QueryStatus
|
||||||
(*reserves_get)(void *cls,
|
(*reserves_get)(void *cls,
|
||||||
struct TALER_EXCHANGEDB_Reserve *reserve);
|
struct TALER_EXCHANGEDB_Reserve *reserve,
|
||||||
|
struct TALER_EXCHANGEDB_KycStatus *kyc);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,7 +136,7 @@ TALER_b2s (const void *buf,
|
|||||||
* @param[out] denom set to the amount found in configuration
|
* @param[out] denom set to the amount found in configuration
|
||||||
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
|
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
|
||||||
*/
|
*/
|
||||||
int
|
enum GNUNET_GenericReturnValue
|
||||||
TALER_config_get_amount (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
TALER_config_get_amount (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
||||||
const char *section,
|
const char *section,
|
||||||
const char *option,
|
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
|
* @param[out] currency where to write the result
|
||||||
* @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
|
* @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
|
||||||
*/
|
*/
|
||||||
int
|
enum GNUNET_GenericReturnValue
|
||||||
TALER_config_get_currency (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
TALER_config_get_currency (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
||||||
char **currency);
|
char **currency);
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
* @param[out] denom set to the amount found in configuration
|
* @param[out] denom set to the amount found in configuration
|
||||||
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
|
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
|
||||||
*/
|
*/
|
||||||
int
|
enum GNUNET_GenericReturnValue
|
||||||
TALER_config_get_amount (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
TALER_config_get_amount (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
||||||
const char *section,
|
const char *section,
|
||||||
const char *option,
|
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,
|
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
|
||||||
section,
|
section,
|
||||||
option,
|
option,
|
||||||
"valid amount");
|
"invalid amount");
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
GNUNET_free (str);
|
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
|
* @param[out] currency where to write the result
|
||||||
* @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
|
* @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
|
||||||
*/
|
*/
|
||||||
int
|
enum GNUNET_GenericReturnValue
|
||||||
TALER_config_get_currency (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
TALER_config_get_currency (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
||||||
char **currency)
|
char **currency)
|
||||||
{
|
{
|
||||||
@ -92,10 +92,10 @@ TALER_config_get_currency (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
|||||||
}
|
}
|
||||||
if (strlen (*currency) >= TALER_CURRENCY_LEN)
|
if (strlen (*currency) >= TALER_CURRENCY_LEN)
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Currency `%s' longer than the allowed limit of %u characters.",
|
"Currency `%s' longer than the allowed limit of %u characters.",
|
||||||
*currency,
|
*currency,
|
||||||
(unsigned int) TALER_CURRENCY_LEN);
|
(unsigned int) TALER_CURRENCY_LEN);
|
||||||
GNUNET_free (*currency);
|
GNUNET_free (*currency);
|
||||||
*currency = NULL;
|
*currency = NULL;
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
|
Loading…
Reference in New Issue
Block a user