introduce refund fee

This commit is contained in:
Christian Grothoff 2016-04-20 01:50:26 +02:00
parent 1d8da4bf84
commit f693e25793
18 changed files with 144 additions and 42 deletions

View File

@ -28,6 +28,7 @@ duration_legal = 3 years
fee_withdraw = EUR:0.01 fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01 fee_deposit = EUR:0.01
fee_refresh = EUR:0.01 fee_refresh = EUR:0.01
fee_refund = EUR:0.01
rsa_keysize = 1024 rsa_keysize = 1024
[coin_eur_5] [coin_eur_5]
@ -39,6 +40,7 @@ duration_legal = 3 years
fee_withdraw = EUR:0.01 fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01 fee_deposit = EUR:0.01
fee_refresh = EUR:0.01 fee_refresh = EUR:0.01
fee_refund = EUR:0.01
rsa_keysize = 1024 rsa_keysize = 1024
[coin_eur_10] [coin_eur_10]
@ -50,6 +52,7 @@ duration_legal = 3 years
fee_withdraw = EUR:0.01 fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01 fee_deposit = EUR:0.01
fee_refresh = EUR:0.01 fee_refresh = EUR:0.01
fee_refund = EUR:0.01
rsa_keysize = 1024 rsa_keysize = 1024
[coin_eur_1000] [coin_eur_1000]
@ -61,4 +64,5 @@ duration_legal = 3 years
fee_withdraw = EUR:0.01 fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01 fee_deposit = EUR:0.01
fee_refresh = EUR:0.01 fee_refresh = EUR:0.01
fee_refund = EUR:0.01
rsa_keysize = 2048 rsa_keysize = 2048

View File

@ -67,6 +67,8 @@ The following options must be in sections starting with "[coin_]" and are used b
What fee is charged for depositing? What fee is charged for depositing?
.IP FEE_REFRESH .IP FEE_REFRESH
What fee is charged for refreshing? What fee is charged for refreshing?
.IP FEE_REFUND
What fee is charged for refunds? When a coin is refunded, the deposit fee is returned. Instead, the refund fee is charged to the customer.
.IP RSA_KEYSIZE .IP RSA_KEYSIZE
What is the RSA keysize modulos (in bits)? What is the RSA keysize modulos (in bits)?

View File

