bugfixes in auditor and rendering

This commit is contained in:
Christian Grothoff 2018-01-04 10:38:16 +01:00
parent 7d60d3a618
commit 0906696ec2
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
3 changed files with 32 additions and 49 deletions

View File

@ -337,7 +337,7 @@ any effects on its own balance, those entries are excluded from the total.
{\bf Operation} & {\bf Coin public key} & \multicolumn{2}{|c|}{ {\bf Exchange}} & \multicolumn{2}{|c}{ {\bf Auditor}} \\ {\bf Operation} & {\bf Coin public key} & \multicolumn{2}{|c|}{ {\bf Exchange}} & \multicolumn{2}{|c}{ {\bf Auditor}} \\
\endfoot \endfoot
\hline \hline
{\bf Total} & & \multicolumn{2}{l|}{ $\sum$ {\bf Delta (Auditor-Exchange)} } &
{{ data.total_coin_delta_plus.value }}.{{ data.total_coin_delta_plus.fraction }} & {{ data.total_coin_delta_plus.value }}.{{ data.total_coin_delta_plus.fraction }} &
{{ data.total_coin_delta_plus.currency }} & {{ data.total_coin_delta_plus.currency }} &
- {{ data.total_coin_delta_minus.value }}.{{ data.total_coin_delta_minus.fraction }} & - {{ data.total_coin_delta_minus.value }}.{{ data.total_coin_delta_minus.fraction }} &

View File

