misc TODOs for KYC left
This commit is contained in:
parent
a9b2140b1e
commit
016551dbb4
@ -24,6 +24,10 @@
|
|||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "taler_curl_lib.h"
|
#include "taler_curl_lib.h"
|
||||||
|
|
||||||
|
// FIXME-workaround: without this, we somehow sometimes forget the header
|
||||||
|
// that indicates compression and then the exchange 400s us!
|
||||||
|
#undef TALER_CURL_COMPRESS_BODIES
|
||||||
|
|
||||||
#if TALER_CURL_COMPRESS_BODIES
|
#if TALER_CURL_COMPRESS_BODIES
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
#endif
|
#endif
|
||||||
@ -76,18 +80,17 @@ TALER_curl_easy_post (struct TALER_CURL_PostContext *ctx,
|
|||||||
slen = (size_t) cbuf_size;
|
slen = (size_t) cbuf_size;
|
||||||
ctx->json_enc = (char *) cbuf;
|
ctx->json_enc = (char *) cbuf;
|
||||||
}
|
}
|
||||||
GNUNET_assert
|
GNUNET_assert (NULL != (ctx->headers = curl_slist_append (
|
||||||
(NULL != (ctx->headers = curl_slist_append
|
ctx->headers,
|
||||||
(ctx->headers,
|
"Content-Encoding: deflate")));
|
||||||
"Content-Encoding: deflate")));
|
|
||||||
#else
|
#else
|
||||||
ctx->json_enc = str;
|
ctx->json_enc = str;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GNUNET_assert
|
GNUNET_assert
|
||||||
(NULL != (ctx->headers = curl_slist_append
|
(NULL != (ctx->headers = curl_slist_append (
|
||||||
(ctx->headers,
|
ctx->headers,
|
||||||
"Content-Type: application/json")));
|
"Content-Type: application/json")));
|
||||||
|
|
||||||
GNUNET_assert (CURLE_OK ==
|
GNUNET_assert (CURLE_OK ==
|
||||||
curl_easy_setopt (eh,
|
curl_easy_setopt (eh,
|
||||||
|
@ -105,6 +105,7 @@ TEH_handler_kyc_check (
|
|||||||
MHD_RESULT res;
|
MHD_RESULT res;
|
||||||
enum GNUNET_GenericReturnValue ret;
|
enum GNUNET_GenericReturnValue ret;
|
||||||
char dummy;
|
char dummy;
|
||||||
|
struct TALER_PaytoHash h_payto;
|
||||||
|
|
||||||
if (1 !=
|
if (1 !=
|
||||||
sscanf (args[0],
|
sscanf (args[0],
|
||||||
@ -118,6 +119,34 @@ TEH_handler_kyc_check (
|
|||||||
TALER_EC_GENERIC_PARAMETER_MALFORMED,
|
TALER_EC_GENERIC_PARAMETER_MALFORMED,
|
||||||
"payment_target_uuid");
|
"payment_target_uuid");
|
||||||
}
|
}
|
||||||
|
/* FIXME: write long polling logic ... */
|
||||||
|
{
|
||||||
|
const char *hps;
|
||||||
|
|
||||||
|
hps = MHD_lookup_connection_value (rc->connection,
|
||||||
|
MHD_GET_ARGUMENT_KIND,
|
||||||
|
"h_payto");
|
||||||
|
if (NULL == hps)
|
||||||
|
{
|
||||||
|
GNUNET_break_op (0);
|
||||||
|
return TALER_MHD_reply_with_error (rc->connection,
|
||||||
|
MHD_HTTP_BAD_REQUEST,
|
||||||
|
TALER_EC_GENERIC_PARAMETER_MISSING,
|
||||||
|
"h_payto");
|
||||||
|
}
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
GNUNET_STRINGS_string_to_data (hps,
|
||||||
|
strlen (hps),
|
||||||
|
&h_payto,
|
||||||
|
sizeof (h_payto)))
|
||||||
|
{
|
||||||
|
GNUNET_break_op (0);
|
||||||
|
return TALER_MHD_reply_with_error (rc->connection,
|
||||||
|
MHD_HTTP_BAD_REQUEST,
|
||||||
|
TALER_EC_GENERIC_PARAMETER_MALFORMED,
|
||||||
|
"h_payto");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (TEH_KYC_NONE == TEH_kyc_config.mode)
|
if (TEH_KYC_NONE == TEH_kyc_config.mode)
|
||||||
return TALER_MHD_reply_static (
|
return TALER_MHD_reply_static (
|
||||||
@ -141,6 +170,16 @@ TEH_handler_kyc_check (
|
|||||||
&kcc);
|
&kcc);
|
||||||
if (GNUNET_SYSERR == ret)
|
if (GNUNET_SYSERR == ret)
|
||||||
return res;
|
return res;
|
||||||
|
if (0 !=
|
||||||
|
GNUNET_memcmp (&kcc.h_payto,
|
||||||
|
&h_payto))
|
||||||
|
{
|
||||||
|
GNUNET_break_op (0);
|
||||||
|
return TALER_MHD_reply_with_error (rc->connection,
|
||||||
|
MHD_HTTP_FORBIDDEN,
|
||||||
|
42, /* FIXME: EC! */
|
||||||
|
"h_payto");
|
||||||
|
}
|
||||||
if (! kcc.kyc.ok)
|
if (! kcc.kyc.ok)
|
||||||
{
|
{
|
||||||
char *url;
|
char *url;
|
||||||
|
@ -224,6 +224,10 @@ withdraw_transaction (void *cls,
|
|||||||
return qs;
|
return qs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
|
"Asked to withdraw from %s amount of %s\n",
|
||||||
|
TALER_B2S (&wc->wsrd.reserve_pub),
|
||||||
|
TALER_amount2s (&wc->amount_required));
|
||||||
/* Don't sign again if we have already signed the coin */
|
/* Don't sign again if we have already signed the coin */
|
||||||
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
|
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
|
||||||
{
|
{
|
||||||
@ -306,6 +310,10 @@ withdraw_transaction (void *cls,
|
|||||||
return GNUNET_DB_STATUS_HARD_ERROR;
|
return GNUNET_DB_STATUS_HARD_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
|
"KYC status is %s for %s\n",
|
||||||
|
wc->kyc.ok ? "ok" : "missing",
|
||||||
|
TALER_B2S (&r.pub));
|
||||||
if ( (! wc->kyc.ok) &&
|
if ( (! wc->kyc.ok) &&
|
||||||
(TEH_KYC_NONE != TEH_kyc_config.mode) &&
|
(TEH_KYC_NONE != TEH_kyc_config.mode) &&
|
||||||
(TALER_EXCHANGEDB_KYC_W2W == wc->kyc.type) )
|
(TALER_EXCHANGEDB_KYC_W2W == wc->kyc.type) )
|
||||||
@ -323,10 +331,7 @@ withdraw_transaction (void *cls,
|
|||||||
struct TALER_Amount acc;
|
struct TALER_Amount acc;
|
||||||
enum GNUNET_DB_QueryStatus qs2;
|
enum GNUNET_DB_QueryStatus qs2;
|
||||||
|
|
||||||
TALER_amount_set_zero (TEH_currency,
|
acc = wc->amount_required;
|
||||||
&acc);
|
|
||||||
accumulate_withdraws (&acc,
|
|
||||||
&wc->amount_required);
|
|
||||||
qs2 = TEH_plugin->select_withdraw_amounts_by_account (
|
qs2 = TEH_plugin->select_withdraw_amounts_by_account (
|
||||||
TEH_plugin->cls,
|
TEH_plugin->cls,
|
||||||
&wc->wsrd.reserve_pub,
|
&wc->wsrd.reserve_pub,
|
||||||
@ -353,6 +358,9 @@ withdraw_transaction (void *cls,
|
|||||||
NULL);
|
NULL);
|
||||||
return GNUNET_DB_STATUS_HARD_ERROR;
|
return GNUNET_DB_STATUS_HARD_ERROR;
|
||||||
}
|
}
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
|
"Amount withdrawn so far is %s\n",
|
||||||
|
TALER_amount2s (&acc));
|
||||||
if (1 == /* 1: acc > withdraw_limit */
|
if (1 == /* 1: acc > withdraw_limit */
|
||||||
TALER_amount_cmp (&acc,
|
TALER_amount_cmp (&acc,
|
||||||
&TEH_kyc_config.withdraw_limit))
|
&TEH_kyc_config.withdraw_limit))
|
||||||
@ -388,6 +396,10 @@ withdraw_transaction (void *cls,
|
|||||||
wc->collectable.reserve_pub = wc->wsrd.reserve_pub;
|
wc->collectable.reserve_pub = wc->wsrd.reserve_pub;
|
||||||
wc->collectable.h_coin_envelope = wc->wsrd.h_coin_envelope;
|
wc->collectable.h_coin_envelope = wc->wsrd.h_coin_envelope;
|
||||||
wc->collectable.reserve_sig = wc->signature;
|
wc->collectable.reserve_sig = wc->signature;
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
|
"Persisting withdraw from %s over %s\n",
|
||||||
|
TALER_B2S (&r.pub),
|
||||||
|
TALER_amount2s (&wc->amount_required));
|
||||||
qs = TEH_plugin->insert_withdraw_info (TEH_plugin->cls,
|
qs = TEH_plugin->insert_withdraw_info (TEH_plugin->cls,
|
||||||
&wc->collectable);
|
&wc->collectable);
|
||||||
if (0 > qs)
|
if (0 > qs)
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "taler_error_codes.h"
|
#include "taler_error_codes.h"
|
||||||
#include "taler_dbevents.h"
|
#include "taler_dbevents.h"
|
||||||
#include "taler_pq_lib.h"
|
#include "taler_pq_lib.h"
|
||||||
|
#include "taler_util.h"
|
||||||
#include "taler_json_lib.h"
|
#include "taler_json_lib.h"
|
||||||
#include "taler_exchangedb_plugin.h"
|
#include "taler_exchangedb_plugin.h"
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
@ -3986,6 +3987,10 @@ postgres_inselect_wallet_kyc_status (
|
|||||||
qs = inselect_account_kyc_status (pg,
|
qs = inselect_account_kyc_status (pg,
|
||||||
payto_uri,
|
payto_uri,
|
||||||
kyc);
|
kyc);
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||||
|
"Wire account for `%s' is %llu\n",
|
||||||
|
payto_uri,
|
||||||
|
(unsigned long long) kyc->payment_target_uuid);
|
||||||
GNUNET_free (payto_uri);
|
GNUNET_free (payto_uri);
|
||||||
return qs;
|
return qs;
|
||||||
}
|
}
|
||||||
@ -4920,7 +4925,7 @@ withdraw_amount_by_account_cb (void *cls,
|
|||||||
struct WithdrawAmountByAccountContext *wac = cls;
|
struct WithdrawAmountByAccountContext *wac = cls;
|
||||||
struct PostgresClosure *pg = wac->pg;
|
struct PostgresClosure *pg = wac->pg;
|
||||||
|
|
||||||
for (unsigned int i = 0; num_results; i++)
|
for (unsigned int i = 0; i < num_results; i++)
|
||||||
{
|
{
|
||||||
struct TALER_Amount val;
|
struct TALER_Amount val;
|
||||||
struct GNUNET_PQ_ResultSpec rs[] = {
|
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#define TALER_CRYPTO_LIB_H
|
#define TALER_CRYPTO_LIB_H
|
||||||
|
|
||||||
#include <gnunet/gnunet_util_lib.h>
|
#include <gnunet/gnunet_util_lib.h>
|
||||||
#include "taler_util.h"
|
|
||||||
#include "taler_error_codes.h"
|
#include "taler_error_codes.h"
|
||||||
#include <gcrypt.h>
|
#include <gcrypt.h>
|
||||||
|
|
||||||
|
@ -166,6 +166,7 @@ TALER_EXCHANGE_kyc_wallet (struct TALER_EXCHANGE_Handle *exchange,
|
|||||||
.purpose = htonl (TALER_SIGNATURE_WALLET_ACCOUNT_SETUP)
|
.purpose = htonl (TALER_SIGNATURE_WALLET_ACCOUNT_SETUP)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* FIXME: move to util/wallet-signatures.c! */
|
||||||
GNUNET_CRYPTO_eddsa_key_get_public (&reserve_priv->eddsa_priv,
|
GNUNET_CRYPTO_eddsa_key_get_public (&reserve_priv->eddsa_priv,
|
||||||
&reserve_pub.eddsa_pub);
|
&reserve_pub.eddsa_pub);
|
||||||
|
|
||||||
@ -187,6 +188,7 @@ TALER_EXCHANGE_kyc_wallet (struct TALER_EXCHANGE_Handle *exchange,
|
|||||||
"/kyc-wallet");
|
"/kyc-wallet");
|
||||||
if (NULL == kwh->url)
|
if (NULL == kwh->url)
|
||||||
{
|
{
|
||||||
|
json_decref (req);
|
||||||
GNUNET_free (kwh);
|
GNUNET_free (kwh);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -96,24 +96,48 @@ run (void *cls,
|
|||||||
*/
|
*/
|
||||||
struct TALER_TESTING_Command withdraw[] = {
|
struct TALER_TESTING_Command withdraw[] = {
|
||||||
CMD_TRANSFER_TO_EXCHANGE ("create-reserve-1",
|
CMD_TRANSFER_TO_EXCHANGE ("create-reserve-1",
|
||||||
"EUR:5.01"),
|
"EUR:15.02"),
|
||||||
TALER_TESTING_cmd_check_bank_admin_transfer (
|
TALER_TESTING_cmd_check_bank_admin_transfer (
|
||||||
"check-create-reserve-1",
|
"check-create-reserve-1",
|
||||||
"EUR:5.01", bc.user42_payto, bc.exchange_payto,
|
"EUR:15.02", bc.user42_payto, bc.exchange_payto,
|
||||||
"create-reserve-1"),
|
"create-reserve-1"),
|
||||||
CMD_EXEC_WIREWATCH ("wirewatch-1"),
|
CMD_EXEC_WIREWATCH ("wirewatch-1"),
|
||||||
|
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1-no-kyc",
|
||||||
|
"create-reserve-1",
|
||||||
|
"EUR:10",
|
||||||
|
MHD_HTTP_ACCEPTED),
|
||||||
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1",
|
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1",
|
||||||
"create-reserve-1",
|
"create-reserve-1",
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
MHD_HTTP_OK),
|
MHD_HTTP_OK),
|
||||||
TALER_TESTING_cmd_end ()
|
TALER_TESTING_cmd_end ()
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* Test withdraw with KYC.
|
||||||
|
*/
|
||||||
|
struct TALER_TESTING_Command withdraw_kyc[] = {
|
||||||
|
CMD_EXEC_WIREWATCH ("wirewatch-1"),
|
||||||
|
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1-lacking-kyc",
|
||||||
|
"create-reserve-1",
|
||||||
|
"EUR:5",
|
||||||
|
MHD_HTTP_ACCEPTED),
|
||||||
|
TALER_TESTING_cmd_proof_kyc ("proof-kyc",
|
||||||
|
"withdraw-coin-1-lacking-kyc",
|
||||||
|
"pass",
|
||||||
|
"state",
|
||||||
|
MHD_HTTP_SEE_OTHER),
|
||||||
|
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1-with-kyc",
|
||||||
|
"create-reserve-1",
|
||||||
|
"EUR:5",
|
||||||
|
MHD_HTTP_OK),
|
||||||
|
TALER_TESTING_cmd_end ()
|
||||||
|
};
|
||||||
struct TALER_TESTING_Command spend[] = {
|
struct TALER_TESTING_Command spend[] = {
|
||||||
TALER_TESTING_cmd_deposit (
|
TALER_TESTING_cmd_deposit (
|
||||||
"deposit-simple",
|
"deposit-simple",
|
||||||
"withdraw-coin-1",
|
"withdraw-coin-1",
|
||||||
0,
|
0,
|
||||||
bc.user42_payto,
|
bc.user43_payto,
|
||||||
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
"{\"items\":[{\"name\":\"ice cream\",\"value\":1}]}",
|
||||||
GNUNET_TIME_UNIT_ZERO,
|
GNUNET_TIME_UNIT_ZERO,
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
@ -156,11 +180,28 @@ run (void *cls,
|
|||||||
ec.exchange_url,
|
ec.exchange_url,
|
||||||
"EUR:4.98",
|
"EUR:4.98",
|
||||||
bc.exchange_payto,
|
bc.exchange_payto,
|
||||||
bc.user42_payto),
|
bc.user43_payto),
|
||||||
TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"),
|
TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"),
|
||||||
TALER_TESTING_cmd_end ()
|
TALER_TESTING_cmd_end ()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct TALER_TESTING_Command wallet_kyc[] = {
|
||||||
|
TALER_TESTING_cmd_wallet_kyc_get (
|
||||||
|
"wallet-kyc-fail",
|
||||||
|
NULL,
|
||||||
|
MHD_HTTP_OK),
|
||||||
|
TALER_TESTING_cmd_proof_kyc ("proof-wallet-kyc",
|
||||||
|
"wallet-kyc-fail",
|
||||||
|
"pass",
|
||||||
|
"state",
|
||||||
|
MHD_HTTP_SEE_OTHER),
|
||||||
|
TALER_TESTING_cmd_check_kyc_get (
|
||||||
|
"wallet-kyc-check",
|
||||||
|
"wallet-kyc-fail",
|
||||||
|
MHD_HTTP_OK),
|
||||||
|
TALER_TESTING_cmd_end ()
|
||||||
|
};
|
||||||
|
|
||||||
struct TALER_TESTING_Command commands[] = {
|
struct TALER_TESTING_Command commands[] = {
|
||||||
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
|
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
|
||||||
CONFIG_FILE,
|
CONFIG_FILE,
|
||||||
@ -183,6 +224,12 @@ run (void *cls,
|
|||||||
spend),
|
spend),
|
||||||
TALER_TESTING_cmd_batch ("track",
|
TALER_TESTING_cmd_batch ("track",
|
||||||
track),
|
track),
|
||||||
|
TALER_TESTING_cmd_batch ("withdraw-kyc",
|
||||||
|
withdraw_kyc),
|
||||||
|
#if 0
|
||||||
|
TALER_TESTING_cmd_batch ("wallet-kyc",
|
||||||
|
wallet_kyc),
|
||||||
|
#endif
|
||||||
TALER_TESTING_cmd_end ()
|
TALER_TESTING_cmd_end ()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ KYC_WALLET_BALANCE_LIMIT = EUR:1
|
|||||||
|
|
||||||
KYC_WITHDRAW_PERIOD = "31 days"
|
KYC_WITHDRAW_PERIOD = "31 days"
|
||||||
|
|
||||||
KYC_WITHDRAW_LIMIT = EUR:150
|
KYC_WITHDRAW_LIMIT = EUR:8
|
||||||
|
|
||||||
[exchange-kyc-oauth2]
|
[exchange-kyc-oauth2]
|
||||||
|
|
||||||
|
@ -94,9 +94,10 @@ wallet_kyc_cb (void *cls,
|
|||||||
if (kwg->expected_response_code != wkr->http_status)
|
if (kwg->expected_response_code != wkr->http_status)
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Unexpected response code %u/%d to command %s in %s:%u\n",
|
"Unexpected response code %u/%d (wanted %u) to command %s in %s:%u\n",
|
||||||
wkr->http_status,
|
wkr->http_status,
|
||||||
(int) wkr->ec,
|
(int) wkr->ec,
|
||||||
|
kwg->expected_response_code,
|
||||||
cmd->label,
|
cmd->label,
|
||||||
__FILE__,
|
__FILE__,
|
||||||
__LINE__);
|
__LINE__);
|
||||||
|
Loading…
Reference in New Issue
Block a user