@ -520,7 +520,8 @@ main (int argc,
NULL, NULL, NULL, NULL, NULL, NULL,
"taler-bank-manage", "taler-bank-manage",
"taler-bank-manage", "taler-bank-manage",
"serve-http", "--port", "8081", "serve-http",
"--port", "8081",
NULL); NULL);
if (NULL == bankd) if (NULL == bankd)
{ {

View File

@ -253,29 +253,32 @@ parse_json_denomkey (struct TALER_EXCHANGE_DenomPublicKey *denom_key,
struct TALER_Amount fee_withdraw; struct TALER_Amount fee_withdraw;
struct TALER_Amount fee_deposit; struct TALER_Amount fee_deposit;
struct TALER_Amount fee_refresh; struct TALER_Amount fee_refresh;
struct TALER_Amount fee_refund;
struct TALER_DenominationKeyValidityPS denom_key_issue; struct TALER_DenominationKeyValidityPS denom_key_issue;
struct GNUNET_CRYPTO_RsaPublicKey *pk; struct GNUNET_CRYPTO_RsaPublicKey *pk;
struct GNUNET_CRYPTO_EddsaSignature sig; struct GNUNET_CRYPTO_EddsaSignature sig;
struct GNUNET_JSON_Specification spec[] = { struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("master_sig", GNUNET_JSON_spec_fixed_auto ("master_sig",
&sig), &sig),
GNUNET_JSON_spec_absolute_time ("stamp_expire_deposit", GNUNET_JSON_spec_absolute_time ("stamp_expire_deposit",
&deposit_valid_until), &deposit_valid_until),
GNUNET_JSON_spec_absolute_time ("stamp_expire_withdraw", GNUNET_JSON_spec_absolute_time ("stamp_expire_withdraw",
&withdraw_valid_until), &withdraw_valid_until),
GNUNET_JSON_spec_absolute_time ("stamp_start", GNUNET_JSON_spec_absolute_time ("stamp_start",
&valid_from), &valid_from),
GNUNET_JSON_spec_absolute_time ("stamp_expire_legal", GNUNET_JSON_spec_absolute_time ("stamp_expire_legal",
&expire_legal), &expire_legal),
TALER_JSON_spec_amount ("value", TALER_JSON_spec_amount ("value",
&value), &value),
TALER_JSON_spec_amount ("fee_withdraw", TALER_JSON_spec_amount ("fee_withdraw",
&fee_withdraw), &fee_withdraw),
TALER_JSON_spec_amount ("fee_deposit", TALER_JSON_spec_amount ("fee_deposit",
&fee_deposit), &fee_deposit),
TALER_JSON_spec_amount ("fee_refresh", TALER_JSON_spec_amount ("fee_refresh",
&fee_refresh), &fee_refresh),
TALER_JSON_spec_amount ("fee_refund",
&fee_refund),
GNUNET_JSON_spec_rsa_public_key ("denom_pub", GNUNET_JSON_spec_rsa_public_key ("denom_pub",
&pk), &pk),
GNUNET_JSON_spec_end() GNUNET_JSON_spec_end()
@ -309,6 +312,8 @@ parse_json_denomkey (struct TALER_EXCHANGE_DenomPublicKey *denom_key,
&fee_deposit); &fee_deposit);
TALER_amount_hton (&denom_key_issue.fee_refresh, TALER_amount_hton (&denom_key_issue.fee_refresh,
&fee_refresh); &fee_refresh);
TALER_amount_hton (&denom_key_issue.fee_refund,
&fee_refund);
EXITIF (GNUNET_SYSERR == EXITIF (GNUNET_SYSERR ==
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY, GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY,
&denom_key_issue.purpose, &denom_key_issue.purpose,
@ -327,6 +332,7 @@ parse_json_denomkey (struct TALER_EXCHANGE_DenomPublicKey *denom_key,
denom_key->fee_withdraw = fee_withdraw; denom_key->fee_withdraw = fee_withdraw;
denom_key->fee_deposit = fee_deposit; denom_key->fee_deposit = fee_deposit;
denom_key->fee_refresh = fee_refresh; denom_key->fee_refresh = fee_refresh;
denom_key->fee_refund = fee_refund;
return GNUNET_OK; return GNUNET_OK;
EXITIF_exit: EXITIF_exit:
@ -435,6 +441,8 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor,
&dk->fee_deposit); &dk->fee_deposit);
TALER_amount_hton (&kv.fee_refresh, TALER_amount_hton (&kv.fee_refresh,
&dk->fee_refresh); &dk->fee_refresh);
TALER_amount_hton (&kv.fee_refund,
&dk->fee_refund);
kv.denom_hash = dk->h_key; kv.denom_hash = dk->h_key;
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_AUDITOR_EXCHANGE_KEYS, GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_AUDITOR_EXCHANGE_KEYS,

View File

@ -48,6 +48,7 @@ duration_legal = 3 years
fee_withdraw = EUR:0.00 fee_withdraw = EUR:0.00
fee_deposit = EUR:0.00 fee_deposit = EUR:0.00
fee_refresh = EUR:0.01 fee_refresh = EUR:0.01
fee_refund = EUR:0.01
rsa_keysize = 1024 rsa_keysize = 1024
[coin_eur_ct_10] [coin_eur_ct_10]
@ -59,6 +60,7 @@ duration_legal = 3 years
fee_withdraw = EUR:0.01 fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01 fee_deposit = EUR:0.01
fee_refresh = EUR:0.03 fee_refresh = EUR:0.03
fee_refund = EUR:0.01
rsa_keysize = 1024 rsa_keysize = 1024
[coin_eur_1] [coin_eur_1]
@ -70,6 +72,7 @@ duration_legal = 3 years
fee_withdraw = EUR:0.01 fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01 fee_deposit = EUR:0.01
fee_refresh = EUR:0.03 fee_refresh = EUR:0.03
fee_refund = EUR:0.01
rsa_keysize = 1024 rsa_keysize = 1024
[coin_eur_5] [coin_eur_5]
@ -81,6 +84,7 @@ duration_legal = 3 years
fee_withdraw = EUR:0.01 fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01 fee_deposit = EUR:0.01
fee_refresh = EUR:0.03 fee_refresh = EUR:0.03
fee_refund = EUR:0.01
rsa_keysize = 1024 rsa_keysize = 1024
[coin_eur_10] [coin_eur_10]
@ -92,4 +96,5 @@ duration_legal = 3 years
fee_withdraw = EUR:0.01 fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01 fee_deposit = EUR:0.01
fee_refresh = EUR:0.03 fee_refresh = EUR:0.03
fee_refund = EUR:0.01
rsa_keysize = 1024 rsa_keysize = 1024

View File

@ -22,4 +22,5 @@
# fee_withdraw = EUR:0.00 # fee_withdraw = EUR:0.00
# fee_deposit = EUR:0.00 # fee_deposit = EUR:0.00
# fee_refresh = EUR:0.01 # fee_refresh = EUR:0.01
# fee_refund = EUR:0.01
# rsa_keysize = 1024 # rsa_keysize = 1024

View File

@ -103,6 +103,12 @@ print_dk (const struct TALER_DenominationKeyValidityPS *dk)
"Refresh fee: %s\n", "Refresh fee: %s\n",
s = TALER_amount_to_string (&a)); s = TALER_amount_to_string (&a));
GNUNET_free (s); GNUNET_free (s);
TALER_amount_ntoh (&a,
&dk->fee_refund);
fprintf (stdout,
"Refund fee: %s\n",
s = TALER_amount_to_string (&a));
GNUNET_free (s);
fprintf (stdout, fprintf (stdout,
"Validity start time: %s\n", "Validity start time: %s\n",

View File

@ -78,6 +78,11 @@ struct CoinTypeNBOP
*/ */
struct TALER_AmountNBO fee_refresh; struct TALER_AmountNBO fee_refresh;
/**
* What is the fee charged for refunds?
*/
struct TALER_AmountNBO fee_refund;
/** /**
* Key size in NBO. * Key size in NBO.
*/ */
@ -140,6 +145,11 @@ struct CoinTypeParams
*/ */
struct TALER_Amount fee_refresh; struct TALER_Amount fee_refresh;
/**
* What is the fee charged for refunds?
*/
struct TALER_Amount fee_refund;
/** /**
* Time at which this coin is supposed to become valid. * Time at which this coin is supposed to become valid.
*/ */
@ -261,6 +271,8 @@ hash_coin_type (const struct CoinTypeParams *p,
&p->fee_deposit); &p->fee_deposit);
TALER_amount_hton (&p_nbo.fee_refresh, TALER_amount_hton (&p_nbo.fee_refresh,
&p->fee_refresh); &p->fee_refresh);
TALER_amount_hton (&p_nbo.fee_refund,
&p->fee_refund);
p_nbo.rsa_keysize = htonl (p->rsa_keysize); p_nbo.rsa_keysize = htonl (p->rsa_keysize);
GNUNET_CRYPTO_hash (&p_nbo, GNUNET_CRYPTO_hash (&p_nbo,
sizeof (struct CoinTypeNBOP), sizeof (struct CoinTypeNBOP),
@ -707,6 +719,17 @@ get_cointype_params (const char *ct,
"fee_refresh"); "fee_refresh");
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (GNUNET_OK !=
TALER_config_get_denom (kcfg,
ct,
"fee_refund",
&params->fee_refund))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
ct,
"fee_refund");
return GNUNET_SYSERR;
}
dir = get_cointype_dir (params); dir = get_cointype_dir (params);
get_anchor (dir, get_anchor (dir,
@ -756,6 +779,8 @@ create_denomkey_issue (const struct CoinTypeParams *params,
&params->fee_deposit); &params->fee_deposit);
TALER_amount_hton (&dki->issue.properties.fee_refresh, TALER_amount_hton (&dki->issue.properties.fee_refresh,
&params->fee_refresh); &params->fee_refresh);
TALER_amount_hton (&dki->issue.properties.fee_refund,
&params->fee_refund);
dki->issue.properties.purpose.purpose dki->issue.properties.purpose.purpose
= htonl (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY); = htonl (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY);
dki->issue.properties.purpose.size dki->issue.properties.purpose.size
@ -776,7 +801,7 @@ create_denomkey_issue (const struct CoinTypeParams *params,
*/ */
static void static void
exchange_keys_update_cointype (void *cls, exchange_keys_update_cointype (void *cls,
const char *coin_alias) const char *coin_alias)
{ {
int *ret = cls; int *ret = cls;
struct CoinTypeParams p; struct CoinTypeParams p;

View File

@ -133,6 +133,7 @@ denom_key_issue_to_json (const struct TALER_DenominationPublicKey *pk,
struct TALER_Amount fee_withdraw; struct TALER_Amount fee_withdraw;
struct TALER_Amount fee_deposit; struct TALER_Amount fee_deposit;
struct TALER_Amount fee_refresh; struct TALER_Amount fee_refresh;
struct TALER_Amount fee_refund;
TALER_amount_ntoh (&value, TALER_amount_ntoh (&value,
&dki->properties.value); &dki->properties.value);
@ -142,8 +143,10 @@ denom_key_issue_to_json (const struct TALER_DenominationPublicKey *pk,
&dki->properties.fee_deposit); &dki->properties.fee_deposit);
TALER_amount_ntoh (&fee_refresh, TALER_amount_ntoh (&fee_refresh,
&dki->properties.fee_refresh); &dki->properties.fee_refresh);
TALER_amount_ntoh (&fee_refund,
&dki->properties.fee_refund);
return return
json_pack ("{s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}", json_pack ("{s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}",
"master_sig", "master_sig",
GNUNET_JSON_from_data (&dki->signature, GNUNET_JSON_from_data (&dki->signature,
sizeof (struct GNUNET_CRYPTO_EddsaSignature)), sizeof (struct GNUNET_CRYPTO_EddsaSignature)),
@ -164,7 +167,9 @@ denom_key_issue_to_json (const struct TALER_DenominationPublicKey *pk,
"fee_deposit", "fee_deposit",
TALER_JSON_from_amount (&fee_deposit), TALER_JSON_from_amount (&fee_deposit),
"fee_refresh", "fee_refresh",
TALER_JSON_from_amount (&fee_refresh)); TALER_JSON_from_amount (&fee_refresh),
"fee_refund",
TALER_JSON_from_amount (&fee_refund));
} }

View File

@ -359,6 +359,9 @@ fake_issue (struct TALER_EXCHANGEDB_DenominationKeyInformationP *issue)
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount_nbo ("EUR:0.1", TALER_string_to_amount_nbo ("EUR:0.1",
&issue->properties.fee_refresh)); &issue->properties.fee_refresh));
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount_nbo ("EUR:0.1",
&issue->properties.fee_refund));
} }

