exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit dcae5e42c3e25447697f848a5c44d280d0793901
parent 14414803dcc83db98a96e82e8afd8c7093ff8404
Author: Christian Grothoff <christian@grothoff.org>
Date:   Wed, 25 Nov 2026 22:24:01 +0100

fix #12272

Diffstat:
Msrc/exchangedb/iterate_unfinished_close_requests.c | 22+++++++++++++---------
Msrc/exchangedb/test_close_requests.c | 3+++
Msrc/exchangedb/test_common.c | 12++++++++++--
3 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/src/exchangedb/iterate_unfinished_close_requests.c b/src/exchangedb/iterate_unfinished_close_requests.c @@ -83,7 +83,7 @@ reserve_cb (void *cls, NULL), GNUNET_PQ_result_spec_auto_from_type ("reserve_pub", &reserve_pub), - TALER_PQ_RESULT_SPEC_AMOUNT ("close", + TALER_PQ_RESULT_SPEC_AMOUNT ("current_balance", &remaining_balance), GNUNET_PQ_result_spec_uint64 ("close_request_serial_id", &close_request_row), @@ -135,23 +135,27 @@ TALER_EXCHANGEDB_iterate_unfinished_close_requests ( PREPARE (pg, "iterate_unfinished_close_requests", - "UPDATE close_requests AS rc" + "UPDATE close_requests AS cr" " SET done=TRUE" - " WHERE NOT done" + " FROM reserves r" + " WHERE NOT cr.done" + " AND r.reserve_pub=cr.reserve_pub" " RETURNING" - " reserve_pub" - " ,close_request_serial_id" - " ,close_timestamp AS expiration_date" - " ,close" + " cr.reserve_pub" + " ,cr.close_request_serial_id" + " ,cr.close_timestamp AS expiration_date" + /* Close the balance the reserve has now, might be different + from the amount we had when the close request was received */ + " ,r.current_balance" /* The account designated by the client (and covered by the KYC check done at the time of the request) takes precedence over the account the reserve was funded from. */ - " ,COALESCE(rc.payto_uri" + " ,COALESCE(cr.payto_uri" " ,(SELECT payto_uri" " FROM reserves_in ri" " JOIN wire_targets wt" " ON (ri.wire_source_h_payto = wt.wire_target_h_payto)" - " WHERE ri.reserve_pub=rc.reserve_pub))" + " WHERE ri.reserve_pub=r.reserve_pub))" " AS account_details;"); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, "iterate_unfinished_close_requests", diff --git a/src/exchangedb/test_close_requests.c b/src/exchangedb/test_close_requests.c @@ -340,6 +340,9 @@ check_insert_and_lookup (struct TALER_EXCHANGEDB_PostgresContext *pg) "0.5")); FAILIF (2 != TDB_count (pg, "FROM close_requests")); + + FAILIF (2 != TDB_count (pg, + "FROM close_requests WHERE NOT done")); return 0; } diff --git a/src/exchangedb/test_common.c b/src/exchangedb/test_common.c @@ -20,6 +20,7 @@ */ #include "test_common.h" #include "exchange-database/create_tables.h" +#include "exchange-database/drop_tables.h" #include "exchange-database/do_insert_known_coins.h" #include "exchange-database/insert_denomination_info.h" #include "exchange-database/get_denomination_info.h" @@ -786,6 +787,7 @@ run (void *cls, result = 77; return; } + (void) TALER_EXCHANGEDB_drop_tables (pg); if (GNUNET_OK != TALER_EXCHANGEDB_create_tables (pg, false, @@ -833,6 +835,12 @@ TDB_main (int argc, const char *description, const struct TDB_Test *tests) { + char *xargv[] = { + argv[0], + "-c", + "test-exchange-db-postgres.conf", + NULL + }; struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_option_string ('t', "test", @@ -846,8 +854,8 @@ TDB_main (int argc, result = 0; tdb_tests = tests; ret = GNUNET_PROGRAM_run (TALER_EXCHANGE_project_data (), - argc, - argv, + 3, + xargv, binary, description, options,