commit 4ec4385dea384c04dc5fd720b43f7bd1f55cf13c
parent 56a0c9af1a4c57820f999b694e854ba9bea48065
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 3 May 2026 20:49:40 +0200
fix #11055
Diffstat:
4 files changed, 51 insertions(+), 8 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_get-exchanges.c b/src/backend/taler-merchant-httpd_get-exchanges.c
@@ -34,6 +34,7 @@
*
* @param cls closure with `json_t *` array to expand
* @param exchange_url base URL of the exchange
+ * @param keys keys of the exchange, NULL if we do not have any yet
* @param next_download when will be the next download
* @param keys_expiration when does the current ``/keys`` response expire
* @param http_status last HTTP status from ``/keys``
@@ -43,6 +44,7 @@ static void
add_exchange (
void *cls,
const char *exchange_url,
+ const json_t *keys,
struct GNUNET_TIME_Absolute next_download,
struct GNUNET_TIME_Absolute keys_expiration,
unsigned int http_status,
@@ -50,6 +52,35 @@ add_exchange (
{
json_t *xa = cls;
json_t *xi;
+ json_t *debit_restrictions = NULL;
+
+ if (NULL != keys)
+ {
+ json_t *accounts;
+ json_t *account;
+ size_t i;
+
+ accounts = json_object_get (keys,
+ "accounts");
+ debit_restrictions = json_object ();
+ json_array_foreach (accounts, i, account)
+ {
+ json_t *dr = json_object_get (account,
+ "debit_restrictions");
+
+ if (NULL != dr)
+ {
+ const char *payto;
+
+ payto = json_string_value (json_object_get (account,
+ "payto_uri"));
+ GNUNET_break (0 ==
+ json_object_set (debit_restrictions,
+ payto,
+ dr));
+ }
+ }
+ }
xi = GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("exchange_url",
@@ -64,6 +95,9 @@ add_exchange (
: GNUNET_JSON_pack_timestamp ("keys_expiration",
GNUNET_TIME_absolute_to_timestamp (
keys_expiration)),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_object_steal ("debit_restrictions",
+ debit_restrictions)),
GNUNET_JSON_pack_uint64 ("keys_http_status",
http_status),
GNUNET_JSON_pack_uint64 ("keys_ec",
diff --git a/src/backend/taler-merchant-httpd_post-private-orders.c b/src/backend/taler-merchant-httpd_post-private-orders.c
@@ -2826,7 +2826,8 @@ get_acceptable (struct OrderContext *oc,
i<oc->add_payment_details.num_max_choice_limits;
i++)
{
- struct TALER_Amount *val = &oc->add_payment_details.max_choice_limits[i];
+ const struct TALER_Amount *val
+ = &oc->add_payment_details.max_choice_limits[i];
if (0 == strcasecmp (val->currency,
TMH_EXCHANGES_get_currency (exchange)))
@@ -3040,8 +3041,7 @@ keys_cb (
keys->accounts_len);
add_rejection (oc,
rx->url,
- TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_WIRE_METHOD_UNSUPPORTED)
- ;
+ TALER_EC_MERCHANT_POST_ORDERS_ID_PAY_WIRE_METHOD_UNSUPPORTED);
}
if (applicable &&
settings->use_stefan)
diff --git a/src/backenddb/select_exchanges.c b/src/backenddb/select_exchanges.c
@@ -65,6 +65,7 @@ lookup_exchanges_cb (void *cls,
for (unsigned int i = 0; i < num_results; i++)
{
char *exchange_url;
+ json_t *keys = NULL;
struct GNUNET_TIME_Absolute next_download;
struct GNUNET_TIME_Absolute keys_expiration;
uint32_t hc;
@@ -76,6 +77,10 @@ lookup_exchanges_cb (void *cls,
&keys_expiration),
GNUNET_PQ_result_spec_string ("exchange_url",
&exchange_url),
+ GNUNET_PQ_result_spec_allow_null (
+ TALER_PQ_result_spec_json ("keys_json",
+ &keys),
+ NULL),
GNUNET_PQ_result_spec_uint32 ("exchange_http_status",
&hc),
GNUNET_PQ_result_spec_uint32 ("exchange_ec_code",
@@ -94,6 +99,7 @@ lookup_exchanges_cb (void *cls,
}
plc->cb (plc->cb_cls,
exchange_url,
+ keys,
next_download,
keys_expiration,
(unsigned int) hc,
@@ -127,6 +133,7 @@ TALER_MERCHANTDB_select_exchanges (
" exchange_url"
" ,first_retry"
" ,expiration_time"
+ " ,keys_json::TEXT"
" ,exchange_http_status"
" ,exchange_ec_code"
" FROM merchant_exchange_keys");
diff --git a/src/include/merchant-database/select_exchanges.h b/src/include/merchant-database/select_exchanges.h
@@ -26,14 +26,13 @@
#include "merchantdb_lib.h"
-struct TALER_MERCHANTDB_PostgresContext;
-/* Callback typedefs */
/**
* Function called about the ``/keys`` status of every exchange
* we are working with.
*
* @param cls closure
* @param exchange_url base URL of the exchange
+ * @param keys keys of the exchange, NULL if we do not have any yet
* @param next_download when will be the next download
* @param keys_expiration when does the current ``/keys`` response expire
* @param http_status last HTTP status from ``/keys``
@@ -43,11 +42,13 @@ typedef void
(*TALER_MERCHANTDB_ExchangesCallback)(
void *cls,
const char *exchange_url,
+ const json_t *keys,
struct GNUNET_TIME_Absolute next_download,
struct GNUNET_TIME_Absolute keys_expiration,
unsigned int http_status,
enum TALER_ErrorCode ec);
+
/**
* Call @a cb on each exchange we have in the database.
*
@@ -57,9 +58,10 @@ typedef void
* @return transaction status code
*/
enum GNUNET_DB_QueryStatus
-TALER_MERCHANTDB_select_exchanges (struct TALER_MERCHANTDB_PostgresContext *pg,
- TALER_MERCHANTDB_ExchangesCallback cb,
- void *cb_cls);
+TALER_MERCHANTDB_select_exchanges (
+ struct TALER_MERCHANTDB_PostgresContext *pg,
+ TALER_MERCHANTDB_ExchangesCallback cb,
+ void *cb_cls);
#endif