View File

@ -50,6 +50,7 @@ duration_legal = 3 years
fee_withdraw = EUR:0.00 fee_withdraw = EUR:0.00
fee_deposit = EUR:0.00 fee_deposit = EUR:0.00
fee_refresh = EUR:0.01 fee_refresh = EUR:0.01
fee_refund = EUR:0.01
rsa_keysize = 1024 rsa_keysize = 1024
[coin_eur_ct_10] [coin_eur_ct_10]
@ -61,6 +62,7 @@ duration_legal = 3 years
fee_withdraw = EUR:0.01 fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01 fee_deposit = EUR:0.01
fee_refresh = EUR:0.03 fee_refresh = EUR:0.03
fee_refund = EUR:0.01
rsa_keysize = 1024 rsa_keysize = 1024
[coin_eur_1] [coin_eur_1]
@ -72,4 +74,5 @@ duration_legal = 3 years
fee_withdraw = EUR:0.01 fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01 fee_deposit = EUR:0.01
fee_refresh = EUR:0.03 fee_refresh = EUR:0.03
fee_refund = EUR:0.01
rsa_keysize = 1024 rsa_keysize = 1024

View File

@ -1,6 +1,6 @@
/* /*
This file is part of TALER This file is part of TALER
Copyright (C) 2014, 2015 GNUnet e.V. Copyright (C) 2014, 2015, 2016 Inria and GNUnet e.V.
TALER is free software; you can redistribute it and/or modify it under the 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 terms of the GNU General Public License as published by the Free Software
@ -17,6 +17,7 @@
* @file exchangedb/perf_taler_exchangedb.c * @file exchangedb/perf_taler_exchangedb.c
* @brief Exchange database performance analysis * @brief Exchange database performance analysis
* @author Nicolas Fournier * @author Nicolas Fournier
* @author Christian Grothoff
*/ */
#include "platform.h" #include "platform.h"
#include "perf_taler_exchangedb_interpreter.h" #include "perf_taler_exchangedb_interpreter.h"

