diff options
Diffstat (limited to 'src/exchange/taler-exchange-httpd_kyc-wallet.c')
-rw-r--r-- | src/exchange/taler-exchange-httpd_kyc-wallet.c | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/src/exchange/taler-exchange-httpd_kyc-wallet.c b/src/exchange/taler-exchange-httpd_kyc-wallet.c index 81acde4c3..21d07422d 100644 --- a/src/exchange/taler-exchange-httpd_kyc-wallet.c +++ b/src/exchange/taler-exchange-httpd_kyc-wallet.c @@ -42,6 +42,11 @@ struct KycRequestContext struct TALER_PaytoHashP h_payto; /** + * The reserve's public key + */ + struct TALER_ReservePublicKeyP reserve_pub; + + /** * KYC status, with row with the legitimization requirement. */ struct TALER_EXCHANGEDB_KycStatus kyc; @@ -54,7 +59,7 @@ struct KycRequestContext /** * Name of the required check. */ - const char *required; + char *required; }; @@ -109,26 +114,39 @@ 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_INFO, - "KYC check required at %s is `%s'\n", - TALER_amount2s (&krc->balance), - krc->required); + 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); krc->kyc.ok = false; qs = TEH_plugin->insert_kyc_requirement_for_account (TEH_plugin->cls, krc->required, &krc->h_payto, + &krc->reserve_pub, &krc->kyc.requirement_row); if (qs < 0) { @@ -158,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), @@ -184,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); @@ -201,7 +215,7 @@ 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_INFO, @@ -228,6 +242,7 @@ TEH_handler_kyc_wallet ( NULL, 0); } + GNUNET_free (krc.required); return TEH_RESPONSE_reply_kyc_required (rc->connection, &krc.h_payto, &krc.kyc); |