From f406f96129766c144c1531dc853969664f410d8c Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 3 Mar 2017 20:31:29 +0100 Subject: implement #4929: add wire transfer fee to /wire (but not yet charged by aggregator) --- src/include/taler_exchangedb_lib.h | 78 +++++++++++++++++++++++++++++++++++++- src/include/taler_signatures.h | 38 ++++++++++++++++++- 2 files changed, 114 insertions(+), 2 deletions(-) (limited to 'src/include') diff --git a/src/include/taler_exchangedb_lib.h b/src/include/taler_exchangedb_lib.h index 4ebe4841f..02e8cdfec 100644 --- a/src/include/taler_exchangedb_lib.h +++ b/src/include/taler_exchangedb_lib.h @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014, 2015, 2016 Inria & GNUnet e.V. + Copyright (C) 2014-2017 Inria & GNUnet e.V. 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 @@ -25,6 +25,7 @@ #include "taler_signatures.h" + /** * Subdirectroy under the exchange's base directory which contains * the exchange's signing keys. @@ -297,4 +298,79 @@ void TALER_EXCHANGEDB_plugin_unload (struct TALER_EXCHANGEDB_Plugin *plugin); +/** + * Sorted list of fees to be paid for aggregate wire transfers. + */ +struct TALER_EXCHANGEDB_AggregateFees +{ + /** + * This is a linked list. + */ + struct TALER_EXCHANGEDB_AggregateFees *next; + + /** + * Fee to be paid. + */ + struct TALER_Amount wire_fee; + + /** + * Time when this fee goes into effect (inclusive) + */ + struct GNUNET_TIME_Absolute start_date; + + /** + * Time when this fee stops being in effect (exclusive). + */ + struct GNUNET_TIME_Absolute end_date; + + /** + * Signature affirming the above fee structure. + */ + struct TALER_MasterSignatureP master_sig; +}; + + +/** + * Read the current fee structure from disk. + * + * @param cfg configuration to use + * @param wireplugin name of the wire plugin to read fees for + * @return sorted list of aggregation fees, NULL on error + */ +struct TALER_EXCHANGEDB_AggregateFees * +TALER_EXCHANGEDB_fees_read (const struct GNUNET_CONFIGURATION_Handle *cfg, + const char *wireplugin); + + +/** + * Convert @a af to @a wf. + * + * @param[in,out] af aggregate fees, host format (updated to round time) + * @param[out] wf aggregate fees, disk / signature format + */ +void +TALER_EXCHANGEDB_fees_2_wf (struct TALER_EXCHANGEDB_AggregateFees *af, + struct TALER_MasterWireFeePS *wf); + + +/** + * Write given fee structure to disk. + * + * @param filename where to write the fees + * @param af fee structure to write + * @return #GNUNET_OK on success, #GNUNET_SYSERR on error + */ +int +TALER_EXCHANGEDB_fees_write (const char *filename, + struct TALER_EXCHANGEDB_AggregateFees *af); + + +/** + * Free @a af data structure + * + * @param af list to free + */ +void +TALER_EXCHANGEDB_fees_free (struct TALER_EXCHANGEDB_AggregateFees *af); + #endif diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h index ef241c8b8..35967399d 100644 --- a/src/include/taler_signatures.h +++ b/src/include/taler_signatures.h @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014, 2015, 2016 GNUnet e.V. + Copyright (C) 2014-2017 GNUnet e.V. 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 @@ -78,6 +78,11 @@ */ #define TALER_SIGNATURE_MASTER_TEST_DETAILS 1027 +/** + * Fees charged per (aggregate) wire transfer to the merchant. + */ +#define TALER_SIGNATURE_MASTER_WIRE_FEES 1028 + /*********************************************/ /* Exchange online signatures (with signing key) */ @@ -879,6 +884,37 @@ struct TALER_MasterWireDetailsPS }; + +/** + * @brief Information signed by the exchange's master + * key stating the wire fee to be paid per wire transfer. + */ +struct TALER_MasterWireFeePS +{ + + /** + * Purpose is #TALER_SIGNATURE_MASTER_WIRE_FEES. + */ + struct GNUNET_CRYPTO_EccSignaturePurpose purpose; + + /** + * Start date when the fee goes into effect. + */ + struct GNUNET_TIME_AbsoluteNBO start_date; + + /** + * End date when the fee stops being in effect (exclusive) + */ + struct GNUNET_TIME_AbsoluteNBO end_date; + + /** + * Fee charged to the merchant per wire transfer. + */ + struct TALER_AmountNBO wire_fee; + +}; + + /** * @brief Format used to generate the signature on a request to obtain * the wire transfer identifier associated with a deposit. -- cgit v1.2.3