commit 4feb426272d362d0713e3548414da902f7144491
parent 5d5e2ef86158f43e4defb2eb531098891bbc6c21
Author: Özgür Kesim <oec@codeblau.de>
Date: Fri, 13 Nov 2026 13:20:35 +0100
[lib] melt: the caller chooses the commitment version once (#11862)
MeltInput.rc_version is kept for retries; another version would yield another rc, a new melt.
Diffstat:
6 files changed, 32 insertions(+), 34 deletions(-)
diff --git a/src/include/taler/exchange/post-melt.h b/src/include/taler/exchange/post-melt.h
@@ -30,6 +30,20 @@ struct TALER_EXCHANGE_PostMeltHandle;
/**
+ * Determine which version of the refresh commitment to use for a melt
+ * at the exchange with the given @a keys: exchanges before protocol v45
+ * only accept the commitment without the transfer public keys (#11862).
+ * The result belongs into the #TALER_EXCHANGE_MeltInput of the melt.
+ *
+ * @param keys the keys of the exchange
+ * @return version of the refresh commitment to use
+ */
+enum TALER_RefreshCommitmentVersion
+TALER_EXCHANGE_refresh_commitment_version (
+ const struct TALER_EXCHANGE_Keys *keys);
+
+
+/**
* Set up POST /melt operation.
* Note that you must explicitly start the operation after setup.
*
diff --git a/src/include/taler/exchange/post-reveal-melt.h b/src/include/taler/exchange/post-reveal-melt.h
@@ -127,6 +127,15 @@ struct TALER_EXCHANGE_MeltInput
*/
const struct TALER_EXCHANGE_DenomPublicKey *fresh_denom_pubs;
+ /**
+ * Version of the refresh commitment, see
+ * TALER_EXCHANGE_refresh_commitment_version(). Choose it once, before
+ * the first request of this melt, and keep it for all retries: another
+ * version yields another commitment, which the exchange treats as a new
+ * melt.
+ */
+ enum TALER_RefreshCommitmentVersion rc_version;
+
};
diff --git a/src/lib/exchange_api_post-melt.c b/src/lib/exchange_api_post-melt.c
@@ -385,8 +385,7 @@ start_melt (struct TALER_EXCHANGE_PostMeltHandle *mh)
? NULL
: &mh->blinding_seed,
mh->melt_blinding_values,
- TALER_EXCHANGE_refresh_commitment_version_ (
- mh->keys),
+ mh->rd->rc_version,
&mh->md))
{
GNUNET_break (0);
diff --git a/src/lib/exchange_api_refresh_common.c b/src/lib/exchange_api_refresh_common.c
@@ -332,7 +332,7 @@ TALER_EXCHANGE_get_melt_data (
enum TALER_RefreshCommitmentVersion
-TALER_EXCHANGE_refresh_commitment_version_ (
+TALER_EXCHANGE_refresh_commitment_version (
const struct TALER_EXCHANGE_Keys *keys)
{
struct TALER_JSON_ProtocolVersion pv;
diff --git a/src/lib/exchange_api_refresh_common.h b/src/lib/exchange_api_refresh_common.h
@@ -216,19 +216,6 @@ TALER_EXCHANGE_get_melt_data (
/**
- * Determine which version of the refresh commitment to use for
- * a melt at the exchange with the given @a keys: exchanges before
- * protocol v45 only accept the commitment without the transfer
- * public keys (#11862).
- *
- * @param keys the keys of the exchange
- * @return version of the refresh commitment to use
- */
-enum TALER_RefreshCommitmentVersion
-TALER_EXCHANGE_refresh_commitment_version_ (
- const struct TALER_EXCHANGE_Keys *keys);
-
-/**
* Free all information associated with a melting session. Note
* that we allow the melting session to be only partially initialized,
* as we use this function also when freeing melt data that was not
diff --git a/src/testing/testing_api_cmd_refresh.c b/src/testing/testing_api_cmd_refresh.c
@@ -680,29 +680,12 @@ static enum GNUNET_GenericReturnValue
start_melt (struct MeltState *ms,
TALER_EXCHANGE_PostMeltCallback cb)
{
- struct TALER_EXCHANGE_Keys *keys = TALER_TESTING_get_keys (ms->is);
-
- if (ms->legacy_commitment)
- {
- /* Pretend that the exchange speaks a protocol version from before
- the fix of the refresh commitment */
- json_t *jkeys = TALER_EXCHANGE_keys_to_json (keys);
-
- GNUNET_assert (NULL != jkeys);
- keys = TALER_EXCHANGE_keys_from_json (jkeys);
- json_decref (jkeys);
- GNUNET_assert (NULL != keys);
- GNUNET_free (keys->version);
- keys->version = GNUNET_strdup ("42:0:8");
- }
ms->mh = TALER_EXCHANGE_post_melt_create (
TALER_TESTING_interpreter_get_context (ms->is),
TALER_TESTING_get_exchange_url (ms->is),
- keys,
+ TALER_TESTING_get_keys (ms->is),
&ms->rms,
&ms->melt_input);
- if (ms->legacy_commitment)
- TALER_EXCHANGE_keys_decref (keys);
if (NULL == ms->mh)
return GNUNET_SYSERR;
GNUNET_assert (TALER_EC_NONE ==
@@ -1019,6 +1002,12 @@ melt_run (void *cls,
}
rms->melt_input.fresh_denom_pubs = rms->fresh_pks;
rms->melt_input.num_fresh_denom_pubs = num_fresh_coins;
+ /* chosen once, so that retries keep the same commitment */
+ rms->melt_input.rc_version
+ = rms->legacy_commitment
+ ? TALER_REFRESH_COMMITMENT_VERSION_LEGACY_VDOLDPLUS_BROKEN
+ : TALER_EXCHANGE_refresh_commitment_version (
+ TALER_TESTING_get_keys (is));
GNUNET_assert (age_restricted_denom ==
(NULL != age_commitment_proof));