From 74ba46db39d3a906e819cd0ed48f1d46dffe9e38 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 14 Aug 2022 18:04:09 +0200 Subject: -work on new KYC logic: tests pass again --- src/lib/exchange_api_batch_withdraw.c | 2 +- src/lib/exchange_api_batch_withdraw2.c | 4 ++-- src/lib/exchange_api_kyc_wallet.c | 2 +- src/lib/exchange_api_purse_create_with_merge.c | 22 +++++++++++++++++++--- src/lib/exchange_api_purse_merge.c | 21 +++++++++++++++++++++ src/lib/exchange_api_reserves_status.c | 2 -- src/lib/exchange_api_withdraw.c | 5 +++-- src/lib/exchange_api_withdraw2.c | 2 +- 8 files changed, 48 insertions(+), 12 deletions(-) (limited to 'src/lib') diff --git a/src/lib/exchange_api_batch_withdraw.c b/src/lib/exchange_api_batch_withdraw.c index 4e0d6abcf..e1f6005f1 100644 --- a/src/lib/exchange_api_batch_withdraw.c +++ b/src/lib/exchange_api_batch_withdraw.c @@ -207,7 +207,7 @@ handle_reserve_batch_withdraw_finished ( case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS: { struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_uint64 ("payment_target_uuid", + GNUNET_JSON_spec_uint64 ("legitimization_uuid", &wr.details.accepted.payment_target_uuid), GNUNET_JSON_spec_end () }; diff --git a/src/lib/exchange_api_batch_withdraw2.c b/src/lib/exchange_api_batch_withdraw2.c index e9da21992..e14ed92fd 100644 --- a/src/lib/exchange_api_batch_withdraw2.c +++ b/src/lib/exchange_api_batch_withdraw2.c @@ -288,12 +288,12 @@ handle_reserve_batch_withdraw_finished (void *cls, GNUNET_assert (NULL == wh->cb); TALER_EXCHANGE_batch_withdraw2_cancel (wh); return; - case MHD_HTTP_ACCEPTED: + case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS: /* only validate reply is well-formed */ { uint64_t ptu; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_uint64 ("payment_target_uuid", + GNUNET_JSON_spec_uint64 ("legitimization_uuid", &ptu), GNUNET_JSON_spec_end () }; diff --git a/src/lib/exchange_api_kyc_wallet.c b/src/lib/exchange_api_kyc_wallet.c index a03b17654..fc9fbcde4 100644 --- a/src/lib/exchange_api_kyc_wallet.c +++ b/src/lib/exchange_api_kyc_wallet.c @@ -98,7 +98,7 @@ handle_kyc_wallet_finished (void *cls, case MHD_HTTP_OK: { struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_uint64 ("payment_target_uuid", + GNUNET_JSON_spec_uint64 ("legitimization_uuid", &ks.payment_target_uuid), GNUNET_JSON_spec_end () }; diff --git a/src/lib/exchange_api_purse_create_with_merge.c b/src/lib/exchange_api_purse_create_with_merge.c index f3c72d4f7..03ffc8bde 100644 --- a/src/lib/exchange_api_purse_create_with_merge.c +++ b/src/lib/exchange_api_purse_create_with_merge.c @@ -295,9 +295,25 @@ handle_purse_create_with_merge_finished (void *cls, dr.hr.hint = TALER_JSON_get_error_hint (j); break; case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS: - /* aka KYC required */ - dr.hr.ec = TALER_JSON_get_error_code (j); - dr.hr.hint = TALER_JSON_get_error_hint (j); + { + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_uint64 ( + "legitimization_uuid", + &dr.details.unavailable_for_legal_reasons.payment_target_uuid), + GNUNET_JSON_spec_end () + }; + + if (GNUNET_OK != + GNUNET_JSON_parse (j, + spec, + NULL, NULL)) + { + GNUNET_break_op (0); + dr.hr.http_status = 0; + dr.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED; + break; + } + } break; case MHD_HTTP_INTERNAL_SERVER_ERROR: dr.hr.ec = TALER_JSON_get_error_code (j); diff --git a/src/lib/exchange_api_purse_merge.c b/src/lib/exchange_api_purse_merge.c index 07e6cd9d6..07f37bd93 100644 --- a/src/lib/exchange_api_purse_merge.c +++ b/src/lib/exchange_api_purse_merge.c @@ -256,6 +256,27 @@ handle_purse_merge_finished (void *cls, dr.hr.ec = TALER_JSON_get_error_code (j); dr.hr.hint = TALER_JSON_get_error_hint (j); break; + case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS: + { + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_uint64 ( + "legitimization_uuid", + &dr.details.unavailable_for_legal_reasons.payment_target_uuid), + GNUNET_JSON_spec_end () + }; + + if (GNUNET_OK != + GNUNET_JSON_parse (j, + spec, + NULL, NULL)) + { + GNUNET_break_op (0); + dr.hr.http_status = 0; + dr.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED; + break; + } + } + break; case MHD_HTTP_INTERNAL_SERVER_ERROR: dr.hr.ec = TALER_JSON_get_error_code (j); dr.hr.hint = TALER_JSON_get_error_hint (j); diff --git a/src/lib/exchange_api_reserves_status.c b/src/lib/exchange_api_reserves_status.c index 35f5846f3..27f63d244 100644 --- a/src/lib/exchange_api_reserves_status.c +++ b/src/lib/exchange_api_reserves_status.c @@ -98,8 +98,6 @@ handle_reserves_status_ok (struct TALER_EXCHANGE_ReservesStatusHandle *rsh, struct GNUNET_JSON_Specification spec[] = { TALER_JSON_spec_amount_any ("balance", &rs.details.ok.balance), - GNUNET_JSON_spec_bool ("kyc_passed", - &rs.details.ok.kyc_ok), GNUNET_JSON_spec_json ("history", &history), GNUNET_JSON_spec_end () diff --git a/src/lib/exchange_api_withdraw.c b/src/lib/exchange_api_withdraw.c index b8ab1df44..f3ac962c3 100644 --- a/src/lib/exchange_api_withdraw.c +++ b/src/lib/exchange_api_withdraw.c @@ -160,8 +160,9 @@ handle_reserve_withdraw_finished ( case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS: { struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_uint64 ("payment_target_uuid", - &wr.details.accepted.payment_target_uuid), + GNUNET_JSON_spec_uint64 ( + "legitimization_uuid", + &wr.details.unavailable_for_legal_reasons.payment_target_uuid), GNUNET_JSON_spec_end () }; diff --git a/src/lib/exchange_api_withdraw2.c b/src/lib/exchange_api_withdraw2.c index fc7c755da..4e5ca0622 100644 --- a/src/lib/exchange_api_withdraw2.c +++ b/src/lib/exchange_api_withdraw2.c @@ -316,7 +316,7 @@ handle_reserve_withdraw_finished (void *cls, { uint64_t ptu; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_uint64 ("payment_target_uuid", + GNUNET_JSON_spec_uint64 ("legitimization_uuid", &ptu), GNUNET_JSON_spec_end () }; -- cgit v1.2.3