gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-exchange] 03/03: more work on coin/denomination audi


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] 03/03: more work on coin/denomination audit
Date: Fri, 17 Mar 2017 17:15:15 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository exchange.

commit 8ea9b0dad7a67f0e04debcd1f6e6621538c0613f
Author: Christian Grothoff <address@hidden>
AuthorDate: Fri Mar 17 17:17:07 2017 +0100

    more work on coin/denomination audit
---
 src/auditor/taler-auditor.c               | 419 ++++++++++++++++++++++++++----
 src/auditordb/plugin_auditordb_postgres.c |  92 +------
 src/include/taler_auditordb_plugin.h      |  18 --
 3 files changed, 383 insertions(+), 146 deletions(-)

diff --git a/src/auditor/taler-auditor.c b/src/auditor/taler-auditor.c
index c018a71..dab3d90 100644
--- a/src/auditor/taler-auditor.c
+++ b/src/auditor/taler-auditor.c
@@ -41,6 +41,7 @@
 #include <gnunet/gnunet_util_lib.h>
 #include "taler_auditordb_plugin.h"
 #include "taler_exchangedb_plugin.h"
+#include "taler_json_lib.h"
 #include "taler_signatures.h"
 
 
@@ -526,7 +527,8 @@ handle_reserve_in (void *cls,
 
 
 /**
- * Function called with details about withdraw operations.
+ * Function called with details about withdraw operations.  Verifies
+ * the signature and updates the reserve's balance.
  *
  * @param cls our `struct ReserveContext`
  * @param rowid unique serial ID for the refresh session in our DB
@@ -957,21 +959,6 @@ struct DenominationSummary
   struct TALER_Amount denom_balance;
 
   /**
-   * Total amount of deposit fees made.
-   */
-  struct TALER_Amount deposit_fee_balance;
-
-  /**
-   * Total amount of melt fees made.
-   */
-  struct TALER_Amount melt_fee_balance;
-
-  /**
-   * Total amount of refund fees made.
-   */
-  struct TALER_Amount refund_fee_balance;
-
-  /**
    * Up to which point have we processed reserves_out?
    */
   uint64_t last_reserve_out_serial_id;
@@ -1074,9 +1061,6 @@ init_denomination (const struct GNUNET_HashCode 
*denom_hash,
                                        asession,
                                        denom_hash,
                                        &ds->denom_balance,
-                                       &ds->deposit_fee_balance,
-                                       &ds->melt_fee_balance,
-                                       &ds->refund_fee_balance,
                                        &ds->last_reserve_out_serial_id,
                                        &ds->last_deposit_serial_id,
                                        &ds->last_melt_serial_id,
@@ -1094,15 +1078,6 @@ init_denomination (const struct GNUNET_HashCode 
*denom_hash,
   GNUNET_assert (GNUNET_OK ==
                  TALER_amount_get_zero (currency,
                                         &ds->denom_balance));
-  GNUNET_assert (GNUNET_OK ==
-                 TALER_amount_get_zero (currency,
-                                        &ds->deposit_fee_balance));
-  GNUNET_assert (GNUNET_OK ==
-                 TALER_amount_get_zero (currency,
-                                        &ds->melt_fee_balance));
-  GNUNET_assert (GNUNET_OK ==
-                 TALER_amount_get_zero (currency,
-                                        &ds->refund_fee_balance));
   return GNUNET_OK;
 }
 
@@ -1171,9 +1146,6 @@ sync_denomination (void *cls,
                                             asession,
                                             denom_hash,
                                             &ds->denom_balance,
-                                            &ds->deposit_fee_balance,
-                                            &ds->melt_fee_balance,
-                                            &ds->refund_fee_balance,
                                             ds->last_reserve_out_serial_id,
                                             ds->last_deposit_serial_id,
                                             ds->last_melt_serial_id,
@@ -1183,9 +1155,6 @@ sync_denomination (void *cls,
                                             asession,
                                             denom_hash,
                                             &ds->denom_balance,
-                                            &ds->deposit_fee_balance,
-                                            &ds->melt_fee_balance,
-                                            &ds->refund_fee_balance,
                                             ds->last_reserve_out_serial_id,
                                             ds->last_deposit_serial_id,
                                             ds->last_melt_serial_id,
@@ -1233,12 +1202,128 @@ free_coin (void *cls,
 
 
 /**
+ * Check coin's transaction history for plausibility.  Does NOT check
+ * the signatures (those are checked independently), but does check
+ * that the amounts add up to a plausible overall picture.
+ *
+ * FIXME: is it wise to do this here? Maybe better to do this during
+ * processing of payments to the merchants...
+ *
+ * @param coin_pub public key of the coin (for reporting)
+ * @param dki denomination information about the coin
+ * @param tl_head head of transaction history to verify
+ */
+static void
+check_transaction_history (const struct TALER_CoinSpendPublicKeyP *coin_pub,
+                           const struct 
TALER_EXCHANGEDB_DenominationKeyInformationP *dki,
+                           const struct TALER_EXCHANGEDB_TransactionList 
*tl_head)
+{
+  struct TALER_Amount expenditures;
+  struct TALER_Amount refunds;
+  struct TALER_Amount fees;
+  struct TALER_Amount final_expenditures;
+
+  GNUNET_assert (NULL != tl_head);
+  TALER_amount_get_zero (currency,
+                         &expenditures);
+  TALER_amount_get_zero (currency,
+                         &refunds);
+  TALER_amount_get_zero (currency,
+                         &fees);
+  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 *fee;
+    const struct TALER_AmountNBO *fee_dki;
+    struct TALER_Amount *add_to;
+    struct TALER_Amount tmp;
+
+    add_to = NULL;
+    switch (tl->type) {
+    case TALER_EXCHANGEDB_TT_DEPOSIT:
+      amount_with_fee = &tl->details.deposit->amount_with_fee;
+      fee = &tl->details.deposit->deposit_fee;
+      fee_dki = &dki->properties.fee_deposit;
+      add_to = &expenditures;
+      break;
+    case TALER_EXCHANGEDB_TT_REFRESH_MELT:
+      amount_with_fee = &tl->details.melt->amount_with_fee;
+      fee = &tl->details.melt->melt_fee;
+      fee_dki = &dki->properties.fee_refresh;
+      add_to = &expenditures;
+      break;
+    case TALER_EXCHANGEDB_TT_REFUND:
+      amount_with_fee = &tl->details.refund->refund_amount;
+      fee = &tl->details.refund->refund_fee;
+      fee_dki = &dki->properties.fee_refund;
+      add_to = &refunds;
+      // FIXME: where do we check that the refund(s)
+      // of the coin match the deposit(s) of the coin (by merchant, timestamp, 
etc.)?
+      break;
+    }
+    GNUNET_assert (NULL != add_to); /* check switch was exhaustive */
+    if (GNUNET_OK !=
+        TALER_amount_add (add_to,
+                          add_to,
+                          amount_with_fee))
+    {
+      /* overflow in history already!? inconceivable! Bad DB! */
+      GNUNET_break (0);
+      // FIXME: report!
+      return;
+    }
+    TALER_amount_ntoh (&tmp,
+                       fee_dki);
+    if (0 !=
+        TALER_amount_cmp (&tmp,
+                          fee))
+    {
+      /* Disagreement in fee structure within DB! */
+      GNUNET_break (0);
+      // FIXME: report!
+      return;
+    }
+    if (GNUNET_OK !=
+        TALER_amount_add (&fees,
+                          &fees,
+                          fee))
+    {
+      /* overflow in fee total? inconceivable! Bad DB! */
+      GNUNET_break (0);
+      // FIXME: report!
+      return;
+    }
+  } /* for 'tl' */
+
+  /* Finally, calculate total balance change, i.e. expenditures minus refunds 
*/
+  if (GNUNET_OK !=
+      TALER_amount_subtract (&final_expenditures,
+                             &expenditures,
+                             &refunds))
+  {
+    /* refunds above expenditures? inconceivable! Bad DB! */
+    GNUNET_break (0);
+    // FIXME: report!
+    return;
+  }
+
+}
+
+
+/**
  * Obtain information about the coin from the cache or the database.
  *
+ * If we obtain this information for the first time, also check that
+ * the coin's transaction history is internally consistent.
+ *
  * @param cc caching information
  * @param coin_pub public key of the coin to get information about
  * @return NULL on error
  */
+// FIXME: move this to _outgoing_ transaction checking,
+// replace HERE by something that just gets the denomination hash!
+// (avoids confusion on checking coin's transaction history AND
+//  makes this part WAY more efficient!)
 static struct CoinSummary *
 get_coin_summary (struct CoinContext *cc,
                   const struct TALER_CoinSpendPublicKeyP *coin_pub)
@@ -1247,7 +1332,9 @@ get_coin_summary (struct CoinContext *cc,
   struct GNUNET_HashCode chash;
   struct TALER_EXCHANGEDB_TransactionList *tl;
   const struct TALER_CoinPublicInfo *coin;
+  const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki;
 
+  /* Check cache */
   GNUNET_CRYPTO_hash (coin_pub,
                       sizeof (*coin_pub),
                       &chash);
@@ -1255,6 +1342,8 @@ get_coin_summary (struct CoinContext *cc,
                                           &chash);
   if (NULL != cs)
     return cs; /* cache hit */
+
+  /* Get transaction history of @a coin_pub from DB */
   tl = edb->get_coin_transactions (edb->cls,
                                    esession,
                                    coin_pub);
@@ -1263,6 +1352,8 @@ get_coin_summary (struct CoinContext *cc,
     GNUNET_break (0);
     return NULL;
   }
+
+  /* Obtain general denomination information about the coin */
   coin = NULL;
   switch (tl->type)
   {
@@ -1279,7 +1370,7 @@ get_coin_summary (struct CoinContext *cc,
   GNUNET_assert (NULL != coin); /* hard check that switch worked */
   if (GNUNET_OK !=
       get_denomination_info (&coin->denom_pub,
-                             &cs->dki,
+                             &dki,
                              NULL))
   {
     GNUNET_break (0);
@@ -1288,6 +1379,11 @@ get_coin_summary (struct CoinContext *cc,
     return NULL;
   }
 
+  /* verify that the transaction history we are given is reasonable */
+  check_transaction_history (coin_pub,
+                             dki,
+                             tl);
+
   /* allocate coin slot in ring buffer */
   if (MAX_COIN_SUMMARIES >= cc->summaries_off)
     cc->summaries_off = 0;
@@ -1301,6 +1397,7 @@ get_coin_summary (struct CoinContext *cc,
   cs->coin_pub = *coin_pub;
   cs->coin_hash = chash;
   cs->tl = tl;
+  cs->dki = dki;
   GNUNET_assert (GNUNET_YES ==
                  GNUNET_CONTAINER_multihashmap_put (cc->coins,
                                                     &cs->coin_hash,
@@ -1312,6 +1409,11 @@ get_coin_summary (struct CoinContext *cc,
 
 /**
  * Function called with details about all withdraw operations.
+ * Updates the denomination balance and the overall balance as
+ * we now have additional coins that have been issued.
+ *
+ * Note that the signature was already checked in
+ * #handle_reserve_out(), so we do not check it again here.
  *
  * @param cls our `struct CoinContext`
  * @param rowid unique serial ID for the refresh session in our DB
@@ -1339,6 +1441,7 @@ withdraw_cb (void *cls,
   struct DenominationSummary *ds;
   struct GNUNET_HashCode dh;
   const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki;
+  struct TALER_Amount value;
 
   if (GNUNET_OK !=
       get_denomination_info (denom_pub,
@@ -1350,16 +1453,35 @@ withdraw_cb (void *cls,
   }
   ds = get_denomination_summary (cc,
                                  &dh);
-  // FIXME: use ds, dki, etc.
-  // FIXME: update 'cc'
-
+  TALER_amount_ntoh (&value,
+                     &dki->properties.value);
+  if (GNUNET_OK !=
+      TALER_amount_add (&ds->denom_balance,
+                        &ds->denom_balance,
+                        &value))
+  {
+    GNUNET_break (0);
+    return GNUNET_SYSERR;
+  }
+  if (GNUNET_OK !=
+      TALER_amount_add (&cc->denom_balance,
+                        &cc->denom_balance,
+                        &value))
+  {
+    GNUNET_break (0);
+    return GNUNET_SYSERR;
+  }
   return GNUNET_OK;
 }
 
 
 /**
- * Function called with details about coins that were melted,
- * with the goal of auditing the refresh's execution.
+ * Function called with details about coins that were melted, with the
+ * goal of auditing the refresh's execution.  Verifies the signature
+ * and updates our information about coins outstanding (the old coin's
+ * denomination has less, the fresh coins increased outstanding
+ * balances).  As a side-effect, #get_coin_summary will report
+ * inconsistencies in the melted coin's balance.
  *
  * @param cls closure
  * @param rowid unique serial ID for the refresh session in our DB
@@ -1385,6 +1507,8 @@ refresh_session_cb (void *cls,
   struct TALER_RefreshMeltCoinAffirmationPS rmc;
   struct CoinSummary *cs;
   const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki;
+  struct DenominationSummary *dso;
+  struct TALER_Amount amount_without_fee;
 
   cs = get_coin_summary (cc,
                          coin_pub);
@@ -1394,6 +1518,8 @@ refresh_session_cb (void *cls,
     return GNUNET_SYSERR;
   }
   dki = cs->dki;
+
+  /* verify melt signature */
   rmc.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT);
   rmc.purpose.size = htonl (sizeof (rmc));
   rmc.session_hash = *session_hash;
@@ -1413,8 +1539,149 @@ refresh_session_cb (void *cls,
     return GNUNET_OK;
   }
 
-  // TODO: update risk, denomination outstanding amounts, etc.
+  {
+    struct TALER_DenominationPublicKey new_dp[num_newcoins];
+    const struct TALER_EXCHANGEDB_DenominationKeyInformationP 
*new_dki[num_newcoins];
+    struct TALER_Amount refresh_cost;
 
+    GNUNET_assert (GNUNET_OK ==
+                   TALER_amount_get_zero (amount_with_fee->currency,
+                                          &refresh_cost));
+
+    /* Update outstanding amounts for all new coin's denominations, and check
+       that the resulting amounts are consistent with the value being 
refreshed. */
+    for (unsigned int i=0;i<num_newcoins;i++)
+    {
+      /* lookup new coin denomination key */
+      if (GNUNET_OK !=
+          edb->get_refresh_order (edb->cls,
+                                  esession,
+                                  session_hash,
+                                  i,
+                                  &new_dp[i]))
+      {
+        GNUNET_break (0);
+        return GNUNET_SYSERR;
+      }
+      if (GNUNET_OK !=
+          get_denomination_info (&new_dp[i],
+                                 &new_dki[i],
+                                 NULL))
+      {
+        GNUNET_break (0);
+        return GNUNET_SYSERR;
+      }
+
+      /* update cost of refresh */
+      {
+        struct TALER_Amount fee;
+        struct TALER_Amount value;
+
+        TALER_amount_ntoh (&fee,
+                           &new_dki[i]->properties.fee_withdraw);
+        TALER_amount_ntoh (&value,
+                           &new_dki[i]->properties.value);
+        if ( (GNUNET_OK !=
+              TALER_amount_add (&refresh_cost,
+                                &refresh_cost,
+                                &fee)) ||
+             (GNUNET_OK !=
+              TALER_amount_add (&refresh_cost,
+                                &refresh_cost,
+                                &value)) )
+        {
+          GNUNET_break (0);
+          return GNUNET_SYSERR;
+        }
+      }
+    }
+
+    /* compute contribution of old coin */
+    {
+      struct TALER_Amount melt_fee;
+
+      TALER_amount_ntoh (&melt_fee,
+                         &dki->properties.fee_refresh);
+      if (GNUNET_OK !=
+          TALER_amount_subtract (&amount_without_fee,
+                                 amount_with_fee,
+                                 &melt_fee))
+      {
+        GNUNET_break (0);
+        return GNUNET_SYSERR;
+      }
+    }
+
+    /* check old coin covers complete expenses */
+    if (1 == TALER_amount_cmp (&refresh_cost,
+                               &amount_without_fee))
+    {
+      /* refresh_cost > amount_without_fee */
+      report_row_inconsistency ("melt",
+                                rowid,
+                                "refresh costs exceed value of melt");
+      return GNUNET_OK;
+    }
+
+    /* update outstanding denomination amounts */
+    for (unsigned int i=0;i<num_newcoins;i++)
+    {
+      struct DenominationSummary *dsi;
+      struct TALER_Amount value;
+
+      dsi = get_denomination_summary (cc,
+                                      &new_dki[i]->properties.denom_hash);
+      TALER_amount_ntoh (&value,
+                         &new_dki[i]->properties.value);
+      if (GNUNET_OK !=
+          TALER_amount_add (&dsi->denom_balance,
+                            &dsi->denom_balance,
+                            &value))
+      {
+        GNUNET_break (0);
+        return GNUNET_SYSERR;
+      }
+      if (GNUNET_OK !=
+          TALER_amount_add (&cc->denom_balance,
+                            &cc->denom_balance,
+                            &value))
+      {
+        GNUNET_break (0);
+        return GNUNET_SYSERR;
+      }
+    }
+  }
+
+  /* update old coin's denomination balance */
+  dso = get_denomination_summary (cc,
+                                  &dki->properties.denom_hash);
+  if (GNUNET_OK !=
+      TALER_amount_subtract (&dso->denom_balance,
+                             &dso->denom_balance,
+                             amount_with_fee))
+  {
+    // FIXME: trigger EMERGENCY PROTOCOL HERE! Exchange has been compromised!
+    GNUNET_break (0);
+    return GNUNET_SYSERR;
+  }
+
+  /* update global up melt fees */
+  {
+    struct TALER_Amount rfee;
+
+    TALER_amount_ntoh (&rfee,
+                       &dki->properties.fee_refresh);
+    if (GNUNET_OK !=
+        TALER_amount_add (&cc->melt_fee_balance,
+                          &cc->melt_fee_balance,
+                          &rfee))
+    {
+      GNUNET_break (0);
+      return GNUNET_SYSERR;
+    }
+  }
+
+  /* We're good! */
   return GNUNET_OK;
 }
 
@@ -1423,6 +1690,9 @@ refresh_session_cb (void *cls,
  * Function called with details about deposits that have been made,
  * with the goal of auditing the deposit's execution.
  *
+ * As a side-effect, #get_coin_summary will report
+ * inconsistencies in the deposited coin's balance.
+ *
  * @param cls closure
  * @param rowid unique serial ID for the deposit in our DB
  * @param timestamp when did the deposit happen
@@ -1456,6 +1726,7 @@ deposit_cb (void *cls,
   struct CoinContext *cc = cls;
   struct CoinSummary *cs;
   const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki;
+  struct DenominationSummary *ds;
   struct TALER_DepositRequestPS dr;
 
   cs = get_coin_summary (cc,
@@ -1467,6 +1738,7 @@ deposit_cb (void *cls,
   }
   dki = cs->dki;
 
+  /* Verify deposit signature */
   dr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_DEPOSIT);
   dr.purpose.size = htonl (sizeof (dr));
   dr.h_proposal_data = *h_proposal_data;
@@ -1496,14 +1768,47 @@ deposit_cb (void *cls,
     return GNUNET_OK;
   }
 
-  // TODO: update expected amounts in 'cc'
+  /* update old coin's denomination balance */
+  ds = get_denomination_summary (cc,
+                                 &dki->properties.denom_hash);
+  if (GNUNET_OK !=
+      TALER_amount_subtract (&ds->denom_balance,
+                             &ds->denom_balance,
+                             amount_with_fee))
+  {
+    // FIXME: trigger EMERGENCY PROTOCOL HERE! Exchange has been compromised!
+    GNUNET_break (0);
+    return GNUNET_SYSERR;
+  }
+
+  /* update global up melt fees */
+  {
+    struct TALER_Amount dfee;
+
+    TALER_amount_ntoh (&dfee,
+                       &dki->properties.fee_deposit);
+    if (GNUNET_OK !=
+        TALER_amount_add (&cc->deposit_fee_balance,
+                          &cc->deposit_fee_balance,
+                          &dfee))
+    {
+      GNUNET_break (0);
+      return GNUNET_SYSERR;
+    }
+  }
+
   return GNUNET_OK;
 }
 
 
 /**
  * Function called with details about coins that were refunding,
- * with the goal of auditing the refund's execution.
+ * with the goal of auditing the refund's execution.  Adds the
+ * refunded amount back to the outstanding balance of the respective
+ * denomination.
+ *
+ * As a side-effect, #get_coin_summary will report
+ * inconsistencies in the refunded coin's balance.
  *
  * @param cls closure
  * @param rowid unique serial ID for the refund in our DB
@@ -1528,6 +1833,7 @@ refund_cb (void *cls,
   struct CoinContext *cc = cls;
   struct CoinSummary *cs;
   const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki;
+  struct TALER_RefundRequestPS rr;
 
   cs = get_coin_summary (cc,
                          coin_pub);
@@ -1538,7 +1844,29 @@ refund_cb (void *cls,
   }
   dki = cs->dki;
 
-  // TODO: verify signature
+  /* verify refund signature */
+  rr.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_REFUND);
+  rr.purpose.size = htonl (sizeof (rr));
+  rr.h_proposal_data = *h_proposal_data;
+  rr.coin_pub = *coin_pub;
+  rr.merchant = *merchant_pub;
+  rr.rtransaction_id = GNUNET_htonll (rtransaction_id);
+  TALER_amount_hton (&rr.refund_amount,
+                     amount_with_fee);
+  rr.refund_fee = dki->properties.fee_refund;
+  if (GNUNET_OK !=
+      GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_REFUND,
+                                  &rr.purpose,
+                                  &merchant_sig->eddsa_sig,
+                                  &merchant_pub->eddsa_pub))
+  {
+    report_row_inconsistency ("deposit",
+                              rowid,
+                              "invalid signature for coin deposit");
+    return GNUNET_OK;
+  }
+
+  // TODO: update denomination key balance!
 
   // TODO: update expected amounts in 'cc'
   return GNUNET_OK;
@@ -1559,6 +1887,7 @@ analyze_coins (void *cls)
   int rret;
 
   /* setup 'cc' */
+  // FIXME: FIX misnomer "denomination_summary", as this is no longer exactly 
about denominations!
   dret = adb->get_denomination_summary (adb->cls,
                                         asession,
                                         &master_pub,
@@ -1674,6 +2003,8 @@ analyze_coins (void *cls)
                                      &master_pub,
                                      &cc.risk);
   // FIXME: handle error in 'rret'!
+
+  // FIXME: FIX misnomer "denomination_summary", as this is no longer about 
denominations!
   if (GNUNET_YES == dret)
       dret = adb->update_denomination_summary (adb->cls,
                                                asession,
diff --git a/src/auditordb/plugin_auditordb_postgres.c 
b/src/auditordb/plugin_auditordb_postgres.c
index ebcd0ef..15180a7 100644
--- a/src/auditordb/plugin_auditordb_postgres.c
+++ b/src/auditordb/plugin_auditordb_postgres.c
@@ -330,15 +330,6 @@ postgres_create_tables (void *cls)
            ",denom_balance_val INT8 NOT NULL"
            ",denom_balance_frac INT4 NOT NULL"
            ",denom_balance_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
-           ",deposit_fee_balance_val INT8 NOT NULL"
-           ",deposit_fee_balance_frac INT4 NOT NULL"
-           ",deposit_fee_balance_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT 
NULL"
-           ",melt_fee_balance_val INT8 NOT NULL"
-           ",melt_fee_balance_frac INT4 NOT NULL"
-           ",melt_fee_balance_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
-           ",refund_fee_balance_val INT8 NOT NULL"
-           ",refund_fee_balance_frac INT4 NOT NULL"
-           ",refund_fee_balance_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT 
NULL"
            ",last_reserve_out_serial_id INT8 NOT NULL"
            ",last_deposit_serial_id INT8 NOT NULL"
           ",last_melt_serial_id INT8 NOT NULL"
@@ -703,21 +694,12 @@ postgres_prepare (PGconn *db_conn)
            ",denom_balance_val"
            ",denom_balance_frac"
            ",denom_balance_curr"
-           ",deposit_fee_balance_val"
-           ",deposit_fee_balance_frac"
-           ",deposit_fee_balance_curr"
-           ",melt_fee_balance_val"
-           ",melt_fee_balance_frac"
-           ",melt_fee_balance_curr"
-           ",refund_fee_balance_val"
-           ",refund_fee_balance_frac"
-           ",refund_fee_balance_curr"
            ",last_reserve_out_serial_id"
            ",last_deposit_serial_id"
           ",last_melt_serial_id"
           ",last_refund_serial_id"
-           ") VALUES 
($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17);",
-           17, NULL);
+           ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8);",
+           11, NULL);
 
   /* Used in #postgres_update_denomination_balance() */
   PREPARE ("denomination_pending_update",
@@ -725,21 +707,12 @@ postgres_prepare (PGconn *db_conn)
            " denom_balance_val=$1"
            ",denom_balance_frac=$2"
            ",denom_balance_curr=$3"
-           ",deposit_fee_balance_val=$4"
-           ",deposit_fee_balance_frac=$5"
-           ",deposit_fee_balance_curr=$6"
-           ",melt_fee_balance_val=$7"
-           ",melt_fee_balance_frac=$8"
-           ",melt_fee_balance_curr=$9"
-           ",refund_fee_balance_val=$10"
-           ",refund_fee_balance_frac=$11"
-           ",refund_fee_balance_curr=$12"
-           ",last_reserve_out_serial_id=$13"
-           ",last_deposit_serial_id=$14"
-          ",last_melt_serial_id=$15"
-          ",last_refund_serial_id=$16"
-           " WHERE denom_pub_hash=$17",
-           18, NULL);
+           ",last_reserve_out_serial_id=$4"
+           ",last_deposit_serial_id=$5"
+          ",last_melt_serial_id=$6"
+          ",last_refund_serial_id=$7"
+           " WHERE denom_pub_hash=$8",
+           8, NULL);
 
   /* Used in #postgres_get_denomination_balance() */
   PREPARE ("denomination_pending_select",
@@ -747,15 +720,6 @@ postgres_prepare (PGconn *db_conn)
            " denom_balance_val"
            ",denom_balance_frac"
            ",denom_balance_curr"
-           ",deposit_fee_balance_val"
-           ",deposit_fee_balance_frac"
-           ",deposit_fee_balance_curr"
-           ",melt_fee_balance_val"
-           ",melt_fee_balance_frac"
-           ",melt_fee_balance_curr"
-           ",refund_fee_balance_val"
-           ",refund_fee_balance_frac"
-           ",refund_fee_balance_curr"
            ",last_reserve_out_serial_id"
            ",last_deposit_serial_id"
           ",last_melt_serial_id"
@@ -1895,9 +1859,6 @@ postgres_get_reserve_summary (void *cls,
  * @param session connection to use
  * @param denom_pub_hash hash of the denomination public key
  * @param denom_balance value of coins outstanding with this denomination key
- * @param deposit_fee_balance total deposit fees collected for this DK
- * @param melt_fee_balance total melt fees collected for this DK
- * @param refund_fee_balance total refund fees collected for this DK
  * @param last_reserve_out_serial_id up to which point did we consider
  *                 withdrawals for the above information
  * @param last_deposit_serial_id up to which point did we consider
@@ -1913,9 +1874,6 @@ postgres_insert_denomination_balance (void *cls,
                                       struct TALER_AUDITORDB_Session *session,
                                       const struct GNUNET_HashCode 
*denom_pub_hash,
                                       const struct TALER_Amount *denom_balance,
-                                      const struct TALER_Amount 
*deposit_fee_balance,
-                                      const struct TALER_Amount 
*melt_fee_balance,
-                                      const struct TALER_Amount 
*refund_fee_balance,
                                       uint64_t last_reserve_out_serial_id,
                                       uint64_t last_deposit_serial_id,
                                       uint64_t last_melt_serial_id,
@@ -1926,9 +1884,6 @@ postgres_insert_denomination_balance (void *cls,
   struct GNUNET_PQ_QueryParam params[] = {
     GNUNET_PQ_query_param_auto_from_type (denom_pub_hash),
     TALER_PQ_query_param_amount (denom_balance),
-    TALER_PQ_query_param_amount (deposit_fee_balance),
-    TALER_PQ_query_param_amount (melt_fee_balance),
-    TALER_PQ_query_param_amount (refund_fee_balance),
     GNUNET_PQ_query_param_uint64 (&last_reserve_out_serial_id),
     GNUNET_PQ_query_param_uint64 (&last_deposit_serial_id),
     GNUNET_PQ_query_param_uint64 (&last_melt_serial_id),
@@ -1936,18 +1891,6 @@ postgres_insert_denomination_balance (void *cls,
     GNUNET_PQ_query_param_end
   };
 
-  GNUNET_assert (GNUNET_YES ==
-                 TALER_amount_cmp_currency (denom_balance,
-                                            deposit_fee_balance));
-
-  GNUNET_assert (GNUNET_YES ==
-                 TALER_amount_cmp_currency (denom_balance,
-                                            melt_fee_balance));
-
-  GNUNET_assert (GNUNET_YES ==
-                 TALER_amount_cmp_currency (denom_balance,
-                                            refund_fee_balance));
-
   result = GNUNET_PQ_exec_prepared (session->conn,
                                    "denomination_pending_insert",
                                    params);
@@ -1973,9 +1916,6 @@ postgres_insert_denomination_balance (void *cls,
  * @param session connection to use
  * @param denom_pub_hash hash of the denomination public key
  * @param denom_balance value of coins outstanding with this denomination key
- * @param deposit_fee_balance total deposit fees collected for this DK
- * @param melt_fee_balance total melt fees collected for this DK
- * @param refund_fee_balance total refund fees collected for this DK
  * @param last_reserve_out_serial_id up to which point did we consider
  *                 withdrawals for the above information
  * @param last_deposit_serial_id up to which point did we consider
@@ -1991,9 +1931,6 @@ postgres_update_denomination_balance (void *cls,
                                       struct TALER_AUDITORDB_Session *session,
                                       const struct GNUNET_HashCode 
*denom_pub_hash,
                                       const struct TALER_Amount *denom_balance,
-                                      const struct TALER_Amount 
*deposit_fee_balance,
-                                      const struct TALER_Amount 
*melt_fee_balance,
-                                      const struct TALER_Amount 
*refund_fee_balance,
                                       uint64_t last_reserve_out_serial_id,
                                       uint64_t last_deposit_serial_id,
                                       uint64_t last_melt_serial_id,
@@ -2003,9 +1940,6 @@ postgres_update_denomination_balance (void *cls,
   int ret;
   struct GNUNET_PQ_QueryParam params[] = {
     TALER_PQ_query_param_amount (denom_balance),
-    TALER_PQ_query_param_amount (deposit_fee_balance),
-    TALER_PQ_query_param_amount (melt_fee_balance),
-    TALER_PQ_query_param_amount (refund_fee_balance),
     GNUNET_PQ_query_param_uint64 (&last_reserve_out_serial_id),
     GNUNET_PQ_query_param_uint64 (&last_deposit_serial_id),
     GNUNET_PQ_query_param_uint64 (&last_melt_serial_id),
@@ -2038,9 +1972,6 @@ postgres_update_denomination_balance (void *cls,
  * @param session connection to use
  * @param denom_pub_hash hash of the denomination public key
  * @param[out] denom_balance value of coins outstanding with this denomination 
key
- * @param[out] deposit_fee_balance total deposit fees collected for this DK
- * @param[out] melt_fee_balance total melt fees collected for this DK
- * @param[out] refund_fee_balance total refund fees collected for this DK
  * @param[out] last_reserve_out_serial_id up to which point did we consider
  *                 withdrawals for the above information
  * @param[out] last_deposit_serial_id up to which point did we consider
@@ -2056,9 +1987,6 @@ postgres_get_denomination_balance (void *cls,
                                    struct TALER_AUDITORDB_Session *session,
                                    const struct GNUNET_HashCode 
*denom_pub_hash,
                                    struct TALER_Amount *denom_balance,
-                                   struct TALER_Amount *deposit_fee_balance,
-                                   struct TALER_Amount *melt_fee_balance,
-                                   struct TALER_Amount *refund_fee_balance,
                                    uint64_t *last_reserve_out_serial_id,
                                    uint64_t *last_deposit_serial_id,
                                    uint64_t *last_melt_serial_id,
@@ -2093,10 +2021,6 @@ postgres_get_denomination_balance (void *cls,
 
   struct GNUNET_PQ_ResultSpec rs[] = {
     TALER_PQ_result_spec_amount ("denom_balance", denom_balance),
-    TALER_PQ_result_spec_amount ("deposit_fee_balance", deposit_fee_balance),
-    TALER_PQ_result_spec_amount ("melt_fee_balance", melt_fee_balance),
-    TALER_PQ_result_spec_amount ("refund_fee_balance", refund_fee_balance),
-
     GNUNET_PQ_result_spec_uint64 ("last_reserve_out_serial_id", 
last_reserve_out_serial_id),
     GNUNET_PQ_result_spec_uint64 ("last_deposit_serial_id", 
last_deposit_serial_id),
     GNUNET_PQ_result_spec_uint64 ("last_melt_serial_id", last_melt_serial_id),
diff --git a/src/include/taler_auditordb_plugin.h 
b/src/include/taler_auditordb_plugin.h
index 15d9a4c..a2aefcc 100644
--- a/src/include/taler_auditordb_plugin.h
+++ b/src/include/taler_auditordb_plugin.h
@@ -523,9 +523,6 @@ struct TALER_AUDITORDB_Plugin
    * @param session connection to use
    * @param denom_pub_hash hash of the denomination public key
    * @param denom_balance value of coins outstanding (or issued?) with this 
denomination key
-   * @param deposit_fee_balance total deposit fees collected for this DK
-   * @param melt_fee_balance total melt fees collected for this DK
-   * @param refund_fee_balance total refund fees collected for this DK
    * @param last_reserve_out_serial_id up to which point did we consider
    *                 withdrawals for the above information
    * @param last_deposit_serial_id up to which point did we consider
@@ -541,9 +538,6 @@ struct TALER_AUDITORDB_Plugin
                                  struct TALER_AUDITORDB_Session *session,
                                  const struct GNUNET_HashCode *denom_pub_hash,
                                  const struct TALER_Amount *denom_balance,
-                                 const struct TALER_Amount 
*deposit_fee_balance,
-                                 const struct TALER_Amount *melt_fee_balance,
-                                 const struct TALER_Amount *refund_fee_balance,
                                  uint64_t last_reserve_out_serial_id,
                                  uint64_t last_deposit_serial_id,
                                  uint64_t last_melt_serial_id,
@@ -558,9 +552,6 @@ struct TALER_AUDITORDB_Plugin
    * @param session connection to use
    * @param denom_pub_hash hash of the denomination public key
    * @param denom_balance value of coins outstanding (or issued?) with this 
denomination key
-   * @param deposit_fee_balance total deposit fees collected for this DK
-   * @param melt_fee_balance total melt fees collected for this DK
-   * @param refund_fee_balance total refund fees collected for this DK
    * @param last_reserve_out_serial_id up to which point did we consider
    *                 withdrawals for the above information
    * @param last_deposit_serial_id up to which point did we consider
@@ -576,9 +567,6 @@ struct TALER_AUDITORDB_Plugin
                                  struct TALER_AUDITORDB_Session *session,
                                  const struct GNUNET_HashCode *denom_pub_hash,
                                  const struct TALER_Amount *denom_balance,
-                                 const struct TALER_Amount 
*deposit_fee_balance,
-                                 const struct TALER_Amount *melt_fee_balance,
-                                 const struct TALER_Amount *refund_fee_balance,
                                  uint64_t last_reserve_out_serial_id,
                                  uint64_t last_deposit_serial_id,
                                  uint64_t last_melt_serial_id,
@@ -592,9 +580,6 @@ struct TALER_AUDITORDB_Plugin
    * @param session connection to use
    * @param denom_pub_hash hash of the denomination public key
    * @param[out] denom_balance value of coins outstanding (or issued?) with 
this denomination key
-   * @param[out] deposit_fee_balance total deposit fees collected for this DK
-   * @param[out] melt_fee_balance total melt fees collected for this DK
-   * @param[out] refund_fee_balance total refund fees collected for this DK
    * @param[out] last_reserve_out_serial_id up to which point did we consider
    *                 withdrawals for the above information
    * @param[out] last_deposit_serial_id up to which point did we consider
@@ -610,9 +595,6 @@ struct TALER_AUDITORDB_Plugin
                               struct TALER_AUDITORDB_Session *session,
                               const struct GNUNET_HashCode *denom_pub_hash,
                               struct TALER_Amount *denom_balance,
-                              struct TALER_Amount *deposit_fee_balance,
-                              struct TALER_Amount *melt_fee_balance,
-                              struct TALER_Amount *refund_fee_balance,
                               uint64_t *last_reserve_out_serial_id,
                               uint64_t *last_deposit_serial_id,
                               uint64_t *last_melt_serial_id,

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]