merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit d8ca2a2ea064d0e0f76fdbd7f0e16e843d89b677
parent ea8f733b33f336a1eb741f73a9f0037cb1bfe097
Author: bohdan-potuzhnyi <bohdan.potuzhnyi@gmail.com>
Date:   Sat,  9 Nov 2024 13:33:21 +0100

Merge branch 'master' into dev/bohdan-potuzhnyi/donau-integration

Diffstat:
Mcontrib/merchant-spa.lock | 2+-
Msrc/backend/taler-merchant-depositcheck.c | 18------------------
Msrc/backend/taler-merchant-exchangekeyupdate.c | 7+------
Msrc/backend/taler-merchant-httpd.c | 8+++++---
Msrc/backend/taler-merchant-httpd.h | 8++++----
Msrc/backend/taler-merchant-httpd_exchanges.c | 9+++++++--
Msrc/backend/taler-merchant-httpd_helper.c | 39++++++++++++++++++++-------------------
Msrc/backend/taler-merchant-httpd_helper.h | 15++++++++-------
Msrc/backend/taler-merchant-httpd_private-get-accounts-ID.c | 6+++---
Msrc/backend/taler-merchant-httpd_private-get-accounts.c | 5+++--
Msrc/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c | 26+++++++++++++++-----------
Msrc/backend/taler-merchant-httpd_private-get-instances-ID.c | 2+-
Msrc/backend/taler-merchant-httpd_private-get-orders.c | 2+-
Msrc/backend/taler-merchant-httpd_private-get-transfers.c | 29+++++++++++++++++++++--------
Msrc/backend/taler-merchant-httpd_private-patch-instances-ID.c | 2+-
Msrc/backend/taler-merchant-httpd_private-post-account.c | 18+++++++++---------
Msrc/backend/taler-merchant-httpd_private-post-transfers.c | 8++++----
Msrc/backend/taler-merchant-kyccheck.c | 38+++++++++++++++++++-------------------
Msrc/backend/taler-merchant-reconciliation.c | 15+++++----------
Msrc/backend/taler-merchant-webhook.c | 5-----
Msrc/backend/taler-merchant-wirewatch.c | 24++++++++----------------
Asrc/backenddb/merchant-0012.sql | 33+++++++++++++++++++++++++++++++++
Msrc/backenddb/pg_account_kyc_get_status.c | 4++--
Msrc/backenddb/pg_delete_transfer.c | 1+
Msrc/backenddb/pg_get_kyc_limits.c | 4++--
Msrc/backenddb/pg_get_kyc_limits.h | 2+-
Msrc/backenddb/pg_get_kyc_status.c | 4++--
Msrc/backenddb/pg_get_kyc_status.h | 2+-
Msrc/backenddb/pg_insert_account.c | 2+-
Msrc/backenddb/pg_insert_exchange_account.c | 4++--
Msrc/backenddb/pg_insert_exchange_account.h | 2+-
Msrc/backenddb/pg_insert_transfer.c | 4++--
Msrc/backenddb/pg_insert_transfer.h | 2+-
Msrc/backenddb/pg_insert_transfer_details.c | 4++--
Msrc/backenddb/pg_insert_transfer_details.h | 2+-
Msrc/backenddb/pg_lookup_account.c | 4++--
Msrc/backenddb/pg_lookup_account.h | 2+-
Msrc/backenddb/pg_lookup_transfers.c | 10+++++-----
Msrc/backenddb/pg_lookup_transfers.h | 2+-
Msrc/backenddb/pg_select_account.c | 2+-
Msrc/backenddb/pg_select_account_by_uri.c | 7++++---
Msrc/backenddb/pg_select_account_by_uri.h | 2+-
Msrc/backenddb/pg_select_accounts.c | 4++--
Msrc/backenddb/pg_select_accounts_by_exchange.c | 4++--
Msrc/backenddb/pg_select_open_transfers.c | 4++--
Msrc/backenddb/pg_select_wirewatch_accounts.c | 4++--
Msrc/backenddb/pg_update_wirewatch_progress.c | 4++--
Msrc/backenddb/pg_update_wirewatch_progress.h | 2+-
Msrc/backenddb/test_merchantdb.c | 34++++++++++++++--------------------
Msrc/bank/mb_common.c | 13+++++++++++++
Msrc/bank/mb_credit.c | 10+++++-----
Msrc/bank/mb_parse.c | 54++++++++++++++++++++++++++++++++++++++++++++++++++++--
Msrc/include/taler_merchant_bank_lib.h | 20++++++++++++++++++--
Msrc/include/taler_merchant_service.h | 16++++++++--------
Msrc/include/taler_merchant_testing_lib.h | 19++++++++++---------
Msrc/include/taler_merchantdb_plugin.h | 35+++++++++++++++--------------------
Msrc/lib/merchant_api_get_account.c | 8++++----
Msrc/lib/merchant_api_get_accounts.c | 4++--
Msrc/lib/merchant_api_get_kyc.c | 10+++++-----
Msrc/lib/merchant_api_get_orders.c | 8+++++---
Msrc/lib/merchant_api_get_transfers.c | 79+++++++++++++++++++++++++++++++++++++++++++++----------------------------------
Msrc/lib/merchant_api_post_account.c | 6+++---
Msrc/lib/merchant_api_post_transfers.c | 6+++---
Msrc/merchant-tools/benchmark-common.conf | 2+-
Msrc/merchant-tools/benchmark-cs.conf | 2+-
Msrc/merchant-tools/benchmark-rsa.conf | 2+-
Msrc/merchant-tools/taler-merchant-dbinit.c | 5-----
Msrc/merchant-tools/taler-merchant-passwd.c | 5-----
Msrc/merchant-tools/taler-merchant-setup-reserve.c | 5-----
Msrc/testing/test-merchant-walletharness.sh | 2+-
Msrc/testing/test_key_rotation.conf | 4++--
Msrc/testing/test_kyc_api.c | 24++++++++++++------------
Msrc/testing/test_merchant_api.c | 39+++++++++++++++++++--------------------
Msrc/testing/test_merchant_api.conf | 2++
Msrc/testing/test_merchant_api_twisted.c | 37+++++++++++++++++--------------------
Msrc/testing/test_merchant_wirewatch.sh | 2+-
Msrc/testing/test_template.conf | 4++--
Msrc/testing/testing_api_cmd_get_transfers.c | 15++++++++-------
Msrc/testing/testing_api_cmd_kyc_get.c | 12++++++------
Msrc/testing/testing_api_cmd_post_account.c | 11++++++-----
Msrc/testing/testing_api_cmd_post_transfers.c | 42++++++++++++++++++++++++++----------------
81 files changed, 521 insertions(+), 423 deletions(-)