@ -391,7 +391,7 @@ report_amount_arithmetic_inconsistency (const char *operation,
"profitable", (json_int_t) profitable)); "profitable", (json_int_t) profitable));
if (0 != profitable) if (0 != profitable)
{ {
target = profitable target = (1 == profitable)
? &total_arithmetic_delta_plus ? &total_arithmetic_delta_plus
: &total_arithmetic_delta_minus; : &total_arithmetic_delta_minus;
GNUNET_break (GNUNET_OK == GNUNET_break (GNUNET_OK ==
@ -452,7 +452,7 @@ report_coin_arithmetic_inconsistency (const char *operation,
"profitable", (json_int_t) profitable)); "profitable", (json_int_t) profitable));
if (0 != profitable) if (0 != profitable)
{ {
target = profitable target = (1 == profitable)
? &total_coin_delta_plus ? &total_coin_delta_plus
: &total_coin_delta_minus; : &total_coin_delta_minus;
GNUNET_break (GNUNET_OK == GNUNET_break (GNUNET_OK ==
@ -1798,7 +1798,6 @@ struct WireCheckContext
* @param dki denomination information about the coin * @param dki denomination information about the coin
* @param tl_head head of transaction history to verify * @param tl_head head of transaction history to verify
* @param[out] merchant_gain amount the coin contributes to the wire transfer to the merchant * @param[out] merchant_gain amount the coin contributes to the wire transfer to the merchant
* @param[out] merchant_fees fees the exchange charged the merchant for the transaction(s)
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/ */
static int static int
@ -1807,8 +1806,7 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_MerchantPublicKeyP *merchant_pub, const struct TALER_MerchantPublicKeyP *merchant_pub,
const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki, const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki,
const struct TALER_EXCHANGEDB_TransactionList *tl_head, const struct TALER_EXCHANGEDB_TransactionList *tl_head,
struct TALER_Amount *merchant_gain, struct TALER_Amount *merchant_gain)
struct TALER_Amount *merchant_fees)
{ {
struct TALER_Amount expenditures; struct TALER_Amount expenditures;
struct TALER_Amount refunds; struct TALER_Amount refunds;
@ -1816,6 +1814,8 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub,
struct TALER_Amount value; struct TALER_Amount value;
struct TALER_Amount merchant_loss; struct TALER_Amount merchant_loss;
struct TALER_Amount merchant_delta; struct TALER_Amount merchant_delta;
const struct TALER_Amount *deposit_fee;
int refund_deposit_fee;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Checking transaction history of coin %s\n", "Checking transaction history of coin %s\n",
@ -1831,9 +1831,6 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub,
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_get_zero (currency, TALER_amount_get_zero (currency,
merchant_gain)); merchant_gain));
GNUNET_assert (GNUNET_OK ==
TALER_amount_get_zero (currency,
merchant_fees));
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_get_zero (currency, TALER_amount_get_zero (currency,
&merchant_loss)); &merchant_loss));
@ -1841,6 +1838,8 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub,
know the order, so instead of subtracting we compute positive know the order, so instead of subtracting we compute positive
(deposit, melt) and negative (refund) values separately here, (deposit, melt) and negative (refund) values separately here,
and then subtract the negative from the positive after the loop. */ and then subtract the negative from the positive after the loop. */
refund_deposit_fee = GNUNET_NO;
deposit_fee = NULL;
for (const struct TALER_EXCHANGEDB_TransactionList *tl = tl_head;NULL != tl;tl = tl->next) for (const struct TALER_EXCHANGEDB_TransactionList *tl = tl_head;NULL != tl;tl = tl->next)
{ {
const struct TALER_Amount *amount_with_fee; const struct TALER_Amount *amount_with_fee;
@ -1872,7 +1871,7 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub,
{ {
struct TALER_Amount amount_without_fee; struct TALER_Amount amount_without_fee;
if (GNUNET_OK != if (GNUNET_OK !=
TALER_amount_subtract (&amount_without_fee, TALER_amount_subtract (&amount_without_fee,
amount_with_fee, amount_with_fee,
fee)) fee))
@ -1891,14 +1890,7 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Detected applicable deposit of %s\n", "Detected applicable deposit of %s\n",
TALER_amount2s (&amount_without_fee)); TALER_amount2s (&amount_without_fee));
if (GNUNET_OK != deposit_fee = fee;
TALER_amount_add (merchant_fees,
merchant_fees,
fee))
{
GNUNET_break (0);
return GNUNET_SYSERR;
}
} }
/* Check that the fees given in the transaction list and in dki match */ /* Check that the fees given in the transaction list and in dki match */
TALER_amount_ntoh (&tmp, TALER_amount_ntoh (&tmp,
@ -1976,14 +1968,7 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Detected applicable refund of %s\n", "Detected applicable refund of %s\n",
TALER_amount2s (amount_with_fee)); TALER_amount2s (amount_with_fee));
if (GNUNET_OK != refund_deposit_fee = GNUNET_YES;
TALER_amount_add (merchant_fees,
merchant_fees,
fee))
{
GNUNET_break (0);
return GNUNET_SYSERR;
}
} }
/* Check that the fees given in the transaction list and in dki match */ /* Check that the fees given in the transaction list and in dki match */
TALER_amount_ntoh (&tmp, TALER_amount_ntoh (&tmp,
@ -2009,9 +1994,19 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub,
} }
break; break;
} }
} /* for 'tl' */ } /* for 'tl' */
if ( (GNUNET_YES == refund_deposit_fee) &&
(NULL != deposit_fee) )
{
/* We had a /deposit operation AND a /refund operation,
and should thus not charge the merchant the /deposit fee */
GNUNET_assert (GNUNET_OK ==
TALER_amount_add (merchant_gain,
merchant_gain,
deposit_fee));
}
/* Calculate total balance change, i.e. expenditures minus refunds */ /* Calculate total balance change, i.e. expenditures minus refunds */
if (GNUNET_SYSERR == if (GNUNET_SYSERR ==
TALER_amount_subtract (&spent, TALER_amount_subtract (&spent,
@ -2023,7 +2018,7 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub,
coin_pub, coin_pub,
&expenditures, &expenditures,
&refunds, &refunds,
0); 1);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
@ -2042,7 +2037,8 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub,
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
/* Finally, update @a merchant_gain by subtracting what he "lost" from refunds */ /* Finally, update @a merchant_gain by subtracting what he "lost"
from refunds */
if (GNUNET_SYSERR == if (GNUNET_SYSERR ==
TALER_amount_subtract (&merchant_delta, TALER_amount_subtract (&merchant_delta,
merchant_gain, merchant_gain,
@ -2053,7 +2049,7 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub,
coin_pub, coin_pub,
merchant_gain, merchant_gain,
&merchant_loss, &merchant_loss,
0); 1);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
*merchant_gain = merchant_delta; *merchant_gain = merchant_delta;
@ -2079,7 +2075,8 @@ check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub,
* @param h_contract_terms which proposal was this payment about * @param h_contract_terms which proposal was this payment about
* @param coin_pub which public key was this payment about * @param coin_pub which public key was this payment about
* @param coin_value amount contributed by this coin in total (with fee) * @param coin_value amount contributed by this coin in total (with fee)
* @param coin_fee applicable fee for this coin * @param deposit_fee applicable deposit fee for this coin, actual
* fees charged may differ if coin was refunded
*/ */
static void static void
wire_transfer_information_cb (void *cls, wire_transfer_information_cb (void *cls,
@ -2091,12 +2088,11 @@ wire_transfer_information_cb (void *cls,
const struct GNUNET_HashCode *h_contract_terms, const struct GNUNET_HashCode *h_contract_terms,
const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_Amount *coin_value, const struct TALER_Amount *coin_value,
const struct TALER_Amount *coin_fee) const struct TALER_Amount *deposit_fee)
{ {
struct WireCheckContext *wcc = cls; struct WireCheckContext *wcc = cls;
const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki; const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki;
struct TALER_Amount computed_value; struct TALER_Amount computed_value;
struct TALER_Amount computed_fees;
struct TALER_Amount coin_value_without_fee; struct TALER_Amount coin_value_without_fee;
struct TALER_EXCHANGEDB_TransactionList *tl; struct TALER_EXCHANGEDB_TransactionList *tl;
const struct TALER_CoinPublicInfo *coin; const struct TALER_CoinPublicInfo *coin;
@ -2158,18 +2154,17 @@ wire_transfer_information_cb (void *cls,
merchant_pub, merchant_pub,
dki, dki,
tl, tl,
&computed_value, &computed_value);
&computed_fees);
if (GNUNET_SYSERR == if (GNUNET_SYSERR ==
TALER_amount_subtract (&coin_value_without_fee, TALER_amount_subtract (&coin_value_without_fee,
coin_value, coin_value,
coin_fee)) deposit_fee))
{ {
wcc->qs = GNUNET_DB_STATUS_HARD_ERROR; wcc->qs = GNUNET_DB_STATUS_HARD_ERROR;
report_amount_arithmetic_inconsistency ("aggregation (fee structure)", report_amount_arithmetic_inconsistency ("aggregation (fee structure)",
rowid, rowid,
coin_value, coin_value,
coin_fee, deposit_fee,
-1); -1);
return; return;
} }
@ -2184,17 +2179,6 @@ wire_transfer_information_cb (void *cls,
&computed_value, &computed_value,
-1); -1);
} }
if (0 !=
TALER_amount_cmp (&computed_fees,
coin_fee))
{
wcc->qs = GNUNET_DB_STATUS_HARD_ERROR;
report_amount_arithmetic_inconsistency ("aggregation (fee)",
rowid,
coin_fee,
&computed_fees,
1);
}
edb->free_coin_transaction_list (edb->cls, edb->free_coin_transaction_list (edb->cls,
tl); tl);

View File

@ -285,7 +285,6 @@ refund_transaction (void *cls,
} }
/* check if we already send the money for the /deposit */ /* check if we already send the money for the /deposit */
// FIXME: DB API...
qs = TEH_plugin->test_deposit_done (TEH_plugin->cls, qs = TEH_plugin->test_deposit_done (TEH_plugin->cls,
session, session,
dep); dep);