diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-03-05 14:36:49 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-03-05 14:36:55 +0100 |
commit | 7ff58c3d8f2351c57142b4b65ab75304f355fc4f (patch) | |
tree | 4d5de28cbc2cb51b9946c924b7dd228cfe0d0634 /src/util | |
parent | 8a906bf96c9c418dbd58727284eb5cfdd6fdff24 (diff) | |
download | exchange-7ff58c3d8f2351c57142b4b65ab75304f355fc4f.tar.xz |
refactor /wire to include logic to return the wad fee (for W2W payments)
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/offline_signatures.c | 20 | ||||
-rw-r--r-- | src/util/util.c | 40 |
2 files changed, 47 insertions, 13 deletions
diff --git a/src/util/offline_signatures.c b/src/util/offline_signatures.c index 5aef4ac3e..2a358bbf1 100644 --- a/src/util/offline_signatures.c +++ b/src/util/offline_signatures.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2020, 2021 Taler Systems SA + Copyright (C) 2020-2022 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -415,8 +415,7 @@ TALER_exchange_offline_wire_fee_sign ( const char *payment_method, struct GNUNET_TIME_Timestamp start_time, struct GNUNET_TIME_Timestamp end_time, - const struct TALER_Amount *wire_fee, - const struct TALER_Amount *closing_fee, + const struct TALER_WireFeeSet *fees, const struct TALER_MasterPrivateKeyP *master_priv, struct TALER_MasterSignatureP *master_sig) { @@ -430,10 +429,8 @@ TALER_exchange_offline_wire_fee_sign ( GNUNET_CRYPTO_hash (payment_method, strlen (payment_method) + 1, &kv.h_wire_method); - TALER_amount_hton (&kv.wire_fee, - wire_fee); - TALER_amount_hton (&kv.closing_fee, - closing_fee); + TALER_wire_fee_set_hton (&kv.fees, + fees); GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv, &kv, &master_sig->eddsa_signature); @@ -445,8 +442,7 @@ TALER_exchange_offline_wire_fee_verify ( const char *payment_method, struct GNUNET_TIME_Timestamp start_time, struct GNUNET_TIME_Timestamp end_time, - const struct TALER_Amount *wire_fee, - const struct TALER_Amount *closing_fee, + const struct TALER_WireFeeSet *fees, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_MasterSignatureP *master_sig) { @@ -460,10 +456,8 @@ TALER_exchange_offline_wire_fee_verify ( GNUNET_CRYPTO_hash (payment_method, strlen (payment_method) + 1, &wf.h_wire_method); - TALER_amount_hton (&wf.wire_fee, - wire_fee); - TALER_amount_hton (&wf.closing_fee, - closing_fee); + TALER_wire_fee_set_hton (&wf.fees, + fees); return GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_WIRE_FEES, &wf, diff --git a/src/util/util.c b/src/util/util.c index 6dfd65574..33b0a77cc 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -124,6 +124,46 @@ TALER_wire_fee_set_ntoh (struct TALER_WireFeeSet *fees, } +int +TALER_global_fee_set_cmp (const struct TALER_GlobalFeeSet *f1, + const struct TALER_GlobalFeeSet *f2) +{ + int ret; + + ret = TALER_amount_cmp (&f1->history, + &f2->history); + if (0 != ret) + return ret; + ret = TALER_amount_cmp (&f1->kyc, + &f2->kyc); + if (0 != ret) + return ret; + return 0; +} + + +int +TALER_wire_fee_set_cmp (const struct TALER_WireFeeSet *f1, + const struct TALER_WireFeeSet *f2) +{ + int ret; + + ret = TALER_amount_cmp (&f1->wire, + &f2->wire); + if (0 != ret) + return ret; + ret = TALER_amount_cmp (&f1->closing, + &f2->closing); + if (0 != ret) + return ret; + ret = TALER_amount_cmp (&f1->wad, + &f2->wad); + if (0 != ret) + return ret; + return 0; +} + + enum GNUNET_GenericReturnValue TALER_denom_fee_check_currency ( const char *currency, |