diff --git a/contrib/merchant-spa.lock b/contrib/merchant-spa.lock @@ -1 +1 @@ -0.12.12 +0.13.8-dev.1 diff --git a/src/backend/taler-merchant-depositcheck.c b/src/backend/taler-merchant-depositcheck.c @@ -437,19 +437,6 @@ deposit_get_cb ( GNUNET_SCHEDULER_shutdown (); return; } - qs = db_plugin->update_deposit_confirmation_status ( - db_plugin->cls, - w->deposit_serial, - false, /* we are done, wire_pending is now false */ - GNUNET_TIME_absolute_to_timestamp (future_retry), - w->retry_backoff, - NULL); - if (qs < 0) - { - GNUNET_break (0); - GNUNET_SCHEDULER_shutdown (); - return; - } break; } case MHD_HTTP_ACCEPTED: @@ -1094,10 +1081,6 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; TALER_OS_init (); ret = GNUNET_PROGRAM_run ( argc, argv, @@ -1106,7 +1089,6 @@ main (int argc, "background process that checks with the exchange on deposits that are past the wire deadline"), options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret) diff --git a/src/backend/taler-merchant-exchangekeyupdate.c b/src/backend/taler-merchant-exchangekeyupdate.c @@ -361,7 +361,7 @@ insert_keys_data (const struct TALER_EXCHANGE_Keys *keys) qs = db_plugin->insert_exchange_account ( db_plugin->cls, &keys->master_pub, - account->payto_uri, + account->fpayto_uri, account->conversion_url, debit_restrictions, credit_restrictions, @@ -1008,10 +1008,6 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; TALER_OS_init (); ret = GNUNET_PROGRAM_run ( argc, argv, @@ -1020,7 +1016,6 @@ main (int argc, "background process that ensures our key and configuration data on exchanges is up-to-date"), options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret) diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c @@ -342,7 +342,7 @@ TMH_compute_auth (const char *token, void TMH_wire_method_free (struct TMH_WireMethod *wm) { - GNUNET_free (wm->payto_uri); + GNUNET_free (wm->payto_uri.full_payto); GNUNET_free (wm->wire_method); GNUNET_free (wm->credit_facade_url); json_decref (wm->credit_facade_credentials); @@ -2051,9 +2051,11 @@ add_account_cb (void *cls, (void) merchant_priv; wm = GNUNET_new (struct TMH_WireMethod); wm->h_wire = acc->h_wire; - wm->payto_uri = GNUNET_strdup (acc->payto_uri); + wm->payto_uri.full_payto + = GNUNET_strdup (acc->payto_uri.full_payto); wm->wire_salt = acc->salt; - wm->wire_method = TALER_payto_get_method (acc->payto_uri); + wm->wire_method + = TALER_payto_get_method (acc->payto_uri.full_payto); wm->active = acc->active; GNUNET_CONTAINER_DLL_insert (mi->wm_head, mi->wm_tail, diff --git a/src/backend/taler-merchant-httpd.h b/src/backend/taler-merchant-httpd.h @@ -31,9 +31,9 @@ * Shorthand for exit jumps. */ #define EXITIF(cond) \ - do { \ - if (cond) { GNUNET_break (0); goto EXITIF_exit; } \ - } while (0) + do { \ + if (cond) { GNUNET_break (0); goto EXITIF_exit; } \ + } while (0) /** @@ -59,7 +59,7 @@ struct TMH_WireMethod /** * Wire details for this instance */ - char *payto_uri; + struct TALER_FullPayto payto_uri; /** * Salt to use when computing @e h_wire from @e payto_uri. diff --git a/src/backend/taler-merchant-httpd_exchanges.c b/src/backend/taler-merchant-httpd_exchanges.c @@ -674,6 +674,7 @@ TMH_exchange_check_debit ( struct TALER_Amount *max_amount) { const struct TALER_EXCHANGE_Keys *keys = exchange->keys; + struct TALER_NormalizedPayto np; bool account_ok = false; bool have_kyc = false; struct TALER_Amount kyc_limit; @@ -687,11 +688,14 @@ TMH_exchange_check_debit ( GNUNET_break (0); return GNUNET_SYSERR; } + np = TALER_payto_normalize (wm->payto_uri); + /* For all accounts of the exchange */ for (unsigned int i = 0; i<keys->accounts_len; i++) { const struct TALER_EXCHANGE_WireAccount *account = &keys->accounts[i]; + if (NULL != account->conversion_url) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -702,12 +706,13 @@ TMH_exchange_check_debit ( if (GNUNET_YES != TALER_EXCHANGE_test_account_allowed (account, false, /* debit */ - wm->payto_uri)) + np)) continue; account_ok = true; /* Check legitimization limits we have with this account at this exchange, if we have any, apply them */ } + GNUNET_free (np.normalized_payto); { bool kyc_ok = false; json_t *jlimits = NULL; @@ -722,7 +727,7 @@ TMH_exchange_check_debit ( GNUNET_break (qs >= 0); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "get_kyc_limits for %s at %s returned %s/%s\n", - wm->payto_uri, + wm->payto_uri.full_payto, exchange->url, kyc_ok ? "KYC OK" : "KYC missing", NULL == jlimits ? "default limits" : "custom limits"); diff --git a/src/backend/taler-merchant-httpd_helper.c b/src/backend/taler-merchant-httpd_helper.c @@ -35,10 +35,10 @@ TMH_cmp_wire_account ( { const char *credit_facade_url = NULL; const json_t *credit_facade_credentials = NULL; - const char *uri; + struct TALER_FullPayto uri; struct GNUNET_JSON_Specification ispec[] = { - TALER_JSON_spec_payto_uri ("payto_uri", - &uri), + TALER_JSON_spec_full_payto_uri ("payto_uri", + &uri), GNUNET_JSON_spec_mark_optional ( TALER_JSON_spec_web_url ("credit_facade_url", &credit_facade_url), @@ -66,8 +66,8 @@ TMH_cmp_wire_account ( return GNUNET_SYSERR; } if (0 != - strcmp (wm->payto_uri, - uri)) + TALER_full_payto_cmp (wm->payto_uri, + uri)) { return GNUNET_SYSERR; } @@ -111,10 +111,10 @@ TMH_accounts_array_valid (const json_t *accounts) i); const char *credit_facade_url = NULL; const json_t *credit_facade_credentials = NULL; - const char *uri; + struct TALER_FullPayto uri; struct GNUNET_JSON_Specification ispec[] = { - TALER_JSON_spec_payto_uri ("payto_uri", - &uri), + TALER_JSON_spec_full_payto_uri ("payto_uri", + &uri), GNUNET_JSON_spec_mark_optional ( TALER_JSON_spec_web_url ("credit_facade_url", &credit_facade_url), @@ -147,7 +147,7 @@ TMH_accounts_array_valid (const json_t *accounts) { json_t *old_uri = json_array_get (accounts, j); - if (0 == strcmp (uri, + if (0 == strcmp (uri.full_payto, json_string_value ( json_object_get (old_uri, "payto_uri")))) @@ -164,7 +164,7 @@ TMH_accounts_array_valid (const json_t *accounts) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Encountered invalid payto://-URI `%s': %s\n", - uri, + uri.full_payto, err); GNUNET_free (err); return false; @@ -175,7 +175,7 @@ TMH_accounts_array_valid (const json_t *accounts) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "If credit_facade_url is given, credit_facade_credentials must also be specified (violated for %s)\n", - uri); + uri.full_payto); return false; } if ( (NULL != credit_facade_url) || @@ -490,7 +490,7 @@ TMH_taxes_array_valid (const json_t *taxes) struct TMH_WireMethod * TMH_setup_wire_account ( - const char *payto_uri, + struct TALER_FullPayto payto_uri, const char *credit_facade_url, const json_t *credit_facade_credentials) { @@ -501,7 +501,7 @@ TMH_setup_wire_account ( { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid URI `%s': %s\n", - payto_uri, + payto_uri.full_payto, emsg); GNUNET_free (emsg); return NULL; @@ -517,12 +517,13 @@ TMH_setup_wire_account ( GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, &wm->wire_salt, sizeof (wm->wire_salt)); - wm->payto_uri = GNUNET_strdup (payto_uri); + wm->payto_uri.full_payto + = GNUNET_strdup (payto_uri.full_payto); TALER_merchant_wire_signature_hash (payto_uri, &wm->wire_salt, &wm->h_wire); wm->wire_method - = TALER_payto_get_method (payto_uri); + = TALER_payto_get_method (payto_uri.full_payto); wm->active = true; return wm; } @@ -912,7 +913,7 @@ struct ExchangeMatchContext static void add_matching_account ( void *cls, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const char *conversion_url, const json_t *debit_restrictions, const json_t *credit_restrictions, @@ -921,7 +922,7 @@ add_matching_account ( struct ExchangeMatchContext *rc = cls; char *method; - method = TALER_payto_get_method (payto_uri); + method = TALER_payto_get_method (payto_uri.full_payto); if ( (NULL == rc->wire_method) || (0 == strcmp (method, rc->wire_method)) ) @@ -929,8 +930,8 @@ add_matching_account ( json_t *acc; acc = 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", master_sig), GNUNET_JSON_pack_allow_null ( diff --git a/src/backend/taler-merchant-httpd_helper.h b/src/backend/taler-merchant-httpd_helper.h @@ -108,7 +108,7 @@ TMH_template_contract_valid (const json_t *template_contract); */ struct TMH_WireMethod * TMH_setup_wire_account ( - const char *payto_uri, + struct TALER_FullPayto payto_uri, const char *credit_facade_url, const json_t *credit_facade_credentials); @@ -238,12 +238,13 @@ TMH_make_order_status_url (struct MHD_Connection *con, * @param hr a `TALER_EXCHANGE_HttpResponse` */ #define TMH_pack_exchange_reply(hr) \ - GNUNET_JSON_pack_uint64 ("exchange_code", (hr)->ec), \ - GNUNET_JSON_pack_uint64 ("exchange_http_status", (hr)->http_status), \ - GNUNET_JSON_pack_uint64 ("exchange_ec", (hr)->ec), /* LEGACY */ \ - GNUNET_JSON_pack_uint64 ("exchange_hc", (hr)->http_status), /* LEGACY */ \ - GNUNET_JSON_pack_allow_null ( \ - GNUNET_JSON_pack_object_incref ("exchange_reply", (json_t *) (hr)->reply)) + GNUNET_JSON_pack_uint64 ("exchange_code", (hr)->ec), \ + GNUNET_JSON_pack_uint64 ("exchange_http_status", (hr)->http_status), \ + GNUNET_JSON_pack_uint64 ("exchange_ec", (hr)->ec), /* LEGACY */ \ + GNUNET_JSON_pack_uint64 ("exchange_hc", (hr)->http_status), /* LEGACY */ \ + GNUNET_JSON_pack_allow_null ( \ + GNUNET_JSON_pack_object_incref ("exchange_reply", (json_t *) (hr)-> \ + reply)) /** diff --git a/src/backend/taler-merchant-httpd_private-get-accounts-ID.c b/src/backend/taler-merchant-httpd_private-get-accounts-ID.c @@ -83,8 +83,8 @@ TMH_private_get_accounts_ID (const struct TMH_RequestHandler *rh, MHD_HTTP_OK, GNUNET_JSON_pack_bool ("active", tp.active), - GNUNET_JSON_pack_string ("payto_uri", - tp.payto_uri), + TALER_JSON_pack_full_payto ("payto_uri", + tp.payto_uri), GNUNET_JSON_pack_data_auto ("h_wire", &tp.h_wire), GNUNET_JSON_pack_data_auto ("salt", @@ -95,7 +95,7 @@ TMH_private_get_accounts_ID (const struct TMH_RequestHandler *rh, /* We do not return the credentials, as they may be sensitive */ json_decref (tp.credit_facade_credentials); - GNUNET_free (tp.payto_uri); + GNUNET_free (tp.payto_uri.full_payto); GNUNET_free (tp.credit_facade_url); return ret; } diff --git a/src/backend/taler-merchant-httpd_private-get-accounts.c b/src/backend/taler-merchant-httpd_private-get-accounts.c @@ -20,6 +20,7 @@ */ #include "platform.h" #include "taler-merchant-httpd_private-get-accounts.h" +#include <taler/taler_json_lib.h> /** @@ -43,8 +44,8 @@ add_account (void *cls, GNUNET_JSON_PACK ( GNUNET_JSON_pack_bool ("active", ad->active), - GNUNET_JSON_pack_string ("payto_uri", - ad->payto_uri), + TALER_JSON_pack_full_payto ("payto_uri", + ad->payto_uri), GNUNET_JSON_pack_data_auto ("h_wire", &ad->h_wire)))); } diff --git a/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c b/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c @@ -102,7 +102,7 @@ struct ExchangeKycRequest /** * Our account's payto URI. */ - char *payto_uri; + struct TALER_FullPayto payto_uri; /** * Base URL of the exchange. @@ -332,7 +332,7 @@ kyc_context_cleanup (void *cls) if (NULL != ekr->keys) TALER_EXCHANGE_keys_decref (ekr->keys); GNUNET_free (ekr->exchange_url); - GNUNET_free (ekr->payto_uri); + GNUNET_free (ekr->payto_uri.full_payto); GNUNET_free (ekr); } if (NULL != kc->eh) @@ -525,7 +525,7 @@ ekr_expand_response (struct ExchangeKycRequest *ekr) json_array_append_new ( ekr->kc->kycs_data, GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ( + TALER_JSON_pack_full_payto ( "payto_uri", ekr->payto_uri), GNUNET_JSON_pack_data_auto ( @@ -586,7 +586,7 @@ ekr_finished (struct ExchangeKycRequest *ekr) if (NULL != ekr->keys) TALER_EXCHANGE_keys_decref (ekr->keys); GNUNET_free (ekr->exchange_url); - GNUNET_free (ekr->payto_uri); + GNUNET_free (ekr->payto_uri.full_payto); GNUNET_free (ekr); if (NULL != kc->exchange_pending_head) @@ -633,6 +633,7 @@ determine_eligible_accounts ( const struct TALER_EXCHANGE_Keys *keys = ekr->keys; struct TALER_Amount kyc_amount; char *merchant_pub_str; + struct TALER_NormalizedPayto np; ekr->pkaa = json_array (); GNUNET_assert (NULL != ekr->pkaa); @@ -659,12 +660,11 @@ determine_eligible_accounts ( &kc->mi->merchant_pub, sizeof (kc->mi->merchant_pub)); /* For all accounts of the exchange */ + np = TALER_payto_normalize (ekr->payto_uri); for (unsigned int i = 0; i<keys->accounts_len; i++) { const struct TALER_EXCHANGE_WireAccount *account = &keys->accounts[i]; - const char *exchange_account_payto - = account->payto_uri; /* KYC auth transfers are never supported with conversion */ if (NULL != account->conversion_url) @@ -673,10 +673,12 @@ determine_eligible_accounts ( if (GNUNET_YES != TALER_EXCHANGE_test_account_allowed (account, true, /* credit */ - ekr->payto_uri)) + np)) continue; /* exchange account is allowed, add it */ { + const char *exchange_account_payto + = account->fpayto_uri.full_payto; char *payto_kycauth; if (TALER_amount_is_zero (&kyc_amount)) @@ -707,6 +709,7 @@ determine_eligible_accounts ( GNUNET_free (payto_kycauth); } } + GNUNET_free (np.normalized_payto); GNUNET_free (merchant_pub_str); } @@ -749,7 +752,7 @@ kyc_with_exchange (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "KYC auth to `%s' impossible for merchant account `%s'\n", ekr->exchange_url, - ekr->payto_uri); + ekr->payto_uri.full_payto); ekr->kyc_auth_conflict = true; } } @@ -777,7 +780,7 @@ static void kyc_status_cb ( void *cls, const struct TALER_MerchantWireHashP *h_wire, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const char *exchange_url, struct GNUNET_TIME_Timestamp last_check, bool kyc_ok, @@ -792,7 +795,7 @@ kyc_status_cb ( GNUNET_log (GNUNET_ERROR_TYPE_INFO, "KYC status for `%s' at `%s' is %u/%s/%s/%s\n", - payto_uri, + payto_uri.full_payto, exchange_url, last_http_status, kyc_ok ? "KYC OK" : "KYC NEEDED", @@ -825,7 +828,8 @@ kyc_status_cb ( ekr->jlimits = json_incref ((json_t *) jlimits); ekr->h_wire = *h_wire; ekr->exchange_url = GNUNET_strdup (exchange_url); - ekr->payto_uri = GNUNET_strdup (payto_uri); + ekr->payto_uri.full_payto + = GNUNET_strdup (payto_uri.full_payto); ekr->last_check = last_check; ekr->kyc_ok = kyc_ok; ekr->kc = kc; diff --git a/src/backend/taler-merchant-httpd_private-get-instances-ID.c b/src/backend/taler-merchant-httpd_private-get-instances-ID.c @@ -49,7 +49,7 @@ get_instances_ID (struct TMH_MerchantInstance *mi, json_array_append_new ( ja, GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ( + TALER_JSON_pack_full_payto ( "payto_uri", wm->payto_uri), GNUNET_JSON_pack_allow_null ( diff --git a/src/backend/taler-merchant-httpd_private-get-orders.c b/src/backend/taler-merchant-httpd_private-get-orders.c @@ -754,7 +754,7 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, TALER_EC_GENERIC_PARAMETER_MALFORMED, - "date_ms"); + "date_s"); } po->of.date = GNUNET_TIME_absolute_to_timestamp ( diff --git a/src/backend/taler-merchant-httpd_private-get-transfers.c b/src/backend/taler-merchant-httpd_private-get-transfers.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2014-2021 Taler Systems SA + (C) 2014-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software @@ -46,7 +46,7 @@ static void transfer_cb (void *cls, const struct TALER_Amount *credit_amount, const struct TALER_WireTransferIdentifierRawP *wtid, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const char *exchange_url, uint64_t transfer_serial_id, struct GNUNET_TIME_Timestamp execution_time, @@ -61,8 +61,8 @@ transfer_cb (void *cls, credit_amount), GNUNET_JSON_pack_data_auto ("wtid", wtid), - GNUNET_JSON_pack_string ("payto_uri", - payto_uri), + TALER_JSON_pack_full_payto ("payto_uri", + payto_uri), GNUNET_JSON_pack_string ("exchange_url", exchange_url), GNUNET_JSON_pack_uint64 ("transfer_serial_id", @@ -96,7 +96,9 @@ TMH_private_get_transfers (const struct TMH_RequestHandler *rh, struct MHD_Connection *connection, struct TMH_HandlerContext *hc) { - const char *payto_uri; + struct TALER_FullPayto payto_uri = { + .full_payto = NULL + }; struct GNUNET_TIME_Timestamp before = GNUNET_TIME_UNIT_FOREVER_TS; struct GNUNET_TIME_Timestamp after = GNUNET_TIME_UNIT_ZERO_TS; int64_t limit = -20; @@ -104,9 +106,19 @@ TMH_private_get_transfers (const struct TMH_RequestHandler *rh, enum TALER_EXCHANGE_YesNoAll verified; (void) rh; - payto_uri = MHD_lookup_connection_value (connection, - MHD_GET_ARGUMENT_KIND, - "payto_uri"); + { + const char *esc_payto; + + esc_payto = MHD_lookup_connection_value (connection, + MHD_GET_ARGUMENT_KIND, + "payto_uri"); + if (NULL != esc_payto) + { + payto_uri.full_payto + = GNUNET_strdup (esc_payto); + MHD_http_unescape (payto_uri.full_payto); + } + } { const char *before_s; @@ -173,6 +185,7 @@ TMH_private_get_transfers (const struct TMH_RequestHandler *rh, verified, &transfer_cb, ja); + GNUNET_free (payto_uri.full_payto); if (0 > qs) { /* Simple select queries should not cause serialization issues */ diff --git a/src/backend/taler-merchant-httpd_private-patch-instances-ID.c b/src/backend/taler-merchant-httpd_private-patch-instances-ID.c @@ -43,7 +43,7 @@ static void free_wm (struct TMH_WireMethod *wm) { - GNUNET_free (wm->payto_uri); + GNUNET_free (wm->payto_uri.full_payto); GNUNET_free (wm->wire_method); GNUNET_free (wm); } diff --git a/src/backend/taler-merchant-httpd_private-post-account.c b/src/backend/taler-merchant-httpd_private-post-account.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2020-2023 Taler Systems SA + (C) 2020-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -38,10 +38,10 @@ TMH_private_post_account (const struct TMH_RequestHandler *rh, struct TMH_MerchantInstance *mi = hc->instance; const char *credit_facade_url = NULL; const json_t *credit_facade_credentials = NULL; - const char *uri; + struct TALER_FullPayto uri; struct GNUNET_JSON_Specification ispec[] = { - TALER_JSON_spec_payto_uri ("payto_uri", - &uri), + TALER_JSON_spec_full_payto_uri ("payto_uri", + &uri), GNUNET_JSON_spec_mark_optional ( TALER_JSON_spec_web_url ("credit_facade_url", &credit_facade_url), @@ -149,8 +149,8 @@ TMH_private_post_account (const struct TMH_RequestHandler *rh, switch (qs) { case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - if ( (0 == strcmp (adx.payto_uri, - ad.payto_uri) ) && + if ( (0 == TALER_full_payto_cmp (adx.payto_uri, + ad.payto_uri) ) && ( (adx.credit_facade_credentials == ad.credit_facade_credentials) || ( (NULL != adx.credit_facade_credentials) && @@ -164,7 +164,7 @@ TMH_private_post_account (const struct TMH_RequestHandler *rh, ad.credit_facade_url)) ) ) ) { TMH_wire_method_free (wm); - GNUNET_free (adx.payto_uri); + GNUNET_free (adx.payto_uri.full_payto); GNUNET_free (adx.credit_facade_url); json_decref (adx.credit_facade_credentials); return TALER_MHD_REPLY_JSON_PACK ( @@ -177,7 +177,7 @@ TMH_private_post_account (const struct TMH_RequestHandler *rh, "h_wire", &adx.h_wire)); } - GNUNET_free (adx.payto_uri); + GNUNET_free (adx.payto_uri.full_payto); GNUNET_free (adx.credit_facade_url); json_decref (adx.credit_facade_credentials); break; @@ -196,7 +196,7 @@ TMH_private_post_account (const struct TMH_RequestHandler *rh, return TALER_MHD_reply_with_error (connection, MHD_HTTP_CONFLICT, TALER_EC_MERCHANT_PRIVATE_ACCOUNT_EXISTS, - uri); + uri.full_payto); case GNUNET_DB_STATUS_SOFT_ERROR: case GNUNET_DB_STATUS_HARD_ERROR: GNUNET_break (0); diff --git a/src/backend/taler-merchant-httpd_private-post-transfers.c b/src/backend/taler-merchant-httpd_private-post-transfers.c @@ -40,7 +40,7 @@ TMH_private_post_transfers (const struct TMH_RequestHandler *rh, struct MHD_Connection *connection, struct TMH_HandlerContext *hc) { - const char *payto_uri; + struct TALER_FullPayto payto_uri; const char *exchange_url; struct TALER_WireTransferIdentifierRawP wtid; struct TALER_Amount amount; @@ -49,8 +49,8 @@ TMH_private_post_transfers (const struct TMH_RequestHandler *rh, &amount), GNUNET_JSON_spec_fixed_auto ("wtid", &wtid), - TALER_JSON_spec_payto_uri ("payto_uri", - &payto_uri), + TALER_JSON_spec_full_payto_uri ("payto_uri", + &payto_uri), TALER_JSON_spec_web_url ("exchange_url", &exchange_url), GNUNET_JSON_spec_end () @@ -68,7 +68,7 @@ TMH_private_post_transfers (const struct TMH_RequestHandler *rh, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New inbound wire transfer over %s to %s from %s\n", TALER_amount2s (&amount), - payto_uri, + payto_uri.full_payto, exchange_url); /* Check if transfer data is in database, if not, add it. */ diff --git a/src/backend/taler-merchant-kyccheck.c b/src/backend/taler-merchant-kyccheck.c @@ -117,7 +117,7 @@ struct Account /** * The payto-URI of this account. */ - char *merchant_account_uri; + struct TALER_FullPayto merchant_account_uri; /** * Wire hash of the merchant bank account (with the @@ -133,7 +133,7 @@ struct Account /** * Hash of the @e merchant_account_uri. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * Database generation when this account @@ -483,7 +483,7 @@ exchange_check_cb ( i->last_ec = ks->hr.ec; GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Checking KYC status of `%s' at `%s' is %u\n", - i->a->merchant_account_uri, + i->a->merchant_account_uri.full_payto, i->e->keys->exchange_url, ks->hr.http_status); switch (ks->hr.http_status) @@ -655,7 +655,7 @@ inquiry_work (void *cls) at_limit = false; GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Checking KYC status of `%s' at `%s'\n", - i->a->merchant_account_uri, + i->a->merchant_account_uri.full_payto, i->e->keys->exchange_url); i->timeout = GNUNET_TIME_relative_to_absolute (EXCHANGE_TIMEOUT); @@ -713,6 +713,9 @@ static bool is_eligible (const struct TALER_EXCHANGE_Keys *keys, const struct Account *a) { + struct TALER_NormalizedPayto np; + + np = TALER_payto_normalize (a->merchant_account_uri); /* For all accounts of the exchange */ for (unsigned int i = 0; i<keys->accounts_len; i++) { @@ -727,11 +730,13 @@ is_eligible (const struct TALER_EXCHANGE_Keys *keys, if (GNUNET_YES != TALER_EXCHANGE_test_account_allowed (account, true, /* credit */ - a->merchant_account_uri)) + np)) continue; /* exchange account is allowed, add it */ + GNUNET_free (np.normalized_payto); return true; } + GNUNET_free (np.normalized_payto); return false; } @@ -911,7 +916,7 @@ account_cb ( const struct TALER_MerchantPrivateKeyP *merchant_priv, const struct TALER_MERCHANTDB_AccountDetails *ad) { - const char *payto_uri = ad->payto_uri; + struct TALER_FullPayto payto_uri = ad->payto_uri; if (! ad->active) return; @@ -922,8 +927,8 @@ account_cb ( a = a->next) { if (0 == - strcmp (payto_uri, - a->merchant_account_uri)) + TALER_full_payto_cmp (payto_uri, + a->merchant_account_uri)) { a->account_gen = database_gen; return; @@ -933,16 +938,16 @@ account_cb ( struct Account *a = GNUNET_new (struct Account); a->account_gen = database_gen; - a->merchant_account_uri - = GNUNET_strdup (ad->payto_uri); + a->merchant_account_uri.full_payto + = GNUNET_strdup (ad->payto_uri.full_payto); a->instance_id = GNUNET_strdup (ad->instance_id); a->h_wire = ad->h_wire; a->ap.merchant_priv = *merchant_priv; - TALER_payto_hash (a->merchant_account_uri, - &a->h_payto); + TALER_full_payto_normalize_and_hash (a->merchant_account_uri, + &a->h_payto); GNUNET_CONTAINER_DLL_insert (a_head, a_tail, @@ -1204,7 +1209,7 @@ rule_triggered (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Starting %skyc-check for `%s' due to KYC rule trigger\n", exchange_url, - i->a->merchant_account_uri); + i->a->merchant_account_uri.full_payto); i->task = GNUNET_SCHEDULER_add_at (i->due, &inquiry_work, i); @@ -1292,7 +1297,7 @@ shutdown_task (void *cls) GNUNET_CONTAINER_DLL_remove (a_head, a_tail, a); - GNUNET_free (a->merchant_account_uri); + GNUNET_free (a->merchant_account_uri.full_payto); GNUNET_free (a); } if (NULL != eh_accounts) @@ -1451,10 +1456,6 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; TALER_OS_init (); ret = GNUNET_PROGRAM_run ( argc, argv, @@ -1463,7 +1464,6 @@ main (int argc, "background process that checks the KYC state of our bank accounts at various exchanges"), options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret) diff --git a/src/backend/taler-merchant-reconciliation.c b/src/backend/taler-merchant-reconciliation.c @@ -134,7 +134,7 @@ struct Inquiry /** * payto:// URI used for the transfer. */ - char *payto_uri; + struct TALER_FullPayto payto_uri; /** * Handle for the /wire/transfers request. @@ -397,7 +397,7 @@ end_inquiry (struct Inquiry *w) w->wdh = NULL; } GNUNET_free (w->instance_id); - GNUNET_free (w->payto_uri); + GNUNET_free (w->payto_uri.full_payto); GNUNET_CONTAINER_DLL_remove (e->w_head, e->w_tail, w); @@ -520,7 +520,7 @@ check_wire_fee (struct Inquiry *w, GNUNET_break (0); return GNUNET_NO; } - wire_method = TALER_payto_get_method (w->payto_uri); + wire_method = TALER_payto_get_method (w->payto_uri.full_payto); qs = db_plugin->lookup_wire_fee (db_plugin->cls, &keys->master_pub, wire_method, @@ -978,7 +978,7 @@ start_inquiry ( uint64_t rowid, const char *instance_id, const char *exchange_url, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_Amount *total, struct GNUNET_TIME_Absolute next_attempt) @@ -1010,7 +1010,7 @@ start_inquiry ( active_inquiries++; w = GNUNET_new (struct Inquiry); - w->payto_uri = GNUNET_strdup (payto_uri); + w->payto_uri.full_payto = GNUNET_strdup (payto_uri.full_payto); w->instance_id = GNUNET_strdup (instance_id); w->rowid = rowid; w->wtid = *wtid; @@ -1252,10 +1252,6 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; TALER_OS_init (); ret = GNUNET_PROGRAM_run ( argc, argv, @@ -1264,7 +1260,6 @@ main (int argc, "background process that reconciles bank transfers with orders by asking the exchange"), options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret) diff --git a/src/backend/taler-merchant-webhook.c b/src/backend/taler-merchant-webhook.c @@ -567,10 +567,6 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; TALER_OS_init (); ret = GNUNET_PROGRAM_run ( argc, argv, @@ -579,7 +575,6 @@ main (int argc, "background process that executes webhooks"), options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret) diff --git a/src/backend/taler-merchant-wirewatch.c b/src/backend/taler-merchant-wirewatch.c @@ -68,7 +68,7 @@ struct Watch /** * For which account are we importing bank transfers? */ - char *payto_uri; + struct TALER_FullPayto payto_uri; /** * Bank history request. @@ -189,7 +189,7 @@ save (struct Watch *w) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to persist wirewatch progress for %s/%s (%d)\n", w->instance_id, - w->payto_uri, + w->payto_uri.full_payto, qs); GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_FAILURE; @@ -216,7 +216,7 @@ end_watch (struct Watch *w) w->hh = NULL; } GNUNET_free (w->instance_id); - GNUNET_free (w->payto_uri); + GNUNET_free (w->payto_uri.full_payto); TALER_MERCHANT_BANK_auth_free (&w->ad); GNUNET_CONTAINER_DLL_remove (w_head, w_tail, @@ -351,7 +351,6 @@ credit_cb ( enum GNUNET_DB_QueryStatus qs; char *exchange_url; struct TALER_WireTransferIdentifierRawP wtid; - char *credit_payto; GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received wire transfer `%s' over %s\n", @@ -372,13 +371,12 @@ credit_cb ( } /* FIXME-Performance-Optimization: consider grouping multiple inserts into one bigger transaction with just one notify. */ - credit_payto = TALER_payto_normalize (details->credit_account_uri); qs = db_plugin->insert_transfer (db_plugin->cls, w->instance_id, exchange_url, &wtid, &details->amount, - credit_payto, + details->credit_account_uri, true /* confirmed */); if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) { @@ -404,7 +402,7 @@ credit_cb ( GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Inserting transfer for %s into database failed. Is the credit account %s configured correctly?\n", w->instance_id, - credit_payto); + details->credit_account_uri.full_payto); } if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) { @@ -425,7 +423,6 @@ credit_cb ( } } } - GNUNET_free (credit_payto); GNUNET_free (exchange_url); if (qs < 0) { @@ -553,7 +550,7 @@ static void start_watch ( void *cls, const char *instance, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const char *credit_facade_url, const json_t *credit_facade_credentials, uint64_t last_serial) @@ -570,7 +567,7 @@ start_watch ( GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to parse authentication data of `%s/%s'\n", instance, - payto_uri); + payto_uri.full_payto); GNUNET_free (w); GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_NOTCONFIGURED; @@ -581,7 +578,7 @@ start_watch ( w_tail, w); w->instance_id = GNUNET_strdup (instance); - w->payto_uri = TALER_payto_normalize (payto_uri); + w->payto_uri.full_payto = GNUNET_strdup (payto_uri.full_payto); w->start_row = last_serial; w->task = GNUNET_SCHEDULER_add_now (&do_work, w); @@ -728,10 +725,6 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return EXIT_INVALIDARGUMENT; TALER_OS_init (); do { config_changed_flag = false; @@ -744,7 +737,6 @@ main (int argc, &run, NULL); } while ( (1 == persist_mode) && config_changed_flag); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == ret) diff --git a/src/backenddb/merchant-0012.sql b/src/backenddb/merchant-0012.sql @@ -0,0 +1,33 @@ +-- +-- This file is part of TALER +-- Copyright (C) 2024 Taler Systems SA +-- +-- TALER is free software; you can redistribute it and/or modify it under the +-- terms of the GNU General Public License as published by the Free Software +-- Foundation; either version 3, or (at your option) any later version. +-- +-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +-- A PARTICULAR PURPOSE. See the GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License along with +-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +-- + +-- @file merchant-0012.sql +-- @brief Remove bogus UNIQUE constraint on categories (#9266) +-- @author Christian Grothoff + +-- Everything in one big transaction +BEGIN; + +-- Check patch versioning is in place. +SELECT _v.register_patch('merchant-0012', NULL, NULL); + +SET search_path TO merchant; + +ALTER TABLE merchant_categories + DROP CONSTRAINT merchant_categories_category_name_key, + ADD UNIQUE (merchant_serial,category_name); + +COMMIT; diff --git a/src/backenddb/pg_account_kyc_get_status.c b/src/backenddb/pg_account_kyc_get_status.c @@ -74,7 +74,7 @@ kyc_status_cb (void *cls, { struct TALER_MerchantWireHashP h_wire; char *exchange_url; - char *payto_uri; + struct TALER_FullPayto payto_uri; struct GNUNET_TIME_Timestamp last_check; bool kyc_ok; struct TALER_AccountAccessTokenP access_token; @@ -87,7 +87,7 @@ kyc_status_cb (void *cls, GNUNET_PQ_result_spec_auto_from_type ("h_wire", &h_wire), GNUNET_PQ_result_spec_string ("payto_uri", - &payto_uri), + &payto_uri.full_payto), GNUNET_PQ_result_spec_string ("exchange_url", &exchange_url), GNUNET_PQ_result_spec_timestamp ("kyc_timestamp", diff --git a/src/backenddb/pg_delete_transfer.c b/src/backenddb/pg_delete_transfer.c @@ -25,6 +25,7 @@ #include "pg_delete_transfer.h" #include "pg_helper.h" + enum GNUNET_DB_QueryStatus TMH_PG_delete_transfer (void *cls, const char *instance_id, diff --git a/src/backenddb/pg_get_kyc_limits.c b/src/backenddb/pg_get_kyc_limits.c @@ -28,7 +28,7 @@ enum GNUNET_DB_QueryStatus TMH_PG_get_kyc_limits ( void *cls, - const char *merchant_account_uri, + struct TALER_FullPayto merchant_account_uri, const char *instance_id, const char *exchange_url, bool *kyc_ok, @@ -36,7 +36,7 @@ TMH_PG_get_kyc_limits ( { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_string (merchant_account_uri), + GNUNET_PQ_query_param_string (merchant_account_uri.full_payto), GNUNET_PQ_query_param_string (instance_id), GNUNET_PQ_query_param_string (exchange_url), GNUNET_PQ_query_param_end diff --git a/src/backenddb/pg_get_kyc_limits.h b/src/backenddb/pg_get_kyc_limits.h @@ -39,7 +39,7 @@ enum GNUNET_DB_QueryStatus TMH_PG_get_kyc_limits ( void *cls, - const char *merchant_account_uri, + struct TALER_FullPayto merchant_account_uri, const char *instance_id, const char *exchange_url, bool *kyc_ok, diff --git a/src/backenddb/pg_get_kyc_status.c b/src/backenddb/pg_get_kyc_status.c @@ -29,7 +29,7 @@ enum GNUNET_DB_QueryStatus TMH_PG_get_kyc_status ( void *cls, - const char *merchant_account_uri, + struct TALER_FullPayto merchant_account_uri, const char *instance_id, const char *exchange_url, bool *auth_ok, @@ -43,7 +43,7 @@ TMH_PG_get_kyc_status ( { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_string (merchant_account_uri), + GNUNET_PQ_query_param_string (merchant_account_uri.full_payto), GNUNET_PQ_query_param_string (instance_id), GNUNET_PQ_query_param_string (exchange_url), GNUNET_PQ_query_param_end diff --git a/src/backenddb/pg_get_kyc_status.h b/src/backenddb/pg_get_kyc_status.h @@ -46,7 +46,7 @@ enum GNUNET_DB_QueryStatus TMH_PG_get_kyc_status ( void *cls, - const char *merchant_account_uri, + struct TALER_FullPayto merchant_account_uri, const char *instance_id, const char *exchange_url, bool *auth_ok, diff --git a/src/backenddb/pg_insert_account.c b/src/backenddb/pg_insert_account.c @@ -36,7 +36,7 @@ TMH_PG_insert_account ( GNUNET_PQ_query_param_string (account_details->instance_id), GNUNET_PQ_query_param_auto_from_type (&account_details->h_wire), GNUNET_PQ_query_param_auto_from_type (&account_details->salt), - GNUNET_PQ_query_param_string (account_details->payto_uri), + GNUNET_PQ_query_param_string (account_details->payto_uri.full_payto), NULL ==account_details->credit_facade_url ? GNUNET_PQ_query_param_null () : GNUNET_PQ_query_param_string (account_details->credit_facade_url), diff --git a/src/backenddb/pg_insert_exchange_account.c b/src/backenddb/pg_insert_exchange_account.c @@ -30,7 +30,7 @@ enum GNUNET_DB_QueryStatus TMH_PG_insert_exchange_account ( void *cls, const struct TALER_MasterPublicKeyP *master_pub, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const char *conversion_url, const json_t *debit_restrictions, const json_t *credit_restrictions, @@ -39,7 +39,7 @@ TMH_PG_insert_exchange_account ( struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), - GNUNET_PQ_query_param_string (payto_uri), + GNUNET_PQ_query_param_string (payto_uri.full_payto), NULL == conversion_url ? GNUNET_PQ_query_param_null () : GNUNET_PQ_query_param_string (conversion_url), diff --git a/src/backenddb/pg_insert_exchange_account.h b/src/backenddb/pg_insert_exchange_account.h @@ -41,7 +41,7 @@ enum GNUNET_DB_QueryStatus TMH_PG_insert_exchange_account ( void *cls, const struct TALER_MasterPublicKeyP *master_pub, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const char *conversion_url, const json_t *debit_restrictions, const json_t *credit_restrictions, diff --git a/src/backenddb/pg_insert_transfer.c b/src/backenddb/pg_insert_transfer.c @@ -33,7 +33,7 @@ TMH_PG_insert_transfer ( const char *exchange_url, const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_Amount *credit_amount, - const char *payto_uri, + struct TALER_FullPayto payto_uri, bool confirmed) { struct PostgresClosure *pg = cls; @@ -42,7 +42,7 @@ TMH_PG_insert_transfer ( GNUNET_PQ_query_param_auto_from_type (wtid), TALER_PQ_query_param_amount_with_currency (pg->conn, credit_amount), - GNUNET_PQ_query_param_string (payto_uri), + GNUNET_PQ_query_param_string (payto_uri.full_payto), GNUNET_PQ_query_param_bool (confirmed), GNUNET_PQ_query_param_string (instance_id), GNUNET_PQ_query_param_end diff --git a/src/backenddb/pg_insert_transfer.h b/src/backenddb/pg_insert_transfer.h @@ -45,7 +45,7 @@ TMH_PG_insert_transfer ( const char *exchange_url, const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_Amount *credit_amount, - const char *payto_uri, + struct TALER_FullPayto payto_uri, bool confirmed); diff --git a/src/backenddb/pg_insert_transfer_details.c b/src/backenddb/pg_insert_transfer_details.c @@ -37,7 +37,7 @@ TMH_PG_insert_transfer_details ( void *cls, const char *instance_id, const char *exchange_url, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_EXCHANGE_TransferData *td) { @@ -87,7 +87,7 @@ TMH_PG_insert_transfer_details ( struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_string (instance_id), GNUNET_PQ_query_param_string (exchange_url), - GNUNET_PQ_query_param_string (payto_uri), + GNUNET_PQ_query_param_string (payto_uri.full_payto), GNUNET_PQ_query_param_auto_from_type (wtid), GNUNET_PQ_query_param_timestamp (&td->execution_time), GNUNET_PQ_query_param_auto_from_type (&td->exchange_pub), diff --git a/src/backenddb/pg_insert_transfer_details.h b/src/backenddb/pg_insert_transfer_details.h @@ -44,7 +44,7 @@ TMH_PG_insert_transfer_details ( void *cls, const char *instance_id, const char *exchange_url, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_EXCHANGE_TransferData *td); diff --git a/src/backenddb/pg_lookup_account.c b/src/backenddb/pg_lookup_account.c @@ -28,13 +28,13 @@ enum GNUNET_DB_QueryStatus TMH_PG_lookup_account (void *cls, const char *instance_id, - const char *payto_uri, + struct TALER_FullPayto payto_uri, uint64_t *account_serial) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_string (instance_id), - GNUNET_PQ_query_param_string (payto_uri), + GNUNET_PQ_query_param_string (payto_uri.full_payto), GNUNET_PQ_query_param_end }; struct GNUNET_PQ_ResultSpec rs[] = { diff --git a/src/backenddb/pg_lookup_account.h b/src/backenddb/pg_lookup_account.h @@ -37,7 +37,7 @@ enum GNUNET_DB_QueryStatus TMH_PG_lookup_account (void *cls, const char *instance_id, - const char *payto_uri, + struct TALER_FullPayto payto_uri, uint64_t *account_serial); #endif diff --git a/src/backenddb/pg_lookup_transfers.c b/src/backenddb/pg_lookup_transfers.c @@ -73,7 +73,7 @@ lookup_transfers_cb (void *cls, { struct TALER_Amount credit_amount; struct TALER_WireTransferIdentifierRawP wtid; - char *payto_uri; + struct TALER_FullPayto payto_uri; char *exchange_url; uint64_t transfer_serial_id; struct GNUNET_TIME_Timestamp execution_time = GNUNET_TIME_UNIT_FOREVER_TS; @@ -85,7 +85,7 @@ lookup_transfers_cb (void *cls, GNUNET_PQ_result_spec_auto_from_type ("wtid", &wtid), GNUNET_PQ_result_spec_string ("payto_uri", - &payto_uri), + &payto_uri.full_payto), GNUNET_PQ_result_spec_string ("exchange_url", &exchange_url), GNUNET_PQ_result_spec_uint64 ("credit_serial", @@ -128,7 +128,7 @@ lookup_transfers_cb (void *cls, enum GNUNET_DB_QueryStatus TMH_PG_lookup_transfers (void *cls, const char *instance_id, - const char *payto_uri, + struct TALER_FullPayto payto_uri, struct GNUNET_TIME_Timestamp before, struct GNUNET_TIME_Timestamp after, int64_t limit, @@ -152,9 +152,9 @@ TMH_PG_lookup_transfers (void *cls, GNUNET_PQ_query_param_timestamp (&after), GNUNET_PQ_query_param_uint64 (&offset), GNUNET_PQ_query_param_uint64 (&plimit), - NULL == payto_uri + NULL == payto_uri.full_payto ? GNUNET_PQ_query_param_null () /* NULL: do not filter by payto URI */ - : GNUNET_PQ_query_param_string (payto_uri), + : GNUNET_PQ_query_param_string (payto_uri.full_payto), GNUNET_PQ_query_param_bool (! by_time), /* $7: filter by time? */ GNUNET_PQ_query_param_bool (TALER_EXCHANGE_YNA_ALL == verified), /* filter by verified? */ GNUNET_PQ_query_param_bool (TALER_EXCHANGE_YNA_YES == verified), diff --git a/src/backenddb/pg_lookup_transfers.h b/src/backenddb/pg_lookup_transfers.h @@ -48,7 +48,7 @@ enum GNUNET_DB_QueryStatus TMH_PG_lookup_transfers (void *cls, const char *instance_id, - const char *payto_uri, + struct TALER_FullPayto payto_uri, struct GNUNET_TIME_Timestamp before, struct GNUNET_TIME_Timestamp after, int64_t limit, diff --git a/src/backenddb/pg_select_account.c b/src/backenddb/pg_select_account.c @@ -42,7 +42,7 @@ TMH_PG_select_account (void *cls, GNUNET_PQ_result_spec_auto_from_type ("salt", &ad->salt), GNUNET_PQ_result_spec_string ("payto_uri", - &ad->payto_uri), + &ad->payto_uri.full_payto), GNUNET_PQ_result_spec_allow_null ( GNUNET_PQ_result_spec_string ("credit_facade_url", &ad->credit_facade_url), diff --git a/src/backenddb/pg_select_account_by_uri.c b/src/backenddb/pg_select_account_by_uri.c @@ -29,13 +29,13 @@ enum GNUNET_DB_QueryStatus TMH_PG_select_account_by_uri (void *cls, const char *id, - const char *payto_uri, + struct TALER_FullPayto payto_uri, struct TALER_MERCHANTDB_AccountDetails *ad) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_string (id), - GNUNET_PQ_query_param_string (payto_uri), + GNUNET_PQ_query_param_string (payto_uri.full_payto), GNUNET_PQ_query_param_end }; struct GNUNET_PQ_ResultSpec rs[] = { @@ -58,7 +58,8 @@ TMH_PG_select_account_by_uri (void *cls, ad->credit_facade_url = NULL; ad->credit_facade_credentials = NULL; - ad->payto_uri = GNUNET_strdup (payto_uri); + ad->payto_uri.full_payto + = GNUNET_strdup (payto_uri.full_payto); ad->instance_id = id; check_connection (pg); PREPARE (pg, diff --git a/src/backenddb/pg_select_account_by_uri.h b/src/backenddb/pg_select_account_by_uri.h @@ -38,7 +38,7 @@ enum GNUNET_DB_QueryStatus TMH_PG_select_account_by_uri (void *cls, const char *id, - const char *payto_uri, + struct TALER_FullPayto payto_uri, struct TALER_MERCHANTDB_AccountDetails *ad); #endif diff --git a/src/backenddb/pg_select_accounts.c b/src/backenddb/pg_select_accounts.c @@ -71,7 +71,7 @@ select_account_cb (void *cls, for (unsigned int i = 0; i < num_results; i++) { - char *payto; + struct TALER_FullPayto payto; char *instance_id; char *facade_url = NULL; json_t *credential = NULL; @@ -84,7 +84,7 @@ select_account_cb (void *cls, GNUNET_PQ_result_spec_auto_from_type ("salt", &acc.salt), GNUNET_PQ_result_spec_string ("payto_uri", - &payto), + &payto.full_payto), GNUNET_PQ_result_spec_string ("merchant_id", &instance_id), GNUNET_PQ_result_spec_allow_null ( diff --git a/src/backenddb/pg_select_accounts_by_exchange.c b/src/backenddb/pg_select_accounts_by_exchange.c @@ -64,7 +64,7 @@ parse_accounts (void *cls, for (unsigned int i = 0; i < num_results; i++) { - char *payto_uri; + struct TALER_FullPayto payto_uri; char *conversion_url = NULL; json_t *debit_restrictions; json_t *credit_restrictions; @@ -73,7 +73,7 @@ parse_accounts (void *cls, GNUNET_PQ_result_spec_auto_from_type ("master_sig", &master_sig), GNUNET_PQ_result_spec_string ("payto_uri", - &payto_uri), + &payto_uri.full_payto), GNUNET_PQ_result_spec_allow_null ( GNUNET_PQ_result_spec_string ("conversion_url", &conversion_url), diff --git a/src/backenddb/pg_select_open_transfers.c b/src/backenddb/pg_select_open_transfers.c @@ -73,7 +73,7 @@ open_transfers_cb (void *cls, uint64_t rowid; char *instance_id; char *exchange_url; - char *payto_uri; + struct TALER_FullPayto payto_uri; struct TALER_WireTransferIdentifierRawP wtid; struct TALER_Amount total; struct GNUNET_TIME_Absolute next_attempt; @@ -85,7 +85,7 @@ open_transfers_cb (void *cls, GNUNET_PQ_result_spec_string ("exchange_url", &exchange_url), GNUNET_PQ_result_spec_string ("payto_uri", - &payto_uri), + &payto_uri.full_payto), GNUNET_PQ_result_spec_auto_from_type ("wtid", &wtid), TALER_PQ_result_spec_amount_with_currency ("credit_amount", diff --git a/src/backenddb/pg_select_wirewatch_accounts.c b/src/backenddb/pg_select_wirewatch_accounts.c @@ -66,7 +66,7 @@ handle_results (void *cls, for (unsigned int i = 0; i < num_results; i++) { char *instance; - char *payto_uri; + struct TALER_FullPayto payto_uri; char *facade_url; json_t *credential; uint64_t last_serial; @@ -74,7 +74,7 @@ handle_results (void *cls, GNUNET_PQ_result_spec_string ("merchant_id", &instance), GNUNET_PQ_result_spec_string ("payto_uri", - &payto_uri), + &payto_uri.full_payto), GNUNET_PQ_result_spec_string ("credit_facade_url", &facade_url), GNUNET_PQ_result_spec_allow_null ( diff --git a/src/backenddb/pg_update_wirewatch_progress.c b/src/backenddb/pg_update_wirewatch_progress.c @@ -30,13 +30,13 @@ enum GNUNET_DB_QueryStatus TMH_PG_update_wirewatch_progress ( void *cls, const char *instance, - const char *payto_uri, + struct TALER_FullPayto payto_uri, uint64_t last_serial) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_string (instance), - GNUNET_PQ_query_param_string (payto_uri), + GNUNET_PQ_query_param_string (payto_uri.full_payto), GNUNET_PQ_query_param_uint64 (&last_serial), GNUNET_PQ_query_param_end }; diff --git a/src/backenddb/pg_update_wirewatch_progress.h b/src/backenddb/pg_update_wirewatch_progress.h @@ -39,7 +39,7 @@ enum GNUNET_DB_QueryStatus TMH_PG_update_wirewatch_progress ( void *cls, const char *instance, - const char *payto_uri, + struct TALER_FullPayto payto_uri, uint64_t last_serial); diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c @@ -107,8 +107,8 @@ make_instance (const char *instance_id, GNUNET_CRYPTO_eddsa_key_create (&instance->merchant_priv.eddsa_priv); GNUNET_CRYPTO_eddsa_key_get_public (&instance->merchant_priv.eddsa_priv, &instance->merchant_pub.eddsa_pub); - instance->instance.id = instance_id; - instance->instance.name = "Test"; + instance->instance.id = (char *) instance_id; + instance->instance.name = (char *) "Test"; instance->instance.address = json_array (); GNUNET_assert (NULL != instance->instance.address); GNUNET_assert (0 == json_array_append_new (instance->instance.address, @@ -153,7 +153,8 @@ make_account (struct TALER_MERCHANTDB_AccountDetails *account) GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG, &account->salt, sizeof (account->salt)); - account->payto_uri = "payto://x-taler-bank/bank.demo.taler.net/4"; + account->payto_uri.full_payto + = (char *) "payto://x-taler-bank/bank.demo.taler.net/4"; account->active = true; } @@ -236,6 +237,7 @@ check_instances_equal (const struct TALER_MERCHANTDB_InstanceSettings *a, } +#if 0 /** * Compares two accounts for equality. * @@ -251,25 +253,15 @@ check_accounts_equal (const struct TALER_MERCHANTDB_AccountDetails *a, &b->h_wire)) || (0 != GNUNET_memcmp (&a->salt, &b->salt)) || - (0 != strcmp (a->payto_uri, - b->payto_uri)) || + (0 != TALER_full_payto_cmp (a->payto_uri, + b->payto_uri)) || (a->active != b->active)) return 1; return 0; } -// FIXME: use this! -void -lookup_accounts_cb (void *cls, - const struct TALER_MERCHANTDB_AccountDetails *account) -{ - const struct TALER_MERCHANTDB_AccountDetails *want = cls; - - GNUNET_assert (0 == - check_accounts_equal (want, - account)); -} +#endif /** @@ -633,7 +625,9 @@ run_test_instances (struct TestInstances_Closure *cls) if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != plugin->lookup_account (plugin->cls, cls->instances[0].instance.id, - "payto://other-uri", + (struct TALER_FullPayto) { + (char *) "payto://other-uri" + }, &account_serial)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -4078,7 +4072,7 @@ static void lookup_transfers_cb (void *cls, const struct TALER_Amount *credit_amount, const struct TALER_WireTransferIdentifierRawP *wtid, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const char *exchange_url, uint64_t transfer_serial_id, struct GNUNET_TIME_Timestamp execution_time, @@ -5581,7 +5575,7 @@ static void kyc_status_ok ( void *cls, const struct TALER_MerchantWireHashP *h_wire, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const char *exchange_url, struct GNUNET_TIME_Timestamp last_check, bool kyc_ok, @@ -5602,7 +5596,7 @@ static void kyc_status_fail ( void *cls, const struct TALER_MerchantWireHashP *h_wire, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const char *exchange_url, struct GNUNET_TIME_Timestamp last_check, bool kyc_ok, diff --git a/src/bank/mb_common.c b/src/bank/mb_common.c @@ -55,6 +55,19 @@ TALER_MERCHANT_BANK_setup_auth_ ( GNUNET_free (up); break; } + case TALER_MERCHANT_BANK_AUTH_BEARER: + { + if ( (CURLE_OK != + curl_easy_setopt (easy, + CURLOPT_HTTPAUTH, + CURLAUTH_BEARER)) || + (CURLE_OK != + curl_easy_setopt (easy, + CURLOPT_XOAUTH2_BEARER, + auth->details.bearer.token)) ) + ret = GNUNET_SYSERR; + break; + } } return ret; } diff --git a/src/bank/mb_credit.c b/src/bank/mb_credit.c @@ -70,12 +70,12 @@ parse_account_history (struct TALER_MERCHANT_BANK_CreditHistoryHandle *hh, const json_t *history) { const json_t *history_array; - const char *credit_account_uri; + struct TALER_FullPayto credit_account_uri; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_array_const ("incoming_transactions", &history_array), - GNUNET_JSON_spec_string ("credit_account", - &credit_account_uri), + TALER_JSON_spec_full_payto_uri ("credit_account", + &credit_account_uri), GNUNET_JSON_spec_end () }; @@ -101,8 +101,8 @@ parse_account_history (struct TALER_MERCHANT_BANK_CreditHistoryHandle *hh, &row_id), GNUNET_JSON_spec_string ("subject", &td.wire_subject), - GNUNET_JSON_spec_string ("debit_account", - &td.debit_account_uri), + TALER_JSON_spec_full_payto_uri ("debit_account", + &td.debit_account_uri), GNUNET_JSON_spec_end () }; json_t *transaction = json_array_get (history_array, diff --git a/src/bank/mb_parse.c b/src/bank/mb_parse.c @@ -32,8 +32,9 @@ static const struct const char *m; enum TALER_MERCHANT_BANK_AuthenticationMethod e; } methods[] = { - { "NONE", TALER_MERCHANT_BANK_AUTH_NONE }, - { "BASIC", TALER_MERCHANT_BANK_AUTH_BASIC }, + { "NONE", TALER_MERCHANT_BANK_AUTH_NONE }, + { "BASIC", TALER_MERCHANT_BANK_AUTH_BASIC }, + { "BEARER", TALER_MERCHANT_BANK_AUTH_BEARER }, { NULL, TALER_MERCHANT_BANK_AUTH_NONE } }; @@ -113,6 +114,23 @@ TALER_MERCHANT_BANK_auth_parse_cfg ( auth->method = TALER_MERCHANT_BANK_AUTH_BASIC; GNUNET_free (method); return GNUNET_OK; + case TALER_MERCHANT_BANK_AUTH_BEARER: + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (cfg, + section, + "TOKEN", + &auth->details.bearer.token)) + { + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + section, + "TOKEN"); + GNUNET_free (method); + GNUNET_free (auth->wire_gateway_url); + return GNUNET_SYSERR; + } + auth->method = TALER_MERCHANT_BANK_AUTH_BEARER; + GNUNET_free (method); + return GNUNET_OK; } } } @@ -191,6 +209,35 @@ TALER_MERCHANT_BANK_auth_parse_json ( } auth->method = TALER_MERCHANT_BANK_AUTH_BASIC; return GNUNET_OK; + case TALER_MERCHANT_BANK_AUTH_BEARER: + { + const char *token; + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_string ("token", + &token), + GNUNET_JSON_spec_end () + }; + enum GNUNET_GenericReturnValue res; + const char *err; + unsigned int eline; + + res = GNUNET_JSON_parse (cred, + spec, + &err, + &eline); + if (GNUNET_OK != res) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Credentials malformed: %s (%u)\n", + err, + eline); + GNUNET_free (auth->wire_gateway_url); + return GNUNET_SYSERR; + } + auth->details.bearer.token = GNUNET_strdup (token); + } + auth->method = TALER_MERCHANT_BANK_AUTH_BEARER; + return GNUNET_OK; } } } @@ -210,6 +257,9 @@ TALER_MERCHANT_BANK_auth_free ( GNUNET_free (auth->details.basic.username); GNUNET_free (auth->details.basic.password); break; + case TALER_MERCHANT_BANK_AUTH_BEARER: + GNUNET_free (auth->details.bearer.token); + break; } GNUNET_free (auth->wire_gateway_url); } diff --git a/src/include/taler_merchant_bank_lib.h b/src/include/taler_merchant_bank_lib.h @@ -43,6 +43,11 @@ enum TALER_MERCHANT_BANK_AuthenticationMethod * Basic authentication with cleartext username and password. */ TALER_MERCHANT_BANK_AUTH_BASIC, + + /** + * Bearer token authentication. + */ + TALER_MERCHANT_BANK_AUTH_BEARER, }; @@ -85,6 +90,17 @@ struct TALER_MERCHANT_BANK_AuthenticationData char *password; } basic; + /** + * Details for #TALER_MERCHANT_BANK_AUTH_BASIC. + */ + struct + { + /** + * Token to use. + */ + char *token; + } bearer; + } details; }; @@ -122,13 +138,13 @@ struct TALER_MERCHANT_BANK_CreditDetails * payto://-URL of the source account that * send the funds. */ - const char *debit_account_uri; + struct TALER_FullPayto debit_account_uri; /** * payto://-URL of the target account that * received the funds. */ - const char *credit_account_uri; + struct TALER_FullPayto credit_account_uri; }; diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h @@ -1012,7 +1012,7 @@ struct TALER_MERCHANT_AccountsPostHandle * TALER_MERCHANT_accounts_post ( struct GNUNET_CURL_Context *ctx, const char *backend_url, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const char *credit_facade_url, const json_t *credit_facade_credentials, TALER_MERCHANT_AccountsPostCallback cb, @@ -1049,7 +1049,7 @@ struct TALER_MERCHANT_AccountDetails /** * payto:// URI of the account. */ - const char *payto_uri; + struct TALER_FullPayto payto_uri; /** * Credit facade URL of the account. @@ -1160,7 +1160,7 @@ struct TALER_MERCHANT_AccountEntry /** * account payto URI. */ - const char *payto_uri; + struct TALER_FullPayto payto_uri; /** * Hash of @e payto_uri and salt. @@ -4151,7 +4151,7 @@ TALER_MERCHANT_transfers_post ( const char *backend_url, const struct TALER_Amount *credit_amount, const struct TALER_WireTransferIdentifierRawP *wtid, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const char *exchange_url, TALER_MERCHANT_PostTransfersCallback cb, void *cls); @@ -4245,7 +4245,7 @@ struct TALER_MERCHANT_TransferData /** * URI of the target account. */ - const char *payto_uri; + struct TALER_FullPayto payto_uri; /** * URL of the exchange that made the transfer. @@ -4360,7 +4360,7 @@ struct TALER_MERCHANT_GetTransfersHandle * TALER_MERCHANT_transfers_get ( struct GNUNET_CURL_Context *ctx, const char *backend_url, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const struct GNUNET_TIME_Timestamp before, const struct GNUNET_TIME_Timestamp after, int64_t limit, @@ -4409,7 +4409,7 @@ struct TALER_MERCHANT_AccountKycRedirectDetail /** * Our bank wire account this is about. */ - const char *payto_uri; + struct TALER_FullPayto payto_uri; /** * Array of length @e limits_array with (exposed) limits that apply to the @@ -4423,7 +4423,7 @@ struct TALER_MERCHANT_AccountKycRedirectDetail * the given account. Needed if @e kyc_url is NULL * and @e limits are to be passed. */ - const char **payto_kycauths; + struct TALER_FullPayto *payto_kycauths; /** * Length of the @e limits array. diff --git a/src/include/taler_merchant_testing_lib.h b/src/include/taler_merchant_testing_lib.h @@ -169,7 +169,7 @@ struct TALER_TESTING_Command TALER_TESTING_cmd_merchant_post_account ( const char *label, const char *merchant_url, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const char *credit_facade_url, const json_t *credit_facade_credentials, unsigned int http_status); @@ -1167,7 +1167,7 @@ struct TALER_TESTING_Command TALER_TESTING_cmd_merchant_post_transfer ( const char *label, const struct TALER_BANK_AuthenticationData *auth, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const char *merchant_url, const char *credit_amount, unsigned int http_code, @@ -1191,7 +1191,7 @@ struct TALER_TESTING_Command TALER_TESTING_cmd_merchant_post_transfer2 ( const char *label, const char *merchant_url, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const char *credit_amount, const char *wtid, const char *exchange_url, @@ -1225,11 +1225,12 @@ TALER_TESTING_cmd_merchant_post_transfer_set_serial ( * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_merchant_get_transfers (const char *label, - const char *merchant_url, - const char *payto_uri, - unsigned int http_code, - ...); +TALER_TESTING_cmd_merchant_get_transfers ( + const char *label, + const char *merchant_url, + struct TALER_FullPayto payto_uri, + unsigned int http_code, + ...); /** @@ -1875,7 +1876,7 @@ TALER_TESTING_cmd_merchant_get_donau_instances(const char *label, #define TALER_MERCHANT_TESTING_INDEXED_TRAITS(op) \ op (coin_reference, const char) \ op (paths, const char) \ - op (payto_uris, const char) \ + op (payto_uris, const struct TALER_FullPayto) \ op (h_wires, const struct TALER_MerchantWireHashP) \ op (amounts, const struct TALER_Amount) \ op (urls, const char) \ diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h @@ -150,7 +150,7 @@ struct TALER_MERCHANTDB_AccountDetails /** * Actual account address as a payto://-URI. */ - char *payto_uri; + struct TALER_FullPayto payto_uri; /** * Where can the taler-merchant-wirewatch helper @@ -885,7 +885,7 @@ typedef void (*TALER_MERCHANTDB_KycCallback)( void *cls, const struct TALER_MerchantWireHashP *h_wire, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const char *exchange_url, struct GNUNET_TIME_Timestamp last_check, bool kyc_ok, @@ -975,7 +975,7 @@ typedef void uint64_t rowid, const char *instance_id, const char *exchange_url, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_Amount *total, struct GNUNET_TIME_Absolute next_attempt); @@ -1040,7 +1040,7 @@ typedef void (*TALER_MERCHANTDB_WirewatchWorkCallback)( void *cls, const char *instance, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const char *credit_facade_url, const json_t *credit_facade_credentials, uint64_t last_serial); @@ -1067,7 +1067,7 @@ typedef void void *cls, const struct TALER_Amount *credit_amount, const struct TALER_WireTransferIdentifierRawP *wtid, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const char *exchange_url, uint64_t transfer_serial_id, struct GNUNET_TIME_Timestamp execution_time, @@ -1089,7 +1089,7 @@ typedef void typedef void (*TALER_MERCHANTDB_ExchangeAccountCallback) ( void *cls, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const char *conversion_url, const json_t *debit_restrictions, const json_t *credit_restrictions, @@ -1660,7 +1660,7 @@ struct TALER_MERCHANTDB_Plugin (*select_account_by_uri)( void *cls, const char *id, - const char *payto_uri, + struct TALER_FullPayto payto_uri, struct TALER_MERCHANTDB_AccountDetails *ad); @@ -1784,7 +1784,7 @@ struct TALER_MERCHANTDB_Plugin enum GNUNET_DB_QueryStatus (*get_kyc_status)( void *cls, - const char *merchant_account_uri, + struct TALER_FullPayto merchant_account_uri, const char *instance_id, const char *exchange_url, bool *auth_ok, @@ -1811,7 +1811,7 @@ struct TALER_MERCHANTDB_Plugin enum GNUNET_DB_QueryStatus (*get_kyc_limits)( void *cls, - const char *merchant_account_uri, + struct TALER_FullPayto merchant_account_uri, const char *instance_id, const char *exchange_url, bool *kyc_ok, @@ -2799,7 +2799,7 @@ struct TALER_MERCHANTDB_Plugin (*update_wirewatch_progress)( void *cls, const char *instance, - const char *payto_uri, + struct TALER_FullPayto payto_uri, uint64_t last_serial); @@ -2838,7 +2838,7 @@ struct TALER_MERCHANTDB_Plugin const char *exchange_url, const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_Amount *credit_amount, - const char *payto_uri, + struct TALER_FullPayto payto_uri, bool confirmed); @@ -2886,7 +2886,7 @@ struct TALER_MERCHANTDB_Plugin enum GNUNET_DB_QueryStatus (*lookup_account)(void *cls, const char *instance_id, - const char *payto_uri, + struct TALER_FullPayto payto_uri, uint64_t *account_serial); @@ -2908,7 +2908,7 @@ struct TALER_MERCHANTDB_Plugin void *cls, const char *instance_id, const char *exchange_url, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_EXCHANGE_TransferData *td); @@ -2967,7 +2967,6 @@ struct TALER_MERCHANTDB_Plugin * @param cls closure * @param instance_id the instance to look up details at * @param exchange_url the exchange that made the transfer - * @param payto_uri account that received the transfer * @param wtid wire transfer subject * @param[out] total_amount amount that was debited from our * aggregate balance at the exchange (in total, sum of @@ -3016,9 +3015,7 @@ struct TALER_MERCHANTDB_Plugin * Lookup transfer summary (used if we already verified the details). * * @param cls closure - * @param instance_id instance to lookup payments for * @param exchange_url the exchange that made the transfer - * @param payto_uri account that received the transfer * @param wtid wire transfer subject * @param cb function to call with detailed transfer data * @param cb_cls closure for @a cb @@ -3037,9 +3034,7 @@ struct TALER_MERCHANTDB_Plugin * Lookup transfer details. Used if we still need to verify the details. * * @param cls closure - * @param instance_id instance to lookup payments for * @param exchange_url the exchange that made the transfer - * @param payto_uri account that received the transfer * @param wtid wire transfer subject * @param cb function to call with detailed transfer data * @param cb_cls closure for @a cb @@ -3074,7 +3069,7 @@ struct TALER_MERCHANTDB_Plugin (*lookup_transfers)( void *cls, const char *instance_id, - const char *payto_uri, + struct TALER_FullPayto payto_uri, struct GNUNET_TIME_Timestamp before, struct GNUNET_TIME_Timestamp after, int64_t limit, @@ -3154,7 +3149,7 @@ struct TALER_MERCHANTDB_Plugin (*insert_exchange_account)( void *cls, const struct TALER_MasterPublicKeyP *master_pub, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const char *conversion_url, const json_t *debit_restrictions, const json_t *credit_restrictions, diff --git a/src/lib/merchant_api_get_account.c b/src/lib/merchant_api_get_account.c @@ -74,8 +74,8 @@ struct TALER_MERCHANT_AccountGetHandle */ static void handle_get_account_finished (void *cls, - long response_code, - const void *response) + long response_code, + const void *response) { struct TALER_MERCHANT_AccountGetHandle *tgh = cls; const json_t *json = response; @@ -99,8 +99,8 @@ handle_get_account_finished (void *cls, TALER_JSON_spec_web_url ("credit_facade_url", &tgr.details.ok.ad.credit_facade_url), NULL), - TALER_JSON_spec_payto_uri ("payto_uri", - &tgr.details.ok.ad.payto_uri), + TALER_JSON_spec_full_payto_uri ("payto_uri", + &tgr.details.ok.ad.payto_uri), GNUNET_JSON_spec_fixed_auto ("h_wire", &tgr.details.ok.ad.h_wire), GNUNET_JSON_spec_bool ("active", diff --git a/src/lib/merchant_api_get_accounts.c b/src/lib/merchant_api_get_accounts.c @@ -97,8 +97,8 @@ parse_accounts (const json_t *ia, json_array_foreach (ia, index, value) { struct TALER_MERCHANT_AccountEntry *ie = &tmpl[index]; struct GNUNET_JSON_Specification spec[] = { - TALER_JSON_spec_payto_uri ("payto_uri", - &ie->payto_uri), + TALER_JSON_spec_full_payto_uri ("payto_uri", + &ie->payto_uri), GNUNET_JSON_spec_fixed_auto ("h_wire", &ie->h_wire), GNUNET_JSON_spec_end () diff --git a/src/lib/merchant_api_get_kyc.c b/src/lib/merchant_api_get_kyc.c @@ -136,7 +136,7 @@ parse_kyc (struct TALER_MERCHANT_KycGetHandle *kyc, GNUNET_NZL (num_kycs)]; struct TALER_EXCHANGE_AccountLimit limits[ GNUNET_NZL (num_limits)]; - const char *payto_kycauths[ + struct TALER_FullPayto payto_kycauths[ GNUNET_NZL (num_kycauths)]; memset (kycs, @@ -150,7 +150,7 @@ parse_kyc (struct TALER_MERCHANT_KycGetHandle *kyc, const json_t *jkycauths = NULL; uint32_t hs; struct GNUNET_JSON_Specification spec[] = { - TALER_JSON_spec_payto_uri ( + TALER_JSON_spec_full_payto_uri ( "payto_uri", &rd->payto_uri), TALER_JSON_spec_web_url ( @@ -250,9 +250,9 @@ parse_kyc (struct TALER_MERCHANT_KycGetHandle *kyc, json_array_foreach (jkycauths, j, jkycauth) { GNUNET_assert (pos_kycauths < num_kycauths); - payto_kycauths[pos_kycauths] - = json_string_value (jkycauth); - if (NULL == payto_kycauths[pos_kycauths]) + payto_kycauths[pos_kycauths].full_payto + = (char *) json_string_value (jkycauth); + if (NULL == payto_kycauths[pos_kycauths].full_payto) { GNUNET_break (0); json_dumpf (json_array_get (jkyc, diff --git a/src/lib/merchant_api_get_orders.c b/src/lib/merchant_api_get_orders.c @@ -306,7 +306,7 @@ TALER_MERCHANT_orders_get3 ( /* build ogh->url with the various optional arguments */ { - char *dstr; + char dstr[30]; char *fec = NULL; char *sid = NULL; bool have_date; @@ -335,7 +335,10 @@ TALER_MERCHANT_orders_get3 ( (void) GNUNET_STRINGS_urlencode (strlen (fulfillment_url), fulfillment_url, &fec); - dstr = GNUNET_strdup (GNUNET_TIME_timestamp2s (date)); + GNUNET_snprintf (dstr, + sizeof (dstr), + "%llu", + (unsigned long long) GNUNET_TIME_timestamp_to_s (date)); if (delta > 0) { have_date = ! GNUNET_TIME_absolute_is_zero (date.abs_time); @@ -381,7 +384,6 @@ TALER_MERCHANT_orders_get3 ( "fulfillment_url", fec, NULL); - GNUNET_free (dstr); GNUNET_free (sid); GNUNET_free (fec); } diff --git a/src/lib/merchant_api_get_transfers.c b/src/lib/merchant_api_get_transfers.c @@ -130,8 +130,8 @@ handle_transfers_get_finished (void *cls, &td->credit_amount), GNUNET_JSON_spec_fixed_auto ("wtid", &td->wtid), - TALER_JSON_spec_payto_uri ("payto_uri", - &td->payto_uri), + TALER_JSON_spec_full_payto_uri ("payto_uri", + &td->payto_uri), TALER_JSON_spec_web_url ("exchange_url", &td->exchange_url), GNUNET_JSON_spec_uint64 ("transfer_serial_id", @@ -219,7 +219,7 @@ struct TALER_MERCHANT_GetTransfersHandle * TALER_MERCHANT_transfers_get ( struct GNUNET_CURL_Context *ctx, const char *backend_url, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const struct GNUNET_TIME_Timestamp before, const struct GNUNET_TIME_Timestamp after, int64_t limit, @@ -233,8 +233,8 @@ TALER_MERCHANT_transfers_get ( const char *verified_s = NULL; char limit_s[30]; char offset_s[30]; - char *before_s; - char *after_s; + char before_s[30]; + char after_s[30]; gth = GNUNET_new (struct TALER_MERCHANT_GetTransfersHandle); gth->ctx = ctx; @@ -249,35 +249,46 @@ TALER_MERCHANT_transfers_get ( sizeof (offset_s), "%lld", (unsigned long long) offset); - before_s = GNUNET_strdup (GNUNET_TIME_timestamp2s (before)); - after_s = GNUNET_strdup (GNUNET_TIME_timestamp2s (after)); - gth->url = TALER_url_join (backend_url, - "private/transfers", - "payto_uri", - payto_uri, - "verified", - (TALER_EXCHANGE_YNA_ALL != verified) - ? verified_s - : NULL, - "limit", - 0 != limit - ? limit_s - : NULL, - "offset", - ((0 != offset) && (UINT64_MAX != offset)) - ? offset_s - : NULL, - "before", - GNUNET_TIME_absolute_is_never (before.abs_time) - ? NULL - : before_s, - "after", - GNUNET_TIME_absolute_is_zero (after.abs_time) - ? NULL - : after_s, - NULL); - GNUNET_free (before_s); - GNUNET_free (after_s); + + + GNUNET_snprintf (before_s, + sizeof (before_s), + "%llu", + (unsigned long long) GNUNET_TIME_timestamp_to_s (before)); + GNUNET_snprintf (after_s, + sizeof (after_s), + "%llu", + (unsigned long long) GNUNET_TIME_timestamp_to_s (after)); + { + char *enc_payto = TALER_urlencode (payto_uri.full_payto); + + gth->url = TALER_url_join (backend_url, + "private/transfers", + "payto_uri", + enc_payto, + "verified", + (TALER_EXCHANGE_YNA_ALL != verified) + ? verified_s + : NULL, + "limit", + 0 != limit + ? limit_s + : NULL, + "offset", + ((0 != offset) && (UINT64_MAX != offset)) + ? offset_s + : NULL, + "before", + GNUNET_TIME_absolute_is_never (before.abs_time) + ? NULL + : before_s, + "after", + GNUNET_TIME_absolute_is_zero (after.abs_time) + ? NULL + : after_s, + NULL); + GNUNET_free (enc_payto); + } if (NULL == gth->url) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, diff --git a/src/lib/merchant_api_post_account.c b/src/lib/merchant_api_post_account.c @@ -116,7 +116,7 @@ handle_post_account_finished (void *cls, GNUNET_JSON_parse (json, spec, NULL, NULL)) - { + { GNUNET_break_op (0); apr.hr.http_status = 0; apr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; @@ -175,7 +175,7 @@ struct TALER_MERCHANT_AccountsPostHandle * TALER_MERCHANT_accounts_post ( struct GNUNET_CURL_Context *ctx, const char *backend_url, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const char *credit_facade_url, const json_t *credit_facade_credentials, TALER_MERCHANT_AccountsPostCallback cb, @@ -185,7 +185,7 @@ TALER_MERCHANT_accounts_post ( json_t *req_obj; req_obj = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ( + TALER_JSON_pack_full_payto ( "payto_uri", payto_uri), GNUNET_JSON_pack_allow_null ( diff --git a/src/lib/merchant_api_post_transfers.c b/src/lib/merchant_api_post_transfers.c @@ -183,7 +183,7 @@ TALER_MERCHANT_transfers_post ( const char *backend_url, const struct TALER_Amount *credit_amount, const struct TALER_WireTransferIdentifierRawP *wtid, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const char *exchange_url, TALER_MERCHANT_PostTransfersCallback cb, void *cb_cls) @@ -211,8 +211,8 @@ TALER_MERCHANT_transfers_post ( credit_amount), GNUNET_JSON_pack_data_auto ("wtid", wtid), - GNUNET_JSON_pack_string ("payto_uri", - payto_uri), + TALER_JSON_pack_full_payto ("payto_uri", + payto_uri), GNUNET_JSON_pack_string ("exchange_url", exchange_url)); eh = TALER_MERCHANT_curl_easy_get_ (pth->url); diff --git a/src/merchant-tools/benchmark-common.conf b/src/merchant-tools/benchmark-common.conf @@ -54,7 +54,7 @@ PAYTO_URI = payto://iban/SANDBOXX/DE033310?receiver-name=Exchange+Company [exchange-accountcredentials-2] WIRE_GATEWAY_AUTH_METHOD = basic USERNAME = exchange -PASSWORD = x +PASSWORD = password WIRE_GATEWAY_URL = "http://localhost:8082/accounts/exchange/taler-wire-gateway/" diff --git a/src/merchant-tools/benchmark-cs.conf b/src/merchant-tools/benchmark-cs.conf @@ -13,4 +13,4 @@ ENABLE_CREDIT = YES WIRE_GATEWAY_URL = http://localhost:8082/accounts/Exchange/taler-wire-gateway/ WIRE_GATEWAY_AUTH_METHOD = "basic" USERNAME = Exchange -PASSWORD = x +PASSWORD = password diff --git a/src/merchant-tools/benchmark-rsa.conf b/src/merchant-tools/benchmark-rsa.conf @@ -13,4 +13,4 @@ ENABLE_CREDIT = YES WIRE_GATEWAY_URL = http://localhost:8082/accounts/Exchange/taler-wire-gateway/ WIRE_GATEWAY_AUTH_METHOD = "basic" USERNAME = Exchange -PASSWORD = x +PASSWORD = password diff --git a/src/merchant-tools/taler-merchant-dbinit.c b/src/merchant-tools/taler-merchant-dbinit.c @@ -110,17 +110,12 @@ main (int argc, not do this, the linker may "optimize" libtalerutil away and skip #TALER_OS_init(), which we do need */ (void) TALER_project_data_default (); - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return 4; ret = GNUNET_PROGRAM_run ( argc, argv, "taler-merchant-dbinit", gettext_noop ("Initialize Taler merchant database"), options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return 3; if (GNUNET_NO == ret) diff --git a/src/merchant-tools/taler-merchant-passwd.c b/src/merchant-tools/taler-merchant-passwd.c @@ -175,17 +175,12 @@ main (int argc, not do this, the linker may "optimize" libtalerutil away and skip #TALER_OS_init(), which we do need */ (void) TALER_project_data_default (); - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return 4; ret = GNUNET_PROGRAM_run ( argc, argv, "taler-merchant-passwd", gettext_noop ("Reset instance password"), options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return 3; if (GNUNET_NO == ret) diff --git a/src/merchant-tools/taler-merchant-setup-reserve.c b/src/merchant-tools/taler-merchant-setup-reserve.c @@ -416,17 +416,12 @@ main (int argc, not do this, the linker may "optimize" libtalerutil away and skip #TALER_OS_init(), which we do need */ (void) TALER_project_data_default (); - if (GNUNET_OK != - GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) - return 4; ret = GNUNET_PROGRAM_run ( argc, argv, "taler-merchant-setup-reserve", gettext_noop ("Setup reserve for tipping"), options, &run, NULL); - GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return 3; if (GNUNET_NO == ret) diff --git a/src/testing/test-merchant-walletharness.sh b/src/testing/test-merchant-walletharness.sh @@ -36,7 +36,7 @@ taler-harness --help >/dev/null </dev/null || exit_skip " MISSING" echo " FOUND" -export WALLET_HARNESS_WITH_EUFIN=1 +export WITH_LIBEUFIN=1 res=0 taler-harness run-integrationtests --dry --suites merchant 2&>/dev/null || res=$? diff --git a/src/testing/test_key_rotation.conf b/src/testing/test_key_rotation.conf @@ -93,13 +93,13 @@ enable_credit = yes WIRE_GATEWAY_URL = "http://localhost:8082/accounts/Exchange/taler-wire-gateway/" WIRE_GATEWAY_AUTH_METHOD = basic USERNAME = Exchange -PASSWORD = x +PASSWORD = password [admin-accountcredentials-1] WIRE_GATEWAY_URL = "http://localhost:8082/accounts/Exchange/taler-wire-gateway/" WIRE_GATEWAY_AUTH_METHOD = basic USERNAME = Exchange -PASSWORD = x +PASSWORD = password [merchant-exchange-default] EXCHANGE_BASE_URL = http://localhost:8081/ diff --git a/src/testing/test_kyc_api.c b/src/testing/test_kyc_api.c @@ -51,17 +51,17 @@ /** * Payto URI of the customer (payer). */ -static const char *payer_payto; +static struct TALER_FullPayto payer_payto; /** * Payto URI of the exchange (escrow account). */ -static const char *exchange_payto; +static struct TALER_FullPayto exchange_payto; /** * Payto URI of the merchant (receiver). */ -static const char *merchant_payto; +static struct TALER_FullPayto merchant_payto; /** * Credentials for the test. @@ -540,15 +540,15 @@ int main (int argc, char *const *argv) { - payer_payto = - "payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME "?receiver-name=" - USER_ACCOUNT_NAME; - exchange_payto = - "payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME "?receiver-name=" - EXCHANGE_ACCOUNT_NAME; - merchant_payto = - "payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME "?receiver-name=" - MERCHANT_ACCOUNT_NAME; + payer_payto.full_payto = + (char *) "payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME + "?receiver-name=" USER_ACCOUNT_NAME; + exchange_payto.full_payto = + (char *) "payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME + "?receiver-name=" EXCHANGE_ACCOUNT_NAME; + merchant_payto.full_payto = + (char *) "payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME + "?receiver-name=" MERCHANT_ACCOUNT_NAME; merchant_url = "http://localhost:8080/"; GNUNET_asprintf (&merchant_url_i1a, "%sinstances/i1a/", diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c @@ -60,8 +60,6 @@ */ static char *config_file; -#define PAYTO_I1 "payto://x-taler-bank/localhost/3?receiver-name=3" - /** * Exchange base URL. Could also be taken from config. */ @@ -70,17 +68,17 @@ static char *config_file; /** * Payto URI of the customer (payer). */ -static const char *payer_payto; +static struct TALER_FullPayto payer_payto; /** * Payto URI of the exchange (escrow account). */ -static const char *exchange_payto; +static struct TALER_FullPayto exchange_payto; /** * Payto URI of the merchant (receiver). */ -static const char *merchant_payto; +static struct TALER_FullPayto merchant_payto; /** * Credentials for the test. @@ -216,7 +214,7 @@ run (void *cls, TALER_TESTING_cmd_merchant_post_account ( "instance-create-default-account", merchant_url, - PAYTO_I1, + merchant_payto, NULL, NULL, MHD_HTTP_OK), TALER_TESTING_cmd_merchant_kyc_get ( @@ -490,7 +488,7 @@ run (void *cls, merchant_payto), TALER_TESTING_cmd_merchant_post_transfer ("post-transfer-1", &cred.ba, - PAYTO_I1, + merchant_payto, merchant_url, "EUR:4.98", MHD_HTTP_NO_CONTENT, @@ -500,7 +498,7 @@ run (void *cls, config_file), TALER_TESTING_cmd_merchant_post_transfer2 ("post-transfer-bad", merchant_url, - PAYTO_I1, + merchant_payto, "EUR:4.98", NULL, /*non-routable IP address @@ -510,7 +508,7 @@ run (void *cls, MHD_HTTP_NO_CONTENT), TALER_TESTING_cmd_merchant_get_transfers ("get-transfers-1", merchant_url, - PAYTO_I1, + merchant_payto, MHD_HTTP_OK, "post-transfer-1", "post-transfer-bad", @@ -977,7 +975,7 @@ run (void *cls, TALER_TESTING_cmd_merchant_post_account ( "instance-create-i1a-account", merchant_url_i1a, - PAYTO_I1, + merchant_payto, NULL, NULL, MHD_HTTP_OK), TALER_TESTING_cmd_merchant_get_product ("get-nx-product-i1a-1", @@ -1862,7 +1860,7 @@ run (void *cls, TALER_TESTING_cmd_merchant_post_account ( "instance-create-default-account", merchant_url, - PAYTO_I1, + merchant_payto, NULL, NULL, MHD_HTTP_OK), TALER_TESTING_cmd_merchant_post_instances ( @@ -1996,7 +1994,7 @@ run (void *cls, TALER_TESTING_cmd_merchant_post_account ( "instance-create-default-account-after-purge", merchant_url, - PAYTO_I1, + merchant_payto, NULL, NULL, MHD_HTTP_OK), TALER_TESTING_cmd_merchant_get_products ( @@ -2185,15 +2183,16 @@ main (int argc, cipher); GNUNET_free (cipher); } - payer_payto = - "payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME "?receiver-name=" - USER_ACCOUNT_NAME; - exchange_payto = - "payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME "?receiver-name=" + payer_payto.full_payto = + (char *) "payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME + "?receiver-name=" USER_ACCOUNT_NAME; + exchange_payto.full_payto = + (char *) "payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME + "?receiver-name=" EXCHANGE_ACCOUNT_NAME; - merchant_payto = - "payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME "?receiver-name=" - MERCHANT_ACCOUNT_NAME; + merchant_payto.full_payto = + (char *) "payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME + "?receiver-name=" MERCHANT_ACCOUNT_NAME; merchant_url = "http://localhost:8080/"; GNUNET_asprintf (&merchant_url_i1a, "%sinstances/i1a/", diff --git a/src/testing/test_merchant_api.conf b/src/testing/test_merchant_api.conf @@ -32,6 +32,8 @@ REGISTRATION_BONUS = EUR:100 SUGGESTED_WITHDRAWAL_EXCHANGE = http://localhost:8081/ SERVE = tcp PORT = 8082 +PWD_HASH_CONFIG = { "cost": 4 } +PWD_AUTH_COMPAT = yes [merchant] PORT = 8080 diff --git a/src/testing/test_merchant_api_twisted.c b/src/testing/test_merchant_api_twisted.c @@ -61,23 +61,19 @@ static char *config_file; */ #define USER_ACCOUNT_NAME "62" - -#define PAYTO_I1 "payto://x-taler-bank/localhost/3?receiver-name=user3" - - /** * Configuration file for the proxy between merchant and * exchange. Not used directly here in the code (instead * used in the merchant config), but kept around for consistency. */ #define PROXY_EXCHANGE_config_file \ - "test_merchant_api_proxy_exchange.conf" + "test_merchant_api_proxy_exchange.conf" /** * Configuration file for the proxy between "lib" and merchant. */ #define PROXY_MERCHANT_config_file \ - "test_merchant_api_proxy_merchant.conf" + "test_merchant_api_proxy_merchant.conf" /** * Exchange base URL. Could also be taken from config. @@ -119,10 +115,10 @@ static struct GNUNET_OS_Process *twisterexchanged; */ static struct GNUNET_OS_Process *twistermerchantd; +static struct TALER_FullPayto payer_payto; +static struct TALER_FullPayto exchange_payto; +static struct TALER_FullPayto merchant_payto; -static const char *payer_payto; -static const char *exchange_payto; -static const char *merchant_payto; static struct TALER_TESTING_Credentials cred; /** @@ -155,8 +151,8 @@ CMD_EXEC_WIREWATCH (const char *label) * @param label label to use for the command. */ #define CMD_EXEC_AGGREGATOR(label) \ - TALER_TESTING_cmd_exec_aggregator (label "-aggregator", config_file), \ - TALER_TESTING_cmd_exec_transfer (label "-transfer", config_file) + TALER_TESTING_cmd_exec_aggregator (label "-aggregator", config_file), \ + TALER_TESTING_cmd_exec_transfer (label "-transfer", config_file) /** @@ -341,7 +337,7 @@ run (void *cls, TALER_TESTING_cmd_merchant_post_account ( "instance-create-default-account", twister_merchant_url, - PAYTO_I1, + merchant_payto, NULL, NULL, MHD_HTTP_OK), TALER_TESTING_cmd_batch ("pay", @@ -452,14 +448,15 @@ main (int argc, cipher); GNUNET_free (cipher); } - payer_payto = - "payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME "?receiver-name=user"; - exchange_payto = - "payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME - "?receiver-name=exchange"; - merchant_payto = - "payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME - "?receiver-name=merchant"; + payer_payto.full_payto = + (char *) "payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME + "?receiver-name=" USER_ACCOUNT_NAME; + exchange_payto.full_payto = + (char *) "payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME + "?receiver-name=" EXCHANGE_ACCOUNT_NAME; + merchant_payto.full_payto = + (char *) "payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME + "?receiver-name=" MERCHANT_ACCOUNT_NAME; merchant_url = "http://localhost:8080/"; if (NULL == (twister_exchange_url = TALER_TWISTER_prepare_twister ( PROXY_EXCHANGE_config_file))) diff --git a/src/testing/test_merchant_wirewatch.sh b/src/testing/test_merchant_wirewatch.sh @@ -64,7 +64,7 @@ if [ 1 = "$USE_FAKEBANK" ] then FACADE_URL="http://localhost:8082/accounts/gnunet/taler-revenue/" FACADE_USERNAME="gnunet" - FACADE_PASSWORD="x" + FACADE_PASSWORD="password" else echo "not implemented for current libeufin-bank" exit 1 diff --git a/src/testing/test_template.conf b/src/testing/test_template.conf @@ -82,13 +82,13 @@ ENABLE_CREDIT = YES WIRE_GATEWAY_URL = "http://localhost:8082/accounts/exchange/taler-wire-gateway/" WIRE_GATEWAY_AUTH_METHOD = basic USERNAME = exchange -PASSWORD = x +PASSWORD = password [admin-accountcredentials-1] WIRE_GATEWAY_URL = "http://localhost:8082/accounts/exchange/taler-wire-gateway/" WIRE_GATEWAY_AUTH_METHOD = basic USERNAME = exchange -PASSWORD = x +PASSWORD = password [exchange-account-2] PAYTO_URI = "payto://x-taler-bank/localhost/exchange?receiver-name=exchange" diff --git a/src/testing/testing_api_cmd_get_transfers.c b/src/testing/testing_api_cmd_get_transfers.c @@ -53,7 +53,7 @@ struct GetTransfersState /** * payto URI of the merchant to filter by. */ - const char *payto_uri; + struct TALER_FullPayto payto_uri; /** * Expected HTTP response code. @@ -157,7 +157,7 @@ get_transfers_cb ( transfer->credit_serial); } { - const char *payto_uri; + const struct TALER_FullPayto *payto_uri; if (GNUNET_OK != TALER_TESTING_get_trait_credit_payto_uri (transfer_cmd, @@ -168,13 +168,14 @@ get_transfers_cb ( TALER_TESTING_interpreter_fail (gts->is); return; } - if (0 != strcmp (payto_uri, - transfer->payto_uri)) + if (0 != + TALER_full_payto_cmp (*payto_uri, + transfer->payto_uri)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Wire transfer payto uri does not match: %s != %s\n", - payto_uri, - transfer->payto_uri); + payto_uri->full_payto, + transfer->payto_uri.full_payto); TALER_TESTING_interpreter_fail (gts->is); return; } @@ -296,7 +297,7 @@ struct TALER_TESTING_Command TALER_TESTING_cmd_merchant_get_transfers ( const char *label, const char *merchant_url, - const char *payto_uri, + struct TALER_FullPayto payto_uri, unsigned int http_code, ...) { diff --git a/src/testing/testing_api_cmd_kyc_get.c b/src/testing/testing_api_cmd_kyc_get.c @@ -63,7 +63,7 @@ struct KycGetState * Set to the payto hash of the first account * for which we failed to pass the KYC check. */ - struct TALER_PaytoHashP h_payto; + struct TALER_NormalizedPaytoHashP h_payto; /** * Access token the user needs to start a KYC process. @@ -154,15 +154,15 @@ kyc_get_cb (void *cls, } for (unsigned int i = 0; i<kr->details.ok.kycs_length; i++) { - const char *payto_uri; + struct TALER_FullPayto payto_uri; payto_uri = kr->details.ok.kycs[i].payto_uri; - if (NULL == payto_uri) + if (NULL == payto_uri.full_payto) { continue; } - TALER_payto_hash (payto_uri, - &cs->h_payto); + TALER_full_payto_normalize_and_hash (payto_uri, + &cs->h_payto); if (! kr->details.ok.kycs[i].no_access_token) { cs->access_token @@ -263,7 +263,7 @@ kyc_get_traits (void *cls, /* Must be first, skipped if we have no token! */ TALER_TESTING_make_trait_account_access_token ( &cs->access_token), - TALER_TESTING_make_trait_h_payto ( + TALER_TESTING_make_trait_h_normalized_payto ( &cs->h_payto), TALER_TESTING_trait_end () }; diff --git a/src/testing/testing_api_cmd_post_account.c b/src/testing/testing_api_cmd_post_account.c @@ -57,7 +57,7 @@ struct PostAccountState /** * RFC 8905 URI for the account to create. */ - char *payto_uri; + struct TALER_FullPayto payto_uri; /** * Credit facade URL for the account to create. @@ -176,7 +176,7 @@ post_account_traits (void *cls, &pps->h_wire), TALER_TESTING_make_trait_payto_uris ( 0, - pps->payto_uri), + &pps->payto_uri), TALER_TESTING_make_trait_merchant_base_url ( pps->merchant_url), TALER_TESTING_trait_end (), @@ -208,7 +208,7 @@ post_account_cleanup (void *cls, "POST /account operation did not complete\n"); TALER_MERCHANT_accounts_post_cancel (pas->aph); } - GNUNET_free (pas->payto_uri); + GNUNET_free (pas->payto_uri.full_payto); GNUNET_free (pas->credit_facade_url); json_decref (pas->credit_facade_credentials); GNUNET_free (pas); @@ -219,7 +219,7 @@ struct TALER_TESTING_Command TALER_TESTING_cmd_merchant_post_account ( const char *label, const char *merchant_url, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const char *credit_facade_url, const json_t *credit_facade_credentials, unsigned int http_status) @@ -228,7 +228,8 @@ TALER_TESTING_cmd_merchant_post_account ( pas = GNUNET_new (struct PostAccountState); pas->merchant_url = merchant_url; - pas->payto_uri = GNUNET_strdup (payto_uri); + pas->payto_uri.full_payto + = GNUNET_strdup (payto_uri.full_payto); if (NULL != credit_facade_url) pas->credit_facade_url = GNUNET_strdup (credit_facade_url); if (NULL != credit_facade_credentials) diff --git a/src/testing/testing_api_cmd_post_transfers.c b/src/testing/testing_api_cmd_post_transfers.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2020, 2023 Taler Systems SA + Copyright (C) 2020, 2023, 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -62,17 +62,22 @@ struct PostTransfersState /** * Credit account of the merchant. */ - char *credit_account; + struct TALER_FullPayto credit_account; /** * Payto URI to filter on. */ - const char *payto_uri; + struct TALER_FullPayto payto_uri; /** * Set to the hash of the @e payto_uri. */ - struct TALER_PaytoHashP h_payto; + struct TALER_FullPaytoHashP h_payto; + + /** + * Set to the hash of the normalized @e payto_uri. + */ + struct TALER_NormalizedPaytoHashP h_normalized_payto; /** * Authentication details to authenticate to the bank. @@ -176,8 +181,9 @@ post_transfers_traits (void *cls, struct PostTransfersState *pts = cls; struct TALER_TESTING_Trait traits[] = { TALER_TESTING_make_trait_wtid (&pts->wtid), - TALER_TESTING_make_trait_credit_payto_uri (pts->credit_account), - TALER_TESTING_make_trait_h_payto (&pts->h_payto), + TALER_TESTING_make_trait_credit_payto_uri (&pts->credit_account), + TALER_TESTING_make_trait_h_full_payto (&pts->h_payto), + TALER_TESTING_make_trait_h_normalized_payto (&pts->h_normalized_payto), TALER_TESTING_make_trait_amount (&pts->credit_amount), TALER_TESTING_make_trait_exchange_url (pts->exchange_url), TALER_TESTING_make_trait_bank_row (&pts->serial), @@ -257,18 +263,19 @@ debit_cb ( GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Bank reports transfer of %s to %s\n", TALER_amount2s (&details->amount), - details->credit_account_uri); + details->credit_account_uri.full_payto); if (0 != TALER_amount_cmp (&pts->credit_amount, &details->amount)) continue; pts->wtid = details->wtid; - pts->credit_account = GNUNET_strdup (details->credit_account_uri); + pts->credit_account.full_payto + = GNUNET_strdup (details->credit_account_uri.full_payto); pts->exchange_url = GNUNET_strdup (details->exchange_base_url); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Bank transfer found, checking with merchant backend at %s about %s from %s to %s with %s\n", pts->merchant_url, TALER_amount2s (&pts->credit_amount), - pts->payto_uri, + pts->payto_uri.full_payto, pts->exchange_url, TALER_B2S (&pts->wtid)); pts->pth = TALER_MERCHANT_transfers_post ( @@ -311,7 +318,7 @@ post_transfers_run (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Looking for transfer of %s from %s at bank\n", TALER_amount2s (&pts->credit_amount), - pts->payto_uri); + pts->payto_uri.full_payto); pts->dhh = TALER_BANK_debit_history (TALER_TESTING_interpreter_get_context ( is), &pts->auth, @@ -353,7 +360,7 @@ post_transfers_cleanup (void *cls, pts->deposits_length, 0); GNUNET_free (pts->exchange_url); - GNUNET_free (pts->credit_account); + GNUNET_free (pts->credit_account.full_payto); GNUNET_free (pts); } @@ -362,7 +369,7 @@ struct TALER_TESTING_Command TALER_TESTING_cmd_merchant_post_transfer ( const char *label, const struct TALER_BANK_AuthenticationData *auth, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const char *merchant_url, const char *credit_amount, unsigned int http_code, @@ -374,8 +381,10 @@ TALER_TESTING_cmd_merchant_post_transfer ( pts->merchant_url = merchant_url; pts->auth = *auth; pts->payto_uri = payto_uri; - TALER_payto_hash (payto_uri, - &pts->h_payto); + TALER_full_payto_hash (payto_uri, + &pts->h_payto); + TALER_full_payto_normalize_and_hash (payto_uri, + &pts->h_normalized_payto); GNUNET_assert (GNUNET_OK == TALER_string_to_amount (credit_amount, &pts->credit_amount)); @@ -411,7 +420,7 @@ struct TALER_TESTING_Command TALER_TESTING_cmd_merchant_post_transfer2 ( const char *label, const char *merchant_url, - const char *payto_uri, + struct TALER_FullPayto payto_uri, const char *credit_amount, const char *wtid, const char *exchange_url, @@ -421,7 +430,8 @@ TALER_TESTING_cmd_merchant_post_transfer2 ( pts = GNUNET_new (struct PostTransfersState); pts->merchant_url = merchant_url; - pts->credit_account = GNUNET_strdup (payto_uri); + pts->credit_account.full_payto + = GNUNET_strdup (payto_uri.full_payto); pts->exchange_url = GNUNET_strdup (exchange_url); GNUNET_assert (GNUNET_OK == TALER_string_to_amount (credit_amount,