work on global fee structure

This commit is contained in:
Christian Grothoff 2022-03-05 15:13:07 +01:00
parent 841e56bafd
commit 5fa977cc05
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
5 changed files with 113 additions and 1 deletions

View File

@ -858,6 +858,14 @@ CREATE TABLE IF NOT EXISTS global_fee
,history_fee_frac INT4 NOT NULL
,kyc_fee_val INT8 NOT NULL
,kyc_fee_frac INT4 NOT NULL
,account_fee_val INT8 NOT NULL
,account_fee_frac INT4 NOT NULL
,purse_fee_val INT8 NOT NULL
,purse_fee_frac INT4 NOT NULL
,purse_timeout INT8 NOT NULL
,kyc_timeout INT8 NOT NULL
,history_expiration INT8 NOT NULL
,purse_account_limit INT4 NOT NULL
,master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64)
,PRIMARY KEY (start_date)
);

View File

@ -695,6 +695,18 @@ struct TALER_GlobalFeeSetNBOP
*/
struct TALER_AmountNBO kyc;
/**
* The fee the exchange charges for keeping
* an account or reserve open for a year.
*/
struct TALER_AmountNBO account;
/**
* The fee the exchange charges if a purse
* is abandoned and this was not covered by
* the account limit.
*/
struct TALER_AmountNBO purse;
};
@ -783,6 +795,18 @@ struct TALER_GlobalFeeSet
*/
struct TALER_Amount kyc;
/**
* The fee the exchange charges for keeping
* an account or reserve open for a year.
*/
struct TALER_Amount account;
/**
* The fee the exchange charges if a purse
* is abandoned and this was not covered by
* the account limit.
*/
struct TALER_Amount purse;
};
@ -3296,6 +3320,10 @@ TALER_exchange_offline_wire_fee_verify (
* @param start_time when do the fees start to apply
* @param end_time when do the fees start to apply
* @param fees the global fees
* @param purse_timeout how long do unmerged purses stay around
* @param kyc_timeout how long do we keep funds in a reserve without KYC?
* @param history_expiration how long do we keep the history of an account
* @param purse_account_limit how many concurrent purses are free per account holder
* @param master_priv private key to sign with
* @param[out] master_sig where to write the signature
*/
@ -3304,6 +3332,10 @@ TALER_exchange_offline_global_fee_sign (
struct GNUNET_TIME_Timestamp start_time,
struct GNUNET_TIME_Timestamp end_time,
const struct TALER_GlobalFeeSet *fees,
struct GNUNET_TIME_Relative purse_timeout,
struct GNUNET_TIME_Relative kyc_timeout,
struct GNUNET_TIME_Relative history_expiration,
uint32_t purse_account_limit,
const struct TALER_MasterPrivateKeyP *master_priv,
struct TALER_MasterSignatureP *master_sig);
@ -3314,6 +3346,10 @@ TALER_exchange_offline_global_fee_sign (
* @param start_time when do the fees start to apply
* @param end_time when do the fees start to apply
* @param fees the global fees
* @param purse_timeout how long do unmerged purses stay around
* @param kyc_timeout how long do we keep funds in a reserve without KYC?
* @param history_expiration how long do we keep the history of an account
* @param purse_account_limit how many concurrent purses are free per account holder
* @param master_pub public key to verify against
* @param master_sig the signature the signature
* @return #GNUNET_OK if the signature is valid
@ -3323,6 +3359,10 @@ TALER_exchange_offline_global_fee_verify (
struct GNUNET_TIME_Timestamp start_time,
struct GNUNET_TIME_Timestamp end_time,
const struct TALER_GlobalFeeSet *fees,
struct GNUNET_TIME_Relative purse_timeout,
struct GNUNET_TIME_Relative kyc_timeout,
struct GNUNET_TIME_Relative history_expiration,
uint32_t purse_account_limit,
const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_MasterSignatureP *master_sig);

View File

@ -1274,11 +1274,43 @@ struct TALER_MasterGlobalFeePS
*/
struct GNUNET_TIME_TimestampNBO end_date;
/**
* How long does an exchange keep a purse around after a purse
* has expired (or been successfully merged)? A 'GET' request
* for a purse will succeed until the purse expiration time
* plus this value.
*/
struct GNUNET_TIME_RelativeNBO purse_timeout;
/**
* How long does the exchange promise to keep funds
* an account for which the KYC has never happened
* after a purse was merged into an account? Basically,
* after this time funds in an account without KYC are
* forfeit.
*/
struct GNUNET_TIME_RelativeNBO kyc_timeout;
/**
* How long will the exchange preserve the account history? After an
* account was deleted/closed, the exchange will retain the account history
* for legal reasons until this time.
*/
struct GNUNET_TIME_RelativeNBO history_expiration;
/**
* Fee charged to the merchant per wire transfer.
*/
struct TALER_GlobalFeeSetNBOP fees;
/**
* Number of concurrent purses that any
* account holder is allowed to create without having
* to pay the @e purse_fee. Here given in NBO.
*/
uint32_t purse_account_limit;
};

View File

@ -471,6 +471,10 @@ TALER_exchange_offline_global_fee_sign (
struct GNUNET_TIME_Timestamp start_time,
struct GNUNET_TIME_Timestamp end_time,
const struct TALER_GlobalFeeSet *fees,
struct GNUNET_TIME_Relative purse_timeout,
struct GNUNET_TIME_Relative kyc_timeout,
struct GNUNET_TIME_Relative history_expiration,
uint32_t purse_account_limit,
const struct TALER_MasterPrivateKeyP *master_priv,
struct TALER_MasterSignatureP *master_sig)
{
@ -479,6 +483,10 @@ TALER_exchange_offline_global_fee_sign (
.purpose.size = htonl (sizeof (kv)),
.start_date = GNUNET_TIME_timestamp_hton (start_time),
.end_date = GNUNET_TIME_timestamp_hton (end_time),
.purse_timeout = GNUNET_TIME_relative_hton (purse_timeout),
.kyc_timeout = GNUNET_TIME_relative_hton (kyc_timeout),
.history_expiration = GNUNET_TIME_relative_hton (history_expiration),
.purse_account_limit = htonl (purse_account_limit)
};
TALER_global_fee_set_hton (&kv.fees,
@ -494,6 +502,10 @@ TALER_exchange_offline_global_fee_verify (
struct GNUNET_TIME_Timestamp start_time,
struct GNUNET_TIME_Timestamp end_time,
const struct TALER_GlobalFeeSet *fees,
struct GNUNET_TIME_Relative purse_timeout,
struct GNUNET_TIME_Relative kyc_timeout,
struct GNUNET_TIME_Relative history_expiration,
uint32_t purse_account_limit,
const struct TALER_MasterPublicKeyP *master_pub,
const struct TALER_MasterSignatureP *master_sig)
{
@ -501,7 +513,11 @@ TALER_exchange_offline_global_fee_verify (
.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_GLOBAL_FEES),
.purpose.size = htonl (sizeof (wf)),
.start_date = GNUNET_TIME_timestamp_hton (start_time),
.end_date = GNUNET_TIME_timestamp_hton (end_time)
.end_date = GNUNET_TIME_timestamp_hton (end_time),
.purse_timeout = GNUNET_TIME_relative_hton (purse_timeout),
.kyc_timeout = GNUNET_TIME_relative_hton (kyc_timeout),
.history_expiration = GNUNET_TIME_relative_hton (history_expiration),
.purse_account_limit = htonl (purse_account_limit)
};
TALER_global_fee_set_hton (&wf.fees,

View File

@ -84,6 +84,10 @@ TALER_global_fee_set_hton (struct TALER_GlobalFeeSetNBOP *nbo,
&fees->history);
TALER_amount_hton (&nbo->kyc,
&fees->kyc);
TALER_amount_hton (&nbo->account,
&fees->account);
TALER_amount_hton (&nbo->purse,
&fees->purse);
}
@ -95,6 +99,10 @@ TALER_global_fee_set_ntoh (struct TALER_GlobalFeeSet *fees,
&nbo->history);
TALER_amount_ntoh (&fees->kyc,
&nbo->kyc);
TALER_amount_ntoh (&fees->account,
&nbo->account);
TALER_amount_ntoh (&fees->purse,
&nbo->purse);
}
@ -138,6 +146,14 @@ TALER_global_fee_set_cmp (const struct TALER_GlobalFeeSet *f1,
&f2->kyc);
if (0 != ret)
return ret;
ret = TALER_amount_cmp (&f1->account,
&f2->account);
if (0 != ret)
return ret;
ret = TALER_amount_cmp (&f1->purse,
&f2->purse);
if (0 != ret)
return ret;
return 0;
}