diff options
Diffstat (limited to 'src/exchange/taler-exchange-httpd_kyc-wallet.c')
-rw-r--r-- | src/exchange/taler-exchange-httpd_kyc-wallet.c | 65 |
1 files changed, 41 insertions, 24 deletions
diff --git a/src/exchange/taler-exchange-httpd_kyc-wallet.c b/src/exchange/taler-exchange-httpd_kyc-wallet.c index 9a1133c7f..21d07422d 100644 --- a/src/exchange/taler-exchange-httpd_kyc-wallet.c +++ b/src/exchange/taler-exchange-httpd_kyc-wallet.c @@ -42,9 +42,14 @@ struct KycRequestContext struct TALER_PaytoHashP h_payto; /** - * Row with the legitimization requirement. + * The reserve's public key */ - uint64_t legi_row; + struct TALER_ReservePublicKeyP reserve_pub; + + /** + * KYC status, with row with the legitimization requirement. + */ + struct TALER_EXCHANGEDB_KycStatus kyc; /** * Balance threshold crossed by the wallet. @@ -54,7 +59,7 @@ struct KycRequestContext /** * Name of the required check. */ - const char *required; + char *required; }; @@ -109,23 +114,40 @@ wallet_kyc_check (void *cls, struct KycRequestContext *krc = cls; enum GNUNET_DB_QueryStatus qs; - krc->required = TALER_KYCLOGIC_kyc_test_required ( + qs = TALER_KYCLOGIC_kyc_test_required ( TALER_KYCLOGIC_KYC_TRIGGER_WALLET_BALANCE, &krc->h_payto, TEH_plugin->select_satisfied_kyc_processes, TEH_plugin->cls, &balance_iterator, - krc); - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + krc, + &krc->required); + if (qs < 0) + { + if (GNUNET_DB_STATUS_SOFT_ERROR == qs) + return qs; + GNUNET_break (0); + *mhd_ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "kyc_test_required"); + return qs; + } + if (NULL == krc->required) + { + krc->kyc.ok = true; + return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS; + } + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "KYC check required at %s is `%s'\n", TALER_amount2s (&krc->balance), krc->required); - if (NULL == krc->required) - return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS; + krc->kyc.ok = false; qs = TEH_plugin->insert_kyc_requirement_for_account (TEH_plugin->cls, krc->required, &krc->h_payto, - &krc->legi_row); + &krc->reserve_pub, + &krc->kyc.requirement_row); if (qs < 0) { if (GNUNET_DB_STATUS_SOFT_ERROR == qs) @@ -140,7 +162,7 @@ wallet_kyc_check (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "KYC requirement inserted for wallet %s (%llu, %d)\n", TALER_B2S (&krc->h_payto), - (unsigned long long) krc->legi_row, + (unsigned long long) krc->kyc.requirement_row, qs); return qs; } @@ -154,14 +176,11 @@ TEH_handler_kyc_wallet ( { struct TALER_ReserveSignatureP reserve_sig; struct KycRequestContext krc; - struct TALER_ReservePublicKeyP reserve_pub; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("reserve_sig", &reserve_sig), GNUNET_JSON_spec_fixed_auto ("reserve_pub", - &reserve_pub), - // FIXME: add balance threshold crossed to the request - // to spec and client API! + &krc.reserve_pub), TALER_JSON_spec_amount ("balance", TEH_currency, &krc.balance), @@ -180,10 +199,9 @@ TEH_handler_kyc_wallet ( return MHD_YES; /* failure */ TEH_METRICS_num_verifications[TEH_MT_SIGNATURE_EDDSA]++; - // FIXME: add balance threshold crossed to - // what the wallet signs over! if (GNUNET_OK != - TALER_wallet_account_setup_verify (&reserve_pub, + TALER_wallet_account_setup_verify (&krc.reserve_pub, + &krc.balance, &reserve_sig)) { GNUNET_break_op (0); @@ -197,10 +215,10 @@ TEH_handler_kyc_wallet ( char *payto_uri; payto_uri = TALER_reserve_make_payto (TEH_base_url, - &reserve_pub); + &krc.reserve_pub); TALER_payto_hash (payto_uri, &krc.h_payto); - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "h_payto of wallet %s is %s\n", payto_uri, TALER_B2S (&krc.h_payto)); @@ -224,11 +242,10 @@ TEH_handler_kyc_wallet ( NULL, 0); } - return TALER_MHD_REPLY_JSON_PACK ( - rc->connection, - MHD_HTTP_OK, - GNUNET_JSON_pack_uint64 ("legitimization_uuid", - krc.legi_row)); + GNUNET_free (krc.required); + return TEH_RESPONSE_reply_kyc_required (rc->connection, + &krc.h_payto, + &krc.kyc); } |