commit cdebedf64b2b11f97ef72058a51852254ad1612f
parent 7c6841cba0d787da4824919f65a3a2f0db5596e8
Author: bohdan-potuzhnyi <bohdan.potuzhnyi@gmail.com>
Date: Mon, 23 Jun 2025 23:29:12 +0200
some updates seems like more tests are passing
Diffstat:
1 file changed, 29 insertions(+), 18 deletions(-)
diff --git a/src/lib/taler_merchant_pay_service.c b/src/lib/taler_merchant_pay_service.c
@@ -87,11 +87,14 @@ struct TALER_MERCHANT_OrderPayHandle
const struct TALER_MERCHANT_UseToken *tokens;
} input_tokens;
+ //FIXME: Remove this as we move to the json object for it
struct {
unsigned int num_output_tokens;
const struct TALER_MERCHANT_OutputToken *output_tokens;
} output_tokens;
+ json_t *tokens_evs;
+
/* computed once we see both choice_index and tokens_evs(outputs in the env): */
json_t *wallet_data;
struct GNUNET_HashCode wallet_data_hash;
@@ -563,12 +566,14 @@ TALER_MERCHANT_order_pay_set_options (struct TALER_MERCHANT_OrderPayHandle *ph,
case TALER_MERCHANT_OrderPayOptionType_REFUND_DEADLINE:
{
ph->refund_deadline = o->details.refund_deadline;
+ break;
}
case TALER_MERCHANT_OrderPayOptionType_PAY_DEADLINE:
{
//FIXME: This one comes from the merchant_api_post_order_pay
// no idea do we still need it or not?
+ break;
}
case TALER_MERCHANT_OrderPayOptionType_H_WIRE:
@@ -617,13 +622,10 @@ TALER_MERCHANT_order_pay_set_options (struct TALER_MERCHANT_OrderPayHandle *ph,
);
json_array_append_new (arr, je);
}
- json_t *js = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_array_steal ("tokens_evs", arr)
- );
- enum TALER_MERCHANT_OrderPayOptionErrorCode ec =
- store_json_option (ph, o->ot, js);
- if (TALER_MERCHANT_OPOEC_OK != ec)
- return ec;
+
+ ph->tokens_evs = arr;
+
+ ph->field_seen[o->ot] = true;
}
break;
@@ -640,10 +642,8 @@ TALER_MERCHANT_order_pay_start (struct TALER_MERCHANT_OrderPayHandle *ph)
/* all the old mandatory checks */
if (!ph->merchant_url || !ph->order_id)
return TALER_MERCHANT_OPOEC_MISSING_MANDATORY;
-// if (!ph->field_seen[TALER_MERCHANT_OrderPayOptionType_COINS])
-// return TALER_MERCHANT_OPOEC_MISSING_MANDATORY;
-// if (!ph->field_seen[TALER_MERCHANT_OrderPayOptionType_REFUND_DEADLINE])
-// return TALER_MERCHANT_OPOEC_MISSING_MANDATORY;
+ if ( !(ph->coins.num_coins > 0) )
+ return TALER_MERCHANT_OPOEC_MISSING_MANDATORY;
/* --- build wallet_data hash for signing coins & tokens --- */
if (ph->has_choice_index) {
@@ -651,8 +651,7 @@ TALER_MERCHANT_order_pay_start (struct TALER_MERCHANT_OrderPayHandle *ph)
ph->wallet_data = GNUNET_JSON_PACK (
GNUNET_JSON_pack_int64("choice_index", ph->choice_index),
GNUNET_JSON_pack_allow_null(
- //TODO: WTF IS THIS BULLSHIT...
- GNUNET_JSON_pack_array_incref("tokens_evs", ph->body))
+ GNUNET_JSON_pack_array_incref("tokens_evs", ph->tokens_evs))
);
TALER_json_hash (ph->wallet_data, &ph->wallet_data_hash);
}
@@ -669,16 +668,27 @@ TALER_MERCHANT_order_pay_start (struct TALER_MERCHANT_OrderPayHandle *ph)
/* sign ------------------------------------------------------------ */
struct TALER_Amount fee;
- struct TALER_DenominationHashP h_denom;
+ struct TALER_DenominationHashP h_denom_pub;
- TALER_denom_pub_hash(&c->denom_pub, &h_denom);
+ TALER_denom_pub_hash(&c->denom_pub, &h_denom_pub);
if (0 > TALER_amount_subtract(&fee, &c->amount_with_fee, &c->amount_without_fee))
return TALER_MERCHANT_OPOEC_INVALID_VALUE;
- TALER_wallet_deposit_sign(&c->amount_with_fee, &fee, &ph->h_wire, &ph->h_contract_terms,
- ph->has_choice_index ? &ph->wallet_data_hash : NULL, c->h_age_commitment, NULL,
- &h_denom, ph->timestamp, &ph->merchant_pub, ph->refund_deadline, &c->coin_priv,
+ TALER_wallet_deposit_sign(&c->amount_with_fee,
+ &fee,
+ &ph->h_wire,
+ &ph->h_contract_terms,
+ (NULL != &ph->wallet_data)
+ ? &ph->wallet_data_hash
+ : NULL,
+ c->h_age_commitment,
+ NULL,
+ &h_denom_pub,
+ ph->timestamp,
+ &ph->merchant_pub,
+ ph->refund_deadline,
+ &c->coin_priv,
&pc.coin_sig);
pc.denom_pub = c->denom_pub;
@@ -755,6 +765,7 @@ TALER_MERCHANT_order_pay_start (struct TALER_MERCHANT_OrderPayHandle *ph)
json_t *je = GNUNET_JSON_PACK (
GNUNET_JSON_pack_data_auto ("token_sig", &t->token_sig),
GNUNET_JSON_pack_data_auto ("ub_sig", &t->ub_sig),
+ //TODO: We are missing the h_issue here
GNUNET_JSON_pack_data_auto ("issue_pub", &t->issue_pub)
);
json_array_append_new (arr, je);