summaryrefslogtreecommitdiff
path: root/src/lib/exchange_api_refund.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-06-05 14:07:23 +0200
committerChristian Grothoff <christian@grothoff.org>2022-06-05 14:07:23 +0200
commitb9963f75255e416ca79b2f5c3081bde4ba78fab0 (patch)
tree9575e9558b6f8960798c09dec681dc277f96babc /src/lib/exchange_api_refund.c
parent6c81796d6f39e932d58b4fc1729b472d0e46e3d1 (diff)
downloadexchange-b9963f75255e416ca79b2f5c3081bde4ba78fab0.tar.gz
exchange-b9963f75255e416ca79b2f5c3081bde4ba78fab0.tar.bz2
exchange-b9963f75255e416ca79b2f5c3081bde4ba78fab0.zip
complete P2P/W2W conflict handling, deduplicate code across handlers
Diffstat (limited to 'src/lib/exchange_api_refund.c')
-rw-r--r--src/lib/exchange_api_refund.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/src/lib/exchange_api_refund.c b/src/lib/exchange_api_refund.c
index 004661b00..09a21883d 100644
--- a/src/lib/exchange_api_refund.c
+++ b/src/lib/exchange_api_refund.c
@@ -173,9 +173,12 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,
const json_t *json)
{
json_t *history;
+ struct TALER_DenominationHashP h_denom_pub;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_json ("history",
&history),
+ GNUNET_JSON_spec_fixed_auto ("h_denom_pub",
+ &h_denom_pub),
GNUNET_JSON_spec_end ()
};
size_t len;
@@ -234,7 +237,6 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,
struct TALER_AgeCommitmentHash h_age_commitment;
bool no_hac;
// struct TALER_ExtensionContractHashP h_extensions; // FIXME!
- struct TALER_DenominationHashP h_denom_pub;
struct GNUNET_TIME_Timestamp wallet_timestamp;
struct TALER_MerchantPublicKeyP merchant_pub;
struct GNUNET_TIME_Timestamp refund_deadline;
@@ -246,8 +248,6 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,
&h_contract_terms),
GNUNET_JSON_spec_fixed_auto ("h_wire",
&h_wire),
- GNUNET_JSON_spec_fixed_auto ("h_denom_pub",
- &h_denom_pub),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_fixed_auto ("h_age_commitment",
&h_age_commitment),
@@ -429,24 +429,22 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,
}
}
+ if (have_refund)
{
- if (have_refund)
+ if (0 >
+ TALER_amount_add (&rtotal,
+ &rtotal,
+ &rh->refund_amount))
{
- if (0 >
- TALER_amount_add (&rtotal,
- &rtotal,
- &rh->refund_amount))
- {
- GNUNET_break (0);
- GNUNET_JSON_parse_free (spec);
- return GNUNET_SYSERR;
- }
- }
- else
- {
- rtotal = rh->refund_amount;
+ GNUNET_break (0);
+ GNUNET_JSON_parse_free (spec);
+ return GNUNET_SYSERR;
}
}
+ else
+ {
+ rtotal = rh->refund_amount;
+ }
if (-1 == TALER_amount_cmp (&dtotal,
&rtotal))
{