View File

@ -1,6 +1,6 @@
/* /*
This file is part of TALER This file is part of TALER
Copyright (C) 2014, 2015 GNUnet e.V. Copyright (C) 2014, 2015, 2016 Inria & GNUnet e.V.
TALER is free software; you can redistribute it and/or modify it under the 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 terms of the GNU General Public License as published by the Free Software
@ -17,6 +17,7 @@
* @file exchangedb/perf_taler_exchangedb_init.c * @file exchangedb/perf_taler_exchangedb_init.c
* @brief Interpreter library for exchange database performance analysis * @brief Interpreter library for exchange database performance analysis
* @author Nicolas Fournier * @author Nicolas Fournier
* @author Christian Grothoff
*/ */
#include "platform.h" #include "platform.h"
#include "perf_taler_exchangedb_init.h" #include "perf_taler_exchangedb_init.h"
@ -75,6 +76,7 @@ PERF_TALER_EXCHANGEDB_denomination_init ()
TALER_amount_hton (&properties.fee_withdraw, &amount); TALER_amount_hton (&properties.fee_withdraw, &amount);
TALER_amount_hton (&properties.fee_deposit, &amount); TALER_amount_hton (&properties.fee_deposit, &amount);
TALER_amount_hton (&properties.fee_refresh, &amount); TALER_amount_hton (&properties.fee_refresh, &amount);
TALER_amount_hton (&properties.fee_refund, &amount);
GNUNET_CRYPTO_rsa_public_key_hash (denom_pub.rsa_public_key, GNUNET_CRYPTO_rsa_public_key_hash (denom_pub.rsa_public_key,
&properties.denom_hash); &properties.denom_hash);
issue.properties = properties; issue.properties = properties;

