Compare commits
No commits in common. "2319c00ef63419765564e4abe371ff2456332530" and "399006f2b7734594b802089f5f49e650eb34125a" have entirely different histories.
2319c00ef6
...
399006f2b7
@ -27,51 +27,10 @@
|
||||
#include "taler_json_lib.h"
|
||||
#include "taler_kyclogic_lib.h"
|
||||
#include "taler_mhd_lib.h"
|
||||
#include "taler-exchange-httpd_age-withdraw.h"
|
||||
#include "taler-exchange-httpd_withdraw.h"
|
||||
#include "taler-exchange-httpd_responses.h"
|
||||
#include "taler-exchange-httpd_keys.h"
|
||||
|
||||
/**
|
||||
* Send a response to a "age-withdraw" request.
|
||||
*
|
||||
* @param connection the connection to send the response to
|
||||
* @param ach value the client committed to
|
||||
* @param noreveal_index which index will the client not have to reveal
|
||||
* @return a MHD status code
|
||||
*/
|
||||
static MHD_RESULT
|
||||
reply_age_withdraw_success (struct MHD_Connection *connection,
|
||||
const struct TALER_AgeWithdrawCommitmentHashP *ach,
|
||||
uint32_t noreveal_index)
|
||||
{
|
||||
struct TALER_ExchangePublicKeyP pub;
|
||||
struct TALER_ExchangeSignatureP sig;
|
||||
enum TALER_ErrorCode ec;
|
||||
|
||||
if (TALER_EC_NONE !=
|
||||
(ec = TALER_exchange_online_age_withdraw_confirmation_sign (
|
||||
&TEH_keys_exchange_sign_,
|
||||
ach,
|
||||
noreveal_index,
|
||||
&pub,
|
||||
&sig)))
|
||||
{
|
||||
return TALER_MHD_reply_with_ec (connection,
|
||||
ec,
|
||||
NULL);
|
||||
}
|
||||
|
||||
return TALER_MHD_REPLY_JSON_PACK (
|
||||
connection,
|
||||
MHD_HTTP_OK,
|
||||
GNUNET_JSON_pack_uint64 ("noreveal_index",
|
||||
noreveal_index),
|
||||
GNUNET_JSON_pack_data_auto ("exchange_sig",
|
||||
&sig),
|
||||
GNUNET_JSON_pack_data_auto ("exchange_pub",
|
||||
&pub));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Context for #age_withdraw_transaction.
|
||||
@ -327,7 +286,7 @@ TEH_handler_age_withdraw (struct TEH_RequestContext *rc,
|
||||
struct GNUNET_JSON_Specification spec[] = {
|
||||
GNUNET_JSON_spec_fixed_auto ("reserve_sig",
|
||||
&awc.commitment.reserve_sig),
|
||||
GNUNET_JSON_spec_fixed_auto ("h_commitment",
|
||||
GNUNET_JSON_spec_fixed_auto ("age_restricted_coins_commitment",
|
||||
&awc.commitment.h_commitment),
|
||||
TALER_JSON_spec_amount ("amount",
|
||||
&awc.commitment.amount_with_fee);
|
||||
@ -341,7 +300,6 @@ TEH_handler_age_withdraw (struct TEH_RequestContext *rc,
|
||||
awc.commitment.reserve_pub = *reserve_pub;
|
||||
|
||||
|
||||
/* Parse the JSON body */
|
||||
{
|
||||
enum GNUNET_GenericReturnValue res;
|
||||
|
||||
@ -352,7 +310,6 @@ TEH_handler_age_withdraw (struct TEH_RequestContext *rc,
|
||||
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
||||
}
|
||||
|
||||
/* If request was made before successfully, return the previous answer */
|
||||
if (request_is_idempotent (rc,
|
||||
&awc,
|
||||
&mret))
|
||||
@ -361,7 +318,6 @@ TEH_handler_age_withdraw (struct TEH_RequestContext *rc,
|
||||
return mret;
|
||||
}
|
||||
|
||||
/* Verify the signature of the request body with the reserve key */
|
||||
TEH_METRICS_num_verifications[TEH_MT_SIGNATURE_EDDSA]++;
|
||||
if (GNUNET_OK !=
|
||||
TALER_wallet_age_withdraw_verify (&awc.commitment.h_commitment,
|
||||
@ -392,7 +348,7 @@ TEH_handler_age_withdraw (struct TEH_RequestContext *rc,
|
||||
{
|
||||
/* Even if #withdraw_transaction() failed, it may have created a signature
|
||||
(or we might have done it optimistically above). */
|
||||
/* TODO:oec:which function to call here!? */
|
||||
/*TODO:oec:which function to call here!? */
|
||||
TALER_blinded_denom_sig_free (&awc.commitment.sig);
|
||||
GNUNET_JSON_parse_free (spec);
|
||||
return mhd_ret;
|
||||
@ -406,10 +362,23 @@ TEH_handler_age_withdraw (struct TEH_RequestContext *rc,
|
||||
return TEH_RESPONSE_reply_kyc_required (rc->connection,
|
||||
&awc.h_payto,
|
||||
&awc.kyc);
|
||||
{
|
||||
MHD_RESULT ret;
|
||||
|
||||
return reply_age_withdraw_success (rc->connection,
|
||||
&awc.commitment.h_commitment,
|
||||
awc.commitment.noreveal_index);
|
||||
ret = TALER_MHD_REPLY_JSON_PACK (
|
||||
rc->connection,
|
||||
MHD_HTTP_OK,
|
||||
/* TODO:oec: put in the right answer fields */
|
||||
GNUNET_JSON_pack_uint64 ("noreveal_index",
|
||||
&awc->commitment.noreveal_index),
|
||||
GNUNET_JSON_pack_data_auto ("exchange_sig",
|
||||
&awc->commitment.sig),
|
||||
GNUNET_JSON_pack_data_auto ("exchange_pub",
|
||||
/* TODO:oec: where does the pub come from? */
|
||||
&pub));
|
||||
TALER_blinded_denom_sig_free (&awc.commitment.sig);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1239,7 +1239,7 @@ struct TALER_AgeMask
|
||||
/**
|
||||
* @brief Age commitment of a coin.
|
||||
*/
|
||||
struct TALER_AgeCommitmentHashP
|
||||
struct TALER_AgeCommitmentHash
|
||||
{
|
||||
/**
|
||||
* The commitment is a SHA-256 hash code.
|
||||
|
@ -1879,7 +1879,7 @@ struct TALER_EXCHANGEDB_MeltListEntry
|
||||
* applicable to the denomination. May be all zeroes if no age restriction
|
||||
* applies.
|
||||
*/
|
||||
struct TALER_AgeCommitmentHashP h_age_commitment;
|
||||
struct TALER_AgeCommitmentHash h_age_commitment;
|
||||
|
||||
/**
|
||||
* true, if no h_age_commitment is applicable
|
||||
|
Loading…
Reference in New Issue
Block a user