diff options
-rw-r--r-- | src/exchange/taler-exchange-httpd_purses_merge.c | 5 | ||||
-rw-r--r-- | src/include/taler_exchange_service.h | 4 | ||||
-rw-r--r-- | src/include/taler_json_lib.h | 16 | ||||
-rw-r--r-- | src/json/json_helper.c | 58 | ||||
-rw-r--r-- | src/lib/exchange_api_add_aml_decision.c | 8 | ||||
-rw-r--r-- | src/lib/exchange_api_batch_deposit.c | 4 | ||||
-rw-r--r-- | src/lib/exchange_api_common.c | 17 | ||||
-rw-r--r-- | src/lib/exchange_api_handle.c | 4 | ||||
-rw-r--r-- | src/lib/exchange_api_kyc_check.c | 2 | ||||
-rw-r--r-- | src/lib/exchange_api_kyc_proof.c | 4 | ||||
-rw-r--r-- | src/lib/exchange_api_lookup_aml_decisions.c | 2 | ||||
-rw-r--r-- | src/lib/exchange_api_lookup_kyc_attributes.c | 6 | ||||
-rw-r--r-- | src/lib/exchange_api_management_drain_profits.c | 6 | ||||
-rw-r--r-- | src/lib/exchange_api_management_wire_disable.c | 6 | ||||
-rw-r--r-- | src/lib/exchange_api_management_wire_enable.c | 6 | ||||
-rw-r--r-- | src/lib/exchange_api_purse_create_with_merge.c | 4 | ||||
-rw-r--r-- | src/lib/exchange_api_purse_merge.c | 6 | ||||
-rw-r--r-- | src/lib/exchange_api_reserves_close.c | 16 | ||||
-rw-r--r-- | src/lib/exchange_api_reserves_history.c | 26 | ||||
-rw-r--r-- | src/lib/exchange_api_restrictions.c | 10 |
20 files changed, 145 insertions, 65 deletions
diff --git a/src/exchange/taler-exchange-httpd_purses_merge.c b/src/exchange/taler-exchange-httpd_purses_merge.c index 9d3dd2b73..98d731c35 100644 --- a/src/exchange/taler-exchange-httpd_purses_merge.c +++ b/src/exchange/taler-exchange-httpd_purses_merge.c @@ -529,9 +529,8 @@ TEH_handler_purses_merge ( { struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_string ( - "payto_uri", - (const char **) &pmc->payto_uri.normalized_payto), + TALER_JSON_spec_normalized_payto_uri ("payto_uri", + &pmc->payto_uri), GNUNET_JSON_spec_fixed_auto ("reserve_sig", &pmc->reserve_sig), GNUNET_JSON_spec_fixed_auto ("merge_sig", diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h index 7a5d55d83..f2b62c9d6 100644 --- a/src/include/taler_exchange_service.h +++ b/src/include/taler_exchange_service.h @@ -1281,7 +1281,7 @@ struct TALER_EXCHANGE_DepositContractDetail * The merchant’s account details, in the payto://-format supported by the * exchange. */ - const struct TALER_FullPayto merchant_payto_uri; + struct TALER_FullPayto merchant_payto_uri; /** * Policy extension specific details about the deposit relevant to the exchange. @@ -6505,7 +6505,7 @@ TALER_EXCHANGE_post_aml_decision ( struct GNUNET_CURL_Context *ctx, const char *url, const struct TALER_NormalizedPaytoHashP *h_payto, - const struct TALER_NormalizedPayto payto_uri, + const struct TALER_FullPayto payto_uri, struct GNUNET_TIME_Timestamp decision_time, const char *successor_measure, const char *new_measures, diff --git a/src/include/taler_json_lib.h b/src/include/taler_json_lib.h index fa3a25b31..cd747d94a 100644 --- a/src/include/taler_json_lib.h +++ b/src/include/taler_json_lib.h @@ -471,7 +471,7 @@ TALER_JSON_spec_web_url (const char *field, /** - * Generate line in parser specification for + * Generate line in parser specification for full * "payto://" URIs. * * @param field name of the field @@ -485,6 +485,20 @@ TALER_JSON_spec_full_payto_uri ( /** + * Generate line in parser specification for normalized + * "payto://" URIs. + * + * @param field name of the field + * @param[out] payto_uri RFC 8905 URI to initialize + * @return corresponding field spec + */ +struct GNUNET_JSON_Specification +TALER_JSON_spec_normalized_payto_uri ( + const char *field, + struct TALER_NormalizedPayto *payto_uri); + + +/** * Representation of a protocol version. */ struct TALER_JSON_ProtocolVersion diff --git a/src/json/json_helper.c b/src/json/json_helper.c index 12dadbff1..5ed4571a2 100644 --- a/src/json/json_helper.c +++ b/src/json/json_helper.c @@ -1245,6 +1245,64 @@ TALER_JSON_spec_full_payto_uri ( /** + * Parse given JSON object to payto:// URI. + * + * @param cls closure, NULL + * @param root the json object representing data + * @param[out] spec where to write the data + * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error + */ +static enum GNUNET_GenericReturnValue +parse_normalized_payto_uri (void *cls, + json_t *root, + struct GNUNET_JSON_Specification *spec) +{ + struct TALER_NormalizedPayto *payto_uri = spec->ptr; + const char *str; + + (void) cls; + str = json_string_value (root); + if (NULL == str) + { + GNUNET_break_op (0); + return GNUNET_SYSERR; + } + payto_uri->normalized_payto = (char *) str; +#if FIXME /* need reduced validation for normalized paytos! */ + { + char *err; + + err = TALER_payto_validate (*payto_uri); + if (NULL != err) + { + GNUNET_break_op (0); + GNUNET_free (err); + payto_uri->normalized_payto = NULL; + return GNUNET_SYSERR; + } + } +#endif + return GNUNET_OK; +} + + +struct GNUNET_JSON_Specification +TALER_JSON_spec_normalized_payto_uri ( + const char *field, + struct TALER_NormalizedPayto *payto_uri) +{ + struct GNUNET_JSON_Specification ret = { + .parser = &parse_normalized_payto_uri, + .field = field, + .ptr = payto_uri + }; + + payto_uri->normalized_payto = NULL; + return ret; +} + + +/** * Parse given JSON object with protocol version. * * @param cls closure, NULL diff --git a/src/lib/exchange_api_add_aml_decision.c b/src/lib/exchange_api_add_aml_decision.c index e60b88c6c..69ba03f08 100644 --- a/src/lib/exchange_api_add_aml_decision.c +++ b/src/lib/exchange_api_add_aml_decision.c @@ -127,8 +127,8 @@ struct TALER_EXCHANGE_AddAmlDecision * TALER_EXCHANGE_post_aml_decision ( struct GNUNET_CURL_Context *ctx, const char *url, - const struct TALER_PaytoHashP *h_payto, - const char *payto_uri, + const struct TALER_NormalizedPaytoHashP *h_payto, + const struct TALER_FullPayto payto_uri, struct GNUNET_TIME_Timestamp decision_time, const char *successor_measure, const char *new_measures, @@ -271,8 +271,8 @@ TALER_EXCHANGE_post_aml_decision ( GNUNET_JSON_pack_data_auto ("h_payto", h_payto), GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_string ("payto_uri", - payto_uri)), + TALER_JSON_pack_full_payto ("payto_uri", + payto_uri)), GNUNET_JSON_pack_object_steal ("new_rules", new_rules), GNUNET_JSON_pack_object_incref ("properties", diff --git a/src/lib/exchange_api_batch_deposit.c b/src/lib/exchange_api_batch_deposit.c index 1c169495c..26f00c7a7 100644 --- a/src/lib/exchange_api_batch_deposit.c +++ b/src/lib/exchange_api_batch_deposit.c @@ -712,8 +712,8 @@ TALER_EXCHANGE_batch_deposit ( wallet_data_hashp = &dcd->wallet_data_hash; deposit_obj = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("merchant_payto_uri", - dcd->merchant_payto_uri), + TALER_JSON_pack_full_payto ("merchant_payto_uri", + dcd->merchant_payto_uri), GNUNET_JSON_pack_data_auto ("wire_salt", &dcd->wire_salt), GNUNET_JSON_pack_data_auto ("h_contract_terms", diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c index bd731ad37..42dd9c2ba 100644 --- a/src/lib/exchange_api_common.c +++ b/src/lib/exchange_api_common.c @@ -130,7 +130,7 @@ TALER_EXCHANGE_check_purse_merge_conflict_ ( &reserve_pub), GNUNET_JSON_spec_end () }; - char *payto_uri; + struct TALER_NormalizedPayto payto_uri; if (GNUNET_OK != GNUNET_JSON_parse (proof, @@ -153,10 +153,10 @@ TALER_EXCHANGE_check_purse_merge_conflict_ ( &merge_sig)) { GNUNET_break_op (0); - GNUNET_free (payto_uri); + GNUNET_free (payto_uri.normalized_payto); return GNUNET_SYSERR; } - GNUNET_free (payto_uri); + GNUNET_free (payto_uri.normalized_payto); if (0 == GNUNET_memcmp (&merge_sig, cmerge_sig)) @@ -514,15 +514,15 @@ TALER_EXCHANGE_parse_accounts ( i++) { struct TALER_EXCHANGE_WireAccount *wa = &was[i]; - const char *payto_uri; + struct TALER_FullPayto payto_uri; const char *conversion_url = NULL; const char *bank_label = NULL; int64_t priority = 0; const json_t *credit_restrictions; const json_t *debit_restrictions; struct GNUNET_JSON_Specification spec_account[] = { - TALER_JSON_spec_payto_uri ("payto_uri", - &payto_uri), + TALER_JSON_spec_full_payto_uri ("payto_uri", + &payto_uri), GNUNET_JSON_spec_mark_optional ( TALER_JSON_spec_web_url ("conversion_url", &conversion_url), @@ -583,7 +583,8 @@ TALER_EXCHANGE_parse_accounts ( GNUNET_break_op (0); return GNUNET_SYSERR; } - wa->payto_uri = GNUNET_strdup (payto_uri); + wa->fpayto_uri.full_payto + = GNUNET_strdup (payto_uri.full_payto); wa->priority = priority; if (NULL != conversion_url) wa->conversion_url = GNUNET_strdup (conversion_url); @@ -633,7 +634,7 @@ TALER_EXCHANGE_free_accounts ( { struct TALER_EXCHANGE_WireAccount *wa = &was[i]; - GNUNET_free (wa->payto_uri); + GNUNET_free (wa->fpayto_uri.full_payto); GNUNET_free (wa->conversion_url); GNUNET_free (wa->bank_label); free_restrictions (wa->credit_restrictions_length, diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c index a282fdb63..9acb7c2b0 100644 --- a/src/lib/exchange_api_handle.c +++ b/src/lib/exchange_api_handle.c @@ -2461,8 +2461,8 @@ TALER_EXCHANGE_keys_to_json (const struct TALER_EXCHANGE_Keys *kd) json_array_append_new ( accounts, GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("payto_uri", - acc->payto_uri), + TALER_JSON_pack_full_payto ("payto_uri", + acc->fpayto_uri), GNUNET_JSON_pack_allow_null ( GNUNET_JSON_pack_string ("conversion_url", acc->conversion_url)), diff --git a/src/lib/exchange_api_kyc_check.c b/src/lib/exchange_api_kyc_check.c index 1231c7cc1..283fcc009 100644 --- a/src/lib/exchange_api_kyc_check.c +++ b/src/lib/exchange_api_kyc_check.c @@ -256,7 +256,7 @@ struct TALER_EXCHANGE_KycCheckHandle * TALER_EXCHANGE_kyc_check ( struct GNUNET_CURL_Context *ctx, const char *url, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, const union TALER_AccountPrivateKeyP *account_priv, enum TALER_EXCHANGE_KycLongPollTarget lpt, struct GNUNET_TIME_Relative timeout, diff --git a/src/lib/exchange_api_kyc_proof.c b/src/lib/exchange_api_kyc_proof.c index 8be30dbcf..a942b5cee 100644 --- a/src/lib/exchange_api_kyc_proof.c +++ b/src/lib/exchange_api_kyc_proof.c @@ -138,7 +138,7 @@ struct TALER_EXCHANGE_KycProofHandle * TALER_EXCHANGE_kyc_proof ( struct GNUNET_CURL_Context *ctx, const char *url, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, const char *logic, const char *args, TALER_EXCHANGE_KycProofCallback cb, @@ -152,7 +152,7 @@ TALER_EXCHANGE_kyc_proof ( else GNUNET_assert (args[0] == '&'); { - char hstr[sizeof (struct TALER_PaytoHashP) * 2]; + char hstr[sizeof (*h_payto) * 2]; char *end; end = GNUNET_STRINGS_data_to_string (h_payto, diff --git a/src/lib/exchange_api_lookup_aml_decisions.c b/src/lib/exchange_api_lookup_aml_decisions.c index 8f9b2c237..39fb24d28 100644 --- a/src/lib/exchange_api_lookup_aml_decisions.c +++ b/src/lib/exchange_api_lookup_aml_decisions.c @@ -477,7 +477,7 @@ struct TALER_EXCHANGE_LookupAmlDecisions * TALER_EXCHANGE_lookup_aml_decisions ( struct GNUNET_CURL_Context *ctx, const char *exchange_url, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, enum TALER_EXCHANGE_YesNoAll investigation_only, enum TALER_EXCHANGE_YesNoAll active_only, uint64_t offset, diff --git a/src/lib/exchange_api_lookup_kyc_attributes.c b/src/lib/exchange_api_lookup_kyc_attributes.c index 6be04f4e4..e23d50804 100644 --- a/src/lib/exchange_api_lookup_kyc_attributes.c +++ b/src/lib/exchange_api_lookup_kyc_attributes.c @@ -256,7 +256,7 @@ struct TALER_EXCHANGE_LookupKycAttributes * TALER_EXCHANGE_lookup_kyc_attributes ( struct GNUNET_CURL_Context *ctx, const char *exchange_url, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_NormalizedPaytoHashP *h_payto, uint64_t offset, int64_t limit, const struct TALER_AmlOfficerPrivateKeyP *officer_priv, @@ -267,8 +267,8 @@ TALER_EXCHANGE_lookup_kyc_attributes ( CURL *eh; struct TALER_AmlOfficerPublicKeyP officer_pub; struct TALER_AmlOfficerSignatureP officer_sig; - char arg_str[sizeof (struct TALER_AmlOfficerPublicKeyP) * 2 - + sizeof (struct TALER_PaytoHashP) * 2 + char arg_str[sizeof (officer_pub) * 2 + + sizeof (*h_payto) * 2 + 32]; GNUNET_CRYPTO_eddsa_key_get_public (&officer_priv->eddsa_priv, diff --git a/src/lib/exchange_api_management_drain_profits.c b/src/lib/exchange_api_management_drain_profits.c index bc7232b87..ea646aee5 100644 --- a/src/lib/exchange_api_management_drain_profits.c +++ b/src/lib/exchange_api_management_drain_profits.c @@ -130,7 +130,7 @@ TALER_EXCHANGE_management_drain_profits ( const struct TALER_Amount *amount, struct GNUNET_TIME_Timestamp date, const char *account_section, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const struct TALER_MasterSignatureP *master_sig, TALER_EXCHANGE_ManagementDrainProfitsCallback cb, void *cb_cls) @@ -156,8 +156,8 @@ TALER_EXCHANGE_management_drain_profits ( body = GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("debit_account_section", account_section), - GNUNET_JSON_pack_string ("credit_payto_uri", - payto_uri), + TALER_JSON_pack_full_payto ("credit_payto_uri", + payto_uri), GNUNET_JSON_pack_data_auto ("wtid", wtid), GNUNET_JSON_pack_data_auto ("master_sig", diff --git a/src/lib/exchange_api_management_wire_disable.c b/src/lib/exchange_api_management_wire_disable.c index 23b10c58c..73dff6087 100644 --- a/src/lib/exchange_api_management_wire_disable.c +++ b/src/lib/exchange_api_management_wire_disable.c @@ -142,7 +142,7 @@ struct TALER_EXCHANGE_ManagementWireDisableHandle * TALER_EXCHANGE_management_disable_wire ( struct GNUNET_CURL_Context *ctx, const char *url, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, struct GNUNET_TIME_Timestamp validity_end, const struct TALER_MasterSignatureP *master_sig, TALER_EXCHANGE_ManagementWireDisableCallback cb, @@ -167,8 +167,8 @@ TALER_EXCHANGE_management_disable_wire ( return NULL; } body = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("payto_uri", - payto_uri), + TALER_JSON_pack_full_payto ("payto_uri", + payto_uri), GNUNET_JSON_pack_data_auto ("master_sig_del", master_sig), GNUNET_JSON_pack_timestamp ("validity_end", diff --git a/src/lib/exchange_api_management_wire_enable.c b/src/lib/exchange_api_management_wire_enable.c index 9a163b558..d47a3ee81 100644 --- a/src/lib/exchange_api_management_wire_enable.c +++ b/src/lib/exchange_api_management_wire_enable.c @@ -142,7 +142,7 @@ struct TALER_EXCHANGE_ManagementWireEnableHandle * TALER_EXCHANGE_management_enable_wire ( struct GNUNET_CURL_Context *ctx, const char *url, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const char *conversion_url, const json_t *debit_restrictions, const json_t *credit_restrictions, @@ -185,8 +185,8 @@ TALER_EXCHANGE_management_enable_wire ( return NULL; } body = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("payto_uri", - payto_uri), + TALER_JSON_pack_full_payto ("payto_uri", + payto_uri), GNUNET_JSON_pack_array_incref ("debit_restrictions", (json_t *) debit_restrictions), GNUNET_JSON_pack_array_incref ("credit_restrictions", diff --git a/src/lib/exchange_api_purse_create_with_merge.c b/src/lib/exchange_api_purse_create_with_merge.c index 0c8878342..3794fc1ea 100644 --- a/src/lib/exchange_api_purse_create_with_merge.c +++ b/src/lib/exchange_api_purse_create_with_merge.c @@ -457,7 +457,7 @@ TALER_EXCHANGE_purse_create_with_merge ( purse_priv, &pcm->purse_sig); { - char *payto_uri; + struct TALER_NormalizedPayto payto_uri; payto_uri = TALER_reserve_make_payto (url, &pcm->reserve_pub); @@ -466,7 +466,7 @@ TALER_EXCHANGE_purse_create_with_merge ( &pcm->purse_pub, merge_priv, &pcm->merge_sig); - GNUNET_free (payto_uri); + GNUNET_free (payto_uri.normalized_payto); } TALER_wallet_account_merge_sign (merge_timestamp, &pcm->purse_pub, diff --git a/src/lib/exchange_api_purse_merge.c b/src/lib/exchange_api_purse_merge.c index d602078d2..57f2af798 100644 --- a/src/lib/exchange_api_purse_merge.c +++ b/src/lib/exchange_api_purse_merge.c @@ -394,8 +394,8 @@ TALER_EXCHANGE_account_merge ( &pch->reserve_sig); } merge_obj = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("payto_uri", - reserve_url), + TALER_JSON_pack_normalized_payto ("payto_uri", + reserve_url), GNUNET_JSON_pack_data_auto ("merge_sig", &pch->merge_sig), GNUNET_JSON_pack_data_auto ("reserve_sig", @@ -403,7 +403,7 @@ TALER_EXCHANGE_account_merge ( GNUNET_JSON_pack_timestamp ("merge_timestamp", merge_timestamp)); GNUNET_assert (NULL != merge_obj); - GNUNET_free (reserve_url); + GNUNET_free (reserve_url.normalized_payto); eh = TALER_EXCHANGE_curl_easy_get_ (pch->url); if ( (NULL == eh) || (GNUNET_OK != diff --git a/src/lib/exchange_api_reserves_close.c b/src/lib/exchange_api_reserves_close.c index a3769a22f..365246535 100644 --- a/src/lib/exchange_api_reserves_close.c +++ b/src/lib/exchange_api_reserves_close.c @@ -267,14 +267,14 @@ TALER_EXCHANGE_reserves_close ( struct GNUNET_CURL_Context *ctx, const char *url, const struct TALER_ReservePrivateKeyP *reserve_priv, - const char *target_payto_uri, + const struct TALER_FullPayto target_payto_uri, TALER_EXCHANGE_ReservesCloseCallback cb, void *cb_cls) { struct TALER_EXCHANGE_ReservesCloseHandle *rch; CURL *eh; char arg_str[sizeof (struct TALER_ReservePublicKeyP) * 2 + 32]; - struct TALER_PaytoHashP h_payto; + struct TALER_FullPaytoHashP h_payto; rch = GNUNET_new (struct TALER_EXCHANGE_ReservesCloseHandle); rch->cb = cb; @@ -313,11 +313,11 @@ TALER_EXCHANGE_reserves_close ( GNUNET_free (rch); return NULL; } - if (NULL != target_payto_uri) - TALER_payto_hash (target_payto_uri, - &h_payto); + if (NULL != target_payto_uri.full_payto) + TALER_full_payto_hash (target_payto_uri, + &h_payto); TALER_wallet_reserve_close_sign (rch->ts, - (NULL != target_payto_uri) + (NULL != target_payto_uri.full_payto) ? &h_payto : NULL, reserve_priv, @@ -325,8 +325,8 @@ TALER_EXCHANGE_reserves_close ( { json_t *close_obj = GNUNET_JSON_PACK ( GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_string ("payto_uri", - target_payto_uri)), + TALER_JSON_pack_full_payto ("payto_uri", + target_payto_uri)), GNUNET_JSON_pack_timestamp ("request_timestamp", rch->ts), GNUNET_JSON_pack_data_auto ("reserve_sig", diff --git a/src/lib/exchange_api_reserves_history.c b/src/lib/exchange_api_reserves_history.c index 0654ad837..ecf1047c3 100644 --- a/src/lib/exchange_api_reserves_history.c +++ b/src/lib/exchange_api_reserves_history.c @@ -148,7 +148,7 @@ parse_credit (struct TALER_EXCHANGE_ReserveHistoryEntry *rh, struct HistoryParseContext *uc, const json_t *transaction) { - const char *wire_uri; + struct TALER_FullPayto wire_uri; uint64_t wire_reference; struct GNUNET_TIME_Timestamp timestamp; struct GNUNET_JSON_Specification withdraw_spec[] = { @@ -156,8 +156,8 @@ parse_credit (struct TALER_EXCHANGE_ReserveHistoryEntry *rh, &wire_reference), GNUNET_JSON_spec_timestamp ("timestamp", ×tamp), - TALER_JSON_spec_payto_uri ("sender_account_url", - &wire_uri), + TALER_JSON_spec_full_payto_uri ("sender_account_url", + &wire_uri), GNUNET_JSON_spec_end () }; @@ -179,7 +179,8 @@ parse_credit (struct TALER_EXCHANGE_ReserveHistoryEntry *rh, GNUNET_break_op (0); return GNUNET_SYSERR; } - rh->details.in_details.sender_url = GNUNET_strdup (wire_uri); + rh->details.in_details.sender_url.full_payto + = GNUNET_strdup (wire_uri.full_payto); rh->details.in_details.wire_reference = wire_reference; rh->details.in_details.timestamp = timestamp; return GNUNET_OK; @@ -378,10 +379,11 @@ parse_closing (struct TALER_EXCHANGE_ReserveHistoryEntry *rh, const json_t *transaction) { const struct TALER_EXCHANGE_Keys *key_state; + struct TALER_FullPayto receiver_uri; struct GNUNET_JSON_Specification closing_spec[] = { - TALER_JSON_spec_payto_uri ( + TALER_JSON_spec_full_payto_uri ( "receiver_account_details", - &rh->details.close_details.receiver_account_details), + &receiver_uri), GNUNET_JSON_spec_fixed_auto ("wtid", &rh->details.close_details.wtid), GNUNET_JSON_spec_fixed_auto ("exchange_sig", @@ -418,7 +420,7 @@ parse_closing (struct TALER_EXCHANGE_ReserveHistoryEntry *rh, rh->details.close_details.timestamp, &rh->amount, &rh->details.close_details.fee, - rh->details.close_details.receiver_account_details, + receiver_uri, &rh->details.close_details.wtid, uc->reserve_pub, &rh->details.close_details.exchange_pub, @@ -436,6 +438,8 @@ parse_closing (struct TALER_EXCHANGE_ReserveHistoryEntry *rh, GNUNET_break_op (0); return GNUNET_SYSERR; } + rh->details.close_details.receiver_account_details.full_payto + = GNUNET_strdup (receiver_uri.full_payto); return GNUNET_OK; } @@ -654,10 +658,12 @@ free_reserve_history ( { for (unsigned int i = 0; i<len; i++) { - switch (rhistory[i].type) + struct TALER_EXCHANGE_ReserveHistoryEntry *rhi = &rhistory[i]; + + switch (rhi->type) { case TALER_EXCHANGE_RTT_CREDIT: - GNUNET_free (rhistory[i].details.in_details.sender_url); + GNUNET_free (rhi->details.in_details.sender_url.full_payto); break; case TALER_EXCHANGE_RTT_WITHDRAWAL: break; @@ -672,6 +678,8 @@ free_reserve_history ( case TALER_EXCHANGE_RTT_OPEN: break; case TALER_EXCHANGE_RTT_CLOSE: + GNUNET_free (rhi->details.close_details + .receiver_account_details.full_payto); break; } } diff --git a/src/lib/exchange_api_restrictions.c b/src/lib/exchange_api_restrictions.c index 1b5bd0214..1876d277c 100644 --- a/src/lib/exchange_api_restrictions.c +++ b/src/lib/exchange_api_restrictions.c @@ -28,7 +28,7 @@ enum GNUNET_GenericReturnValue TALER_EXCHANGE_test_account_allowed ( const struct TALER_EXCHANGE_WireAccount *account, bool check_credit, - const char *payto_uri) + const struct TALER_NormalizedPayto payto_uri) { unsigned int limit = check_credit @@ -41,8 +41,8 @@ TALER_EXCHANGE_test_account_allowed ( char *wm2; bool ok; - wm1 = TALER_payto_get_method (payto_uri); - wm2 = TALER_payto_get_method (account->payto_uri); + wm1 = TALER_payto_get_method (payto_uri.normalized_payto); + wm2 = TALER_payto_get_method (account->fpayto_uri.full_payto); ok = (0 == strcmp (wm1, wm2)); GNUNET_free (wm1); @@ -78,13 +78,13 @@ TALER_EXCHANGE_test_account_allowed ( return GNUNET_SYSERR; } if (regexec (&ex, - payto_uri, + payto_uri.normalized_payto, 0, NULL, REG_STARTEND)) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Account `%s' allowed by regex\n", - payto_uri); + payto_uri.normalized_payto); allowed = true; } regfree (&ex); |