aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/taler-merchant-httpd_private-post-account.c18
-rw-r--r--src/backend/taler-merchant-httpd_private-post-transfers.c8
-rw-r--r--src/backend/taler-merchant-kyccheck.c33
-rw-r--r--src/backend/taler-merchant-reconciliation.c10
-rw-r--r--src/backend/taler-merchant-wirewatch.c19
-rw-r--r--src/bank/mb_credit.c10
-rw-r--r--src/include/taler_merchant_bank_lib.h4
7 files changed, 52 insertions, 50 deletions
diff --git a/src/backend/taler-merchant-httpd_private-post-account.c b/src/backend/taler-merchant-httpd_private-post-account.c
index 44d9f084..064a55f3 100644
--- 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
index cf6eebaf..5c94549f 100644
--- 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
index 0ef9a353..fe4b5792 100644
--- 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)
diff --git a/src/backend/taler-merchant-reconciliation.c b/src/backend/taler-merchant-reconciliation.c
index 0611204d..238e33fd 100644
--- 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;
diff --git a/src/backend/taler-merchant-wirewatch.c b/src/backend/taler-merchant-wirewatch.c
index fa6d009e..999d5e67 100644
--- 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);
diff --git a/src/bank/mb_credit.c b/src/bank/mb_credit.c
index ea5aff7b..ea6ec2c0 100644
--- 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/include/taler_merchant_bank_lib.h b/src/include/taler_merchant_bank_lib.h
index 2971690a..54ef7e65 100644
--- a/src/include/taler_merchant_bank_lib.h
+++ b/src/include/taler_merchant_bank_lib.h
@@ -138,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;
};