commit 66b465bfec1d723edd02265650d93641ab68eb3f
parent 46da69710427458d402a55ce617ba28286923dba
Author: Christian Grothoff <grothoff@gnunet.org>
Date: Sat, 15 Aug 2026 21:19:37 +0200
fetch minimum age to enforce it on purse deposits
Diffstat:
1 file changed, 42 insertions(+), 0 deletions(-)
diff --git a/src/exchange/taler-exchange-httpd_post-purses-PURSE_PUB-deposit.c b/src/exchange/taler-exchange-httpd_post-purses-PURSE_PUB-deposit.c
@@ -34,6 +34,7 @@
#include "exchangedb_lib.h"
#include "taler-exchange-httpd_get-keys.h"
#include "exchange-database/get_purse.h"
+#include "exchange-database/get_purse_request.h"
#include "exchange-database/do_purse_deposit.h"
#include "exchange-database/event_notify.h"
#include "exchange-database/get_purse_deposit.h"
@@ -435,6 +436,47 @@ TEH_handler_purses_deposit (
}
}
+ /* Obtain the minimum age required for deposits into this purse;
+ #TALER_EXCHANGEDB_get_purse() does not return it, but we must
+ have it before we check the coins below. */
+ {
+ enum GNUNET_DB_QueryStatus qs;
+ struct TALER_PurseMergePublicKeyP merge_pub;
+ struct GNUNET_TIME_Timestamp purse_expiration;
+ struct TALER_PrivateContractHashP h_contract_terms;
+ struct TALER_Amount target_amount;
+ struct TALER_Amount balance;
+ struct TALER_PurseContractSignatureP purse_sig;
+
+ qs = TALER_EXCHANGEDB_get_purse_request (
+ TEH_pg,
+ pcc.purse_pub,
+ &merge_pub,
+ &purse_expiration,
+ &h_contract_terms,
+ &pcc.min_age,
+ &target_amount,
+ &balance,
+ &purse_sig);
+ switch (qs)
+ {
+ case GNUNET_DB_STATUS_HARD_ERROR:
+ case GNUNET_DB_STATUS_SOFT_ERROR:
+ GNUNET_break (0);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ "select purse request");
+ case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_NOT_FOUND,
+ TALER_EC_EXCHANGE_GENERIC_PURSE_UNKNOWN,
+ NULL);
+ case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
+ break;
+ }
+ }
+
/* parse deposits */
pcc.coins = GNUNET_new_array (pcc.num_coins,
struct TEH_PurseDepositedCoin);