fix status code
This commit is contained in:
parent
9d3336f8f7
commit
5ac448738d
@ -1802,7 +1802,6 @@ refund_cb (void *cls,
|
|||||||
.coin_pub = *coin_pub,
|
.coin_pub = *coin_pub,
|
||||||
.merchant = *merchant_pub,
|
.merchant = *merchant_pub,
|
||||||
.rtransaction_id = GNUNET_htonll (rtransaction_id),
|
.rtransaction_id = GNUNET_htonll (rtransaction_id),
|
||||||
.refund_fee = issue->fee_refund
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TALER_amount_hton (&rr.refund_amount,
|
TALER_amount_hton (&rr.refund_amount,
|
||||||
|
@ -550,7 +550,6 @@ handle_reserve_out (void *cls,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check reserve_sig (first: setup remaining members of wsrd) */
|
/* check reserve_sig (first: setup remaining members of wsrd) */
|
||||||
wsrd.withdraw_fee = issue->fee_withdraw;
|
|
||||||
TALER_amount_hton (&wsrd.amount_with_fee,
|
TALER_amount_hton (&wsrd.amount_with_fee,
|
||||||
amount_with_fee);
|
amount_with_fee);
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
|
@ -90,10 +90,11 @@ reply_deposit_success (struct MHD_Connection *connection,
|
|||||||
}
|
}
|
||||||
return TALER_MHD_reply_json_pack (connection,
|
return TALER_MHD_reply_json_pack (connection,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"{s:s, s:o, s:o}",
|
"{s:o, s:o}",
|
||||||
"status", "DEPOSIT_OK",
|
"exchange_sig",
|
||||||
"sig", GNUNET_JSON_from_data_auto (&sig),
|
GNUNET_JSON_from_data_auto (&sig),
|
||||||
"pub", GNUNET_JSON_from_data_auto (&pub));
|
"exchange_pub",
|
||||||
|
GNUNET_JSON_from_data_auto (&pub));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -312,15 +313,22 @@ TEH_handler_deposit (struct MHD_Connection *connection,
|
|||||||
struct GNUNET_HashCode my_h_wire;
|
struct GNUNET_HashCode my_h_wire;
|
||||||
struct GNUNET_JSON_Specification spec[] = {
|
struct GNUNET_JSON_Specification spec[] = {
|
||||||
GNUNET_JSON_spec_json ("wire", &wire),
|
GNUNET_JSON_spec_json ("wire", &wire),
|
||||||
TALER_JSON_spec_amount ("contribution", &deposit.amount_with_fee),
|
TALER_JSON_spec_amount ("contribution",
|
||||||
|
&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_denomination_signature ("ub_sig", &deposit.coin.denom_sig),
|
TALER_JSON_spec_denomination_signature ("ub_sig",
|
||||||
GNUNET_JSON_spec_fixed_auto ("merchant_pub", &deposit.merchant_pub),
|
&deposit.coin.denom_sig),
|
||||||
GNUNET_JSON_spec_fixed_auto ("h_contract_terms", &deposit.h_contract_terms),
|
GNUNET_JSON_spec_fixed_auto ("merchant_pub",
|
||||||
GNUNET_JSON_spec_fixed_auto ("h_wire", &deposit.h_wire),
|
&deposit.merchant_pub),
|
||||||
GNUNET_JSON_spec_fixed_auto ("coin_sig", &deposit.csig),
|
GNUNET_JSON_spec_fixed_auto ("h_contract_terms",
|
||||||
GNUNET_JSON_spec_absolute_time ("timestamp", &deposit.timestamp),
|
&deposit.h_contract_terms),
|
||||||
|
GNUNET_JSON_spec_fixed_auto ("h_wire",
|
||||||
|
&deposit.h_wire),
|
||||||
|
GNUNET_JSON_spec_fixed_auto ("coin_sig",
|
||||||
|
&deposit.csig),
|
||||||
|
GNUNET_JSON_spec_absolute_time ("timestamp",
|
||||||
|
&deposit.timestamp),
|
||||||
GNUNET_JSON_spec_absolute_time ("refund_deadline",
|
GNUNET_JSON_spec_absolute_time ("refund_deadline",
|
||||||
&deposit.refund_deadline),
|
&deposit.refund_deadline),
|
||||||
GNUNET_JSON_spec_absolute_time ("wire_transfer_deadline",
|
GNUNET_JSON_spec_absolute_time ("wire_transfer_deadline",
|
||||||
|
@ -73,12 +73,13 @@ reply_refund_success (struct MHD_Connection *connection,
|
|||||||
TALER_EC_EXCHANGE_BAD_CONFIGURATION,
|
TALER_EC_EXCHANGE_BAD_CONFIGURATION,
|
||||||
"no online signing key");
|
"no online signing key");
|
||||||
}
|
}
|
||||||
return TALER_MHD_reply_json_pack (connection,
|
return TALER_MHD_reply_json_pack (
|
||||||
MHD_HTTP_OK,
|
connection,
|
||||||
"{s:s, s:o, s:o}",
|
MHD_HTTP_OK,
|
||||||
"status", "REFUND_OK",
|
"{s:o, s:o, s:o}",
|
||||||
"sig", GNUNET_JSON_from_data_auto (&sig),
|
"refund_fee", TALER_JSON_from_amount (&refund->refund_fee),
|
||||||
"pub", GNUNET_JSON_from_data_auto (&pub));
|
"exchange_sig", GNUNET_JSON_from_data_auto (&sig),
|
||||||
|
"exchange_pub", GNUNET_JSON_from_data_auto (&pub));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -246,18 +247,15 @@ refund_transaction (void *cls,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check currency is compatible */
|
/* check currency is compatible */
|
||||||
if ( (GNUNET_YES !=
|
if (GNUNET_YES !=
|
||||||
TALER_amount_cmp_currency (&refund->details.refund_amount,
|
TALER_amount_cmp_currency (&refund->details.refund_amount,
|
||||||
&dep->amount_with_fee)) ||
|
&dep->amount_with_fee))
|
||||||
(GNUNET_YES !=
|
|
||||||
TALER_amount_cmp_currency (&refund->details.refund_fee,
|
|
||||||
&dep->deposit_fee)) )
|
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0); /* currency mismatch */
|
GNUNET_break_op (0); /* currency mismatch */
|
||||||
TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
|
TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
|
||||||
tl);
|
tl);
|
||||||
*mhd_ret = TALER_MHD_reply_with_error (connection,
|
*mhd_ret = TALER_MHD_reply_with_error (connection,
|
||||||
MHD_HTTP_PRECONDITION_FAILED,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
TALER_EC_REFUND_CURRENCY_MISMATCH,
|
TALER_EC_REFUND_CURRENCY_MISMATCH,
|
||||||
"currencies involved do not match");
|
"currencies involved do not match");
|
||||||
return GNUNET_DB_STATUS_HARD_ERROR;
|
return GNUNET_DB_STATUS_HARD_ERROR;
|
||||||
@ -339,15 +337,14 @@ refund_transaction (void *cls,
|
|||||||
* the fee structure, so this is not done here.
|
* the fee structure, so this is not done here.
|
||||||
*
|
*
|
||||||
* @param connection the MHD connection to handle
|
* @param connection the MHD connection to handle
|
||||||
* @param refund information about the refund
|
* @param[in,out] refund information about the refund
|
||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
static MHD_RESULT
|
static MHD_RESULT
|
||||||
verify_and_execute_refund (struct MHD_Connection *connection,
|
verify_and_execute_refund (struct MHD_Connection *connection,
|
||||||
const struct TALER_EXCHANGEDB_Refund *refund)
|
struct TALER_EXCHANGEDB_Refund *refund)
|
||||||
{
|
{
|
||||||
struct GNUNET_HashCode denom_hash;
|
struct GNUNET_HashCode denom_hash;
|
||||||
struct TALER_Amount expect_fee;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
struct TALER_RefundRequestPS rr = {
|
struct TALER_RefundRequestPS rr = {
|
||||||
@ -361,8 +358,6 @@ verify_and_execute_refund (struct MHD_Connection *connection,
|
|||||||
|
|
||||||
TALER_amount_hton (&rr.refund_amount,
|
TALER_amount_hton (&rr.refund_amount,
|
||||||
&refund->details.refund_amount);
|
&refund->details.refund_amount);
|
||||||
TALER_amount_hton (&rr.refund_fee,
|
|
||||||
&refund->details.refund_fee);
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_REFUND,
|
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_REFUND,
|
||||||
&rr,
|
&rr,
|
||||||
@ -429,43 +424,12 @@ verify_and_execute_refund (struct MHD_Connection *connection,
|
|||||||
ec,
|
ec,
|
||||||
"denomination not found, but coin known");
|
"denomination not found, but coin known");
|
||||||
}
|
}
|
||||||
TALER_amount_ntoh (&expect_fee,
|
TALER_amount_ntoh (&refund->details.refund_fee,
|
||||||
&dki->issue.properties.fee_refund);
|
&dki->issue.properties.fee_refund);
|
||||||
}
|
}
|
||||||
TEH_KS_release (key_state);
|
TEH_KS_release (key_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check refund fee matches fee of denomination key! */
|
|
||||||
if (GNUNET_YES !=
|
|
||||||
TALER_amount_cmp_currency (&expect_fee,
|
|
||||||
&refund->details.refund_fee) )
|
|
||||||
{
|
|
||||||
GNUNET_break_op (0);
|
|
||||||
return TALER_MHD_reply_with_error (connection,
|
|
||||||
MHD_HTTP_BAD_REQUEST,
|
|
||||||
TALER_EC_REFUND_FEE_CURRENCY_MISMATCH,
|
|
||||||
"refund_fee");
|
|
||||||
}
|
|
||||||
{
|
|
||||||
int fee_cmp;
|
|
||||||
|
|
||||||
fee_cmp = TALER_amount_cmp (&refund->details.refund_fee,
|
|
||||||
&expect_fee);
|
|
||||||
if (-1 == fee_cmp)
|
|
||||||
{
|
|
||||||
return TALER_MHD_reply_with_error (connection,
|
|
||||||
MHD_HTTP_BAD_REQUEST,
|
|
||||||
TALER_EC_REFUND_FEE_TOO_LOW,
|
|
||||||
"refund_fee");
|
|
||||||
}
|
|
||||||
if (1 == fee_cmp)
|
|
||||||
{
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
|
||||||
"Refund fee proposed by merchant is higher than necessary.\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Finally run the actual transaction logic */
|
/* Finally run the actual transaction logic */
|
||||||
{
|
{
|
||||||
MHD_RESULT mhd_ret;
|
MHD_RESULT mhd_ret;
|
||||||
@ -502,16 +466,20 @@ TEH_handler_refund (struct MHD_Connection *connection,
|
|||||||
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
||||||
const json_t *root)
|
const json_t *root)
|
||||||
{
|
{
|
||||||
struct TALER_EXCHANGEDB_Refund refund;
|
struct TALER_EXCHANGEDB_Refund refund = {
|
||||||
|
.details.refund_fee.currency = {0} /* set to invalid, just to be sure */
|
||||||
|
};
|
||||||
struct GNUNET_JSON_Specification spec[] = {
|
struct GNUNET_JSON_Specification spec[] = {
|
||||||
TALER_JSON_spec_amount ("refund_amount", &refund.details.refund_amount),
|
TALER_JSON_spec_amount ("refund_amount",
|
||||||
TALER_JSON_spec_amount ("refund_fee", &refund.details.refund_fee),
|
&refund.details.refund_amount),
|
||||||
GNUNET_JSON_spec_fixed_auto ("h_contract_terms",
|
GNUNET_JSON_spec_fixed_auto ("h_contract_terms",
|
||||||
&refund.details.h_contract_terms),
|
&refund.details.h_contract_terms),
|
||||||
GNUNET_JSON_spec_fixed_auto ("merchant_pub", &refund.details.merchant_pub),
|
GNUNET_JSON_spec_fixed_auto ("merchant_pub",
|
||||||
|
&refund.details.merchant_pub),
|
||||||
GNUNET_JSON_spec_uint64 ("rtransaction_id",
|
GNUNET_JSON_spec_uint64 ("rtransaction_id",
|
||||||
&refund.details.rtransaction_id),
|
&refund.details.rtransaction_id),
|
||||||
GNUNET_JSON_spec_fixed_auto ("merchant_sig", &refund.details.merchant_sig),
|
GNUNET_JSON_spec_fixed_auto ("merchant_sig",
|
||||||
|
&refund.details.merchant_sig),
|
||||||
GNUNET_JSON_spec_end ()
|
GNUNET_JSON_spec_end ()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -527,27 +495,6 @@ TEH_handler_refund (struct MHD_Connection *connection,
|
|||||||
if (GNUNET_NO == res)
|
if (GNUNET_NO == res)
|
||||||
return MHD_YES; /* failure */
|
return MHD_YES; /* failure */
|
||||||
}
|
}
|
||||||
if (GNUNET_YES !=
|
|
||||||
TALER_amount_cmp_currency (&refund.details.refund_amount,
|
|
||||||
&refund.details.refund_fee) )
|
|
||||||
{
|
|
||||||
GNUNET_break_op (0);
|
|
||||||
GNUNET_JSON_parse_free (spec);
|
|
||||||
return TALER_MHD_reply_with_error (connection,
|
|
||||||
MHD_HTTP_BAD_REQUEST,
|
|
||||||
TALER_EC_REFUND_FEE_CURRENCY_MISMATCH,
|
|
||||||
"refund_amount or refund_fee");
|
|
||||||
}
|
|
||||||
if (-1 == TALER_amount_cmp (&refund.details.refund_amount,
|
|
||||||
&refund.details.refund_fee) )
|
|
||||||
{
|
|
||||||
GNUNET_break_op (0);
|
|
||||||
GNUNET_JSON_parse_free (spec);
|
|
||||||
return TALER_MHD_reply_with_error (connection,
|
|
||||||
MHD_HTTP_BAD_REQUEST,
|
|
||||||
TALER_EC_REFUND_FEE_ABOVE_AMOUNT,
|
|
||||||
"refund_amount");
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
MHD_RESULT res;
|
MHD_RESULT res;
|
||||||
|
|
||||||
|
@ -185,8 +185,6 @@ TEH_RESPONSE_compile_transaction_history (
|
|||||||
|
|
||||||
TALER_amount_hton (&rr.refund_amount,
|
TALER_amount_hton (&rr.refund_amount,
|
||||||
&refund->refund_amount);
|
&refund->refund_amount);
|
||||||
TALER_amount_hton (&rr.refund_fee,
|
|
||||||
&refund->refund_fee);
|
|
||||||
#if ENABLE_SANITY_CHECKS
|
#if ENABLE_SANITY_CHECKS
|
||||||
/* internal sanity check before we hand out a bogus sig... */
|
/* internal sanity check before we hand out a bogus sig... */
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
|
@ -306,8 +306,6 @@ withdraw_transaction (void *cls,
|
|||||||
#endif
|
#endif
|
||||||
wc->collectable.denom_pub_hash = wc->denom_pub_hash;
|
wc->collectable.denom_pub_hash = wc->denom_pub_hash;
|
||||||
wc->collectable.amount_with_fee = wc->amount_required;
|
wc->collectable.amount_with_fee = wc->amount_required;
|
||||||
TALER_amount_ntoh (&wc->collectable.withdraw_fee,
|
|
||||||
&wc->dki->issue.properties.fee_withdraw);
|
|
||||||
wc->collectable.reserve_pub = wc->wsrd.reserve_pub;
|
wc->collectable.reserve_pub = wc->wsrd.reserve_pub;
|
||||||
wc->collectable.h_coin_envelope = wc->wsrd.h_coin_envelope;
|
wc->collectable.h_coin_envelope = wc->wsrd.h_coin_envelope;
|
||||||
wc->collectable.reserve_sig = wc->signature;
|
wc->collectable.reserve_sig = wc->signature;
|
||||||
@ -436,8 +434,6 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh,
|
|||||||
}
|
}
|
||||||
TALER_amount_hton (&wc.wsrd.amount_with_fee,
|
TALER_amount_hton (&wc.wsrd.amount_with_fee,
|
||||||
&wc.amount_required);
|
&wc.amount_required);
|
||||||
TALER_amount_hton (&wc.wsrd.withdraw_fee,
|
|
||||||
&fee_withdraw);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* verify signature! */
|
/* verify signature! */
|
||||||
|
@ -878,7 +878,6 @@ typedef void
|
|||||||
* @param amount the amount to be refunded; must be larger than the refund fee
|
* @param amount the amount to be refunded; must be larger than the refund fee
|
||||||
* (as that fee is still being subtracted), and smaller than the amount
|
* (as that fee is still being subtracted), and smaller than the amount
|
||||||
* (with deposit fee) of the original deposit contribution of this coin
|
* (with deposit fee) of the original deposit contribution of this coin
|
||||||
* @param refund_fee fee applicable to this coin for the refund
|
|
||||||
* @param h_contract_terms hash of the contact of the merchant with the customer that is being refunded
|
* @param h_contract_terms hash of the contact of the merchant with the customer that is being refunded
|
||||||
* @param coin_pub coin’s public key of the coin from the original deposit operation
|
* @param coin_pub coin’s public key of the coin from the original deposit operation
|
||||||
* @param rtransaction_id transaction id for the transaction between merchant and customer (of refunding operation);
|
* @param rtransaction_id transaction id for the transaction between merchant and customer (of refunding operation);
|
||||||
@ -894,7 +893,6 @@ typedef void
|
|||||||
struct TALER_EXCHANGE_RefundHandle *
|
struct TALER_EXCHANGE_RefundHandle *
|
||||||
TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange,
|
TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange,
|
||||||
const struct TALER_Amount *amount,
|
const struct TALER_Amount *amount,
|
||||||
const struct TALER_Amount *refund_fee,
|
|
||||||
const struct GNUNET_HashCode *h_contract_terms,
|
const struct GNUNET_HashCode *h_contract_terms,
|
||||||
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
||||||
uint64_t rtransaction_id,
|
uint64_t rtransaction_id,
|
||||||
@ -922,7 +920,6 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange,
|
|||||||
* @param amount the amount to be refunded; must be larger than the refund fee
|
* @param amount the amount to be refunded; must be larger than the refund fee
|
||||||
* (as that fee is still being subtracted), and smaller than the amount
|
* (as that fee is still being subtracted), and smaller than the amount
|
||||||
* (with deposit fee) of the original deposit contribution of this coin
|
* (with deposit fee) of the original deposit contribution of this coin
|
||||||
* @param refund_fee fee applicable to this coin for the refund
|
|
||||||
* @param h_contract_terms hash of the contact of the merchant with the customer that is being refunded
|
* @param h_contract_terms hash of the contact of the merchant with the customer that is being refunded
|
||||||
* @param coin_pub coin’s public key of the coin from the original deposit operation
|
* @param coin_pub coin’s public key of the coin from the original deposit operation
|
||||||
* @param rtransaction_id transaction id for the transaction between merchant and customer (of refunding operation);
|
* @param rtransaction_id transaction id for the transaction between merchant and customer (of refunding operation);
|
||||||
@ -939,7 +936,6 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange,
|
|||||||
struct TALER_EXCHANGE_RefundHandle *
|
struct TALER_EXCHANGE_RefundHandle *
|
||||||
TALER_EXCHANGE_refund2 (struct TALER_EXCHANGE_Handle *exchange,
|
TALER_EXCHANGE_refund2 (struct TALER_EXCHANGE_Handle *exchange,
|
||||||
const struct TALER_Amount *amount,
|
const struct TALER_Amount *amount,
|
||||||
const struct TALER_Amount *refund_fee,
|
|
||||||
const struct GNUNET_HashCode *h_contract_terms,
|
const struct GNUNET_HashCode *h_contract_terms,
|
||||||
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
||||||
uint64_t rtransaction_id,
|
uint64_t rtransaction_id,
|
||||||
|
@ -316,19 +316,6 @@ struct TALER_WithdrawRequestPS
|
|||||||
*/
|
*/
|
||||||
struct TALER_AmountNBO amount_with_fee;
|
struct TALER_AmountNBO amount_with_fee;
|
||||||
|
|
||||||
/**
|
|
||||||
* Withdrawal fee charged by the exchange. This must match the Exchange's
|
|
||||||
* denomination key's withdrawal fee. If the client puts in an
|
|
||||||
* invalid withdrawal fee (too high or too low) that does not match
|
|
||||||
* the Exchange's denomination key, the withdraw operation is invalid
|
|
||||||
* and will be rejected by the exchange. The @e amount_with_fee minus
|
|
||||||
* the @e withdraw_fee is must match the value of the generated
|
|
||||||
* coin. We include this in what is being signed so that we can
|
|
||||||
* verify a exchange's accounting without needing to access the
|
|
||||||
* respective denomination key information each time.
|
|
||||||
*/
|
|
||||||
struct TALER_AmountNBO withdraw_fee;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hash of the denomination public key for the coin that is withdrawn.
|
* Hash of the denomination public key for the coin that is withdrawn.
|
||||||
*/
|
*/
|
||||||
@ -517,17 +504,6 @@ struct TALER_RefundRequestPS
|
|||||||
*/
|
*/
|
||||||
struct TALER_AmountNBO refund_amount;
|
struct TALER_AmountNBO refund_amount;
|
||||||
|
|
||||||
/**
|
|
||||||
* Refund fee charged by the exchange. This must match the
|
|
||||||
* Exchange's denomination key's refund fee. If the client puts in
|
|
||||||
* an invalid refund fee (too high or too low) that does not match
|
|
||||||
* the Exchange's denomination key, the refund operation is invalid
|
|
||||||
* and will be rejected by the exchange. The @e amount_with_fee
|
|
||||||
* minus the @e refund_fee is the amount that will be credited to
|
|
||||||
* the original coin.
|
|
||||||
*/
|
|
||||||
struct TALER_AmountNBO refund_fee;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1670,7 +1670,6 @@ TALER_TESTING_cmd_check_bank_empty (const char *label);
|
|||||||
* @param label command label.
|
* @param label command label.
|
||||||
* @param expected_response_code expected HTTP status code.
|
* @param expected_response_code expected HTTP status code.
|
||||||
* @param refund_amount the amount to ask a refund for.
|
* @param refund_amount the amount to ask a refund for.
|
||||||
* @param refund_fee expected refund fee.
|
|
||||||
* @param coin_reference reference to a command that can
|
* @param coin_reference reference to a command that can
|
||||||
* provide a coin to be refunded.
|
* provide a coin to be refunded.
|
||||||
* @param refund_transaction_id transaction id to use
|
* @param refund_transaction_id transaction id to use
|
||||||
@ -1682,7 +1681,6 @@ struct TALER_TESTING_Command
|
|||||||
TALER_TESTING_cmd_refund_with_id (const char *label,
|
TALER_TESTING_cmd_refund_with_id (const char *label,
|
||||||
unsigned int expected_response_code,
|
unsigned int expected_response_code,
|
||||||
const char *refund_amount,
|
const char *refund_amount,
|
||||||
const char *refund_fee,
|
|
||||||
const char *deposit_reference,
|
const char *deposit_reference,
|
||||||
uint64_t refund_transaction_id);
|
uint64_t refund_transaction_id);
|
||||||
|
|
||||||
@ -1693,7 +1691,6 @@ TALER_TESTING_cmd_refund_with_id (const char *label,
|
|||||||
* @param label command label.
|
* @param label command label.
|
||||||
* @param expected_response_code expected HTTP status code.
|
* @param expected_response_code expected HTTP status code.
|
||||||
* @param refund_amount the amount to ask a refund for.
|
* @param refund_amount the amount to ask a refund for.
|
||||||
* @param refund_fee expected refund fee.
|
|
||||||
* @param coin_reference reference to a command that can
|
* @param coin_reference reference to a command that can
|
||||||
* provide a coin to be refunded.
|
* provide a coin to be refunded.
|
||||||
*
|
*
|
||||||
@ -1703,7 +1700,6 @@ struct TALER_TESTING_Command
|
|||||||
TALER_TESTING_cmd_refund (const char *label,
|
TALER_TESTING_cmd_refund (const char *label,
|
||||||
unsigned int expected_response_code,
|
unsigned int expected_response_code,
|
||||||
const char *refund_amount,
|
const char *refund_amount,
|
||||||
const char *refund_fee,
|
|
||||||
const char *deposit_reference);
|
const char *deposit_reference);
|
||||||
|
|
||||||
|
|
||||||
|
@ -146,11 +146,12 @@ TALER_EXCHANGE_parse_reserve_history (
|
|||||||
{
|
{
|
||||||
struct TALER_ReserveSignatureP sig;
|
struct TALER_ReserveSignatureP sig;
|
||||||
struct TALER_WithdrawRequestPS withdraw_purpose;
|
struct TALER_WithdrawRequestPS withdraw_purpose;
|
||||||
|
struct TALER_Amount withdraw_fee;
|
||||||
struct GNUNET_JSON_Specification withdraw_spec[] = {
|
struct GNUNET_JSON_Specification withdraw_spec[] = {
|
||||||
GNUNET_JSON_spec_fixed_auto ("reserve_sig",
|
GNUNET_JSON_spec_fixed_auto ("reserve_sig",
|
||||||
&sig),
|
&sig),
|
||||||
TALER_JSON_spec_amount_nbo ("withdraw_fee",
|
TALER_JSON_spec_amount ("withdraw_fee",
|
||||||
&withdraw_purpose.withdraw_fee),
|
&withdraw_fee),
|
||||||
GNUNET_JSON_spec_fixed_auto ("h_denom_pub",
|
GNUNET_JSON_spec_fixed_auto ("h_denom_pub",
|
||||||
&withdraw_purpose.h_denomination_pub),
|
&withdraw_purpose.h_denomination_pub),
|
||||||
GNUNET_JSON_spec_fixed_auto ("h_coin_envelope",
|
GNUNET_JSON_spec_fixed_auto ("h_coin_envelope",
|
||||||
@ -189,26 +190,23 @@ TALER_EXCHANGE_parse_reserve_history (
|
|||||||
{
|
{
|
||||||
const struct TALER_EXCHANGE_Keys *key_state;
|
const struct TALER_EXCHANGE_Keys *key_state;
|
||||||
const struct TALER_EXCHANGE_DenomPublicKey *dki;
|
const struct TALER_EXCHANGE_DenomPublicKey *dki;
|
||||||
struct TALER_Amount fee;
|
|
||||||
|
|
||||||
key_state = TALER_EXCHANGE_get_keys (exchange);
|
key_state = TALER_EXCHANGE_get_keys (exchange);
|
||||||
dki = TALER_EXCHANGE_get_denomination_key_by_hash (key_state,
|
dki = TALER_EXCHANGE_get_denomination_key_by_hash (key_state,
|
||||||
&withdraw_purpose.
|
&withdraw_purpose.
|
||||||
h_denomination_pub);
|
h_denomination_pub);
|
||||||
TALER_amount_ntoh (&fee,
|
|
||||||
&withdraw_purpose.withdraw_fee);
|
|
||||||
if ( (GNUNET_YES !=
|
if ( (GNUNET_YES !=
|
||||||
TALER_amount_cmp_currency (&fee,
|
TALER_amount_cmp_currency (&withdraw_fee,
|
||||||
&dki->fee_withdraw)) ||
|
&dki->fee_withdraw)) ||
|
||||||
(0 !=
|
(0 !=
|
||||||
TALER_amount_cmp (&fee,
|
TALER_amount_cmp (&withdraw_fee,
|
||||||
&dki->fee_withdraw)) )
|
&dki->fee_withdraw)) )
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
GNUNET_JSON_parse_free (withdraw_spec);
|
GNUNET_JSON_parse_free (withdraw_spec);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
rh->details.withdraw.fee = fee;
|
rh->details.withdraw.fee = withdraw_fee;
|
||||||
}
|
}
|
||||||
rh->details.withdraw.out_authorization_sig
|
rh->details.withdraw.out_authorization_sig
|
||||||
= json_object_get (transaction,
|
= json_object_get (transaction,
|
||||||
@ -634,9 +632,16 @@ TALER_EXCHANGE_verify_coin_history (
|
|||||||
else if (0 == strcasecmp (type,
|
else if (0 == strcasecmp (type,
|
||||||
"REFUND"))
|
"REFUND"))
|
||||||
{
|
{
|
||||||
struct TALER_RefundRequestPS rr;
|
|
||||||
struct TALER_MerchantSignatureP sig;
|
struct TALER_MerchantSignatureP sig;
|
||||||
|
struct TALER_Amount refund_fee;
|
||||||
|
struct TALER_RefundRequestPS rr = {
|
||||||
|
.purpose.size = htonl (sizeof (rr)),
|
||||||
|
.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_REFUND),
|
||||||
|
.coin_pub = *coin_pub
|
||||||
|
};
|
||||||
struct GNUNET_JSON_Specification spec[] = {
|
struct GNUNET_JSON_Specification spec[] = {
|
||||||
|
TALER_JSON_spec_amount ("refund_fee",
|
||||||
|
&refund_fee),
|
||||||
GNUNET_JSON_spec_fixed_auto ("merchant_sig",
|
GNUNET_JSON_spec_fixed_auto ("merchant_sig",
|
||||||
&sig),
|
&sig),
|
||||||
GNUNET_JSON_spec_fixed_auto ("h_contract_terms",
|
GNUNET_JSON_spec_fixed_auto ("h_contract_terms",
|
||||||
@ -645,8 +650,6 @@ TALER_EXCHANGE_verify_coin_history (
|
|||||||
&rr.merchant),
|
&rr.merchant),
|
||||||
GNUNET_JSON_spec_uint64 ("rtransaction_id",
|
GNUNET_JSON_spec_uint64 ("rtransaction_id",
|
||||||
&rr.rtransaction_id),
|
&rr.rtransaction_id),
|
||||||
TALER_JSON_spec_amount_nbo ("refund_fee",
|
|
||||||
&rr.refund_fee),
|
|
||||||
GNUNET_JSON_spec_end ()
|
GNUNET_JSON_spec_end ()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -658,9 +661,6 @@ TALER_EXCHANGE_verify_coin_history (
|
|||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
rr.purpose.size = htonl (sizeof (rr));
|
|
||||||
rr.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_REFUND);
|
|
||||||
rr.coin_pub = *coin_pub;
|
|
||||||
TALER_amount_hton (&rr.refund_amount,
|
TALER_amount_hton (&rr.refund_amount,
|
||||||
&amount);
|
&amount);
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
@ -683,13 +683,11 @@ TALER_EXCHANGE_verify_coin_history (
|
|||||||
/* check that refund fee matches our expectations from /keys! */
|
/* check that refund fee matches our expectations from /keys! */
|
||||||
if (NULL != dk)
|
if (NULL != dk)
|
||||||
{
|
{
|
||||||
TALER_amount_ntoh (&fee,
|
|
||||||
&rr.refund_fee);
|
|
||||||
if ( (GNUNET_YES !=
|
if ( (GNUNET_YES !=
|
||||||
TALER_amount_cmp_currency (&fee,
|
TALER_amount_cmp_currency (&refund_fee,
|
||||||
&dk->fee_refund)) ||
|
&dk->fee_refund)) ||
|
||||||
(0 !=
|
(0 !=
|
||||||
TALER_amount_cmp (&fee,
|
TALER_amount_cmp (&refund_fee,
|
||||||
&dk->fee_refund)) )
|
&dk->fee_refund)) )
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
|
@ -196,8 +196,8 @@ verify_deposit_signature_ok (struct TALER_EXCHANGE_DepositHandle *dh,
|
|||||||
{
|
{
|
||||||
const struct TALER_EXCHANGE_Keys *key_state;
|
const struct TALER_EXCHANGE_Keys *key_state;
|
||||||
struct GNUNET_JSON_Specification spec[] = {
|
struct GNUNET_JSON_Specification spec[] = {
|
||||||
GNUNET_JSON_spec_fixed_auto ("sig", exchange_sig),
|
GNUNET_JSON_spec_fixed_auto ("exchange_sig", exchange_sig),
|
||||||
GNUNET_JSON_spec_fixed_auto ("pub", exchange_pub),
|
GNUNET_JSON_spec_fixed_auto ("exchange_pub", exchange_pub),
|
||||||
GNUNET_JSON_spec_end ()
|
GNUNET_JSON_spec_end ()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
* Which version of the Taler protocol is implemented
|
* Which version of the Taler protocol is implemented
|
||||||
* by this library? Used to determine compatibility.
|
* by this library? Used to determine compatibility.
|
||||||
*/
|
*/
|
||||||
#define EXCHANGE_PROTOCOL_CURRENT 7
|
#define EXCHANGE_PROTOCOL_CURRENT 8
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How many versions are we backwards compatible with?
|
* How many versions are we backwards compatible with?
|
||||||
|
@ -81,14 +81,14 @@ struct TALER_EXCHANGE_RefundHandle
|
|||||||
* Verify that the signature on the "200 OK" response
|
* Verify that the signature on the "200 OK" response
|
||||||
* from the exchange is valid.
|
* from the exchange is valid.
|
||||||
*
|
*
|
||||||
* @param rh refund handle
|
* @param[in,out] rh refund handle (refund fee added)
|
||||||
* @param json json reply with the signature
|
* @param json json reply with the signature
|
||||||
* @param[out] exchange_pub set to the exchange's public key
|
* @param[out] exchange_pub set to the exchange's public key
|
||||||
* @param[out] exchange_sig set to the exchange's signature
|
* @param[out] exchange_sig set to the exchange's signature
|
||||||
* @return #GNUNET_OK if the signature is valid, #GNUNET_SYSERR if not
|
* @return #GNUNET_OK if the signature is valid, #GNUNET_SYSERR if not
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
verify_refund_signature_ok (const struct TALER_EXCHANGE_RefundHandle *rh,
|
verify_refund_signature_ok (struct TALER_EXCHANGE_RefundHandle *rh,
|
||||||
const json_t *json,
|
const json_t *json,
|
||||||
struct TALER_ExchangePublicKeyP *exchange_pub,
|
struct TALER_ExchangePublicKeyP *exchange_pub,
|
||||||
struct TALER_ExchangeSignatureP *exchange_sig)
|
struct TALER_ExchangeSignatureP *exchange_sig)
|
||||||
@ -96,8 +96,9 @@ verify_refund_signature_ok (const struct TALER_EXCHANGE_RefundHandle *rh,
|
|||||||
{
|
{
|
||||||
const struct TALER_EXCHANGE_Keys *key_state;
|
const struct TALER_EXCHANGE_Keys *key_state;
|
||||||
struct GNUNET_JSON_Specification spec[] = {
|
struct GNUNET_JSON_Specification spec[] = {
|
||||||
GNUNET_JSON_spec_fixed_auto ("sig", exchange_sig),
|
GNUNET_JSON_spec_fixed_auto ("exchange_sig", exchange_sig),
|
||||||
GNUNET_JSON_spec_fixed_auto ("pub", exchange_pub),
|
GNUNET_JSON_spec_fixed_auto ("exchange_pub", exchange_pub),
|
||||||
|
TALER_JSON_spec_amount_nbo ("refund_fee", &rh->depconf.refund_fee),
|
||||||
GNUNET_JSON_spec_end ()
|
GNUNET_JSON_spec_end ()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -256,7 +257,6 @@ handle_refund_finished (void *cls,
|
|||||||
* @param amount the amount to be refunded; must be larger than the refund fee
|
* @param amount the amount to be refunded; must be larger than the refund fee
|
||||||
* (as that fee is still being subtracted), and smaller than the amount
|
* (as that fee is still being subtracted), and smaller than the amount
|
||||||
* (with deposit fee) of the original deposit contribution of this coin
|
* (with deposit fee) of the original deposit contribution of this coin
|
||||||
* @param refund_fee fee applicable to this coin for the refund
|
|
||||||
* @param h_contract_terms hash of the contact of the merchant with the customer that is being refunded
|
* @param h_contract_terms hash of the contact of the merchant with the customer that is being refunded
|
||||||
* @param coin_pub coin’s public key of the coin from the original deposit operation
|
* @param coin_pub coin’s public key of the coin from the original deposit operation
|
||||||
* @param rtransaction_id transaction id for the transaction between merchant and customer (of refunding operation);
|
* @param rtransaction_id transaction id for the transaction between merchant and customer (of refunding operation);
|
||||||
@ -272,7 +272,6 @@ handle_refund_finished (void *cls,
|
|||||||
struct TALER_EXCHANGE_RefundHandle *
|
struct TALER_EXCHANGE_RefundHandle *
|
||||||
TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange,
|
TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange,
|
||||||
const struct TALER_Amount *amount,
|
const struct TALER_Amount *amount,
|
||||||
const struct TALER_Amount *refund_fee,
|
|
||||||
const struct GNUNET_HashCode *h_contract_terms,
|
const struct GNUNET_HashCode *h_contract_terms,
|
||||||
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
||||||
uint64_t rtransaction_id,
|
uint64_t rtransaction_id,
|
||||||
@ -294,14 +293,11 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange,
|
|||||||
rr.rtransaction_id = GNUNET_htonll (rtransaction_id);
|
rr.rtransaction_id = GNUNET_htonll (rtransaction_id);
|
||||||
TALER_amount_hton (&rr.refund_amount,
|
TALER_amount_hton (&rr.refund_amount,
|
||||||
amount);
|
amount);
|
||||||
TALER_amount_hton (&rr.refund_fee,
|
|
||||||
refund_fee);
|
|
||||||
GNUNET_CRYPTO_eddsa_sign (&merchant_priv->eddsa_priv,
|
GNUNET_CRYPTO_eddsa_sign (&merchant_priv->eddsa_priv,
|
||||||
&rr,
|
&rr,
|
||||||
&merchant_sig.eddsa_sig);
|
&merchant_sig.eddsa_sig);
|
||||||
return TALER_EXCHANGE_refund2 (exchange,
|
return TALER_EXCHANGE_refund2 (exchange,
|
||||||
amount,
|
amount,
|
||||||
refund_fee,
|
|
||||||
h_contract_terms,
|
h_contract_terms,
|
||||||
coin_pub,
|
coin_pub,
|
||||||
rtransaction_id,
|
rtransaction_id,
|
||||||
@ -329,7 +325,6 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange,
|
|||||||
* @param amount the amount to be refunded; must be larger than the refund fee
|
* @param amount the amount to be refunded; must be larger than the refund fee
|
||||||
* (as that fee is still being subtracted), and smaller than the amount
|
* (as that fee is still being subtracted), and smaller than the amount
|
||||||
* (with deposit fee) of the original deposit contribution of this coin
|
* (with deposit fee) of the original deposit contribution of this coin
|
||||||
* @param refund_fee fee applicable to this coin for the refund
|
|
||||||
* @param h_contract_terms hash of the contact of the merchant with the customer that is being refunded
|
* @param h_contract_terms hash of the contact of the merchant with the customer that is being refunded
|
||||||
* @param coin_pub coin’s public key of the coin from the original deposit operation
|
* @param coin_pub coin’s public key of the coin from the original deposit operation
|
||||||
* @param rtransaction_id transaction id for the transaction between merchant and customer (of refunding operation);
|
* @param rtransaction_id transaction id for the transaction between merchant and customer (of refunding operation);
|
||||||
@ -346,7 +341,6 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange,
|
|||||||
struct TALER_EXCHANGE_RefundHandle *
|
struct TALER_EXCHANGE_RefundHandle *
|
||||||
TALER_EXCHANGE_refund2 (struct TALER_EXCHANGE_Handle *exchange,
|
TALER_EXCHANGE_refund2 (struct TALER_EXCHANGE_Handle *exchange,
|
||||||
const struct TALER_Amount *amount,
|
const struct TALER_Amount *amount,
|
||||||
const struct TALER_Amount *refund_fee,
|
|
||||||
const struct GNUNET_HashCode *h_contract_terms,
|
const struct GNUNET_HashCode *h_contract_terms,
|
||||||
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
||||||
uint64_t rtransaction_id,
|
uint64_t rtransaction_id,
|
||||||
@ -376,12 +370,11 @@ TALER_EXCHANGE_refund2 (struct TALER_EXCHANGE_Handle *exchange,
|
|||||||
"/coins/%s/refund",
|
"/coins/%s/refund",
|
||||||
pub_str);
|
pub_str);
|
||||||
}
|
}
|
||||||
refund_obj = json_pack ("{s:o, s:o," /* amount/fee */
|
refund_obj = json_pack ("{s:o," /* amount */
|
||||||
" s:o," /* h_contract_terms */
|
" s:o," /* h_contract_terms */
|
||||||
" s:I," /* rtransaction id */
|
" s:I," /* rtransaction id */
|
||||||
" s:o, s:o}", /* merchant_pub, merchant_sig */
|
" s:o, s:o}", /* merchant_pub, merchant_sig */
|
||||||
"refund_amount", TALER_JSON_from_amount (amount),
|
"refund_amount", TALER_JSON_from_amount (amount),
|
||||||
"refund_fee", TALER_JSON_from_amount (refund_fee),
|
|
||||||
"h_contract_terms", GNUNET_JSON_from_data_auto (
|
"h_contract_terms", GNUNET_JSON_from_data_auto (
|
||||||
h_contract_terms),
|
h_contract_terms),
|
||||||
"rtransaction_id", (json_int_t) rtransaction_id,
|
"rtransaction_id", (json_int_t) rtransaction_id,
|
||||||
@ -410,8 +403,6 @@ TALER_EXCHANGE_refund2 (struct TALER_EXCHANGE_Handle *exchange,
|
|||||||
rh->depconf.rtransaction_id = GNUNET_htonll (rtransaction_id);
|
rh->depconf.rtransaction_id = GNUNET_htonll (rtransaction_id);
|
||||||
TALER_amount_hton (&rh->depconf.refund_amount,
|
TALER_amount_hton (&rh->depconf.refund_amount,
|
||||||
amount);
|
amount);
|
||||||
TALER_amount_hton (&rh->depconf.refund_fee,
|
|
||||||
refund_fee);
|
|
||||||
|
|
||||||
eh = TALER_EXCHANGE_curl_easy_get_ (rh->url);
|
eh = TALER_EXCHANGE_curl_easy_get_ (rh->url);
|
||||||
if ( (NULL == eh) ||
|
if ( (NULL == eh) ||
|
||||||
|
@ -429,8 +429,6 @@ TALER_EXCHANGE_withdraw2 (
|
|||||||
|
|
||||||
TALER_amount_hton (&req.amount_with_fee,
|
TALER_amount_hton (&req.amount_with_fee,
|
||||||
&wh->requested_amount);
|
&wh->requested_amount);
|
||||||
TALER_amount_hton (&req.withdraw_fee,
|
|
||||||
&dk->fee_withdraw);
|
|
||||||
GNUNET_CRYPTO_hash (pd->coin_ev,
|
GNUNET_CRYPTO_hash (pd->coin_ev,
|
||||||
pd->coin_ev_size,
|
pd->coin_ev_size,
|
||||||
&req.h_coin_envelope);
|
&req.h_coin_envelope);
|
||||||
|
@ -353,7 +353,6 @@ run (void *cls,
|
|||||||
TALER_TESTING_cmd_refund ("refund-ok",
|
TALER_TESTING_cmd_refund ("refund-ok",
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
"EUR:0.01",
|
|
||||||
"deposit-refund-1"),
|
"deposit-refund-1"),
|
||||||
/**
|
/**
|
||||||
* Spend 4.99 EUR of the refunded 4.99 EUR coin (1ct gone
|
* Spend 4.99 EUR of the refunded 4.99 EUR coin (1ct gone
|
||||||
|
@ -528,18 +528,15 @@ run (void *cls,
|
|||||||
TALER_TESTING_cmd_refund ("refund-ok",
|
TALER_TESTING_cmd_refund ("refund-ok",
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
"EUR:0.01",
|
|
||||||
"deposit-refund-1"),
|
"deposit-refund-1"),
|
||||||
TALER_TESTING_cmd_refund ("refund-ok-double",
|
TALER_TESTING_cmd_refund ("refund-ok-double",
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
"EUR:0.01",
|
|
||||||
"deposit-refund-1"),
|
"deposit-refund-1"),
|
||||||
/* Previous /refund(s) had id == 0. */
|
/* Previous /refund(s) had id == 0. */
|
||||||
TALER_TESTING_cmd_refund_with_id ("refund-conflicting",
|
TALER_TESTING_cmd_refund_with_id ("refund-conflicting",
|
||||||
MHD_HTTP_CONFLICT,
|
MHD_HTTP_CONFLICT,
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
"EUR:0.01",
|
|
||||||
"deposit-refund-1",
|
"deposit-refund-1",
|
||||||
1),
|
1),
|
||||||
/**
|
/**
|
||||||
@ -573,7 +570,6 @@ run (void *cls,
|
|||||||
TALER_TESTING_cmd_refund ("refund-fail",
|
TALER_TESTING_cmd_refund ("refund-fail",
|
||||||
MHD_HTTP_GONE,
|
MHD_HTTP_GONE,
|
||||||
"EUR:4.99",
|
"EUR:4.99",
|
||||||
"EUR:0.01",
|
|
||||||
"deposit-refund-2"),
|
"deposit-refund-2"),
|
||||||
TALER_TESTING_cmd_check_bank_empty ("check-empty-after-refund"),
|
TALER_TESTING_cmd_check_bank_empty ("check-empty-after-refund"),
|
||||||
/**
|
/**
|
||||||
@ -607,7 +603,6 @@ run (void *cls,
|
|||||||
TALER_TESTING_cmd_refund ("refund-ok-fast",
|
TALER_TESTING_cmd_refund ("refund-ok-fast",
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
"EUR:0.01",
|
|
||||||
"deposit-refund-1b"),
|
"deposit-refund-1b"),
|
||||||
/**
|
/**
|
||||||
* Run transfers. This will do the transfer as refund deadline
|
* Run transfers. This will do the transfer as refund deadline
|
||||||
|
@ -173,12 +173,6 @@ run (void *cls,
|
|||||||
TALER_TESTING_cmd_refund ("refund-currency-mismatch",
|
TALER_TESTING_cmd_refund ("refund-currency-mismatch",
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"USD:5",
|
"USD:5",
|
||||||
"USD:0.01",
|
|
||||||
"deposit-refund-1"),
|
|
||||||
TALER_TESTING_cmd_refund ("refund-fee-above-amount",
|
|
||||||
MHD_HTTP_BAD_REQUEST,
|
|
||||||
"EUR:5",
|
|
||||||
"EUR:10",
|
|
||||||
"deposit-refund-1"),
|
"deposit-refund-1"),
|
||||||
TALER_TESTING_cmd_flip_upload ("flip-upload",
|
TALER_TESTING_cmd_flip_upload ("flip-upload",
|
||||||
CONFIG_FILE,
|
CONFIG_FILE,
|
||||||
@ -186,7 +180,6 @@ run (void *cls,
|
|||||||
TALER_TESTING_cmd_refund ("refund-bad-sig",
|
TALER_TESTING_cmd_refund ("refund-bad-sig",
|
||||||
MHD_HTTP_FORBIDDEN,
|
MHD_HTTP_FORBIDDEN,
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
"EUR:0.01",
|
|
||||||
"deposit-refund-1"),
|
"deposit-refund-1"),
|
||||||
|
|
||||||
/* This next deposit CMD is only used to provide a
|
/* This next deposit CMD is only used to provide a
|
||||||
@ -207,17 +200,14 @@ run (void *cls,
|
|||||||
TALER_TESTING_cmd_refund ("refund-deposit-not-found",
|
TALER_TESTING_cmd_refund ("refund-deposit-not-found",
|
||||||
MHD_HTTP_NOT_FOUND,
|
MHD_HTTP_NOT_FOUND,
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
"EUR:0.01",
|
|
||||||
"deposit-refund-to-fail"),
|
"deposit-refund-to-fail"),
|
||||||
TALER_TESTING_cmd_refund ("refund-insufficient-funds",
|
TALER_TESTING_cmd_refund ("refund-insufficient-funds",
|
||||||
MHD_HTTP_PRECONDITION_FAILED,
|
MHD_HTTP_PRECONDITION_FAILED,
|
||||||
"EUR:50",
|
"EUR:50",
|
||||||
"EUR:0.01",
|
|
||||||
"deposit-refund-1"),
|
"deposit-refund-1"),
|
||||||
TALER_TESTING_cmd_refund ("refund-fee-too-low",
|
TALER_TESTING_cmd_refund ("refund-fee-too-low",
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"EUR:5",
|
"EUR:5",
|
||||||
"EUR:0.000001",
|
|
||||||
"deposit-refund-1"),
|
"deposit-refund-1"),
|
||||||
TALER_TESTING_cmd_end ()
|
TALER_TESTING_cmd_end ()
|
||||||
};
|
};
|
||||||
|
@ -43,11 +43,6 @@ struct RefundState
|
|||||||
*/
|
*/
|
||||||
const char *refund_amount;
|
const char *refund_amount;
|
||||||
|
|
||||||
/**
|
|
||||||
* Expected refund fee.
|
|
||||||
*/
|
|
||||||
const char *refund_fee;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reference to any command that can provide a coin to refund.
|
* Reference to any command that can provide a coin to refund.
|
||||||
*/
|
*/
|
||||||
@ -133,7 +128,6 @@ refund_run (void *cls,
|
|||||||
struct TALER_CoinSpendPublicKeyP coin;
|
struct TALER_CoinSpendPublicKeyP coin;
|
||||||
const json_t *contract_terms;
|
const json_t *contract_terms;
|
||||||
struct GNUNET_HashCode h_contract_terms;
|
struct GNUNET_HashCode h_contract_terms;
|
||||||
struct TALER_Amount refund_fee;
|
|
||||||
struct TALER_Amount refund_amount;
|
struct TALER_Amount refund_amount;
|
||||||
const struct TALER_MerchantPrivateKeyP *merchant_priv;
|
const struct TALER_MerchantPrivateKeyP *merchant_priv;
|
||||||
const struct TALER_TESTING_Command *coin_cmd;
|
const struct TALER_TESTING_Command *coin_cmd;
|
||||||
@ -153,19 +147,6 @@ refund_run (void *cls,
|
|||||||
TALER_TESTING_interpreter_fail (is);
|
TALER_TESTING_interpreter_fail (is);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
|
||||||
TALER_string_to_amount (rs->refund_fee,
|
|
||||||
&refund_fee))
|
|
||||||
{
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"Failed to parse amount `%s' at %u/%s\n",
|
|
||||||
rs->refund_fee,
|
|
||||||
is->ip,
|
|
||||||
cmd->label);
|
|
||||||
TALER_TESTING_interpreter_fail (is);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
coin_cmd = TALER_TESTING_interpreter_lookup_command (is,
|
coin_cmd = TALER_TESTING_interpreter_lookup_command (is,
|
||||||
rs->coin_reference);
|
rs->coin_reference);
|
||||||
if (NULL == coin_cmd)
|
if (NULL == coin_cmd)
|
||||||
@ -211,7 +192,6 @@ refund_run (void *cls,
|
|||||||
}
|
}
|
||||||
rs->rh = TALER_EXCHANGE_refund (rs->exchange,
|
rs->rh = TALER_EXCHANGE_refund (rs->exchange,
|
||||||
&refund_amount,
|
&refund_amount,
|
||||||
&refund_fee,
|
|
||||||
&h_contract_terms,
|
&h_contract_terms,
|
||||||
&coin,
|
&coin,
|
||||||
rs->refund_transaction_id,
|
rs->refund_transaction_id,
|
||||||
@ -254,7 +234,6 @@ refund_cleanup (void *cls,
|
|||||||
* @param label command label.
|
* @param label command label.
|
||||||
* @param expected_response_code expected HTTP status code.
|
* @param expected_response_code expected HTTP status code.
|
||||||
* @param refund_amount the amount to ask a refund for.
|
* @param refund_amount the amount to ask a refund for.
|
||||||
* @param refund_fee expected refund fee.
|
|
||||||
* @param coin_reference reference to a command that can
|
* @param coin_reference reference to a command that can
|
||||||
* provide a coin to be refunded.
|
* provide a coin to be refunded.
|
||||||
*
|
*
|
||||||
@ -264,7 +243,6 @@ struct TALER_TESTING_Command
|
|||||||
TALER_TESTING_cmd_refund (const char *label,
|
TALER_TESTING_cmd_refund (const char *label,
|
||||||
unsigned int expected_response_code,
|
unsigned int expected_response_code,
|
||||||
const char *refund_amount,
|
const char *refund_amount,
|
||||||
const char *refund_fee,
|
|
||||||
const char *coin_reference)
|
const char *coin_reference)
|
||||||
{
|
{
|
||||||
struct RefundState *rs;
|
struct RefundState *rs;
|
||||||
@ -273,7 +251,6 @@ TALER_TESTING_cmd_refund (const char *label,
|
|||||||
|
|
||||||
rs->expected_response_code = expected_response_code;
|
rs->expected_response_code = expected_response_code;
|
||||||
rs->refund_amount = refund_amount;
|
rs->refund_amount = refund_amount;
|
||||||
rs->refund_fee = refund_fee;
|
|
||||||
rs->coin_reference = coin_reference;
|
rs->coin_reference = coin_reference;
|
||||||
{
|
{
|
||||||
struct TALER_TESTING_Command cmd = {
|
struct TALER_TESTING_Command cmd = {
|
||||||
@ -295,7 +272,6 @@ TALER_TESTING_cmd_refund (const char *label,
|
|||||||
* @param label command label.
|
* @param label command label.
|
||||||
* @param expected_response_code expected HTTP status code.
|
* @param expected_response_code expected HTTP status code.
|
||||||
* @param refund_amount the amount to ask a refund for.
|
* @param refund_amount the amount to ask a refund for.
|
||||||
* @param refund_fee expected refund fee.
|
|
||||||
* @param coin_reference reference to a command that can
|
* @param coin_reference reference to a command that can
|
||||||
* provide a coin to be refunded.
|
* provide a coin to be refunded.
|
||||||
* @param refund_transaction_id transaction id to use
|
* @param refund_transaction_id transaction id to use
|
||||||
@ -308,7 +284,6 @@ TALER_TESTING_cmd_refund_with_id
|
|||||||
(const char *label,
|
(const char *label,
|
||||||
unsigned int expected_response_code,
|
unsigned int expected_response_code,
|
||||||
const char *refund_amount,
|
const char *refund_amount,
|
||||||
const char *refund_fee,
|
|
||||||
const char *coin_reference,
|
const char *coin_reference,
|
||||||
uint64_t refund_transaction_id)
|
uint64_t refund_transaction_id)
|
||||||
{
|
{
|
||||||
@ -317,7 +292,6 @@ TALER_TESTING_cmd_refund_with_id
|
|||||||
rs = GNUNET_new (struct RefundState);
|
rs = GNUNET_new (struct RefundState);
|
||||||
rs->expected_response_code = expected_response_code;
|
rs->expected_response_code = expected_response_code;
|
||||||
rs->refund_amount = refund_amount;
|
rs->refund_amount = refund_amount;
|
||||||
rs->refund_fee = refund_fee;
|
|
||||||
rs->coin_reference = coin_reference;
|
rs->coin_reference = coin_reference;
|
||||||
rs->refund_transaction_id = refund_transaction_id;
|
rs->refund_transaction_id = refund_transaction_id;
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user