exchange

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

commit 80a430f7045ad68f6c344e917037764b25c0b14b
parent bdc17891c652c97fd5d3f512c61d093db6986a5e
Author: Christian Grothoff <christian@grothoff.org>
Date:   Mon, 12 Oct 2026 17:16:31 +0200

fetch requirement_row, so UPDATE does not clobber it later

Diffstat:
Msrc/exchange/taler-exchange-aggregator.c | 1+
Msrc/exchangedb/get_aggregation_transient.c | 4++++
Msrc/exchangedb/test_aggregation_transient.c | 13+++++++++++++
Msrc/include/exchange-database/get_aggregation_transient.h | 3+++
4 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/src/exchange/taler-exchange-aggregator.c b/src/exchange/taler-exchange-aggregator.c @@ -1233,6 +1233,7 @@ do_aggregate (struct AggregationUnit *au) &au->merchant_pub, au->wa->section_name, &au->wtid, + &au->requirement_row, &au->trans); switch (qs) { diff --git a/src/exchangedb/get_aggregation_transient.c b/src/exchangedb/get_aggregation_transient.c @@ -31,6 +31,7 @@ TALER_EXCHANGEDB_get_aggregation_transient ( const struct TALER_MerchantPublicKeyP *merchant_pub, const char *exchange_account_section, struct TALER_WireTransferIdentifierRawP *wtid, + uint64_t *requirement_row, struct TALER_Amount *total) { struct GNUNET_PQ_QueryParam params[] = { @@ -44,6 +45,8 @@ TALER_EXCHANGEDB_get_aggregation_transient ( total), GNUNET_PQ_result_spec_auto_from_type ("wtid_raw", wtid), + GNUNET_PQ_result_spec_uint64 ("legitimization_requirement_serial_id", + requirement_row), GNUNET_PQ_result_spec_end }; @@ -52,6 +55,7 @@ TALER_EXCHANGEDB_get_aggregation_transient ( "SELECT" " amount" " ,wtid_raw" + " ,legitimization_requirement_serial_id" " FROM aggregation_transient" " WHERE wire_target_h_payto=$1" " AND merchant_pub=$2" diff --git a/src/exchangedb/test_aggregation_transient.c b/src/exchangedb/test_aggregation_transient.c @@ -83,6 +83,7 @@ check_empty (struct TALER_EXCHANGEDB_PostgresContext *pg) &merchant_pub, SECTION, &wtid, + &requirement_row, &total)); FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != TALER_EXCHANGEDB_get_aggregation_transient_by_wtid ( @@ -155,13 +156,17 @@ check_insert_and_lookup (struct TALER_EXCHANGEDB_PostgresContext *pg) &merchant_pub, SECTION, &got_wtid, + &requirement_row, &got)); FAILIF (0 != GNUNET_memcmp (&got_wtid, &wtid)); FAILIF (0 != TALER_amount_cmp (&got, &total)); + /* no legitimization reason was recorded */ + FAILIF (0 != requirement_row); /* by (account, wtid) */ + requirement_row = 42; FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != TALER_EXCHANGEDB_get_aggregation_transient_by_wtid ( pg, @@ -204,6 +209,7 @@ check_insert_and_lookup (struct TALER_EXCHANGEDB_PostgresContext *pg) &other, SECTION, &got_wtid, + &requirement_row, &got)); } /* and neither does a different exchange bank account */ @@ -213,6 +219,7 @@ check_insert_and_lookup (struct TALER_EXCHANGEDB_PostgresContext *pg) &merchant_pub, "exchange-account-2", &got_wtid, + &requirement_row, &got)); return 0; } @@ -252,9 +259,13 @@ check_update (struct TALER_EXCHANGEDB_PostgresContext *pg) &merchant_pub, SECTION, &got_wtid, + &requirement_row, &got)); FAILIF (0 != TALER_amount_cmp (&got, &total)); + /* the legitimization reason is read back, so re-parking keeps it */ + FAILIF (5 != requirement_row); + requirement_row = 0; FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != TALER_EXCHANGEDB_get_aggregation_transient_by_wtid ( pg, @@ -295,6 +306,7 @@ check_delete (struct TALER_EXCHANGEDB_PostgresContext *pg) struct TALER_MerchantPublicKeyP merchant_pub; struct TALER_WireTransferIdentifierRawP wtid; struct TALER_Amount got; + uint64_t requirement_row; TDB_FILL (merchant_pub, 10); @@ -316,6 +328,7 @@ check_delete (struct TALER_EXCHANGEDB_PostgresContext *pg) &merchant_pub, SECTION, &wtid, + &requirement_row, &got)); return 0; } diff --git a/src/include/exchange-database/get_aggregation_transient.h b/src/include/exchange-database/get_aggregation_transient.h @@ -36,6 +36,8 @@ * @param merchant_pub public key of the merchant receiving the transfer * @param exchange_account_section exchange account to use * @param[out] wtid set to the raw wire transfer identifier to be used + * @param[out] requirement_row set to the row of the legitimization + * requirement the transient is waiting on, 0 for none * @param[out] total existing amount to be wired in the future * @return transaction status */ @@ -54,6 +56,7 @@ TALER_EXCHANGEDB_get_aggregation_transient (struct struct TALER_WireTransferIdentifierRawP *wtid, + uint64_t *requirement_row, struct TALER_Amount *total);