commit 46fb385b853733fa54234ae5cdf990a36a18c879
parent 0d3daf756b42e0d0f2e3cdb9c5680a9c91faa72b
Author: Christian Grothoff <christian@grothoff.org>
Date: Fri, 20 Feb 2026 22:56:43 +0100
update CRUD API for #11119
Diffstat:
14 files changed, 95 insertions(+), 17 deletions(-)
diff --git a/bootstrap b/bootstrap
@@ -32,7 +32,7 @@ existence()
}
# Freeze SQL files that must no longer be edited.
-for n in 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 0020 0021 0022 0023 0024 0025 0026 0027 0028 0029 0030
+for n in 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 0020 0021 0022 0023 0024 0025 0026 0027 0028 0029 0030 0031
do
chmod -w src/backenddb/merchant-$n.sql*
done
diff --git a/src/backend/taler-merchant-httpd_get-config.c b/src/backend/taler-merchant-httpd_get-config.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- (C) 2019, 2020, 2021, 2023, 2024, 2025 Taler Systems SA
+ (C) 2019--2026 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
@@ -43,7 +43,7 @@
* #MERCHANT_PROTOCOL_CURRENT and #MERCHANT_PROTOCOL_AGE in
* merchant_api_get_config.c!
*/
-#define MERCHANT_PROTOCOL_VERSION "26:0:14"
+#define MERCHANT_PROTOCOL_VERSION "27:0:15"
/**
diff --git a/src/backend/taler-merchant-httpd_private-get-accounts-ID.c b/src/backend/taler-merchant-httpd_private-get-accounts-ID.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- (C) 2023 Taler Systems SA
+ (C) 2023, 2026 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
@@ -90,11 +90,15 @@ TMH_private_get_accounts_ID (const struct TMH_RequestHandler *rh,
GNUNET_JSON_pack_data_auto ("salt",
&tp.salt),
GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_string ("extra_wire_subject_metadata",
+ tp.extra_wire_subject_metadata)),
+ GNUNET_JSON_pack_allow_null (
GNUNET_JSON_pack_string ("credit_facade_url",
tp.credit_facade_url)));
/* We do not return the credentials, as they may
be sensitive */
json_decref (tp.credit_facade_credentials);
+ GNUNET_free (tp.extra_wire_subject_metadata);
GNUNET_free (tp.payto_uri.full_payto);
GNUNET_free (tp.credit_facade_url);
return ret;
diff --git a/src/backend/taler-merchant-httpd_private-patch-accounts-ID.c b/src/backend/taler-merchant-httpd_private-patch-accounts-ID.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- (C) 2023, 2025 Taler Systems SA
+ (C) 2023, 2025, 2026 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
@@ -46,6 +46,7 @@ TMH_private_patch_accounts_ID (const struct TMH_RequestHandler *rh,
const char *h_wire_s = hc->infix;
enum GNUNET_DB_QueryStatus qs;
const json_t *cfc;
+ const char *extra_wire_subject_metadata = NULL;
const char *cfu;
struct TALER_MerchantWireHashP h_wire;
struct GNUNET_JSON_Specification spec[] = {
@@ -54,6 +55,10 @@ TMH_private_patch_accounts_ID (const struct TMH_RequestHandler *rh,
&cfu),
NULL),
GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_string ("extra_wire_subject_metadata",
+ &extra_wire_subject_metadata),
+ NULL),
+ GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_object_const ("credit_facade_credentials",
&cfc),
NULL),
@@ -74,6 +79,7 @@ TMH_private_patch_accounts_ID (const struct TMH_RequestHandler *rh,
TALER_EC_MERCHANT_GENERIC_H_WIRE_MALFORMED,
h_wire_s);
}
+ // FIXME: check extra_wire_subject_metadata string!
{
enum GNUNET_GenericReturnValue res;
@@ -89,6 +95,7 @@ TMH_private_patch_accounts_ID (const struct TMH_RequestHandler *rh,
qs = TMH_db->update_account (TMH_db->cls,
mi->settings.id,
&h_wire,
+ extra_wire_subject_metadata,
cfu,
cfc);
{
diff --git a/src/backend/taler-merchant-httpd_private-post-account.c b/src/backend/taler-merchant-httpd_private-post-account.c
@@ -39,6 +39,7 @@ TMH_private_post_account (const struct TMH_RequestHandler *rh,
{
struct TMH_MerchantInstance *mi = hc->instance;
const char *credit_facade_url = NULL;
+ const char *extra_wire_subject_metadata = NULL;
const json_t *credit_facade_credentials = NULL;
struct TALER_FullPayto uri;
struct GNUNET_JSON_Specification ispec[] = {
@@ -49,6 +50,10 @@ TMH_private_post_account (const struct TMH_RequestHandler *rh,
&credit_facade_url),
NULL),
GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_string ("extra_wire_subject_metadata",
+ &extra_wire_subject_metadata),
+ NULL),
+ GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_object_const ("credit_facade_credentials",
&credit_facade_credentials),
NULL),
@@ -85,6 +90,7 @@ TMH_private_post_account (const struct TMH_RequestHandler *rh,
return mret;
}
}
+ // FIXME: check extra_wire_subject_metadata string!
{
char *apt = GNUNET_strdup (TMH_allowed_payment_targets);
char *method = TALER_payto_get_method (uri.full_payto);
@@ -214,6 +220,7 @@ TMH_private_post_account (const struct TMH_RequestHandler *rh,
.h_wire = wm->h_wire,
.credit_facade_url = wm->credit_facade_url,
.credit_facade_credentials = wm->credit_facade_credentials,
+ .extra_wire_subject_metadata = (char *) extra_wire_subject_metadata,
.active = wm->active
};
enum GNUNET_DB_QueryStatus qs;
diff --git a/src/backenddb/Makefile.am b/src/backenddb/Makefile.am
@@ -47,6 +47,7 @@ sql_DATA = \
merchant-0028.sql \
merchant-0029.sql \
merchant-0030.sql \
+ merchant-0031.sql \
drop.sql
BUILT_SOURCES = \
diff --git a/src/backenddb/merchant-0030.sql b/src/backenddb/merchant-0030.sql
@@ -13,7 +13,7 @@
-- 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-0029.sql
+-- @file merchant-0030.sql
-- @brief Add field for long-poll signalling to taler-merchant-kyccheck
-- @author Christian Grothoff
diff --git a/src/backenddb/merchant-0031.sql b/src/backenddb/merchant-0031.sql
@@ -0,0 +1,33 @@
+--
+-- This file is part of TALER
+-- Copyright (C) 2026 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-0031.sql
+-- @brief Add field for extra meta data in wire transfer subjects
+-- @author Christian Grothoff
+
+BEGIN;
+
+-- Check patch versioning is in place.
+SELECT _v.register_patch('merchant-0031', NULL, NULL);
+
+SET search_path TO merchant;
+
+ALTER TABLE merchant_accounts
+ ADD COLUMN extra_wire_subject_metadata TEXT DEFAULT(NULL);
+
+COMMENT ON COLUMN merchant_accounts.extra_wire_subject_metadata
+ IS 'Additional meta data that the exchange should include in wire transfer subjects made to this account on behalf of this instance';
+
+COMMIT;
diff --git a/src/backenddb/pg_insert_account.c b/src/backenddb/pg_insert_account.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2022, 2023 Taler Systems SA
+ Copyright (C) 2022, 2023, 2026 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
@@ -44,6 +44,10 @@ TMH_PG_insert_account (
? GNUNET_PQ_query_param_null ()
: TALER_PQ_query_param_json (account_details->credit_facade_credentials),
GNUNET_PQ_query_param_bool (account_details->active),
+ NULL == account_details->extra_wire_subject_metadata
+ ? GNUNET_PQ_query_param_null ()
+ : GNUNET_PQ_query_param_string (
+ account_details->extra_wire_subject_metadata),
GNUNET_PQ_query_param_end
};
@@ -57,8 +61,9 @@ TMH_PG_insert_account (
",payto_uri"
",credit_facade_url"
",credit_facade_credentials"
- ",active)"
- " SELECT merchant_serial, $2, $3, $4, $5, $6::TEXT::JSONB, $7"
+ ",active"
+ ",extra_wire_subject_metadata)"
+ " SELECT merchant_serial, $2, $3, $4, $5, $6::TEXT::JSONB, $7, $8"
" FROM merchant_instances"
" WHERE merchant_id=$1"
" ON CONFLICT(merchant_serial,payto_uri)"
@@ -66,6 +71,7 @@ TMH_PG_insert_account (
" active = true"
",credit_facade_url = EXCLUDED.credit_facade_url"
",credit_facade_credentials = EXCLUDED.credit_facade_credentials"
+ ",extra_wire_subject_metadata = EXCLUDED.extra_wire_subject_metadata"
" WHERE NOT ma.active");
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"insert_account",
diff --git a/src/backenddb/pg_select_account.c b/src/backenddb/pg_select_account.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2023 Taler Systems SA
+ Copyright (C) 2023, 2026 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
@@ -53,6 +53,10 @@ TMH_PG_select_account (void *cls,
NULL),
GNUNET_PQ_result_spec_bool ("active",
&ad->active),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_string ("extra_wire_subject_metadata",
+ &ad->extra_wire_subject_metadata),
+ NULL),
GNUNET_PQ_result_spec_end
};
@@ -67,12 +71,13 @@ TMH_PG_select_account (void *cls,
",credit_facade_url"
",credit_facade_credentials::TEXT"
",active"
+ ",extra_wire_subject_metadata"
" FROM merchant_accounts"
" WHERE merchant_serial="
" (SELECT merchant_serial "
" FROM merchant_instances"
- " WHERE merchant_id=$1) AND "
- " h_wire=$2;");
+ " WHERE merchant_id=$1) "
+ " AND (h_wire=$2);");
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
"select_account",
params,
diff --git a/src/backenddb/pg_update_account.c b/src/backenddb/pg_update_account.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2023 Taler Systems SA
+ Copyright (C) 2023, 2026 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
@@ -31,6 +31,7 @@ TMH_PG_update_account (
void *cls,
const char *id,
const struct TALER_MerchantWireHashP *h_wire,
+ const char *extra_wire_subject_metadata,
const char *credit_facade_url,
const json_t *credit_facade_credentials)
{
@@ -44,6 +45,9 @@ TMH_PG_update_account (
NULL == credit_facade_credentials
? GNUNET_PQ_query_param_null ()
: TALER_PQ_query_param_json (credit_facade_credentials),
+ NULL == extra_wire_subject_metadata
+ ? GNUNET_PQ_query_param_null ()
+ : GNUNET_PQ_query_param_string (extra_wire_subject_metadata),
GNUNET_PQ_query_param_end
};
@@ -54,6 +58,7 @@ TMH_PG_update_account (
" credit_facade_url=$3"
",credit_facade_credentials="
" COALESCE($4::TEXT::JSONB, credit_facade_credentials)"
+ ",extra_wire_subject_metadata=$5"
" WHERE h_wire=$2"
" AND merchant_serial="
" (SELECT merchant_serial"
diff --git a/src/backenddb/pg_update_account.h b/src/backenddb/pg_update_account.h
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2023 Taler Systems SA
+ Copyright (C) 2023, 2026 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
@@ -32,6 +32,7 @@
* @param cls closure
* @param id identifier of the instance
* @param h_wire which account to update
+ * @param extra_wire_subject_metadata additional metadata to include in wire transfer subjects
* @param credit_facade_url new facade URL, can be NULL
* @param credit_facade_credentials new credentials, can be NULL to keep previous credentials
* @return database result code
@@ -41,6 +42,7 @@ TMH_PG_update_account (
void *cls,
const char *id,
const struct TALER_MerchantWireHashP *h_wire,
+ const char *extra_wire_subject_metadata,
const char *credit_facade_url,
const json_t *credit_facade_credentials);
diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h
@@ -156,6 +156,12 @@ struct TALER_MERCHANTDB_AccountDetails
json_t *credit_facade_credentials;
/**
+ * Additional meta data to include in wire transfers to this
+ * account. Can be NULL if not used.
+ */
+ char *extra_wire_subject_metadata;
+
+ /**
* Is the account set for active use in new contracts?
*/
bool active;
@@ -2271,6 +2277,7 @@ struct TALER_MERCHANTDB_Plugin
* @param cls closure
* @param id identifier of the instance
* @param h_wire which account to update
+ * @param extra_wire_subject_metadata additional metadata to include in wire transfer subjects
* @param credit_facade_url new facade URL, can be NULL
* @param credit_facade_credentials new credentials, can be NULL
* @return database result code
@@ -2280,6 +2287,7 @@ struct TALER_MERCHANTDB_Plugin
void *cls,
const char *id,
const struct TALER_MerchantWireHashP *h_wire,
+ const char *extra_wire_subject_metadata,
const char *credit_facade_url,
const json_t *credit_facade_credentials);
diff --git a/src/lib/merchant_api_get_config.c b/src/lib/merchant_api_get_config.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014-2025 Taler Systems SA
+ Copyright (C) 2014-2026 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Lesser General Public License as published by the Free Software
@@ -34,12 +34,12 @@
* Which version of the Taler protocol is implemented
* by this library? Used to determine compatibility.
*/
-#define MERCHANT_PROTOCOL_CURRENT 26
+#define MERCHANT_PROTOCOL_CURRENT 27
/**
* How many configs are we backwards-compatible with?
*/
-#define MERCHANT_PROTOCOL_AGE 2
+#define MERCHANT_PROTOCOL_AGE 3
/**
* How many exchanges do we allow at most per merchant?