diff options
Diffstat (limited to 'src/backenddb/pg_insert_deposit_confirmation.c')
-rw-r--r-- | src/backenddb/pg_insert_deposit_confirmation.c | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/backenddb/pg_insert_deposit_confirmation.c b/src/backenddb/pg_insert_deposit_confirmation.c index 377ba2d8..6ad0f5fb 100644 --- a/src/backenddb/pg_insert_deposit_confirmation.c +++ b/src/backenddb/pg_insert_deposit_confirmation.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022, 2023 Taler Systems SA + Copyright (C) 2022, 2023, 2024 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 @@ -33,6 +33,7 @@ TMH_PG_insert_deposit_confirmation ( struct GNUNET_TIME_Timestamp deposit_timestamp, const struct TALER_PrivateContractHashP *h_contract_terms, const char *exchange_url, + struct GNUNET_TIME_Timestamp wire_transfer_deadline, const struct TALER_Amount *total_without_fees, const struct TALER_Amount *wire_fee, const struct TALER_MerchantWireHashP *h_wire, @@ -40,6 +41,10 @@ TMH_PG_insert_deposit_confirmation ( const struct TALER_ExchangePublicKeyP *exchange_pub, uint64_t *deposit_confirmation_serial_id) { + struct GNUNET_DB_EventHeaderP es = { + .size = htons (sizeof (es)), + .type = htons (TALER_DBEVENT_MERCHANT_NEW_WIRE_DEADLINE) + }; struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_string (instance_id), @@ -53,6 +58,7 @@ TMH_PG_insert_deposit_confirmation ( GNUNET_PQ_query_param_auto_from_type (h_wire), /* 7 */ GNUNET_PQ_query_param_auto_from_type (exchange_sig), GNUNET_PQ_query_param_auto_from_type (exchange_pub), + GNUNET_PQ_query_param_timestamp (&wire_transfer_deadline), GNUNET_PQ_query_param_end }; struct GNUNET_PQ_ResultSpec rs[] = { @@ -60,6 +66,7 @@ TMH_PG_insert_deposit_confirmation ( deposit_confirmation_serial_id), GNUNET_PQ_result_spec_end }; + enum GNUNET_DB_QueryStatus qs; /* no preflight check here, run in transaction by caller! */ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -91,11 +98,12 @@ TMH_PG_insert_deposit_confirmation ( ",total_without_fee" ",wire_fee" ",exchange_sig" + ",wire_transfer_deadline" ",signkey_serial" ",account_serial)" " SELECT " " order_serial" - " ,$3, $4, $5, $6, $8" + " ,$3, $4, $5, $6, $8, $10" " ,ed.signkey_serial" " ,md.account_serial" " FROM merchant_contract_terms" @@ -103,8 +111,20 @@ TMH_PG_insert_deposit_confirmation ( " FULL OUTER JOIN ed ON TRUE" " WHERE h_contract_terms=$2" " RETURNING deposit_confirmation_serial"); - return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, - "insert_deposit_confirmation", - params, - rs); + qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn, + "insert_deposit_confirmation", + params, + rs); + if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) + { + /* inform taler-merchant-depositcheck about new deadline */ + struct GNUNET_TIME_AbsoluteNBO nbo; + + nbo = GNUNET_TIME_absolute_hton (wire_transfer_deadline.abs_time); + GNUNET_PQ_event_notify (pg->conn, + &es, + &nbo, + sizeof (nbo)); + } + return qs; } |