View File

@ -79,8 +79,7 @@ PERF_TALER_EXCHANGEDB_denomination_init (void);
* @return a copy of @a deposit; NULL if error * @return a copy of @a deposit; NULL if error
*/ */
struct TALER_EXCHANGEDB_DenominationKeyIssueInformation * struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *
PERF_TALER_EXCHANGEDB_denomination_copy ( PERF_TALER_EXCHANGEDB_denomination_copy (const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki);
const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki);
/** /**
@ -88,8 +87,7 @@ PERF_TALER_EXCHANGEDB_denomination_copy (
* @param dki pointer to the struct to free * @param dki pointer to the struct to free
*/ */
int int
PERF_TALER_EXCHANGEDB_denomination_free ( PERF_TALER_EXCHANGEDB_denomination_free (struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki);
struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki);
/** /**
@ -122,8 +120,7 @@ PERF_TALER_EXCHANGEDB_reserve_free (struct PERF_TALER_EXCHANGEDB_Reserve *reserv
* @param dki the denomination key used to sign the key * @param dki the denomination key used to sign the key
*/ */
struct TALER_EXCHANGEDB_Deposit * struct TALER_EXCHANGEDB_Deposit *
PERF_TALER_EXCHANGEDB_deposit_init ( PERF_TALER_EXCHANGEDB_deposit_init (const struct PERF_TALER_EXCHANGEDB_Coin *coin);
const struct PERF_TALER_EXCHANGEDB_Coin *coin);
/** /**
@ -150,9 +147,8 @@ PERF_TALER_EXCHANGEDB_deposit_free (struct TALER_EXCHANGEDB_Deposit *deposit);
* @return a randomly generated CollectableBlindcoin * @return a randomly generated CollectableBlindcoin
*/ */
struct PERF_TALER_EXCHANGEDB_Coin * struct PERF_TALER_EXCHANGEDB_Coin *
PERF_TALER_EXCHANGEDB_coin_init ( PERF_TALER_EXCHANGEDB_coin_init (const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki,
const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki, const struct PERF_TALER_EXCHANGEDB_Reserve *reserve);
const struct PERF_TALER_EXCHANGEDB_Reserve *reserve);
/** /**
@ -161,8 +157,7 @@ PERF_TALER_EXCHANGEDB_coin_init (
* @return a copy of coin; NULL if error * @return a copy of coin; NULL if error
*/ */
struct PERF_TALER_EXCHANGEDB_Coin * struct PERF_TALER_EXCHANGEDB_Coin *
PERF_TALER_EXCHANGEDB_coin_copy ( PERF_TALER_EXCHANGEDB_coin_copy (const struct PERF_TALER_EXCHANGEDB_Coin *coin);
const struct PERF_TALER_EXCHANGEDB_Coin *coin);
/** /**
@ -170,8 +165,7 @@ PERF_TALER_EXCHANGEDB_coin_copy (
* @param coin pointer to the structure to free * @param coin pointer to the structure to free
*/ */
int int
PERF_TALER_EXCHANGEDB_coin_free ( PERF_TALER_EXCHANGEDB_coin_free (struct PERF_TALER_EXCHANGEDB_Coin *coin);
struct PERF_TALER_EXCHANGEDB_Coin *coin);
/** /**
@ -186,15 +180,14 @@ PERF_TALER_EXCHANGEDB_refresh_session_init (void);
*/ */
int int
PERF_TALER_EXCHANGEDB_refresh_session_copy (struct TALER_EXCHANGEDB_RefreshSession *session, PERF_TALER_EXCHANGEDB_refresh_session_copy (struct TALER_EXCHANGEDB_RefreshSession *session,
struct TALER_EXCHANGEDB_RefreshSession *copy); struct TALER_EXCHANGEDB_RefreshSession *copy);
/** /**
* Frees memory of a refresh_session * Frees memory of a refresh_session
*/ */
int int
PERF_TALER_EXCHANGEDB_refresh_session_free ( PERF_TALER_EXCHANGEDB_refresh_session_free (struct TALER_EXCHANGEDB_RefreshSession *refresh_session);
struct TALER_EXCHANGEDB_RefreshSession *refresh_session);
/** /**

View File

@ -272,6 +272,9 @@ postgres_create_tables (void *cls,
",fee_refresh_val INT8 NOT NULL" ",fee_refresh_val INT8 NOT NULL"
",fee_refresh_frac INT4 NOT NULL" ",fee_refresh_frac INT4 NOT NULL"
",fee_refresh_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL" ",fee_refresh_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
",fee_refund_val INT8 NOT NULL"
",fee_refund_frac INT4 NOT NULL"
",fee_refund_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
")"); ")");
/* reserves table is for summarization of a reserve. It is updated when new /* reserves table is for summarization of a reserve. It is updated when new
funds are added and existing funds are withdrawn. The 'expiration_date' funds are added and existing funds are withdrawn. The 'expiration_date'
@ -544,10 +547,14 @@ postgres_prepare (PGconn *db_conn)
",fee_refresh_val" ",fee_refresh_val"
",fee_refresh_frac" ",fee_refresh_frac"
",fee_refresh_curr" /* must match coin_curr */ ",fee_refresh_curr" /* must match coin_curr */
",fee_refund_val"
",fee_refund_frac"
",fee_refund_curr" /* must match coin_curr */
") VALUES " ") VALUES "
"($1, $2, $3, $4, $5, $6, $7, $8, $9, $10," "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10,"
" $11, $12, $13, $14, $15, $16, $17, $18, $19);", " $11, $12, $13, $14, $15, $16, $17, $18,"
19, NULL); " $19, $20, $21, $22);",
22, NULL);
/* Used in #postgres_get_denomination_info() */ /* Used in #postgres_get_denomination_info() */
PREPARE ("denomination_get", PREPARE ("denomination_get",
@ -570,6 +577,9 @@ postgres_prepare (PGconn *db_conn)
",fee_refresh_val" ",fee_refresh_val"
",fee_refresh_frac" ",fee_refresh_frac"
",fee_refresh_curr" /* must match coin_curr */ ",fee_refresh_curr" /* must match coin_curr */
",fee_refund_val"
",fee_refund_frac"
",fee_refund_curr" /* must match coin_curr */
" FROM denominations" " FROM denominations"
" WHERE pub=$1;", " WHERE pub=$1;",
1, NULL); 1, NULL);
@ -1378,6 +1388,7 @@ postgres_insert_denomination_info (void *cls,
TALER_PQ_query_param_amount_nbo (&issue->properties.fee_withdraw), TALER_PQ_query_param_amount_nbo (&issue->properties.fee_withdraw),
TALER_PQ_query_param_amount_nbo (&issue->properties.fee_deposit), TALER_PQ_query_param_amount_nbo (&issue->properties.fee_deposit),
TALER_PQ_query_param_amount_nbo (&issue->properties.fee_refresh), TALER_PQ_query_param_amount_nbo (&issue->properties.fee_refresh),
TALER_PQ_query_param_amount_nbo (&issue->properties.fee_refund),
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
}; };
/* check fees match coin currency */ /* check fees match coin currency */
@ -1390,6 +1401,9 @@ postgres_insert_denomination_info (void *cls,
GNUNET_assert (GNUNET_YES == GNUNET_assert (GNUNET_YES ==
TALER_amount_cmp_currency_nbo (&issue->properties.value, TALER_amount_cmp_currency_nbo (&issue->properties.value,
&issue->properties.fee_refresh)); &issue->properties.fee_refresh));
GNUNET_assert (GNUNET_YES ==
TALER_amount_cmp_currency_nbo (&issue->properties.value,
&issue->properties.fee_refund));
result = GNUNET_PQ_exec_prepared (session->conn, result = GNUNET_PQ_exec_prepared (session->conn,
"denomination_insert", "denomination_insert",
@ -1476,6 +1490,8 @@ postgres_get_denomination_info (void *cls,
&issue->properties.fee_deposit), &issue->properties.fee_deposit),
TALER_PQ_result_spec_amount_nbo ("fee_refresh", TALER_PQ_result_spec_amount_nbo ("fee_refresh",
&issue->properties.fee_refresh), &issue->properties.fee_refresh),
TALER_PQ_result_spec_amount_nbo ("fee_refund",
&issue->properties.fee_refund),
GNUNET_PQ_result_spec_end GNUNET_PQ_result_spec_end
}; };

