summaryrefslogtreecommitdiff
path: root/src/backenddb/pg_lookup_instances.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-04-23 17:45:53 +0200
committerChristian Grothoff <christian@grothoff.org>2023-04-23 17:45:53 +0200
commit889595f986d922ffbcdcd746fdfad7f1a0e53595 (patch)
tree41571e0f04caa95c06610440d2b8c9c3698b08ed /src/backenddb/pg_lookup_instances.c
parent4b7d9f5e19e9f28ec1163f3b6e5c00f0805e6221 (diff)
downloadmerchant-889595f986d922ffbcdcd746fdfad7f1a0e53595.tar.gz
merchant-889595f986d922ffbcdcd746fdfad7f1a0e53595.tar.bz2
merchant-889595f986d922ffbcdcd746fdfad7f1a0e53595.zip
make taler-merchant-wirewatch multi-instance capable
Diffstat (limited to 'src/backenddb/pg_lookup_instances.c')
-rw-r--r--src/backenddb/pg_lookup_instances.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/backenddb/pg_lookup_instances.c b/src/backenddb/pg_lookup_instances.c
index acf3ada3..d876ad69 100644
--- a/src/backenddb/pg_lookup_instances.c
+++ b/src/backenddb/pg_lookup_instances.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
+ Copyright (C) 2022, 2023 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
@@ -98,6 +98,8 @@ prepare (struct PostgresClosure *pg)
" h_wire"
",salt"
",payto_uri"
+ ",credit_facade_url"
+ ",credit_facade_credentials"
",active"
" FROM merchant_accounts"
" WHERE merchant_serial=$1");
@@ -165,7 +167,7 @@ call_with_accounts (struct LookupInstancesContext *lic,
* Function to be called with the results of a SELECT statement
* that has returned @a num_results results about accounts.
*
- * @param cls of type `struct FindInstancesContext *`
+ * @param cls of type `struct LookupInstancesContext *`
* @param result the postgres result
* @param num_results the number of results in @a result
*/
@@ -176,8 +178,16 @@ lookup_accounts_cb (void *cls,
{
struct LookupInstancesContext *lic = cls;
char *paytos[num_results];
+ char *facade_urls[num_results];
+ json_t *credentials[num_results];
struct TALER_MERCHANTDB_AccountDetails accounts[num_results];
+ memset (facade_urls,
+ 0,
+ sizeof (facade_urls));
+ memset (credentials,
+ 0,
+ sizeof (credentials));
/* Note: this memset is completely superfluous, but gcc-11 (and gcc-12) have
a bug creating a warning without it! See #7585 */
memset (accounts,
@@ -193,6 +203,14 @@ lookup_accounts_cb (void *cls,
&account->salt),
GNUNET_PQ_result_spec_string ("payto_uri",
&paytos[i]),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_string ("credit_facade_url",
+ &facade_urls[i]),
+ NULL),
+ GNUNET_PQ_result_spec_allow_null (
+ TALER_PQ_result_spec_json ("credit_facade_credentials",
+ &credentials[i]),
+ NULL),
GNUNET_PQ_result_spec_bool ("active",
&account->active),
GNUNET_PQ_result_spec_end
@@ -206,7 +224,11 @@ lookup_accounts_cb (void *cls,
GNUNET_break (0);
lic->qs = GNUNET_DB_STATUS_HARD_ERROR;
for (unsigned int j = 0; j < i; j++)
+ {
GNUNET_free (paytos[j]);
+ GNUNET_free (facade_urls[j]);
+ json_decref (credentials[j]);
+ }
return;
}
account->payto_uri = paytos[i];
@@ -215,7 +237,11 @@ lookup_accounts_cb (void *cls,
num_results,
accounts);
for (unsigned int i = 0; i < num_results; i++)
+ {
GNUNET_free (paytos[i]);
+ GNUNET_free (facade_urls[i]);
+ json_decref (credentials[i]);
+ }
}
@@ -442,4 +468,3 @@ TMH_PG_lookup_instance (void *cls,
return lic.qs;
return qs;
}
-