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/include | |
parent | 8a906bf96c9c418dbd58727284eb5cfdd6fdff24 (diff) |
refactor /wire to include logic to return the wad fee (for W2W payments)
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/taler_crypto_lib.h | 36 | ||||
-rw-r--r-- | src/include/taler_exchange_service.h | 14 | ||||
-rw-r--r-- | src/include/taler_exchangedb_plugin.h | 110 | ||||
-rw-r--r-- | src/include/taler_signatures.h | 10 | ||||
-rw-r--r-- | src/include/taler_testing_lib.h | 5 |
5 files changed, 128 insertions, 47 deletions
diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h index 1beada699..40f407b66 100644 --- a/src/include/taler_crypto_lib.h +++ b/src/include/taler_crypto_lib.h @@ -831,6 +831,18 @@ TALER_global_fee_set_ntoh (struct TALER_GlobalFeeSet *fees, /** + * Compare global fee sets. + * + * @param f1 first set to compare + * @param f2 second set to compare + * @return 0 if sets are equal + */ +int +TALER_global_fee_set_cmp (const struct TALER_GlobalFeeSet *f1, + const struct TALER_GlobalFeeSet *f2); + + +/** * Convert wire fee set from host to network byte order. * * @param[out] nbo where to write the result @@ -853,6 +865,18 @@ TALER_wire_fee_set_ntoh (struct TALER_WireFeeSet *fees, /** + * Compare wire fee sets. + * + * @param f1 first set to compare + * @param f2 second set to compare + * @return 0 if sets are equal + */ +int +TALER_wire_fee_set_cmp (const struct TALER_WireFeeSet *f1, + const struct TALER_WireFeeSet *f2); + + +/** * Hash @a rsa. * * @param rsa key to hash @@ -3231,8 +3255,7 @@ TALER_auditor_denom_validity_verify ( * @param payment_method the payment method * @param start_time when do the fees start to apply * @param end_time when do the fees start to apply - * @param wire_fee the wire fee - * @param closing_fee the closing fee + * @param fees the wire fees * @param master_priv private key to sign with * @param[out] master_sig where to write the signature */ @@ -3241,8 +3264,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); @@ -3253,8 +3275,7 @@ TALER_exchange_offline_wire_fee_sign ( * @param payment_method the payment method * @param start_time when do the fees start to apply * @param end_time when do the fees start to apply - * @param wire_fee the wire fee - * @param closing_fee the closing fee + * @param fees the wire fees * @param master_pub public key to verify against * @param master_sig the signature the signature * @return #GNUNET_OK if the signature is valid @@ -3264,8 +3285,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); diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h index 88be1ee32..00115e12a 100644 --- a/src/include/taler_exchange_service.h +++ b/src/include/taler_exchange_service.h @@ -642,13 +642,7 @@ struct TALER_EXCHANGE_WireAggregateFees /** * Fee to be paid whenever the exchange wires funds to the merchant. */ - struct TALER_Amount wire_fee; - - /** - * Fee to be paid when the exchange closes a reserve and wires funds - * back to a customer. - */ - struct TALER_Amount closing_fee; + struct TALER_WireFeeSet fees; /** * Time when this fee goes into effect (inclusive) @@ -3501,8 +3495,7 @@ struct TALER_EXCHANGE_ManagementSetWireFeeHandle; * @param wire_method for which wire method are fees provided * @param validity_start start date for the provided wire fees * @param validity_end end date for the provided wire fees - * @param wire_fee the wire fee for this time period - * @param closing_fee the closing fee for this time period + * @param fees the wire fees for this time period * @param master_sig signature affirming the wire fees; * of purpose #TALER_SIGNATURE_MASTER_WIRE_FEES * @param cb function to call with the exchange's result @@ -3516,8 +3509,7 @@ TALER_EXCHANGE_management_set_wire_fees ( const char *wire_method, struct GNUNET_TIME_Timestamp validity_start, struct GNUNET_TIME_Timestamp validity_end, - const struct TALER_Amount *wire_fee, - const struct TALER_Amount *closing_fee, + const struct TALER_WireFeeSet *fees, const struct TALER_MasterSignatureP *master_sig, TALER_EXCHANGE_ManagementWireEnableCallback cb, void *cb_cls); diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h index 878cfe2f2..d890cd0ba 100644 --- a/src/include/taler_exchangedb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -168,6 +168,7 @@ enum TALER_EXCHANGEDB_ReplicatedTable TALER_EXCHANGEDB_RT_WIRE_OUT, TALER_EXCHANGEDB_RT_AGGREGATION_TRACKING, TALER_EXCHANGEDB_RT_WIRE_FEE, + TALER_EXCHANGEDB_RT_GLOBAL_FEE, TALER_EXCHANGEDB_RT_RECOUP, TALER_EXCHANGEDB_RT_RECOUP_REFRESH, TALER_EXCHANGEDB_RT_EXTENSIONS, @@ -384,13 +385,20 @@ struct TALER_EXCHANGEDB_TableData char *wire_method; struct GNUNET_TIME_Timestamp start_date; struct GNUNET_TIME_Timestamp end_date; - struct TALER_Amount wire_fee; - struct TALER_Amount closing_fee; + struct TALER_WireFeeSet fees; struct TALER_MasterSignatureP master_sig; } wire_fee; struct { + struct GNUNET_TIME_Timestamp start_date; + struct GNUNET_TIME_Timestamp end_date; + struct TALER_GlobalFeeSet fees; + struct TALER_MasterSignatureP master_sig; + } global_fee; + + struct + { uint64_t known_coin_id; struct TALER_CoinSpendSignatureP coin_sig; union TALER_DenominationBlindingKeyP coin_blind; @@ -1899,8 +1907,7 @@ typedef void * Provide information about wire fees. * * @param cls closure - * @param wire_fee the wire fee we charge - * @param closing_fee the closing fee we charge + * @param fees the wire fees we charge * @param start_date from when are these fees valid (start date) * @param end_date until when are these fees valid (end date, exclusive) * @param master_sig master key signature affirming that this is the correct @@ -1909,8 +1916,26 @@ typedef void typedef void (*TALER_EXCHANGEDB_WireFeeCallback)( void *cls, - const struct TALER_Amount *wire_fee, - const struct TALER_Amount *closing_fee, + const struct TALER_WireFeeSet *fees, + struct GNUNET_TIME_Timestamp start_date, + struct GNUNET_TIME_Timestamp end_date, + const struct TALER_MasterSignatureP *master_sig); + + +/** + * Provide information about global fees. + * + * @param cls closure + * @param fees the global fees we charge + * @param start_date from when are these fees valid (start date) + * @param end_date until when are these fees valid (end date, exclusive) + * @param master_sig master key signature affirming that this is the correct + * fee (of purpose #TALER_SIGNATURE_MASTER_GLOBAL_FEES) + */ +typedef void +(*TALER_EXCHANGEDB_GlobalFeeCallback)( + void *cls, + const struct TALER_GlobalFeeSet *fees, struct GNUNET_TIME_Timestamp start_date, struct GNUNET_TIME_Timestamp end_date, const struct TALER_MasterSignatureP *master_sig); @@ -3256,8 +3281,7 @@ struct TALER_EXCHANGEDB_Plugin * @param wire_method which wire method is the fee about? * @param start_date when does the fee go into effect * @param end_date when does the fee end being valid - * @param wire_fee how high is the wire transfer fee - * @param closing_fee how high is the closing fee + * @param fees how high is are the wire fees * @param master_sig signature over the above by the exchange master key * @return transaction status code */ @@ -3266,12 +3290,29 @@ struct TALER_EXCHANGEDB_Plugin const char *wire_method, struct GNUNET_TIME_Timestamp start_date, struct GNUNET_TIME_Timestamp end_date, - const struct TALER_Amount *wire_fee, - const struct TALER_Amount *closing_fee, + const struct TALER_WireFeeSet *fees, const struct TALER_MasterSignatureP *master_sig); /** + * Insert global fee set into database. + * + * @param cls closure + * @param start_date when does the fee go into effect + * @param end_date when does the fee end being valid + * @param fees how high is are the global fees + * @param master_sig signature over the above by the exchange master key + * @return transaction status code + */ + enum GNUNET_DB_QueryStatus + (*insert_global_fee)(void *cls, + struct GNUNET_TIME_Timestamp start_date, + struct GNUNET_TIME_Timestamp end_date, + const struct TALER_GlobalFeeSet *fees, + const struct TALER_MasterSignatureP *master_sig); + + + /** * Obtain wire fee from database. * * @param cls closure @@ -3279,8 +3320,7 @@ struct TALER_EXCHANGEDB_Plugin * @param date for which date do we want the fee? * @param[out] start_date when does the fee go into effect * @param[out] end_date when does the fee end being valid - * @param[out] wire_fee how high is the wire transfer fee - * @param[out] closing_fee how high is the closing fee + * @param[out] fees how high are the wire fees * @param[out] master_sig signature over the above by the exchange master key * @return query status of the transaction */ @@ -3290,12 +3330,32 @@ struct TALER_EXCHANGEDB_Plugin struct GNUNET_TIME_Timestamp date, struct GNUNET_TIME_Timestamp *start_date, struct GNUNET_TIME_Timestamp *end_date, - struct TALER_Amount *wire_fee, - struct TALER_Amount *closing_fee, + struct TALER_WireFeeSet *fees, struct TALER_MasterSignatureP *master_sig); /** + * Obtain global fees from database. + * + * @param cls closure + * @param date for which date do we want the fee? + * @param[out] start_date when does the fee go into effect + * @param[out] end_date when does the fee end being valid + * @param[out] fees how high are the global fees + * @param[out] master_sig signature over the above by the exchange master key + * @return query status of the transaction + */ + enum GNUNET_DB_QueryStatus + (*get_global_fee)(void *cls, + const char *type, + struct GNUNET_TIME_Timestamp date, + struct GNUNET_TIME_Timestamp *start_date, + struct GNUNET_TIME_Timestamp *end_date, + struct TALER_GlobalFeeSet *fees, + struct TALER_MasterSignatureP *master_sig); + + + /** * Obtain information about expired reserves and their * remaining balances. * @@ -3875,6 +3935,20 @@ struct TALER_EXCHANGEDB_Plugin /** + * Obtain information about the global fee structure of the exchange. + * + * @param cls closure + * @param cb function to call on each account + * @param cb_cls closure for @a cb + * @return transaction status code + */ + enum GNUNET_DB_QueryStatus + (*get_global_fees)(void *cls, + TALER_EXCHANGEDB_GlobalFeeCallback cb, + void *cb_cls); + + + /** * Store information about a revoked online signing key. * * @param cls closure @@ -4012,10 +4086,7 @@ struct TALER_EXCHANGEDB_Plugin * @param wire_method the wire method to lookup fees for * @param start_time starting time of fee * @param end_time end time of fee - * @param[out] wire_fee wire fee for that time period; if - * different wire fee exists within this time - * period, an 'invalid' amount is returned. - * @param[out] closing_fee wire fee for that time period; if + * @param[out] fees set to wire fees for that time period; if * different wire fee exists within this time * period, an 'invalid' amount is returned. * @return transaction status code @@ -4026,8 +4097,7 @@ struct TALER_EXCHANGEDB_Plugin const char *wire_method, struct GNUNET_TIME_Timestamp start_time, struct GNUNET_TIME_Timestamp end_time, - struct TALER_Amount *wire_fee, - struct TALER_Amount *closing_fee); + struct TALER_WireFeeSet *fees); /** diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h index ed985938b..77a234218 100644 --- a/src/include/taler_signatures.h +++ b/src/include/taler_signatures.h @@ -1244,14 +1244,10 @@ struct TALER_MasterWireFeePS struct GNUNET_TIME_TimestampNBO end_date; /** - * Fee charged to the merchant per wire transfer. - */ - struct TALER_AmountNBO wire_fee; - - /** - * Closing fee charged when we wire back funds of a reserve. + * Fees charged for wire transfers using the + * given wire method. */ - struct TALER_AmountNBO closing_fee; + struct TALER_WireFeeSetNBOP fees; }; diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h index 081a93478..5d5cff49d 100644 --- a/src/include/taler_testing_lib.h +++ b/src/include/taler_testing_lib.h @@ -2107,6 +2107,7 @@ TALER_TESTING_cmd_set_wire_fee (const char *label, const char *wire_method, const char *wire_fee, const char *closing_fee, + const char *wad_fee, unsigned int expected_http_status, bool bad_sig); @@ -2180,13 +2181,15 @@ TALER_TESTING_cmd_exec_offline_sign_keys (const char *label, * @param config_filename configuration filename. * @param wire_fee the wire fee to affirm (for the current year) * @param closing_fee the closing fee to affirm (for the current year) + * @param wad_fee the wad fee to affirm * @return the command */ struct TALER_TESTING_Command TALER_TESTING_cmd_exec_offline_sign_fees (const char *label, const char *config_filename, const char *wire_fee, - const char *closing_fee); + const char *closing_fee, + const char *wad_fee); /** |