-batch deposit compiles
This commit is contained in:
parent
bdc4482ac6
commit
46f4a0f9f2
@ -108,6 +108,7 @@ taler_exchange_wirewatch_LDADD = \
|
|||||||
taler_exchange_httpd_SOURCES = \
|
taler_exchange_httpd_SOURCES = \
|
||||||
taler-exchange-httpd.c taler-exchange-httpd.h \
|
taler-exchange-httpd.c taler-exchange-httpd.h \
|
||||||
taler-exchange-httpd_auditors.c taler-exchange-httpd_auditors.h \
|
taler-exchange-httpd_auditors.c taler-exchange-httpd_auditors.h \
|
||||||
|
taler-exchange-httpd_batch-deposit.c taler-exchange-httpd_batch-deposit.h \
|
||||||
taler-exchange-httpd_batch-withdraw.c taler-exchange-httpd_batch-withdraw.h \
|
taler-exchange-httpd_batch-withdraw.c taler-exchange-httpd_batch-withdraw.h \
|
||||||
taler-exchange-httpd_common_deposit.c taler-exchange-httpd_common_deposit.h \
|
taler-exchange-httpd_common_deposit.c taler-exchange-httpd_common_deposit.h \
|
||||||
taler-exchange-httpd_contract.c taler-exchange-httpd_contract.h \
|
taler-exchange-httpd_contract.c taler-exchange-httpd_contract.h \
|
||||||
|
@ -66,10 +66,15 @@ struct BatchDepositContext
|
|||||||
struct TALER_MerchantPublicKeyP merchant_pub;
|
struct TALER_MerchantPublicKeyP merchant_pub;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Salt used by the merchant to compute "h_wire".
|
* Salt used by the merchant to compute @e h_wire.
|
||||||
*/
|
*/
|
||||||
struct TALER_WireSaltP wire_salt;
|
struct TALER_WireSaltP wire_salt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hash over the wire details (with @e wire_salt).
|
||||||
|
*/
|
||||||
|
struct TALER_MerchantWireHashP h_wire;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hash of the payto URI.
|
* Hash of the payto URI.
|
||||||
*/
|
*/
|
||||||
@ -87,6 +92,11 @@ struct BatchDepositContext
|
|||||||
*/
|
*/
|
||||||
json_t *extension_details;
|
json_t *extension_details;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hash over @e extension_details.
|
||||||
|
*/
|
||||||
|
struct TALER_ExtensionContractHashP h_extensions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Time when this request was generated. Used, for example, to
|
* Time when this request was generated. Used, for example, to
|
||||||
* assess when (roughly) the income was achieved for tax purposes.
|
* assess when (roughly) the income was achieved for tax purposes.
|
||||||
@ -136,44 +146,63 @@ struct BatchDepositContext
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
static MHD_RESULT
|
static MHD_RESULT
|
||||||
reply_batch_deposit (
|
reply_batch_deposit_success (
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
const struct BatchDepositContext *bdc)
|
const struct BatchDepositContext *bdc)
|
||||||
{
|
{
|
||||||
struct TALER_ExchangePublicKeyP pub;
|
json_t *arr;
|
||||||
struct TALER_ExchangeSignatureP sig;
|
|
||||||
enum TALER_ErrorCode ec;
|
|
||||||
|
|
||||||
#if FIXME
|
arr = json_array ();
|
||||||
if (TALER_EC_NONE !=
|
GNUNET_assert (NULL != arr);
|
||||||
(ec = TALER_exchange_online_deposit_confirmation_sign (
|
for (unsigned int i = 0; i<bdc->num_coins; i++)
|
||||||
&TEH_keys_exchange_sign_,
|
|
||||||
h_contract_terms,
|
|
||||||
h_wire,
|
|
||||||
h_extensions,
|
|
||||||
exchange_timestamp,
|
|
||||||
wire_deadline,
|
|
||||||
refund_deadline,
|
|
||||||
amount_without_fee,
|
|
||||||
coin_pub,
|
|
||||||
merchant,
|
|
||||||
&pub,
|
|
||||||
&sig)))
|
|
||||||
{
|
{
|
||||||
return TALER_MHD_reply_with_ec (connection,
|
const struct TALER_EXCHANGEDB_Deposit *deposit = &bdc->deposits[i];
|
||||||
ec,
|
struct TALER_ExchangePublicKeyP pub;
|
||||||
NULL);
|
struct TALER_ExchangeSignatureP sig;
|
||||||
|
enum TALER_ErrorCode ec;
|
||||||
|
struct TALER_Amount amount_without_fee;
|
||||||
|
|
||||||
|
GNUNET_assert (0 <=
|
||||||
|
TALER_amount_subtract (&amount_without_fee,
|
||||||
|
&deposit->amount_with_fee,
|
||||||
|
&deposit->deposit_fee));
|
||||||
|
if (TALER_EC_NONE !=
|
||||||
|
(ec = TALER_exchange_online_deposit_confirmation_sign (
|
||||||
|
&TEH_keys_exchange_sign_,
|
||||||
|
&bdc->h_contract_terms,
|
||||||
|
&bdc->h_wire,
|
||||||
|
&bdc->h_extensions,
|
||||||
|
bdc->exchange_timestamp,
|
||||||
|
bdc->wire_deadline,
|
||||||
|
bdc->refund_deadline,
|
||||||
|
&amount_without_fee,
|
||||||
|
&deposit->coin.coin_pub,
|
||||||
|
&bdc->merchant_pub,
|
||||||
|
&pub,
|
||||||
|
&sig)))
|
||||||
|
{
|
||||||
|
return TALER_MHD_reply_with_ec (connection,
|
||||||
|
ec,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
GNUNET_assert (
|
||||||
|
0 ==
|
||||||
|
json_array_append_new (arr,
|
||||||
|
GNUNET_JSON_PACK (
|
||||||
|
GNUNET_JSON_pack_data_auto (
|
||||||
|
"exchange_sig",
|
||||||
|
&sig),
|
||||||
|
GNUNET_JSON_pack_data_auto (
|
||||||
|
"exchange_pub",
|
||||||
|
&pub))));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return TALER_MHD_REPLY_JSON_PACK (
|
return TALER_MHD_REPLY_JSON_PACK (
|
||||||
connection,
|
connection,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
GNUNET_JSON_pack_timestamp ("exchange_timestamp",
|
GNUNET_JSON_pack_timestamp ("exchange_timestamp",
|
||||||
exchange_timestamp),
|
bdc->exchange_timestamp),
|
||||||
GNUNET_JSON_pack_data_auto ("exchange_sig",
|
GNUNET_JSON_pack_array_steal ("confirmations",
|
||||||
&sig),
|
arr));
|
||||||
GNUNET_JSON_pack_data_auto ("exchange_pub",
|
|
||||||
&pub));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -202,17 +231,18 @@ batch_deposit_transaction (void *cls,
|
|||||||
|
|
||||||
for (unsigned int i = 0; i<dc->num_coins; i++)
|
for (unsigned int i = 0; i<dc->num_coins; i++)
|
||||||
{
|
{
|
||||||
|
const struct TALER_EXCHANGEDB_Deposit *deposit = &dc->deposits[i];
|
||||||
uint64_t known_coin_id;
|
uint64_t known_coin_id;
|
||||||
|
|
||||||
qs = TEH_make_coin_known (&dc->deposit->coin,
|
qs = TEH_make_coin_known (&deposit->coin,
|
||||||
connection,
|
connection,
|
||||||
&dc->known_coin_id,
|
&known_coin_id,
|
||||||
mhd_ret);
|
mhd_ret);
|
||||||
if (qs < 0)
|
if (qs < 0)
|
||||||
return qs;
|
return qs;
|
||||||
qs = TEH_plugin->do_deposit (TEH_plugin->cls,
|
qs = TEH_plugin->do_deposit (TEH_plugin->cls,
|
||||||
dc->deposit,
|
deposit,
|
||||||
dc->known_coin_id,
|
known_coin_id,
|
||||||
&dc->h_payto,
|
&dc->h_payto,
|
||||||
false, /* FIXME-OEC: extension blocked */
|
false, /* FIXME-OEC: extension blocked */
|
||||||
&dc->exchange_timestamp,
|
&dc->exchange_timestamp,
|
||||||
@ -236,8 +266,8 @@ batch_deposit_transaction (void *cls,
|
|||||||
= TEH_RESPONSE_reply_coin_insufficient_funds (
|
= TEH_RESPONSE_reply_coin_insufficient_funds (
|
||||||
connection,
|
connection,
|
||||||
TALER_EC_EXCHANGE_DEPOSIT_CONFLICTING_CONTRACT,
|
TALER_EC_EXCHANGE_DEPOSIT_CONFLICTING_CONTRACT,
|
||||||
&dc->deposit->coin.denom_pub_hash,
|
&deposit->coin.denom_pub_hash,
|
||||||
&dc->deposit->coin.coin_pub);
|
&deposit->coin.coin_pub);
|
||||||
return GNUNET_DB_STATUS_HARD_ERROR;
|
return GNUNET_DB_STATUS_HARD_ERROR;
|
||||||
}
|
}
|
||||||
if (! balance_ok)
|
if (! balance_ok)
|
||||||
@ -246,8 +276,8 @@ batch_deposit_transaction (void *cls,
|
|||||||
= TEH_RESPONSE_reply_coin_insufficient_funds (
|
= TEH_RESPONSE_reply_coin_insufficient_funds (
|
||||||
connection,
|
connection,
|
||||||
TALER_EC_EXCHANGE_GENERIC_INSUFFICIENT_FUNDS,
|
TALER_EC_EXCHANGE_GENERIC_INSUFFICIENT_FUNDS,
|
||||||
&dc->deposit->coin.denom_pub_hash,
|
&deposit->coin.denom_pub_hash,
|
||||||
&dc->deposit->coin.coin_pub);
|
&deposit->coin.coin_pub);
|
||||||
return GNUNET_DB_STATUS_HARD_ERROR;
|
return GNUNET_DB_STATUS_HARD_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -263,7 +293,7 @@ batch_deposit_transaction (void *cls,
|
|||||||
*
|
*
|
||||||
* @param connection connection we are handling
|
* @param connection connection we are handling
|
||||||
* @param jcoin coin data to parse
|
* @param jcoin coin data to parse
|
||||||
* @param ctx overall context information to use
|
* @param dc overall batch deposit context information to use
|
||||||
* @param[out] deposit where to store the result
|
* @param[out] deposit where to store the result
|
||||||
* @return #GNUNET_OK on success, #GNUNET_NO if an error was returned,
|
* @return #GNUNET_OK on success, #GNUNET_NO if an error was returned,
|
||||||
* #GNUNET_SYSERR on failure and no error could be returned
|
* #GNUNET_SYSERR on failure and no error could be returned
|
||||||
@ -271,31 +301,31 @@ batch_deposit_transaction (void *cls,
|
|||||||
static enum GNUNET_GenericReturnValue
|
static enum GNUNET_GenericReturnValue
|
||||||
parse_coin (struct MHD_Connection *connection,
|
parse_coin (struct MHD_Connection *connection,
|
||||||
json_t *jcoin,
|
json_t *jcoin,
|
||||||
const struct BatchDepositContext *ctx,
|
const struct BatchDepositContext *dc,
|
||||||
struct TALER_EXCHANGEDB_Deposit *deposit)
|
struct TALER_EXCHANGEDB_Deposit *deposit)
|
||||||
{
|
{
|
||||||
struct GNUNET_JSON_Specification spec[] = {
|
struct GNUNET_JSON_Specification spec[] = {
|
||||||
TALER_JSON_spec_amount ("contribution",
|
TALER_JSON_spec_amount ("contribution",
|
||||||
TEH_currency,
|
TEH_currency,
|
||||||
&deposit.amount_with_fee),
|
&deposit->amount_with_fee),
|
||||||
GNUNET_JSON_spec_fixed_auto ("denom_pub_hash",
|
GNUNET_JSON_spec_fixed_auto ("denom_pub_hash",
|
||||||
&deposit.coin.denom_pub_hash),
|
&deposit->coin.denom_pub_hash),
|
||||||
TALER_JSON_spec_denom_sig ("ub_sig",
|
TALER_JSON_spec_denom_sig ("ub_sig",
|
||||||
&deposit.coin.denom_sig),
|
&deposit->coin.denom_sig),
|
||||||
GNUNET_JSON_spec_fixed_auto ("coin_pub",
|
GNUNET_JSON_spec_fixed_auto ("coin_pub",
|
||||||
&deposit.coin_pub),
|
&deposit->coin.coin_pub),
|
||||||
GNUNET_JSON_spec_mark_optional (
|
GNUNET_JSON_spec_mark_optional (
|
||||||
GNUNET_JSON_spec_fixed_auto ("h_age_commitment",
|
GNUNET_JSON_spec_fixed_auto ("h_age_commitment",
|
||||||
&deposit.coin.h_age_commitment),
|
&deposit->coin.h_age_commitment),
|
||||||
&deposit.coin.no_age_commitment),
|
&deposit->coin.no_age_commitment),
|
||||||
GNUNET_JSON_spec_fixed_auto ("coin_sig",
|
GNUNET_JSON_spec_fixed_auto ("coin_sig",
|
||||||
&deposit.csig),
|
&deposit->csig),
|
||||||
GNUNET_JSON_spec_end ()
|
GNUNET_JSON_spec_end ()
|
||||||
};
|
};
|
||||||
enum GNUNET_GenericReturnValue res;
|
enum GNUNET_GenericReturnValue res;
|
||||||
|
|
||||||
res = TALER_MHD_parse_json_data (connection,
|
res = TALER_MHD_parse_json_data (connection,
|
||||||
root,
|
jcoin,
|
||||||
spec);
|
spec);
|
||||||
if (GNUNET_SYSERR == res)
|
if (GNUNET_SYSERR == res)
|
||||||
{
|
{
|
||||||
@ -313,7 +343,7 @@ parse_coin (struct MHD_Connection *connection,
|
|||||||
struct TEH_DenominationKey *dk;
|
struct TEH_DenominationKey *dk;
|
||||||
MHD_RESULT mret;
|
MHD_RESULT mret;
|
||||||
|
|
||||||
dk = TEH_keys_denomination_by_hash (&deposit.coin.denom_pub_hash,
|
dk = TEH_keys_denomination_by_hash (&deposit->coin.denom_pub_hash,
|
||||||
connection,
|
connection,
|
||||||
&mret);
|
&mret);
|
||||||
if (NULL == dk)
|
if (NULL == dk)
|
||||||
@ -322,7 +352,7 @@ parse_coin (struct MHD_Connection *connection,
|
|||||||
return mret;
|
return mret;
|
||||||
}
|
}
|
||||||
if (0 > TALER_amount_cmp (&dk->meta.value,
|
if (0 > TALER_amount_cmp (&dk->meta.value,
|
||||||
&deposit.amount_with_fee))
|
&deposit->amount_with_fee))
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
@ -337,7 +367,7 @@ parse_coin (struct MHD_Connection *connection,
|
|||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
return TEH_RESPONSE_reply_expired_denom_pub_hash (
|
return TEH_RESPONSE_reply_expired_denom_pub_hash (
|
||||||
connection,
|
connection,
|
||||||
&deposit.coin.denom_pub_hash,
|
&deposit->coin.denom_pub_hash,
|
||||||
TALER_EC_EXCHANGE_GENERIC_DENOMINATION_EXPIRED,
|
TALER_EC_EXCHANGE_GENERIC_DENOMINATION_EXPIRED,
|
||||||
"DEPOSIT");
|
"DEPOSIT");
|
||||||
}
|
}
|
||||||
@ -347,7 +377,7 @@ parse_coin (struct MHD_Connection *connection,
|
|||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
return TEH_RESPONSE_reply_expired_denom_pub_hash (
|
return TEH_RESPONSE_reply_expired_denom_pub_hash (
|
||||||
connection,
|
connection,
|
||||||
&deposit.coin.denom_pub_hash,
|
&deposit->coin.denom_pub_hash,
|
||||||
TALER_EC_EXCHANGE_GENERIC_DENOMINATION_VALIDITY_IN_FUTURE,
|
TALER_EC_EXCHANGE_GENERIC_DENOMINATION_VALIDITY_IN_FUTURE,
|
||||||
"DEPOSIT");
|
"DEPOSIT");
|
||||||
}
|
}
|
||||||
@ -357,11 +387,11 @@ parse_coin (struct MHD_Connection *connection,
|
|||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
return TEH_RESPONSE_reply_expired_denom_pub_hash (
|
return TEH_RESPONSE_reply_expired_denom_pub_hash (
|
||||||
connection,
|
connection,
|
||||||
&deposit.coin.denom_pub_hash,
|
&deposit->coin.denom_pub_hash,
|
||||||
TALER_EC_EXCHANGE_GENERIC_DENOMINATION_REVOKED,
|
TALER_EC_EXCHANGE_GENERIC_DENOMINATION_REVOKED,
|
||||||
"DEPOSIT");
|
"DEPOSIT");
|
||||||
}
|
}
|
||||||
if (dk->denom_pub.cipher != deposit.coin.denom_sig.cipher)
|
if (dk->denom_pub.cipher != deposit->coin.denom_sig.cipher)
|
||||||
{
|
{
|
||||||
/* denomination cipher and denomination signature cipher not the same */
|
/* denomination cipher and denomination signature cipher not the same */
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
@ -371,7 +401,7 @@ parse_coin (struct MHD_Connection *connection,
|
|||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
deposit.deposit_fee = dk->meta.fees.deposit;
|
deposit->deposit_fee = dk->meta.fees.deposit;
|
||||||
/* check coin signature */
|
/* check coin signature */
|
||||||
switch (dk->denom_pub.cipher)
|
switch (dk->denom_pub.cipher)
|
||||||
{
|
{
|
||||||
@ -385,7 +415,7 @@ parse_coin (struct MHD_Connection *connection,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (GNUNET_YES !=
|
if (GNUNET_YES !=
|
||||||
TALER_test_coin_valid (&deposit.coin,
|
TALER_test_coin_valid (&deposit->coin,
|
||||||
&dk->denom_pub))
|
&dk->denom_pub))
|
||||||
{
|
{
|
||||||
TALER_LOG_WARNING ("Invalid coin passed for /deposit\n");
|
TALER_LOG_WARNING ("Invalid coin passed for /deposit\n");
|
||||||
@ -396,8 +426,8 @@ parse_coin (struct MHD_Connection *connection,
|
|||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (0 < TALER_amount_cmp (&deposit.deposit_fee,
|
if (0 < TALER_amount_cmp (&deposit->deposit_fee,
|
||||||
&deposit.amount_with_fee))
|
&deposit->amount_with_fee))
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
@ -409,18 +439,18 @@ parse_coin (struct MHD_Connection *connection,
|
|||||||
|
|
||||||
TEH_METRICS_num_verifications[TEH_MT_SIGNATURE_EDDSA]++;
|
TEH_METRICS_num_verifications[TEH_MT_SIGNATURE_EDDSA]++;
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_wallet_deposit_verify (&deposit.amount_with_fee,
|
TALER_wallet_deposit_verify (&deposit->amount_with_fee,
|
||||||
&deposit.deposit_fee,
|
&deposit->deposit_fee,
|
||||||
&h_wire,
|
&dc->h_wire,
|
||||||
&deposit.h_contract_terms,
|
&dc->h_contract_terms,
|
||||||
&deposit.coin.h_age_commitment,
|
&deposit->coin.h_age_commitment,
|
||||||
NULL /* h_extensions! */,
|
&dc->h_extensions,
|
||||||
&deposit.coin.denom_pub_hash,
|
&deposit->coin.denom_pub_hash,
|
||||||
deposit.timestamp,
|
dc->timestamp,
|
||||||
&deposit.merchant_pub,
|
&dc->merchant_pub,
|
||||||
deposit.refund_deadline,
|
dc->refund_deadline,
|
||||||
&deposit.coin.coin_pub,
|
&deposit->coin.coin_pub,
|
||||||
&deposit.csig))
|
&deposit->csig))
|
||||||
{
|
{
|
||||||
TALER_LOG_WARNING ("Invalid signature on /deposit request\n");
|
TALER_LOG_WARNING ("Invalid signature on /deposit request\n");
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
@ -429,9 +459,18 @@ parse_coin (struct MHD_Connection *connection,
|
|||||||
TALER_EC_EXCHANGE_DEPOSIT_COIN_SIGNATURE_INVALID,
|
TALER_EC_EXCHANGE_DEPOSIT_COIN_SIGNATURE_INVALID,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
deposit->merchant_pub = dc->merchant_pub;
|
||||||
// FIXME: duplicate batch-global values into
|
deposit->h_contract_terms = dc->h_contract_terms;
|
||||||
// per-deposit data structure!
|
deposit->wire_salt = dc->wire_salt;
|
||||||
|
deposit->receiver_wire_account = (char *) dc->payto_uri;
|
||||||
|
/* FIXME-OEC: should NOT insert the extension details N times,
|
||||||
|
but rather insert them ONCE and then per-coin only use
|
||||||
|
the resulting extension UUID/serial; so the data structure
|
||||||
|
here should be changed once we look at extensions in earnest. */
|
||||||
|
deposit->extension_details = dc->extension_details;
|
||||||
|
deposit->timestamp = dc->timestamp;
|
||||||
|
deposit->refund_deadline = dc->refund_deadline;
|
||||||
|
deposit->wire_deadline = dc->wire_deadline;
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,6 +493,8 @@ TEH_handler_batch_deposit (struct MHD_Connection *connection,
|
|||||||
&dc.h_contract_terms),
|
&dc.h_contract_terms),
|
||||||
GNUNET_JSON_spec_json ("coins",
|
GNUNET_JSON_spec_json ("coins",
|
||||||
&coins),
|
&coins),
|
||||||
|
GNUNET_JSON_spec_json ("extension_details",
|
||||||
|
&dc.extension_details),
|
||||||
GNUNET_JSON_spec_timestamp ("timestamp",
|
GNUNET_JSON_spec_timestamp ("timestamp",
|
||||||
&dc.timestamp),
|
&dc.timestamp),
|
||||||
GNUNET_JSON_spec_mark_optional (
|
GNUNET_JSON_spec_mark_optional (
|
||||||
@ -465,7 +506,6 @@ TEH_handler_batch_deposit (struct MHD_Connection *connection,
|
|||||||
GNUNET_JSON_spec_end ()
|
GNUNET_JSON_spec_end ()
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TALER_MerchantWireHashP h_wire;
|
|
||||||
enum GNUNET_GenericReturnValue res;
|
enum GNUNET_GenericReturnValue res;
|
||||||
|
|
||||||
res = TALER_MHD_parse_json_data (connection,
|
res = TALER_MHD_parse_json_data (connection,
|
||||||
@ -501,9 +541,9 @@ TEH_handler_batch_deposit (struct MHD_Connection *connection,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (GNUNET_TIME_timestamp_cmp (deposit.refund_deadline,
|
if (GNUNET_TIME_timestamp_cmp (dc.refund_deadline,
|
||||||
>,
|
>,
|
||||||
deposit.wire_deadline))
|
dc.wire_deadline))
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
@ -512,7 +552,7 @@ TEH_handler_batch_deposit (struct MHD_Connection *connection,
|
|||||||
TALER_EC_EXCHANGE_DEPOSIT_REFUND_DEADLINE_AFTER_WIRE_DEADLINE,
|
TALER_EC_EXCHANGE_DEPOSIT_REFUND_DEADLINE_AFTER_WIRE_DEADLINE,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
if (GNUNET_TIME_absolute_is_never (deposit.wire_deadline.abs_time))
|
if (GNUNET_TIME_absolute_is_never (dc.wire_deadline.abs_time))
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
@ -524,12 +564,17 @@ TEH_handler_batch_deposit (struct MHD_Connection *connection,
|
|||||||
TALER_payto_hash (dc.payto_uri,
|
TALER_payto_hash (dc.payto_uri,
|
||||||
&dc.h_payto);
|
&dc.h_payto);
|
||||||
TALER_merchant_wire_signature_hash (dc.payto_uri,
|
TALER_merchant_wire_signature_hash (dc.payto_uri,
|
||||||
&deposit.wire_salt,
|
&dc.wire_salt,
|
||||||
&h_wire);
|
&dc.h_wire);
|
||||||
|
/* FIXME-OEC: hash actual extension JSON object here */
|
||||||
|
memset (&dc.h_extensions,
|
||||||
|
0,
|
||||||
|
sizeof (dc.h_extensions));
|
||||||
dc.num_coins = json_array_size (coins);
|
dc.num_coins = json_array_size (coins);
|
||||||
if (0 == dc.num_coins)
|
if (0 == dc.num_coins)
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
|
GNUNET_JSON_parse_free (spec);
|
||||||
return TALER_MHD_reply_with_error (connection,
|
return TALER_MHD_reply_with_error (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
TALER_EC_GENERIC_PARAMETER_MALFORMED,
|
TALER_EC_GENERIC_PARAMETER_MALFORMED,
|
||||||
@ -538,13 +583,14 @@ TEH_handler_batch_deposit (struct MHD_Connection *connection,
|
|||||||
if (TALER_MAX_FRESH_COINS < dc.num_coins)
|
if (TALER_MAX_FRESH_COINS < dc.num_coins)
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
|
GNUNET_JSON_parse_free (spec);
|
||||||
return TALER_MHD_reply_with_error (connection,
|
return TALER_MHD_reply_with_error (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
TALER_EC_GENERIC_PARAMETER_MALFORMED,
|
TALER_EC_GENERIC_PARAMETER_MALFORMED,
|
||||||
"coins");
|
"coins");
|
||||||
}
|
}
|
||||||
dc->deposits = GNUNET_new_array (dc.num_coins,
|
dc.deposits = GNUNET_new_array (dc.num_coins,
|
||||||
struct TALER_EXCHANGEDB_Deposit *);
|
struct TALER_EXCHANGEDB_Deposit);
|
||||||
for (unsigned int i = 0; i<dc.num_coins; i++)
|
for (unsigned int i = 0; i<dc.num_coins; i++)
|
||||||
{
|
{
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
@ -552,11 +598,12 @@ TEH_handler_batch_deposit (struct MHD_Connection *connection,
|
|||||||
json_array_get (coins,
|
json_array_get (coins,
|
||||||
i),
|
i),
|
||||||
&dc,
|
&dc,
|
||||||
&dc->deposits[i])))
|
&dc.deposits[i])))
|
||||||
{
|
{
|
||||||
for (unsigned int j = 0; j<i; j++)
|
for (unsigned int j = 0; j<i; j++)
|
||||||
TALER_denom_sig_free (&dc.deposits[j].denom_sig);
|
TALER_denom_sig_free (&dc.deposits[j].coin.denom_sig);
|
||||||
GNUNET_free (dc.deposits);
|
GNUNET_free (dc.deposits);
|
||||||
|
GNUNET_JSON_parse_free (spec);
|
||||||
return (GNUNET_NO == res) ? MHD_YES : MHD_NO;
|
return (GNUNET_NO == res) ? MHD_YES : MHD_NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -566,6 +613,7 @@ TEH_handler_batch_deposit (struct MHD_Connection *connection,
|
|||||||
TEH_plugin->preflight (TEH_plugin->cls))
|
TEH_plugin->preflight (TEH_plugin->cls))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
|
GNUNET_JSON_parse_free (spec);
|
||||||
return TALER_MHD_reply_with_error (connection,
|
return TALER_MHD_reply_with_error (connection,
|
||||||
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
||||||
TALER_EC_GENERIC_DB_START_FAILED,
|
TALER_EC_GENERIC_DB_START_FAILED,
|
||||||
@ -586,8 +634,9 @@ TEH_handler_batch_deposit (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
for (unsigned int j = 0; j<dc.num_coins; j++)
|
for (unsigned int j = 0; j<dc.num_coins; j++)
|
||||||
TALER_denom_sig_free (&dc.deposits[i].denom_sig);
|
TALER_denom_sig_free (&dc.deposits[j].coin.denom_sig);
|
||||||
GNUNET_free (dc.deposits);
|
GNUNET_free (dc.deposits);
|
||||||
|
GNUNET_JSON_parse_free (spec);
|
||||||
return mhd_ret;
|
return mhd_ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -599,7 +648,7 @@ TEH_handler_batch_deposit (struct MHD_Connection *connection,
|
|||||||
res = reply_batch_deposit_success (connection,
|
res = reply_batch_deposit_success (connection,
|
||||||
&dc);
|
&dc);
|
||||||
for (unsigned int j = 0; j<dc.num_coins; j++)
|
for (unsigned int j = 0; j<dc.num_coins; j++)
|
||||||
TALER_denom_sig_free (&dc.deposits[i].denom_sig);
|
TALER_denom_sig_free (&dc.deposits[j].coin.denom_sig);
|
||||||
GNUNET_free (dc.deposits);
|
GNUNET_free (dc.deposits);
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
return res;
|
return res;
|
||||||
|
Loading…
Reference in New Issue
Block a user