View File

@ -16,7 +16,8 @@
/** /**
* @file exchangedb/test_exchangedb.c * @file exchangedb/test_exchangedb.c
* @brief test cases for DB interaction functions * @brief test cases for DB interaction functions
* @author Sree Harsha Totakura <sreeharsha@totakura.in> * @author Sree Harsha Totakura
* @author Christian Grothoff
*/ */
#include "platform.h" #include "platform.h"
#include "taler_exchangedb_lib.h" #include "taler_exchangedb_lib.h"
@ -114,7 +115,8 @@ create_denom_key_pair (unsigned int size,
const struct TALER_Amount *value, const struct TALER_Amount *value,
const struct TALER_Amount *fee_withdraw, const struct TALER_Amount *fee_withdraw,
const struct TALER_Amount *fee_deposit, const struct TALER_Amount *fee_deposit,
const struct TALER_Amount *fee_refresh) const struct TALER_Amount *fee_refresh,
const struct TALER_Amount *fee_refund)
{ {
struct DenomKeyPair *dkp; struct DenomKeyPair *dkp;
struct TALER_EXCHANGEDB_DenominationKeyIssueInformation dki; struct TALER_EXCHANGEDB_DenominationKeyIssueInformation dki;
@ -147,6 +149,7 @@ create_denom_key_pair (unsigned int size,
TALER_amount_hton (&dki.issue.properties.fee_withdraw, fee_withdraw); TALER_amount_hton (&dki.issue.properties.fee_withdraw, fee_withdraw);
TALER_amount_hton (&dki.issue.properties.fee_deposit, fee_deposit); TALER_amount_hton (&dki.issue.properties.fee_deposit, fee_deposit);
TALER_amount_hton (&dki.issue.properties.fee_refresh, fee_refresh); TALER_amount_hton (&dki.issue.properties.fee_refresh, fee_refresh);
TALER_amount_hton (&dki.issue.properties.fee_refund, fee_refund);
GNUNET_CRYPTO_rsa_public_key_hash (dkp->pub.rsa_public_key, GNUNET_CRYPTO_rsa_public_key_hash (dkp->pub.rsa_public_key,
&dki.issue.properties.denom_hash); &dki.issue.properties.denom_hash);
if (GNUNET_OK != if (GNUNET_OK !=
@ -166,11 +169,11 @@ static struct TALER_Amount value;
static struct TALER_Amount fee_withdraw; static struct TALER_Amount fee_withdraw;
static struct TALER_Amount fee_deposit; static struct TALER_Amount fee_deposit;
static struct TALER_Amount fee_refresh; static struct TALER_Amount fee_refresh;
static struct TALER_Amount fee_refund;
static struct TALER_Amount amount_with_fee; static struct TALER_Amount amount_with_fee;
static void static void
free_refresh_commit_coins_array(struct TALER_EXCHANGEDB_RefreshCommitCoin free_refresh_commit_coins_array(struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coins,
*commit_coins,
unsigned int size) unsigned int size)
{ {
unsigned int cnt; unsigned int cnt;
@ -205,7 +208,7 @@ test_refresh_commit_coins (struct TALER_EXCHANGEDB_Session *session,
uint16_t cnc_index; uint16_t cnc_index;
int ret; int ret;
#define COIN_ENC_MAX_SIZE 512 #define COIN_ENC_MAX_SIZE 512
ret = GNUNET_SYSERR; ret = GNUNET_SYSERR;
ret_commit_coins = NULL; ret_commit_coins = NULL;
commit_coins = GNUNET_new_array (MELT_NEW_COINS, commit_coins = GNUNET_new_array (MELT_NEW_COINS,
@ -331,7 +334,8 @@ test_melting (struct TALER_EXCHANGEDB_Session *session)
&value, &value,
&fee_withdraw, &fee_withdraw,
&fee_deposit, &fee_deposit,
&fee_refresh); &fee_refresh,
&fee_refund);
/* create MELT_OLD_COINS number of refresh melts */ /* create MELT_OLD_COINS number of refresh melts */
melts = GNUNET_new_array (MELT_OLD_COINS, struct TALER_EXCHANGEDB_RefreshMelt); melts = GNUNET_new_array (MELT_OLD_COINS, struct TALER_EXCHANGEDB_RefreshMelt);
for (cnt=0; cnt < MELT_OLD_COINS; cnt++) for (cnt=0; cnt < MELT_OLD_COINS; cnt++)
@ -394,7 +398,8 @@ test_melting (struct TALER_EXCHANGEDB_Session *session)
&value, &value,
&fee_withdraw, &fee_withdraw,
&fee_deposit, &fee_deposit,
&fee_refresh); &fee_refresh,
&fee_refund);
new_denom_pubs[cnt]=new_dkp[cnt]->pub; new_denom_pubs[cnt]=new_dkp[cnt]->pub;
} }
FAILIF (GNUNET_OK != plugin->insert_refresh_order (plugin->cls, FAILIF (GNUNET_OK != plugin->insert_refresh_order (plugin->cls,
@ -683,6 +688,9 @@ run (void *cls)
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY ":0.000010", TALER_string_to_amount (CURRENCY ":0.000010",
&fee_refresh)); &fee_refresh));
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY ":0.000010",
&fee_refund));
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (CURRENCY ":1.000010", TALER_string_to_amount (CURRENCY ":1.000010",
&amount_with_fee)); &amount_with_fee));
@ -723,7 +731,8 @@ run (void *cls)
&value, &value,
&fee_withdraw, &fee_withdraw,
&fee_deposit, &fee_deposit,
&fee_refresh); &fee_refresh,
&fee_refund);
RND_BLK(&cbc.h_coin_envelope); RND_BLK(&cbc.h_coin_envelope);
RND_BLK(&cbc.reserve_sig); RND_BLK(&cbc.reserve_sig);
cbc.denom_pub = dkp->pub; cbc.denom_pub = dkp->pub;

