diff options
Diffstat (limited to 'src/lib/exchange_api_lookup_aml_decision.c')
-rw-r--r-- | src/lib/exchange_api_lookup_aml_decision.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/src/lib/exchange_api_lookup_aml_decision.c b/src/lib/exchange_api_lookup_aml_decision.c index 897a21f10..501b9d185 100644 --- a/src/lib/exchange_api_lookup_aml_decision.c +++ b/src/lib/exchange_api_lookup_aml_decision.c @@ -80,7 +80,6 @@ parse_aml_history (const json_t *aml_history, json_array_foreach (aml_history, idx, obj) { struct TALER_EXCHANGE_AmlDecisionDetail *aml = &aml_history_ar[idx]; - uint32_t state32; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_timestamp ("decision_time", &aml->decision_time), @@ -88,8 +87,8 @@ parse_aml_history (const json_t *aml_history, &aml->justification), TALER_JSON_spec_amount_any ("new_threshold", &aml->new_threshold), - GNUNET_JSON_spec_uint32 ("new_state", - &state32), + TALER_JSON_spec_aml_decision ("new_state", + &aml->new_state), GNUNET_JSON_spec_fixed_auto ("decider_pub", &aml->decider_pub), GNUNET_JSON_spec_end () @@ -104,7 +103,6 @@ parse_aml_history (const json_t *aml_history, GNUNET_break_op (0); return GNUNET_SYSERR; } - aml->new_state = (enum TALER_AmlDecisionState) state32; } return GNUNET_OK; } @@ -127,13 +125,12 @@ parse_kyc_attributes (const json_t *kyc_attributes, json_array_foreach (kyc_attributes, idx, obj) { struct TALER_EXCHANGE_KycHistoryDetail *kyc = &kyc_attributes_ar[idx]; - json_t *attributes = NULL; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_timestamp ("collection_time", &kyc->collection_time), GNUNET_JSON_spec_mark_optional ( - GNUNET_JSON_spec_json ("attributes", - &attributes), + GNUNET_JSON_spec_object_const ("attributes", + &kyc->attributes), NULL), GNUNET_JSON_spec_string ("provider_section", &kyc->provider_section), @@ -149,8 +146,6 @@ parse_kyc_attributes (const json_t *kyc_attributes, GNUNET_break_op (0); return GNUNET_SYSERR; } - kyc->attributes = attributes; - json_decref (attributes); /* this is OK, RC preserved via 'kyc_attributes' as long as needed! */ } return GNUNET_OK; } @@ -171,13 +166,13 @@ parse_decision_ok (struct TALER_EXCHANGE_LookupAmlDecision *lh, .hr.reply = json, .hr.http_status = MHD_HTTP_OK }; - json_t *aml_history; - json_t *kyc_attributes; + const json_t *aml_history; + const json_t *kyc_attributes; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_json ("aml_history", - &aml_history), - GNUNET_JSON_spec_json ("kyc_attributes", - &kyc_attributes), + GNUNET_JSON_spec_array_const ("aml_history", + &aml_history), + GNUNET_JSON_spec_array_const ("kyc_attributes", + &kyc_attributes), GNUNET_JSON_spec_end () }; @@ -190,17 +185,23 @@ parse_decision_ok (struct TALER_EXCHANGE_LookupAmlDecision *lh, GNUNET_break_op (0); return GNUNET_SYSERR; } - lr.details.success.aml_history_length = json_array_size (aml_history); - lr.details.success.kyc_attributes_length = json_array_size (kyc_attributes); + lr.details.ok.aml_history_length = json_array_size (aml_history); + lr.details.ok.kyc_attributes_length = json_array_size (kyc_attributes); { struct TALER_EXCHANGE_AmlDecisionDetail aml_history_ar[ - GNUNET_NZL (lr.details.success.aml_history_length)]; + GNUNET_NZL (lr.details.ok.aml_history_length)]; struct TALER_EXCHANGE_KycHistoryDetail kyc_attributes_ar[ - lr.details.success.kyc_attributes_length]; + GNUNET_NZL (lr.details.ok.kyc_attributes_length)]; enum GNUNET_GenericReturnValue ret = GNUNET_SYSERR; - lr.details.success.aml_history = aml_history_ar; - lr.details.success.kyc_attributes = kyc_attributes_ar; + memset (aml_history_ar, + 0, + sizeof (aml_history_ar)); + memset (kyc_attributes_ar, + 0, + sizeof (kyc_attributes_ar)); + lr.details.ok.aml_history = aml_history_ar; + lr.details.ok.kyc_attributes = kyc_attributes_ar; ret = parse_aml_history (aml_history, aml_history_ar); if (GNUNET_OK == ret) @@ -256,6 +257,8 @@ handle_lookup_finished (void *cls, GNUNET_assert (NULL == lh->decision_cb); TALER_EXCHANGE_lookup_aml_decision_cancel (lh); return; + case MHD_HTTP_NO_CONTENT: + break; case MHD_HTTP_BAD_REQUEST: lr.hr.ec = TALER_JSON_get_error_code (j); lr.hr.hint = TALER_JSON_get_error_hint (j); |