diff options
Diffstat (limited to 'src/lib/exchange_api_common.c')
-rw-r--r-- | src/lib/exchange_api_common.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c index 07f5e1873..dc44291d0 100644 --- a/src/lib/exchange_api_common.c +++ b/src/lib/exchange_api_common.c | |||
@@ -146,11 +146,12 @@ TALER_EXCHANGE_parse_reserve_history ( | |||
146 | { | 146 | { |
147 | struct TALER_ReserveSignatureP sig; | 147 | struct TALER_ReserveSignatureP sig; |
148 | struct TALER_WithdrawRequestPS withdraw_purpose; | 148 | struct TALER_WithdrawRequestPS withdraw_purpose; |
149 | struct TALER_Amount withdraw_fee; | ||
149 | struct GNUNET_JSON_Specification withdraw_spec[] = { | 150 | struct GNUNET_JSON_Specification withdraw_spec[] = { |
150 | GNUNET_JSON_spec_fixed_auto ("reserve_sig", | 151 | GNUNET_JSON_spec_fixed_auto ("reserve_sig", |
151 | &sig), | 152 | &sig), |
152 | TALER_JSON_spec_amount_nbo ("withdraw_fee", | 153 | TALER_JSON_spec_amount ("withdraw_fee", |
153 | &withdraw_purpose.withdraw_fee), | 154 | &withdraw_fee), |
154 | GNUNET_JSON_spec_fixed_auto ("h_denom_pub", | 155 | GNUNET_JSON_spec_fixed_auto ("h_denom_pub", |
155 | &withdraw_purpose.h_denomination_pub), | 156 | &withdraw_purpose.h_denomination_pub), |
156 | GNUNET_JSON_spec_fixed_auto ("h_coin_envelope", | 157 | GNUNET_JSON_spec_fixed_auto ("h_coin_envelope", |
@@ -189,26 +190,23 @@ TALER_EXCHANGE_parse_reserve_history ( | |||
189 | { | 190 | { |
190 | const struct TALER_EXCHANGE_Keys *key_state; | 191 | const struct TALER_EXCHANGE_Keys *key_state; |
191 | const struct TALER_EXCHANGE_DenomPublicKey *dki; | 192 | const struct TALER_EXCHANGE_DenomPublicKey *dki; |
192 | struct TALER_Amount fee; | ||
193 | 193 | ||
194 | key_state = TALER_EXCHANGE_get_keys (exchange); | 194 | key_state = TALER_EXCHANGE_get_keys (exchange); |
195 | dki = TALER_EXCHANGE_get_denomination_key_by_hash (key_state, | 195 | dki = TALER_EXCHANGE_get_denomination_key_by_hash (key_state, |
196 | &withdraw_purpose. | 196 | &withdraw_purpose. |
197 | h_denomination_pub); | 197 | h_denomination_pub); |
198 | TALER_amount_ntoh (&fee, | ||
199 | &withdraw_purpose.withdraw_fee); | ||
200 | if ( (GNUNET_YES != | 198 | if ( (GNUNET_YES != |
201 | TALER_amount_cmp_currency (&fee, | 199 | TALER_amount_cmp_currency (&withdraw_fee, |
202 | &dki->fee_withdraw)) || | 200 | &dki->fee_withdraw)) || |
203 | (0 != | 201 | (0 != |
204 | TALER_amount_cmp (&fee, | 202 | TALER_amount_cmp (&withdraw_fee, |
205 | &dki->fee_withdraw)) ) | 203 | &dki->fee_withdraw)) ) |
206 | { | 204 | { |
207 | GNUNET_break_op (0); | 205 | GNUNET_break_op (0); |
208 | GNUNET_JSON_parse_free (withdraw_spec); | 206 | GNUNET_JSON_parse_free (withdraw_spec); |
209 | return GNUNET_SYSERR; | 207 | return GNUNET_SYSERR; |
210 | } | 208 | } |
211 | rh->details.withdraw.fee = fee; | 209 | rh->details.withdraw.fee = withdraw_fee; |
212 | } | 210 | } |
213 | rh->details.withdraw.out_authorization_sig | 211 | rh->details.withdraw.out_authorization_sig |
214 | = json_object_get (transaction, | 212 | = json_object_get (transaction, |
@@ -634,9 +632,16 @@ TALER_EXCHANGE_verify_coin_history ( | |||
634 | else if (0 == strcasecmp (type, | 632 | else if (0 == strcasecmp (type, |
635 | "REFUND")) | 633 | "REFUND")) |
636 | { | 634 | { |
637 | struct TALER_RefundRequestPS rr; | ||
638 | struct TALER_MerchantSignatureP sig; | 635 | struct TALER_MerchantSignatureP sig; |
636 | struct TALER_Amount refund_fee; | ||
637 | struct TALER_RefundRequestPS rr = { | ||
638 | .purpose.size = htonl (sizeof (rr)), | ||
639 | .purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_REFUND), | ||
640 | .coin_pub = *coin_pub | ||
641 | }; | ||
639 | struct GNUNET_JSON_Specification spec[] = { | 642 | struct GNUNET_JSON_Specification spec[] = { |
643 | TALER_JSON_spec_amount ("refund_fee", | ||
644 | &refund_fee), | ||
640 | GNUNET_JSON_spec_fixed_auto ("merchant_sig", | 645 | GNUNET_JSON_spec_fixed_auto ("merchant_sig", |
641 | &sig), | 646 | &sig), |
642 | GNUNET_JSON_spec_fixed_auto ("h_contract_terms", | 647 | GNUNET_JSON_spec_fixed_auto ("h_contract_terms", |
@@ -645,8 +650,6 @@ TALER_EXCHANGE_verify_coin_history ( | |||
645 | &rr.merchant), | 650 | &rr.merchant), |
646 | GNUNET_JSON_spec_uint64 ("rtransaction_id", | 651 | GNUNET_JSON_spec_uint64 ("rtransaction_id", |
647 | &rr.rtransaction_id), | 652 | &rr.rtransaction_id), |
648 | TALER_JSON_spec_amount_nbo ("refund_fee", | ||
649 | &rr.refund_fee), | ||
650 | GNUNET_JSON_spec_end () | 653 | GNUNET_JSON_spec_end () |
651 | }; | 654 | }; |
652 | 655 | ||
@@ -658,9 +661,6 @@ TALER_EXCHANGE_verify_coin_history ( | |||
658 | GNUNET_break_op (0); | 661 | GNUNET_break_op (0); |
659 | return GNUNET_SYSERR; | 662 | return GNUNET_SYSERR; |
660 | } | 663 | } |
661 | rr.purpose.size = htonl (sizeof (rr)); | ||
662 | rr.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_REFUND); | ||
663 | rr.coin_pub = *coin_pub; | ||
664 | TALER_amount_hton (&rr.refund_amount, | 664 | TALER_amount_hton (&rr.refund_amount, |
665 | &amount); | 665 | &amount); |
666 | if (GNUNET_OK != | 666 | if (GNUNET_OK != |
@@ -683,13 +683,11 @@ TALER_EXCHANGE_verify_coin_history ( | |||
683 | /* check that refund fee matches our expectations from /keys! */ | 683 | /* check that refund fee matches our expectations from /keys! */ |
684 | if (NULL != dk) | 684 | if (NULL != dk) |
685 | { | 685 | { |
686 | TALER_amount_ntoh (&fee, | ||
687 | &rr.refund_fee); | ||
688 | if ( (GNUNET_YES != | 686 | if ( (GNUNET_YES != |
689 | TALER_amount_cmp_currency (&fee, | 687 | TALER_amount_cmp_currency (&refund_fee, |
690 | &dk->fee_refund)) || | 688 | &dk->fee_refund)) || |
691 | (0 != | 689 | (0 != |
692 | TALER_amount_cmp (&fee, | 690 | TALER_amount_cmp (&refund_fee, |
693 | &dk->fee_refund)) ) | 691 | &dk->fee_refund)) ) |
694 | { | 692 | { |
695 | GNUNET_break_op (0); | 693 | GNUNET_break_op (0); |