summaryrefslogtreecommitdiff
path: root/src/auditor
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2022-03-31 12:37:39 +0200
committerChristian Grothoff <grothoff@gnunet.org>2022-03-31 12:37:39 +0200
commit747ae5ef094731650911838a51e49db778b18ab6 (patch)
tree967b8e61f5bd746a21de645f989d65aa323b6aa4 /src/auditor
parenteadee56dcf9d2fed8b8e94d271db31e3c3832cfa (diff)
downloadexchange-747ae5ef094731650911838a51e49db778b18ab6.tar.gz
exchange-747ae5ef094731650911838a51e49db778b18ab6.tar.bz2
exchange-747ae5ef094731650911838a51e49db778b18ab6.zip
privatize more signature structs, simplify code
Diffstat (limited to 'src/auditor')
-rw-r--r--src/auditor/report-lib.c39
-rw-r--r--src/auditor/report-lib.h4
-rw-r--r--src/auditor/taler-auditor-httpd_deposit-confirmation.c48
-rw-r--r--src/auditor/taler-helper-auditor-aggregation.c85
-rw-r--r--src/auditor/taler-helper-auditor-coins.c239
-rw-r--r--src/auditor/taler-helper-auditor-reserves.c28
6 files changed, 195 insertions, 248 deletions
diff --git a/src/auditor/report-lib.c b/src/auditor/report-lib.c
index 5337b17b4..8d783e0cf 100644
--- a/src/auditor/report-lib.c
+++ b/src/auditor/report-lib.c
@@ -68,7 +68,7 @@ struct GNUNET_TIME_Absolute start_time;
/**
* Results about denominations, cached per-transaction, maps denomination pub hashes
- * to `struct TALER_DenominationKeyValidityPS`.
+ * to `const struct TALER_EXCHANGEDB_DenominationKeyInformation`.
*/
static struct GNUNET_CONTAINER_MultiHashMap *denominations;
@@ -114,16 +114,14 @@ TALER_ARL_report (json_t *array,
*
* @param cls closure, NULL
* @param denom_pub public key, sometimes NULL (!)
- * @param validity issuing information with value, fees and other info about the denomination.
+ * @param issue issuing information with value, fees and other info about the denomination.
*/
static void
add_denomination (
void *cls,
const struct TALER_DenominationPublicKey *denom_pub,
- const struct TALER_EXCHANGEDB_DenominationKeyInformationP *validity)
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation *issue)
{
- const struct TALER_DenominationKeyValidityPS *issue = &validity->properties;
-
(void) cls;
(void) denom_pub;
if (NULL !=
@@ -132,35 +130,26 @@ add_denomination (
return; /* value already known */
#if GNUNET_EXTRA_LOGGING >= 1
{
- struct TALER_Amount value;
-
- TALER_amount_ntoh (&value,
- &issue->value);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Tracking denomination `%s' (%s)\n",
GNUNET_h2s (&issue->denom_hash.hash),
- TALER_amount2s (&value));
- TALER_amount_ntoh (&value,
- &issue->fees.withdraw);
+ TALER_amount2s (&issue->value));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Withdraw fee is %s\n",
- TALER_amount2s (&value));
+ TALER_amount2s (&issue->fees.withdraw));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Start time is %s\n",
- GNUNET_TIME_timestamp2s
- (GNUNET_TIME_timestamp_ntoh (issue->start)));
+ GNUNET_TIME_timestamp2s (issue->start));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Expire deposit time is %s\n",
- GNUNET_TIME_timestamp2s
- (GNUNET_TIME_timestamp_ntoh (issue->expire_deposit)));
+ GNUNET_TIME_timestamp2s (issue->expire_deposit));
}
#endif
{
- struct TALER_DenominationKeyValidityPS *i;
+ struct TALER_EXCHANGEDB_DenominationKeyInformation *i;
- i = GNUNET_new (struct TALER_DenominationKeyValidityPS);
+ i = GNUNET_new (struct TALER_EXCHANGEDB_DenominationKeyInformation);
*i = *issue;
- i->master = TALER_ARL_master_pub;
GNUNET_assert (GNUNET_OK ==
GNUNET_CONTAINER_multihashmap_put (denominations,
&issue->denom_hash.hash,
@@ -173,7 +162,7 @@ add_denomination (
enum GNUNET_DB_QueryStatus
TALER_ARL_get_denomination_info_by_hash (
const struct TALER_DenominationHashP *dh,
- const struct TALER_DenominationKeyValidityPS **issue)
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation **issue)
{
enum GNUNET_DB_QueryStatus qs;
@@ -192,7 +181,7 @@ TALER_ARL_get_denomination_info_by_hash (
}
}
{
- const struct TALER_DenominationKeyValidityPS *i;
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation *i;
i = GNUNET_CONTAINER_multihashmap_get (denominations,
&dh->hash);
@@ -205,7 +194,7 @@ TALER_ARL_get_denomination_info_by_hash (
}
/* maybe database changed since we last iterated, give it one more shot */
{
- struct TALER_EXCHANGEDB_DenominationKeyInformationP issue;
+ struct TALER_EXCHANGEDB_DenominationKeyInformation issue;
qs = TALER_ARL_edb->get_denomination_info (TALER_ARL_edb->cls,
dh,
@@ -224,7 +213,7 @@ TALER_ARL_get_denomination_info_by_hash (
&issue);
}
{
- const struct TALER_DenominationKeyValidityPS *i;
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation *i;
i = GNUNET_CONTAINER_multihashmap_get (denominations,
&dh->hash);
@@ -246,7 +235,7 @@ TALER_ARL_get_denomination_info_by_hash (
enum GNUNET_DB_QueryStatus
TALER_ARL_get_denomination_info (
const struct TALER_DenominationPublicKey *denom_pub,
- const struct TALER_DenominationKeyValidityPS **issue,
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation **issue,
struct TALER_DenominationHashP *dh)
{
struct TALER_DenominationHashP hc;
diff --git a/src/auditor/report-lib.h b/src/auditor/report-lib.h
index 92560a0b3..8054baa46 100644
--- a/src/auditor/report-lib.h
+++ b/src/auditor/report-lib.h
@@ -102,7 +102,7 @@ TALER_ARL_report (json_t *array,
enum GNUNET_DB_QueryStatus
TALER_ARL_get_denomination_info_by_hash (
const struct TALER_DenominationHashP *dh,
- const struct TALER_DenominationKeyValidityPS **issue);
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation **issue);
/**
@@ -117,7 +117,7 @@ TALER_ARL_get_denomination_info_by_hash (
enum GNUNET_DB_QueryStatus
TALER_ARL_get_denomination_info (
const struct TALER_DenominationPublicKey *denom_pub,
- const struct TALER_DenominationKeyValidityPS **issue,
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation **issue,
struct TALER_DenominationHashP *dh);
diff --git a/src/auditor/taler-auditor-httpd_deposit-confirmation.c b/src/auditor/taler-auditor-httpd_deposit-confirmation.c
index 6042b7409..f4d89b7ca 100644
--- a/src/auditor/taler-auditor-httpd_deposit-confirmation.c
+++ b/src/auditor/taler-auditor-httpd_deposit-confirmation.c
@@ -32,6 +32,50 @@
#include "taler-auditor-httpd_deposit-confirmation.h"
+GNUNET_NETWORK_STRUCT_BEGIN
+
+/**
+ * @brief Information about a signing key of the exchange. Signing keys are used
+ * to sign exchange messages other than coins, i.e. to confirm that a
+ * deposit was successful or that a refresh was accepted.
+ */
+struct ExchangeSigningKeyDataP
+{
+
+ /**
+ * When does this signing key begin to be valid?
+ */
+ struct GNUNET_TIME_TimestampNBO start;
+
+ /**
+ * When does this signing key expire? Note: This is currently when
+ * the Exchange will definitively stop using it. Signatures made with
+ * the key remain valid until @e end. When checking validity periods,
+ * clients should allow for some overlap between keys and tolerate
+ * the use of either key during the overlap time (due to the
+ * possibility of clock skew).
+ */
+ struct GNUNET_TIME_TimestampNBO expire;
+
+ /**
+ * When do signatures with this signing key become invalid? After
+ * this point, these signatures cannot be used in (legal) disputes
+ * anymore, as the Exchange is then allowed to destroy its side of the
+ * evidence. @e end is expected to be significantly larger than @e
+ * expire (by a year or more).
+ */
+ struct GNUNET_TIME_TimestampNBO end;
+
+ /**
+ * The public online signing key that the exchange will use
+ * between @e start and @e expire.
+ */
+ struct TALER_ExchangePublicKeyP signkey_pub;
+};
+
+GNUNET_NETWORK_STRUCT_END
+
+
/**
* Cache of already verified exchange signing keys. Maps the hash of the
* `struct TALER_ExchangeSigningKeyValidityPS` to the (static) string
@@ -65,9 +109,7 @@ verify_and_execute_deposit_confirmation (
enum GNUNET_DB_QueryStatus qs;
struct GNUNET_HashCode h;
const char *cached;
- struct TALER_ExchangeSigningKeyValidityPS skv = {
- .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY),
- .purpose.size = htonl (sizeof (struct TALER_ExchangeSigningKeyValidityPS)),
+ struct ExchangeSigningKeyDataP skv = {
.start = GNUNET_TIME_timestamp_hton (es->ep_start),
.expire = GNUNET_TIME_timestamp_hton (es->ep_expire),
.end = GNUNET_TIME_timestamp_hton (es->ep_end),
diff --git a/src/auditor/taler-helper-auditor-aggregation.c b/src/auditor/taler-helper-auditor-aggregation.c
index da10ae760..20edb5f3d 100644
--- a/src/auditor/taler-helper-auditor-aggregation.c
+++ b/src/auditor/taler-helper-auditor-aggregation.c
@@ -390,7 +390,7 @@ check_transaction_history_for_deposit (
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_PrivateContractHashP *h_contract_terms,
const struct TALER_MerchantPublicKeyP *merchant_pub,
- const struct TALER_DenominationKeyValidityPS *issue,
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation *issue,
const struct TALER_EXCHANGEDB_TransactionList *tl_head,
struct TALER_Amount *merchant_gain,
struct TALER_Amount *deposit_gain)
@@ -461,23 +461,16 @@ check_transaction_history_for_deposit (
deposit_fee = fee_claimed; /* We had a deposit, remember the fee, we may need it */
}
/* Check that the fees given in the transaction list and in dki match */
+ if (0 !=
+ TALER_amount_cmp (&issue->fees.deposit,
+ fee_claimed))
{
- struct TALER_Amount fee_expected;
-
- /* Fee according to denomination data of auditor */
- TALER_amount_ntoh (&fee_expected,
- &issue->fees.deposit);
- if (0 !=
- TALER_amount_cmp (&fee_expected,
- fee_claimed))
- {
- /* Disagreement in fee structure between auditor and exchange DB! */
- report_amount_arithmetic_inconsistency ("deposit fee",
- 0,
- fee_claimed,
- &fee_expected,
- 1);
- }
+ /* Disagreement in fee structure between auditor and exchange DB! */
+ report_amount_arithmetic_inconsistency ("deposit fee",
+ 0,
+ fee_claimed,
+ &issue->fees.deposit,
+ 1);
}
break;
case TALER_EXCHANGEDB_TT_MELT:
@@ -487,22 +480,16 @@ check_transaction_history_for_deposit (
&expenditures,
amount_with_fee);
/* Check that the fees given in the transaction list and in dki match */
+ if (0 !=
+ TALER_amount_cmp (&issue->fees.refresh,
+ fee_claimed))
{
- struct TALER_Amount fee_expected;
-
- TALER_amount_ntoh (&fee_expected,
- &issue->fees.refresh);
- if (0 !=
- TALER_amount_cmp (&fee_expected,
- fee_claimed))
- {
- /* Disagreement in fee structure between exchange and auditor */
- report_amount_arithmetic_inconsistency ("melt fee",
- 0,
- fee_claimed,
- &fee_expected,
- 1);
- }
+ /* Disagreement in fee structure between exchange and auditor */
+ report_amount_arithmetic_inconsistency ("melt fee",
+ 0,
+ fee_claimed,
+ &issue->fees.refresh,
+ 1);
}
break;
case TALER_EXCHANGEDB_TT_REFUND:
@@ -531,22 +518,16 @@ check_transaction_history_for_deposit (
refund_deposit_fee = GNUNET_YES;
}
/* Check that the fees given in the transaction list and in dki match */
+ if (0 !=
+ TALER_amount_cmp (&issue->fees.refund,
+ fee_claimed))
{
- struct TALER_Amount fee_expected;
-
- TALER_amount_ntoh (&fee_expected,
- &issue->fees.refund);
- if (0 !=
- TALER_amount_cmp (&fee_expected,
- fee_claimed))
- {
- /* Disagreement in fee structure between exchange and auditor! */
- report_amount_arithmetic_inconsistency ("refund fee",
- 0,
- fee_claimed,
- &fee_expected,
- 1);
- }
+ /* Disagreement in fee structure between exchange and auditor! */
+ report_amount_arithmetic_inconsistency ("refund fee",
+ 0,
+ fee_claimed,
+ &issue->fees.refund,
+ 1);
}
break;
case TALER_EXCHANGEDB_TT_OLD_COIN_RECOUP:
@@ -641,18 +622,14 @@ check_transaction_history_for_deposit (
else
{
/* Now check that 'spent' is less or equal than the total coin value */
- struct TALER_Amount value;
-
- TALER_amount_ntoh (&value,
- &issue->value);
if (1 == TALER_amount_cmp (&spent,
- &value))
+ &issue->value))
{
/* spent > value */
report_coin_arithmetic_inconsistency ("spend",
coin_pub,
&spent,
- &value,
+ &issue->value,
-1);
}
}
@@ -703,7 +680,7 @@ wire_transfer_information_cb (
const struct TALER_Amount *deposit_fee)
{
struct WireCheckContext *wcc = cls;
- const struct TALER_DenominationKeyValidityPS *issue;
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation *issue;
struct TALER_Amount computed_value;
struct TALER_Amount total_deposit_without_refunds;
struct TALER_EXCHANGEDB_TransactionList *tl;
diff --git a/src/auditor/taler-helper-auditor-coins.c b/src/auditor/taler-helper-auditor-coins.c
index 775f2b598..ad9048a17 100644
--- a/src/auditor/taler-helper-auditor-coins.c
+++ b/src/auditor/taler-helper-auditor-coins.c
@@ -276,7 +276,7 @@ get_cached_history (const struct TALER_CoinSpendPublicKeyP *coin_pub)
*/
static void
report_emergency_by_amount (
- const struct TALER_DenominationKeyValidityPS *issue,
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation *issue,
const struct TALER_Amount *risk,
const struct TALER_Amount *loss)
{
@@ -293,12 +293,12 @@ report_emergency_by_amount (
risk),
TALER_JSON_pack_amount ("denom_loss",
loss),
- TALER_JSON_pack_time_abs_nbo_human ("start",
- issue->start.abs_time_nbo),
- TALER_JSON_pack_time_abs_nbo_human ("deposit_end",
- issue->expire_deposit.abs_time_nbo),
- TALER_JSON_pack_amount_nbo ("value",
- &issue->value)));
+ TALER_JSON_pack_time_abs_human ("start",
+ issue->start.abs_time),
+ TALER_JSON_pack_time_abs_human ("deposit_end",
+ issue->expire_deposit.abs_time),
+ TALER_JSON_pack_amount ("value",
+ &issue->value)));
TALER_ARL_amount_add (&reported_emergency_risk_by_amount,
&reported_emergency_risk_by_amount,
risk);
@@ -324,13 +324,11 @@ report_emergency_by_amount (
*/
static void
report_emergency_by_count (
- const struct TALER_DenominationKeyValidityPS *issue,
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation *issue,
uint64_t num_issued,
uint64_t num_known,
const struct TALER_Amount *risk)
{
- struct TALER_Amount denom_value;
-
TALER_ARL_report (
report_emergencies_by_count,
GNUNET_JSON_PACK (
@@ -342,21 +340,19 @@ report_emergency_by_count (
num_known),
TALER_JSON_pack_amount ("denom_risk",
risk),
- TALER_JSON_pack_time_abs_nbo_human ("start",
- issue->start.abs_time_nbo),
- TALER_JSON_pack_time_abs_nbo_human ("deposit_end",
- issue->expire_deposit.abs_time_nbo),
- TALER_JSON_pack_amount_nbo ("value",
- &issue->value)));
+ TALER_JSON_pack_time_abs_human ("start",
+ issue->start.abs_time),
+ TALER_JSON_pack_time_abs_human ("deposit_end",
+ issue->expire_deposit.abs_time),
+ TALER_JSON_pack_amount ("value",
+ &issue->value)));
TALER_ARL_amount_add (&reported_emergency_risk_by_count,
&reported_emergency_risk_by_count,
risk);
- TALER_amount_ntoh (&denom_value,
- &issue->value);
for (uint64_t i = num_issued; i<num_known; i++)
TALER_ARL_amount_add (&reported_emergency_loss_by_count,
&reported_emergency_loss_by_count,
- &denom_value);
+ &issue->value);
}
@@ -624,7 +620,7 @@ struct DenominationSummary
/**
* Denomination key information for this denomination.
*/
- const struct TALER_DenominationKeyValidityPS *issue;
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation *issue;
/**
* #GNUNET_YES if this record already existed in the DB.
@@ -759,7 +755,8 @@ init_denomination (const struct TALER_DenominationHashP *denom_hash,
*/
static struct DenominationSummary *
get_denomination_summary (struct CoinContext *cc,
- const struct TALER_DenominationKeyValidityPS *issue,
+ const struct
+ TALER_EXCHANGEDB_DenominationKeyInformation *issue,
const struct TALER_DenominationHashP *dh)
{
struct DenominationSummary *ds;
@@ -806,14 +803,14 @@ sync_denomination (void *cls,
.hash = *denom_hash
};
struct DenominationSummary *ds = value;
- const struct TALER_DenominationKeyValidityPS *issue = ds->issue;
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation *issue = ds->issue;
struct GNUNET_TIME_Absolute now;
struct GNUNET_TIME_Timestamp expire_deposit;
struct GNUNET_TIME_Absolute expire_deposit_grace;
enum GNUNET_DB_QueryStatus qs;
now = GNUNET_TIME_absolute_get ();
- expire_deposit = GNUNET_TIME_timestamp_ntoh (issue->expire_deposit);
+ expire_deposit = issue->expire_deposit;
/* add day grace period to deal with clocks not being perfectly synchronized */
expire_deposit_grace = GNUNET_TIME_absolute_add (expire_deposit.abs_time,
DEPOSIT_GRACE_PERIOD);
@@ -973,8 +970,7 @@ withdraw_cb (void *cls,
struct CoinContext *cc = cls;
struct DenominationSummary *ds;
struct TALER_DenominationHashP dh;
- const struct TALER_DenominationKeyValidityPS *issue;
- struct TALER_Amount value;
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation *issue;
enum GNUNET_DB_QueryStatus qs;
/* Note: some optimization potential here: lots of fields we
@@ -1016,29 +1012,27 @@ withdraw_cb (void *cls,
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == cc->qs);
return GNUNET_SYSERR;
}
- TALER_amount_ntoh (&value,
- &issue->value);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Issued coin in denomination `%s' of total value %s\n",
GNUNET_h2s (&dh.hash),
- TALER_amount2s (&value));
+ TALER_amount2s (&issue->value));
ds->num_issued++;
TALER_ARL_amount_add (&ds->denom_balance,
&ds->denom_balance,
- &value);
+ &issue->value);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"New balance of denomination `%s' is %s\n",
GNUNET_h2s (&dh.hash),
TALER_amount2s (&ds->denom_balance));
TALER_ARL_amount_add (&total_escrow_balance,
&total_escrow_balance,
- &value);
+ &issue->value);
TALER_ARL_amount_add (&total_risk,
&total_risk,
- &value);
+ &issue->value);
TALER_ARL_amount_add (&ds->denom_risk,
&ds->denom_risk,
- &value);
+ &issue->value);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
return GNUNET_OK;
@@ -1054,7 +1048,7 @@ struct RevealContext
/**
* Denomination public data of the new coins.
*/
- const struct TALER_DenominationKeyValidityPS **new_issues;
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation **new_issues;
/**
* Set to the size of the @a new_issues array.
@@ -1071,7 +1065,7 @@ struct RevealContext
* #GNUNET_NO if a denomination key was not found
* #GNUNET_SYSERR if we had a database error.
*/
- int err;
+ enum GNUNET_GenericReturnValue err;
/**
* Database error, if @e err is #GNUNET_SYSERR.
@@ -1097,7 +1091,7 @@ reveal_data_cb (void *cls,
rctx->num_freshcoins = num_freshcoins;
rctx->new_issues = GNUNET_new_array (
num_freshcoins,
- const struct TALER_DenominationKeyValidityPS *);
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation *);
/* Update outstanding amounts for all new coin's denominations */
for (unsigned int i = 0; i<num_freshcoins; i++)
@@ -1141,7 +1135,8 @@ reveal_data_cb (void *cls,
*/
static enum GNUNET_DB_QueryStatus
check_known_coin (const char *operation,
- const struct TALER_DenominationKeyValidityPS *issue,
+ const struct
+ TALER_EXCHANGEDB_DenominationKeyInformation *issue,
uint64_t rowid,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_DenominationPublicKey *denom_pub,
@@ -1152,14 +1147,10 @@ check_known_coin (const char *operation,
if (NULL == get_cached_history (coin_pub))
{
- struct TALER_Amount value;
-
- TALER_amount_ntoh (&value,
- &issue->value);
qs = check_coin_history (coin_pub,
rowid,
operation,
- &value);
+ &issue->value);
if (0 > qs)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
@@ -1232,7 +1223,7 @@ refresh_session_cb (void *cls,
const struct TALER_RefreshCommitmentP *rc)
{
struct CoinContext *cc = cls;
- const struct TALER_DenominationKeyValidityPS *issue;
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation *issue;
struct DenominationSummary *dso;
struct TALER_Amount amount_without_fee;
struct TALER_Amount tmp;
@@ -1276,15 +1267,12 @@ refresh_session_cb (void *cls,
/* verify melt signature */
{
struct TALER_DenominationHashP h_denom_pub;
- struct TALER_Amount fee_refresh;
TALER_denom_pub_hash (denom_pub,
&h_denom_pub);
- TALER_amount_ntoh (&fee_refresh,
- &issue->fees.refresh);
if (GNUNET_OK !=
TALER_wallet_melt_verify (amount_with_fee,
- &fee_refresh,
+ &issue->fees.refresh,
rc,
&h_denom_pub,
h_age_commitment,
@@ -1370,46 +1358,36 @@ refresh_session_cb (void *cls,
&refresh_cost));
for (unsigned int i = 0; i<reveal_ctx.num_freshcoins; i++)
{
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation *ni
+ = reveal_ctx.new_issues[i];
/* update cost of refresh */
- struct TALER_Amount fee;
- struct TALER_Amount value;
- TALER_amount_ntoh (&fee,
- &reveal_ctx.new_issues[i]->fees.withdraw);
- TALER_amount_ntoh (&value,
- &reveal_ctx.new_issues[i]->value);
TALER_ARL_amount_add (&refresh_cost,
&refresh_cost,
- &fee);
+ &ni->fees.withdraw);
TALER_ARL_amount_add (&refresh_cost,
&refresh_cost,
- &value);
+ &ni->value);
}
/* compute contribution of old coin */
+ if (TALER_ARL_SR_POSITIVE !=
+ TALER_ARL_amount_subtract_neg (&amount_without_fee,
+ amount_with_fee,
+ &issue->fees.refresh))
{
- struct TALER_Amount melt_fee;
-
- TALER_amount_ntoh (&melt_fee,
- &issue->fees.refresh);
- if (TALER_ARL_SR_POSITIVE !=
- TALER_ARL_amount_subtract_neg (&amount_without_fee,
- amount_with_fee,
- &melt_fee))
- {
- /* Melt fee higher than contribution of melted coin; this makes
- no sense (exchange should never have accepted the operation) */
- report_amount_arithmetic_inconsistency ("melt contribution vs. fee",
- rowid,
- amount_with_fee,
- &melt_fee,
- -1);
- /* To continue, best assumption is the melted coin contributed
- nothing (=> all withdrawal amounts will be counted as losses) */
- GNUNET_assert (GNUNET_OK ==
- TALER_amount_set_zero (TALER_ARL_currency,
- &amount_without_fee));
- }
+ /* Melt fee higher than contribution of melted coin; this makes
+ no sense (exchange should never have accepted the operation) */
+ report_amount_arithmetic_inconsistency ("melt contribution vs. fee",
+ rowid,
+ amount_with_fee,
+ &issue->fees.refresh,
+ -1);
+ /* To continue, best assumption is the melted coin contributed
+ nothing (=> all withdrawal amounts will be counted as losses) */
+ GNUNET_assert (GNUNET_OK ==
+ TALER_amount_set_zero (TALER_ARL_currency,
+ &amount_without_fee));
}
/* check old coin covers complete expenses (of withdraw operations) */
@@ -1427,12 +1405,13 @@ refresh_session_cb (void *cls,
/* update outstanding denomination amounts for fresh coins withdrawn */
for (unsigned int i = 0; i<reveal_ctx.num_freshcoins; i++)
{
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation *ni
+ = reveal_ctx.new_issues[i];
struct DenominationSummary *dsi;
- struct TALER_Amount value;
dsi = get_denomination_summary (cc,
- reveal_ctx.new_issues[i],
- &reveal_ctx.new_issues[i]->denom_hash);
+ ni,
+ &ni->denom_hash);
if (NULL == dsi)
{
report_row_inconsistency ("refresh_reveal",
@@ -1441,29 +1420,27 @@ refresh_session_cb (void *cls,
}
else
{
- TALER_amount_ntoh (&value,
- &reveal_ctx.new_issues[i]->value);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Created fresh coin in denomination `%s' of value %s\n",
- GNUNET_h2s (&reveal_ctx.new_issues[i]->denom_hash.hash),
- TALER_amount2s (&value));
+ GNUNET_h2s (&ni->denom_hash.hash),
+ TALER_amount2s (&ni->value));
dsi->num_issued++;
TALER_ARL_amount_add (&dsi->denom_balance,
&dsi->denom_balance,
- &value);
+ &ni->value);
TALER_ARL_amount_add (&dsi->denom_risk,
&dsi->denom_risk,
- &value);
+ &ni->value);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"New balance of denomination `%s' is %s\n",
- GNUNET_h2s (&reveal_ctx.new_issues[i]->denom_hash.hash),
+ GNUNET_h2s (&ni->denom_hash.hash),
TALER_amount2s (&dsi->denom_balance));
TALER_ARL_amount_add (&total_escrow_balance,
&total_escrow_balance,
- &value);
+ &ni->value);
TALER_ARL_amount_add (&total_risk,
&total_risk,
- &value);
+ &ni->value);
}
}
GNUNET_free (reveal_ctx.new_issues);
@@ -1524,15 +1501,9 @@ refresh_session_cb (void *cls,
}
/* update global melt fees */
- {
- struct TALER_Amount rfee;
-
- TALER_amount_ntoh (&rfee,
- &issue->fees.refresh);
- TALER_ARL_amount_add (&total_melt_fee_income,
- &total_melt_fee_income,
- &rfee);
- }
+ TALER_ARL_amount_add (&total_melt_fee_income,
+ &total_melt_fee_income,
+ &issue->fees.refresh);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
return GNUNET_OK;
@@ -1560,7 +1531,7 @@ deposit_cb (void *cls,
bool done)
{
struct CoinContext *cc = cls;
- const struct TALER_DenominationKeyValidityPS *issue;
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation *issue;
struct DenominationSummary *ds;
enum GNUNET_DB_QueryStatus qs;
@@ -1613,21 +1584,18 @@ deposit_cb (void *cls,
{
struct TALER_MerchantWireHashP h_wire;
struct TALER_DenominationHashP h_denom_pub;
- struct TALER_Amount deposit_fee;
TALER_denom_pub_hash (denom_pub,
&h_denom_pub);
TALER_merchant_wire_signature_hash (deposit->receiver_wire_account,
&deposit->wire_salt,
&h_wire);
- TALER_amount_ntoh (&deposit_fee,
- &issue->fees.deposit);
/* NOTE: This is one of the operations we might eventually
want to do in parallel in the background to improve
auditor performance! */
if (GNUNET_OK !=
TALER_wallet_deposit_verify (&deposit->amount_with_fee,
- &deposit_fee,
+ &issue->fees.deposit,
&h_wire,
&deposit->h_contract_terms,
&deposit->coin.h_age_commitment,
@@ -1722,15 +1690,9 @@ deposit_cb (void *cls,
}
/* update global deposit fees */
- {
- struct TALER_Amount dfee;
-
- TALER_amount_ntoh (&dfee,
- &issue->fees.deposit);
- TALER_ARL_amount_add (&total_deposit_fee_income,
- &total_deposit_fee_income,
- &dfee);
- }
+ TALER_ARL_amount_add (&total_deposit_fee_income,
+ &total_deposit_fee_income,
+ &issue->fees.deposit);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
return GNUNET_OK;
@@ -1766,10 +1728,9 @@ refund_cb (void *cls,
const struct TALER_Amount *amount_with_fee)
{
struct CoinContext *cc = cls;
- const struct TALER_DenominationKeyValidityPS *issue;
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation *issue;
struct DenominationSummary *ds;
struct TALER_Amount amount_without_fee;
- struct TALER_Amount refund_fee;
enum GNUNET_DB_QueryStatus qs;
GNUNET_assert (rowid >= ppc.last_refund_serial_id); /* should be monotonically increasing */
@@ -1820,17 +1781,15 @@ refund_cb (void *cls,
return GNUNET_OK;
}
- TALER_amount_ntoh (&refund_fee,
- &issue->fees.refund);
if (TALER_ARL_SR_INVALID_NEGATIVE ==
TALER_ARL_amount_subtract_neg (&amount_without_fee,
amount_with_fee,
- &refund_fee))
+ &issue->fees.refund))
{
report_amount_arithmetic_inconsistency ("refund (fee)",
rowid,
&amount_without_fee,
- &refund_fee,
+ &issue->fees.refund,
-1);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
@@ -1875,7 +1834,7 @@ refund_cb (void *cls,
/* update total refund fee balance */
TALER_ARL_amount_add (&total_refund_fee_income,
&total_refund_fee_income,
- &refund_fee);
+ &issue->fees.refund);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
return GNUNET_OK;
@@ -1908,7 +1867,7 @@ check_recoup (struct CoinContext *cc,
{
struct DenominationSummary *ds;
enum GNUNET_DB_QueryStatus qs;
- const struct TALER_DenominationKeyValidityPS *issue;
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation *issue;
if (GNUNET_OK !=
TALER_test_coin_valid (coin,
@@ -2096,7 +2055,7 @@ recoup_refresh_cb (void *cls,
const union TALER_DenominationBlindingKeyP *coin_blind)
{
struct CoinContext *cc = cls;
- const struct TALER_DenominationKeyValidityPS *issue;
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation *issue;
enum GNUNET_DB_QueryStatus qs;
(void) timestamp;
@@ -2195,24 +2154,13 @@ static void
check_denomination (
void *cls,
const struct TALER_DenominationPublicKey *denom_pub,
- const struct TALER_EXCHANGEDB_DenominationKeyInformationP *validity)
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation *issue)
{
- const struct TALER_DenominationKeyValidityPS *issue = &validity->properties;
enum GNUNET_DB_QueryStatus qs;
struct TALER_AuditorSignatureP auditor_sig;
- struct TALER_Amount coin_value;
- struct TALER_DenomFeeSet fees;
- struct GNUNET_TIME_Timestamp start;
- struct GNUNET_TIME_Timestamp end;
(void) cls;
(void) denom_pub;
- TALER_amount_ntoh (&coin_value,
- &issue->value);
- TALER_denom_fee_set_ntoh (&fees,
- &issue->fees);
- start = GNUNET_TIME_timestamp_ntoh (issue->start);
- end = GNUNET_TIME_timestamp_ntoh (issue->expire_legal);
qs = TALER_ARL_edb->select_auditor_denom_sig (TALER_ARL_edb->cls,
&issue->denom_hash,
&TALER_ARL_auditor_pub,
@@ -2227,10 +2175,10 @@ check_denomination (
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Encountered denomination `%s' (%s) valid from %s (%llu-%llu) that this auditor is not auditing!\n",
GNUNET_h2s (&issue->denom_hash.hash),
- TALER_amount2s (&coin_value),
- GNUNET_TIME_timestamp2s (start),
- (unsigned long long) start.abs_time.abs_value_us,
- (unsigned long long) end.abs_time.abs_value_us);
+ TALER_amount2s (&issue->value),
+ GNUNET_TIME_timestamp2s (issue->start),
+ (unsigned long long) issue->start.abs_time.abs_value_us,
+ (unsigned long long) issue->expire_legal.abs_time.abs_value_us);
return; /* skip! */
}
if (GNUNET_OK !=
@@ -2238,12 +2186,12 @@ check_denomination (
TALER_ARL_auditor_url,
&issue->denom_hash,
&TALER_ARL_master_pub,
- start,
- GNUNET_TIME_timestamp_ntoh (issue->expire_withdraw),
- GNUNET_TIME_timestamp_ntoh (issue->expire_deposit),
- end,
- &coin_value,
- &fees,
+ issue->start,
+ issue->expire_withdraw,
+ issue->expire_deposit,
+ issue->expire_legal,
+ &issue->value,
+ &issue->fees,
&TALER_ARL_auditor_pub,
&auditor_sig))
{
@@ -2252,11 +2200,12 @@ check_denomination (
GNUNET_JSON_pack_data_auto ("denomination",
&issue->denom_hash),
TALER_JSON_pack_amount ("value",
- &coin_value),
+ &issue->value),
TALER_JSON_pack_time_abs_human ("start_time",
- start.abs_time),
+ issue->start.abs_time),
TALER_JSON_pack_time_abs_human ("end_time",
- end.abs_time)));
+ issue->expire_legal.
+ abs_time)));
}
}
diff --git a/src/auditor/taler-helper-auditor-reserves.c b/src/auditor/taler-helper-auditor-reserves.c
index f34f0c467..17d628399 100644
--- a/src/auditor/taler-helper-auditor-reserves.c
+++ b/src/auditor/taler-helper-auditor-reserves.c
@@ -501,12 +501,8 @@ handle_reserve_out (void *cls,
struct ReserveContext *rc = cls;
struct GNUNET_HashCode key;
struct ReserveSummary *rs;
- const struct TALER_DenominationKeyValidityPS *issue;
- struct TALER_Amount withdraw_fee;
- struct TALER_Amount auditor_value;
+ const struct TALER_EXCHANGEDB_DenominationKeyInformation *issue;
struct TALER_Amount auditor_amount_with_fee;
- struct GNUNET_TIME_Timestamp valid_start;
- struct GNUNET_TIME_Timestamp expire_withdraw;
enum GNUNET_DB_QueryStatus qs;
struct TALER_DenominationHashP h_denom_pub;
@@ -541,17 +537,15 @@ handle_reserve_out (void *cls,
}
/* check that execution date is within withdraw range for denom_pub */
- valid_start = GNUNET_TIME_timestamp_ntoh (issue->start);
- expire_withdraw = GNUNET_TIME_timestamp_ntoh (issue->expire_withdraw);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Checking withdraw timing: %llu, expire: %llu, timing: %llu\n",
- (unsigned long long) valid_start.abs_time.abs_value_us,
- (unsigned long long) expire_withdraw.abs_time.abs_value_us,
+ (unsigned long long) issue->start.abs_time.abs_value_us,
+ (unsigned long long) issue->expire_withdraw.abs_time.abs_value_us,
(unsigned long long) execution_date.abs_time.abs_value_us);
- if (GNUNET_TIME_timestamp_cmp (valid_start,
+ if (GNUNET_TIME_timestamp_cmp (issue->start,
>,
execution_date) ||
- GNUNET_TIME_timestamp_cmp (expire_withdraw,
+ GNUNET_TIME_timestamp_cmp (issue->expire_withdraw,
<,
execution_date))
{
@@ -593,13 +587,9 @@ handle_reserve_out (void *cls,
return GNUNET_OK; /* exit function here, we cannot add this to the legitimate withdrawals */
}
- TALER_amount_ntoh (&withdraw_fee,
- &issue->fees.withdraw);
- TALER_amount_ntoh (&auditor_value,
- &issue->value);
TALER_ARL_amount_add (&auditor_amount_with_fee,
- &auditor_value,
- &withdraw_fee);
+ &issue->value,
+ &issue->fees.withdraw);
if (0 !=
TALER_amount_cmp (&auditor_amount_with_fee,
amount_with_fee))
@@ -652,10 +642,10 @@ handle_reserve_out (void *cls,
TALER_amount2s (&auditor_amount_with_fee));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Increasing withdraw profits by fee %s\n",
- TALER_amount2s (&withdraw_fee));
+ TALER_amount2s (&issue->fees.withdraw));
TALER_ARL_amount_add (&rs->total_fee,
&rs->total_fee,
- &withdraw_fee);
+ &issue->fees.withdraw);
if (TALER_ARL_do_abort ())
return GNUNET_SYSERR;
return GNUNET_OK;