View File

@ -122,9 +122,14 @@ struct TALER_EXCHANGE_DenomPublicKey
struct TALER_Amount fee_deposit; struct TALER_Amount fee_deposit;
/** /**
*The applicable fee to melt/refresh a coin of this denomination * The applicable fee to melt/refresh a coin of this denomination
*/ */
struct TALER_Amount fee_refresh; struct TALER_Amount fee_refresh;
/**
* The applicable fee to refund a coin of this denomination
*/
struct TALER_Amount fee_refund;
}; };

View File

@ -639,6 +639,13 @@ struct TALER_DenominationKeyValidityPS
*/ */
struct TALER_AmountNBO fee_refresh; struct TALER_AmountNBO fee_refresh;
/**
* The fee the exchange charges when a coin of this type is refunded.
* (can be zero). Note that refund fees are charged to the customer;
* if a refund is given, the deposit fee is also refunded.
*/
struct TALER_AmountNBO fee_refund;
/** /**
* Hash code of the denomination public key. (Used to avoid having * Hash code of the denomination public key. (Used to avoid having
* the variable-size RSA key in this struct.) * the variable-size RSA key in this struct.)
@ -735,6 +742,12 @@ struct TALER_ExchangeKeyValidityPS
*/ */
struct TALER_AmountNBO fee_refresh; struct TALER_AmountNBO fee_refresh;
/**
* The fee the exchange charges when a coin of this type is refreshed.
* (can be zero).
*/
struct TALER_AmountNBO fee_refund;
/** /**
* Hash code of the denomination public key. (Used to avoid having * Hash code of the denomination public key. (Used to avoid having
* the variable-size RSA key in this struct.) * the variable-size RSA key in this struct.)