commit 3ac8ef95f9bb89aa821846c2f714fc63c7858005
parent fef8f48d68ee170d0c0c151daf566b3c4774bb04
Author: Christian Grothoff <christian@grothoff.org>
Date: Fri, 27 Feb 2026 20:57:59 +0100
implement #11123
Diffstat:
4 files changed, 109 insertions(+), 24 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_private-get-incoming-ID.c b/src/backend/taler-merchant-httpd_private-get-incoming-ID.c
@@ -72,6 +72,13 @@ TMH_private_get_incoming_ID (const struct TMH_RequestHandler *rh,
unsigned long long serial_id;
struct TALER_Amount wire_fee;
bool no_fee;
+ struct GNUNET_TIME_Timestamp expected_time;
+ struct TALER_Amount expected_credit_amount;
+ struct TALER_WireTransferIdentifierRawP wtid;
+ struct TALER_FullPayto payto_uri;
+ char *exchange_url = NULL;
+ struct GNUNET_TIME_Timestamp execution_time;
+ bool confirmed;
{
char dummy;
@@ -93,16 +100,19 @@ TMH_private_get_incoming_ID (const struct TMH_RequestHandler *rh,
TMH_db->preflight (TMH_db->cls);
{
- struct GNUNET_TIME_Timestamp execution_date;
- char *payto_uri;
struct TALER_MasterPublicKeyP master_pub;
enum GNUNET_DB_QueryStatus qs;
qs = TMH_db->lookup_expected_transfer (TMH_db->cls,
hc->instance->settings.id,
serial_id,
- &execution_date,
+ &expected_time,
+ &expected_credit_amount,
+ &wtid,
&payto_uri,
+ &exchange_url,
+ &execution_time,
+ &confirmed,
&master_pub);
if (0 > qs)
{
@@ -132,16 +142,16 @@ TMH_private_get_incoming_ID (const struct TMH_RequestHandler *rh,
struct TALER_MasterSignatureP master_sig;
struct TALER_WireFeeSet fees;
- method = TALER_payto_get_method (payto_uri);
- GNUNET_free (payto_uri);
- qs = TMH_db->lookup_wire_fee (TMH_db->cls,
- &master_pub,
- method,
- execution_date,
- &fees,
- &start_date,
- &end_date,
- &master_sig);
+ method = TALER_payto_get_method (payto_uri.full_payto);
+ qs = TMH_db->lookup_wire_fee (
+ TMH_db->cls,
+ &master_pub,
+ method,
+ expected_time,
+ &fees,
+ &start_date,
+ &end_date,
+ &master_sig);
GNUNET_free (method);
if (0 > qs)
{
@@ -149,6 +159,8 @@ TMH_private_get_incoming_ID (const struct TMH_RequestHandler *rh,
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs);
/* Always report on hard error as well to enable diagnostics */
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
+ GNUNET_free (exchange_url);
+ GNUNET_free (payto_uri.full_payto);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_DB_FETCH_FAILED,
@@ -164,6 +176,7 @@ TMH_private_get_incoming_ID (const struct TMH_RequestHandler *rh,
{
enum GNUNET_DB_QueryStatus qs;
json_t *rd;
+ MHD_RESULT mret;
rd = json_array ();
GNUNET_assert (NULL != rd);
@@ -178,20 +191,44 @@ TMH_private_get_incoming_ID (const struct TMH_RequestHandler *rh,
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs);
/* Always report on hard error as well to enable diagnostics */
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
+ GNUNET_free (exchange_url);
+ GNUNET_free (payto_uri.full_payto);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_DB_FETCH_FAILED,
"lookup_reconciliation_details");
}
- return TALER_MHD_REPLY_JSON_PACK (
+ mret = TALER_MHD_REPLY_JSON_PACK (
connection,
MHD_HTTP_OK,
GNUNET_JSON_pack_allow_null (
+ TALER_JSON_pack_amount (
+ "expected_credit_amount",
+ TALER_amount_is_valid (&expected_credit_amount)
+ ? &expected_credit_amount
+ : NULL)),
+ GNUNET_JSON_pack_data_auto ("wtid",
+ &wtid),
+ TALER_JSON_pack_full_payto ("payto_uri",
+ payto_uri),
+ GNUNET_JSON_pack_string ("exchange_url",
+ exchange_url),
+ GNUNET_JSON_pack_bool ("confirmed",
+ confirmed),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_timestamp ("execution_time",
+ execution_time)),
+ GNUNET_JSON_pack_timestamp ("expected_time",
+ expected_time),
+ GNUNET_JSON_pack_allow_null (
TALER_JSON_pack_amount ("wire_fee",
no_fee ? NULL : &wire_fee)),
GNUNET_JSON_pack_array_steal ("reconciliation_details",
rd));
+ GNUNET_free (exchange_url);
+ GNUNET_free (payto_uri.full_payto);
+ return mret;
}
}
diff --git a/src/backenddb/pg_lookup_expected_transfer.c b/src/backenddb/pg_lookup_expected_transfer.c
@@ -31,8 +31,13 @@ TMH_PG_lookup_expected_transfer (
void *cls,
const char *instance_id,
uint64_t expected_incoming_serial,
- struct GNUNET_TIME_Timestamp *execution_date,
- char **payto_uri,
+ struct GNUNET_TIME_Timestamp *expected_time,
+ struct TALER_Amount *expected_credit_amount,
+ struct TALER_WireTransferIdentifierRawP *wtid,
+ struct TALER_FullPayto *payto_uri,
+ char **exchange_url,
+ struct GNUNET_TIME_Timestamp *execution_time,
+ bool *confirmed,
struct TALER_MasterPublicKeyP *master_pub)
{
struct PostgresClosure *pg = cls;
@@ -43,20 +48,43 @@ TMH_PG_lookup_expected_transfer (
};
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_timestamp ("expected_time",
- execution_date),
+ expected_time),
+ GNUNET_PQ_result_spec_bool ("confirmed",
+ confirmed),
+ GNUNET_PQ_result_spec_allow_null (
+ TALER_PQ_result_spec_amount_with_currency ("expected_credit_amount",
+ expected_credit_amount),
+ NULL),
+ GNUNET_PQ_result_spec_string ("exchange_url",
+ exchange_url),
+ GNUNET_PQ_result_spec_auto_from_type ("wtid",
+ wtid),
GNUNET_PQ_result_spec_string ("payto_uri",
- payto_uri),
+ &payto_uri->full_payto),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_timestamp ("execution_time",
+ execution_time),
+ NULL),
GNUNET_PQ_result_spec_auto_from_type ("master_pub",
master_pub),
GNUNET_PQ_result_spec_end
};
+ *execution_time = GNUNET_TIME_UNIT_ZERO_TS;
+ memset (expected_credit_amount,
+ 0,
+ sizeof (*expected_credit_amount));
check_connection (pg);
PREPARE (pg,
"lookup_expected_transfer",
"SELECT"
" met.expected_time"
+ " ,met.confirmed"
+ " ,met.expected_credit_amount"
+ " ,met.exchange_url"
+ " ,met.wtid"
" ,ma.payto_uri"
+ " ,mts.execution_time"
" ,esk.master_pub"
" FROM merchant_expected_transfers met"
" JOIN merchant_exchange_signing_keys esk"
@@ -65,6 +93,8 @@ TMH_PG_lookup_expected_transfer (
" USING (account_serial)"
" JOIN merchant_instances inst"
" USING (merchant_serial)"
+ " LEFT JOIN merchant_transfer_signatures mts"
+ " USING (expected_credit_serial)"
" WHERE inst.merchant_id=$1"
" AND met.expected_credit_serial=$2");
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
diff --git a/src/backenddb/pg_lookup_expected_transfer.h b/src/backenddb/pg_lookup_expected_transfer.h
@@ -31,8 +31,12 @@
* @param cls closure
* @param instance_id instance to lookup payments for
* @param expected_incoming_serial serial number of the transfer
- * @param[out] execution_date date of the transfer
+ * @param[out] expected_time expected date of the transfer
+ * @param[out] wtid expected wire transfer subject
* @param[out] payto_uri target bank account
+ * @param[out] exchange_url URL of the exchange
+ * @param[out] execution_time, set to 0 if unknown
+ * @param[out] confirmed set if the transfer was confirmed
* @param[out] master_pub master public key of the exchange
* @return transaction status code
*/
@@ -41,8 +45,13 @@ TMH_PG_lookup_expected_transfer (
void *cls,
const char *instance_id,
uint64_t expected_incoming_serial,
- struct GNUNET_TIME_Timestamp *execution_date,
- char **payto_uri,
+ struct GNUNET_TIME_Timestamp *expected_time,
+ struct TALER_Amount *expected_credit_amount,
+ struct TALER_WireTransferIdentifierRawP *wtid,
+ struct TALER_FullPayto *payto_uri,
+ char **exchange_url,
+ struct GNUNET_TIME_Timestamp *execution_time,
+ bool *confirmed,
struct TALER_MasterPublicKeyP *master_pub);
diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h
@@ -3891,8 +3891,12 @@ struct TALER_MERCHANTDB_Plugin
* @param cls closure
* @param instance_id instance to lookup payments for
* @param expected_incoming_serial serial number of the transfer
- * @param[out] execution_date date of the transfer
+ * @param[out] expected_time expected date of the transfer
+ * @param[out] wtid expected wire transfer subject
* @param[out] payto_uri target bank account
+ * @param[out] exchange_url URL of the exchange
+ * @param[out] execution_time, set to 0 if unknown
+ * @param[out] confirmed set if the transfer was confirmed
* @param[out] master_pub master public key of the exchange
* @return transaction status code
*/
@@ -3901,8 +3905,13 @@ struct TALER_MERCHANTDB_Plugin
void *cls,
const char *instance_id,
uint64_t expected_incoming_serial,
- struct GNUNET_TIME_Timestamp *execution_date,
- char **payto_uri,
+ struct GNUNET_TIME_Timestamp *expected_time,
+ struct TALER_Amount *expected_credit_amount,
+ struct TALER_WireTransferIdentifierRawP *wtid,
+ struct TALER_FullPayto *payto_uri,
+ char **exchange_url,
+ struct GNUNET_TIME_Timestamp *execution_time,
+ bool *confirmed,
struct TALER_MasterPublicKeyP *master_pub);