summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/exchange_api_common.c34
-rw-r--r--src/lib/exchange_api_deposit.c4
-rw-r--r--src/lib/exchange_api_handle.c2
-rw-r--r--src/lib/exchange_api_refund.c21
-rw-r--r--src/lib/exchange_api_withdraw2.c2
5 files changed, 25 insertions, 38 deletions
diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c
index 07f5e187..dc44291d 100644
--- a/src/lib/exchange_api_common.c
+++ b/src/lib/exchange_api_common.c
@@ -146,11 +146,12 @@ TALER_EXCHANGE_parse_reserve_history (
{
struct TALER_ReserveSignatureP sig;
struct TALER_WithdrawRequestPS withdraw_purpose;
+ struct TALER_Amount withdraw_fee;
struct GNUNET_JSON_Specification withdraw_spec[] = {
GNUNET_JSON_spec_fixed_auto ("reserve_sig",
&sig),
- TALER_JSON_spec_amount_nbo ("withdraw_fee",
- &withdraw_purpose.withdraw_fee),
+ TALER_JSON_spec_amount ("withdraw_fee",
+ &withdraw_fee),
GNUNET_JSON_spec_fixed_auto ("h_denom_pub",
&withdraw_purpose.h_denomination_pub),
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_DenomPublicKey *dki;
- struct TALER_Amount fee;
key_state = TALER_EXCHANGE_get_keys (exchange);
dki = TALER_EXCHANGE_get_denomination_key_by_hash (key_state,
&withdraw_purpose.
h_denomination_pub);
- TALER_amount_ntoh (&fee,
- &withdraw_purpose.withdraw_fee);
if ( (GNUNET_YES !=
- TALER_amount_cmp_currency (&fee,
+ TALER_amount_cmp_currency (&withdraw_fee,
&dki->fee_withdraw)) ||
(0 !=
- TALER_amount_cmp (&fee,
+ TALER_amount_cmp (&withdraw_fee,
&dki->fee_withdraw)) )
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (withdraw_spec);
return GNUNET_SYSERR;
}
- rh->details.withdraw.fee = fee;
+ rh->details.withdraw.fee = withdraw_fee;
}
rh->details.withdraw.out_authorization_sig
= json_object_get (transaction,
@@ -634,9 +632,16 @@ TALER_EXCHANGE_verify_coin_history (
else if (0 == strcasecmp (type,
"REFUND"))
{
- struct TALER_RefundRequestPS rr;
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[] = {
+ TALER_JSON_spec_amount ("refund_fee",
+ &refund_fee),
GNUNET_JSON_spec_fixed_auto ("merchant_sig",
&sig),
GNUNET_JSON_spec_fixed_auto ("h_contract_terms",
@@ -645,8 +650,6 @@ TALER_EXCHANGE_verify_coin_history (
&rr.merchant),
GNUNET_JSON_spec_uint64 ("rtransaction_id",
&rr.rtransaction_id),
- TALER_JSON_spec_amount_nbo ("refund_fee",
- &rr.refund_fee),
GNUNET_JSON_spec_end ()
};
@@ -658,9 +661,6 @@ TALER_EXCHANGE_verify_coin_history (
GNUNET_break_op (0);
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,
&amount);
if (GNUNET_OK !=
@@ -683,13 +683,11 @@ TALER_EXCHANGE_verify_coin_history (
/* check that refund fee matches our expectations from /keys! */
if (NULL != dk)
{
- TALER_amount_ntoh (&fee,
- &rr.refund_fee);
if ( (GNUNET_YES !=
- TALER_amount_cmp_currency (&fee,
+ TALER_amount_cmp_currency (&refund_fee,
&dk->fee_refund)) ||
(0 !=
- TALER_amount_cmp (&fee,
+ TALER_amount_cmp (&refund_fee,
&dk->fee_refund)) )
{
GNUNET_break_op (0);
diff --git a/src/lib/exchange_api_deposit.c b/src/lib/exchange_api_deposit.c
index 5f374993..a5cf6c36 100644
--- a/src/lib/exchange_api_deposit.c
+++ b/src/lib/exchange_api_deposit.c
@@ -196,8 +196,8 @@ verify_deposit_signature_ok (struct TALER_EXCHANGE_DepositHandle *dh,
{
const struct TALER_EXCHANGE_Keys *key_state;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_fixed_auto ("sig", exchange_sig),
- GNUNET_JSON_spec_fixed_auto ("pub", exchange_pub),
+ GNUNET_JSON_spec_fixed_auto ("exchange_sig", exchange_sig),
+ GNUNET_JSON_spec_fixed_auto ("exchange_pub", exchange_pub),
GNUNET_JSON_spec_end ()
};
diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c
index c3ae1663..c9c1b09b 100644
--- a/src/lib/exchange_api_handle.c
+++ b/src/lib/exchange_api_handle.c
@@ -39,7 +39,7 @@
* Which version of the Taler protocol is implemented
* 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?
diff --git a/src/lib/exchange_api_refund.c b/src/lib/exchange_api_refund.c
index c64dcc97..9cb8794d 100644
--- a/src/lib/exchange_api_refund.c
+++ b/src/lib/exchange_api_refund.c
@@ -81,14 +81,14 @@ struct TALER_EXCHANGE_RefundHandle
* Verify that the signature on the "200 OK" response
* 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[out] exchange_pub set to the exchange's public key
* @param[out] exchange_sig set to the exchange's signature
* @return #GNUNET_OK if the signature is valid, #GNUNET_SYSERR if not
*/
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,
struct TALER_ExchangePublicKeyP *exchange_pub,
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;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_fixed_auto ("sig", exchange_sig),
- GNUNET_JSON_spec_fixed_auto ("pub", exchange_pub),
+ GNUNET_JSON_spec_fixed_auto ("exchange_sig", exchange_sig),
+ GNUNET_JSON_spec_fixed_auto ("exchange_pub", exchange_pub),
+ TALER_JSON_spec_amount_nbo ("refund_fee", &rh->depconf.refund_fee),
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
* (as that fee is still being subtracted), and smaller than the amount
* (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 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);
@@ -272,7 +272,6 @@ handle_refund_finished (void *cls,
struct TALER_EXCHANGE_RefundHandle *
TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange,
const struct TALER_Amount *amount,
- const struct TALER_Amount *refund_fee,
const struct GNUNET_HashCode *h_contract_terms,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
uint64_t rtransaction_id,
@@ -294,14 +293,11 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange,
rr.rtransaction_id = GNUNET_htonll (rtransaction_id);
TALER_amount_hton (&rr.refund_amount,
amount);
- TALER_amount_hton (&rr.refund_fee,
- refund_fee);
GNUNET_CRYPTO_eddsa_sign (&merchant_priv->eddsa_priv,
&rr,
&merchant_sig.eddsa_sig);
return TALER_EXCHANGE_refund2 (exchange,
amount,
- refund_fee,
h_contract_terms,
coin_pub,
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
* (as that fee is still being subtracted), and smaller than the amount
* (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 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);
@@ -346,7 +341,6 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange,
struct TALER_EXCHANGE_RefundHandle *
TALER_EXCHANGE_refund2 (struct TALER_EXCHANGE_Handle *exchange,
const struct TALER_Amount *amount,
- const struct TALER_Amount *refund_fee,
const struct GNUNET_HashCode *h_contract_terms,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
uint64_t rtransaction_id,
@@ -376,12 +370,11 @@ TALER_EXCHANGE_refund2 (struct TALER_EXCHANGE_Handle *exchange,
"/coins/%s/refund",
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:I," /* rtransaction id */
" s:o, s:o}", /* merchant_pub, merchant_sig */
"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),
"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);
TALER_amount_hton (&rh->depconf.refund_amount,
amount);
- TALER_amount_hton (&rh->depconf.refund_fee,
- refund_fee);
eh = TALER_EXCHANGE_curl_easy_get_ (rh->url);
if ( (NULL == eh) ||
diff --git a/src/lib/exchange_api_withdraw2.c b/src/lib/exchange_api_withdraw2.c
index f9468927..25f66914 100644
--- a/src/lib/exchange_api_withdraw2.c
+++ b/src/lib/exchange_api_withdraw2.c
@@ -429,8 +429,6 @@ TALER_EXCHANGE_withdraw2 (
TALER_amount_hton (&req.amount_with_fee,
&wh->requested_amount);
- TALER_amount_hton (&req.withdraw_fee,
- &dk->fee_withdraw);
GNUNET_CRYPTO_hash (pd->coin_ev,
pd->coin_ev_size,
&req.h_coin_envelope);