commit 83fbd9e472b787e3a2ae5b5e8c88eac73865a243
parent e1431c7a82daa19b2cbfb95b5851f186fd65ceb8
Author: Christian Grothoff <christian@grothoff.org>
Date: Tue, 7 Apr 2026 11:31:54 +0200
add lpt option to libtalerexchange API
Diffstat:
2 files changed, 69 insertions(+), 16 deletions(-)
diff --git a/src/include/taler/taler-exchange/get-deposits-H_WIRE-MERCHANT_PUB-H_CONTRACT_TERMS-COIN_PUB.h b/src/include/taler/taler-exchange/get-deposits-H_WIRE-MERCHANT_PUB-H_CONTRACT_TERMS-COIN_PUB.h
@@ -39,7 +39,14 @@ enum TALER_EXCHANGE_GetDepositsOption
* How long to wait for the wire transfer to be executed,
* enabling long polling. Default is zero (no long polling).
*/
- TALER_EXCHANGE_GET_DEPOSITS_OPTION_TIMEOUT
+ TALER_EXCHANGE_GET_DEPOSITS_OPTION_TIMEOUT,
+
+ /**
+ * Set the long-poll target type. Default is #TALER_DGLPT_OK.
+ * Use #TALER_DGLPT_KYC_REQUIRED_OR_OK to also wake up when
+ * the KYC status changes.
+ */
+ TALER_EXCHANGE_GET_DEPOSITS_OPTION_LONG_POLL_TARGET
};
@@ -64,6 +71,12 @@ struct TALER_EXCHANGE_GetDepositsOptionValue
*/
struct GNUNET_TIME_Relative timeout;
+ /**
+ * Value if @e option is
+ * #TALER_EXCHANGE_GET_DEPOSITS_OPTION_LONG_POLL_TARGET.
+ */
+ enum TALER_DepositGetLongPollTarget lpt;
+
} details;
};
@@ -124,6 +137,20 @@ TALER_EXCHANGE_get_deposits_create (
.details.timeout = (t) \
}
+/**
+ * Set the long-poll target type.
+ *
+ * @param target a #TALER_DepositGetLongPollTarget value
+ * @return representation of the option as a struct TALER_EXCHANGE_GetDepositsOptionValue
+ */
+#define TALER_EXCHANGE_get_deposits_option_long_poll_target(target) \
+ (const struct TALER_EXCHANGE_GetDepositsOptionValue) \
+ { \
+ .option = \
+ TALER_EXCHANGE_GET_DEPOSITS_OPTION_LONG_POLL_TARGET, \
+ .details.lpt = (target) \
+ }
+
/**
* Set the requested options for the operation.
diff --git a/src/lib/exchange_api_get-deposits-H_WIRE-MERCHANT_PUB-H_CONTRACT_TERMS-COIN_PUB.c b/src/lib/exchange_api_get-deposits-H_WIRE-MERCHANT_PUB-H_CONTRACT_TERMS-COIN_PUB.c
@@ -103,6 +103,11 @@ struct TALER_EXCHANGE_GetDepositsHandle
* Default: zero (no long polling).
*/
struct GNUNET_TIME_Relative timeout;
+
+ /**
+ * Long-poll target type. Defaults to #TALER_DGLPT_NONE (0).
+ */
+ enum TALER_DepositGetLongPollTarget lpt;
} options;
};
@@ -326,6 +331,9 @@ TALER_EXCHANGE_get_deposits_set_options_ (
case TALER_EXCHANGE_GET_DEPOSITS_OPTION_TIMEOUT:
gdh->options.timeout = opt->details.timeout;
break;
+ case TALER_EXCHANGE_GET_DEPOSITS_OPTION_LONG_POLL_TARGET:
+ gdh->options.lpt = opt->details.lpt;
+ break;
}
}
return GNUNET_OK;
@@ -340,11 +348,6 @@ TALER_EXCHANGE_get_deposits_start (
{
struct TALER_MerchantPublicKeyP merchant;
struct TALER_MerchantSignatureP merchant_sig;
- char arg_str[(sizeof (struct TALER_CoinSpendPublicKeyP)
- + sizeof (struct TALER_MerchantWireHashP)
- + sizeof (struct TALER_MerchantPublicKeyP)
- + sizeof (struct TALER_PrivateContractHashP)
- + sizeof (struct TALER_MerchantSignatureP)) * 2 + 48];
unsigned int tms;
CURL *eh;
@@ -370,7 +373,12 @@ TALER_EXCHANGE_get_deposits_start (
char msig_str[sizeof (struct TALER_MerchantSignatureP) * 2];
char chash_str[sizeof (struct TALER_PrivateContractHashP) * 2];
char whash_str[sizeof (struct TALER_MerchantWireHashP) * 2];
+ char arg_str[sizeof (whash_str)
+ + sizeof (mpub_str)
+ + sizeof (chash_str)
+ + sizeof (cpub_str) + 48];
char timeout_str[24];
+ char lpt_str[12];
char *end;
end = GNUNET_STRINGS_data_to_string (&gdh->h_wire,
@@ -410,27 +418,45 @@ TALER_EXCHANGE_get_deposits_start (
"%u",
tms);
}
+ if (TALER_DGLPT_OK == gdh->options.lpt)
+ {
+ lpt_str[0] = '\0';
+ }
+ else
+ {
+ GNUNET_snprintf (
+ lpt_str,
+ sizeof (lpt_str),
+ "%u",
+ (unsigned int) gdh->options.lpt);
+ }
+
GNUNET_snprintf (arg_str,
sizeof (arg_str),
- "deposits/%s/%s/%s/%s?merchant_sig=%s%s%s",
+ "deposits/%s/%s/%s/%s",
whash_str,
mpub_str,
chash_str,
- cpub_str,
- msig_str,
- 0 == tms
- ? ""
- : "&timeout_ms=",
- timeout_str);
+ cpub_str);
+ gdh->url = TALER_url_join (
+ gdh->base_url,
+ arg_str,
+ "merchant_sig", msig_str,
+ "timeout_ms", (0 == tms) ? NULL : timeout_str,
+ "lpt", (TALER_DGLPT_NONE == gdh->options.lpt) ? NULL : lpt_str,
+ NULL);
}
- gdh->url = TALER_url_join (gdh->base_url,
- arg_str,
- NULL);
if (NULL == gdh->url)
+ {
+ GNUNET_break (0);
return TALER_EC_GENERIC_CONFIGURATION_INVALID;
+ }
eh = TALER_EXCHANGE_curl_easy_get_ (gdh->url);
if (NULL == eh)
+ {
+ GNUNET_break (0);
return TALER_EC_GENERIC_CONFIGURATION_INVALID;
+ }
if (0 != tms)
{
GNUNET_break (CURLE_OK ==