gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated (67d39354 -> 481ffc1a)


From: gnunet
Subject: [taler-exchange] branch master updated (67d39354 -> 481ffc1a)
Date: Tue, 01 Nov 2022 16:44:05 +0100

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

grothoff pushed a change to branch master
in repository exchange.

    from 67d39354 -reduce loglevel
     new 22357678 purse auditor helper theoretically complete (but DB logic 
still missing)
     new 481ffc1a remove wad fee, kyc fee and kyc-timeout

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/auditor/.gitignore                             |   1 +
 src/auditor/generate-auditor-basedb.sh             |   4 +-
 src/auditor/generate-revoke-basedb.sh              |   4 +-
 src/auditor/taler-helper-auditor-purses.c          | 674 ++++++++++++++++-----
 src/benchmark/taler-aggregator-benchmark.c         |   1 -
 src/exchange-tools/taler-exchange-offline.c        |  60 +-
 src/exchange/taler-exchange-httpd_keys.c           |   5 -
 src/exchange/taler-exchange-httpd_keys.h           |   5 -
 .../taler-exchange-httpd_management_global_fees.c  |   9 -
 .../taler-exchange-httpd_management_wire_fees.c    |   3 -
 src/exchange/taler-exchange-httpd_purses_create.c  |  18 +-
 src/exchange/taler-exchange-httpd_purses_deposit.c |   2 +
 src/exchange/taler-exchange-httpd_purses_get.c     |   2 +
 src/exchange/taler-exchange-httpd_purses_merge.c   |  25 +-
 src/exchange/taler-exchange-httpd_reserves_purse.c |   2 +-
 src/exchange/taler-exchange-httpd_wire.c           |   2 -
 src/exchangedb/exchange-0001-part.sql              |   5 -
 src/exchangedb/pg_insert_records_by_table.c        |  10 +-
 src/exchangedb/pg_lookup_records_by_table.c        |  11 -
 src/exchangedb/plugin_exchangedb_postgres.c        | 227 ++++---
 src/exchangedb/test_exchangedb.c                   |   3 -
 src/include/taler_auditordb_plugin.h               |  55 +-
 src/include/taler_crypto_lib.h                     |  53 +-
 src/include/taler_exchange_service.h               |   7 -
 src/include/taler_exchangedb_plugin.h              |  98 ++-
 src/include/taler_json_lib.h                       |   2 -
 src/include/taler_testing_lib.h                    |  10 +-
 src/lib/exchange_api_handle.c                      |   3 -
 src/lib/exchange_api_management_set_global_fee.c   |   5 -
 src/lib/exchange_api_management_set_wire_fee.c     |   2 -
 src/lib/exchange_api_wire.c                        |   2 -
 src/testing/test_auditor_api.c                     |   1 -
 src/testing/test_exchange_api.c                    |   3 -
 .../test_exchange_api_keys_cherry_picking.c        |   1 -
 src/testing/test_exchange_management_api.c         |   5 -
 src/testing/test_exchange_p2p.c                    |   3 -
 src/testing/test_kyc_api.c                         |   3 -
 src/testing/test_taler_exchange_aggregator.c       |   1 -
 src/testing/test_taler_exchange_wirewatch.c        |   1 -
 .../testing_api_cmd_offline_sign_global_fees.c     |  22 -
 .../testing_api_cmd_offline_sign_wire_fees.c       |  10 +-
 src/testing/testing_api_cmd_set_wire_fee.c         |  10 -
 src/util/offline_signatures.c                      |  13 -
 src/util/util.c                                    |  16 -
 src/util/wallet_signatures.c                       |   4 +-
 45 files changed, 870 insertions(+), 533 deletions(-)

diff --git a/src/auditor/.gitignore b/src/auditor/.gitignore
index 59088a1b..963062c1 100644
--- a/src/auditor/.gitignore
+++ b/src/auditor/.gitignore
@@ -23,3 +23,4 @@ auditor-basedb.sqlite3
 taler-auditor-test.sqlite3
 libeufin-nexus.pid
 libeufin-sandbox.pid
+taler-helper-auditor-purses
diff --git a/src/auditor/generate-auditor-basedb.sh 
b/src/auditor/generate-auditor-basedb.sh
index 7c68acf4..cf9cbc9c 100755
--- a/src/auditor/generate-auditor-basedb.sh
+++ b/src/auditor/generate-auditor-basedb.sh
@@ -376,8 +376,8 @@ taler-exchange-offline -c $CONF \
   download sign \
   enable-account `taler-config -c $CONF -s exchange-account-1 -o PAYTO_URI` \
   enable-auditor $AUDITOR_PUB $AUDITOR_URL "TESTKUDOS Auditor" \
-  wire-fee now iban TESTKUDOS:0.07 TESTKUDOS:0.01 TESTKUDOS:0.01 \
-  global-fee now TESTKUDOS:0.01 TESTKUDOS:0.01 TESTKUDOS:0.01 TESTKUDOS:0.01 
1h 1h 1year 5 \
+  wire-fee now iban TESTKUDOS:0.07 TESTKUDOS:0.01 \
+  global-fee now TESTKUDOS:0.01 TESTKUDOS:0.01 TESTKUDOS:0.01 1h 1year 5 \
   upload &> ${MY_TMP_DIR}/taler-exchange-offline.log
 
 echo -n "."
diff --git a/src/auditor/generate-revoke-basedb.sh 
b/src/auditor/generate-revoke-basedb.sh
index 4188f051..0474f2b6 100755
--- a/src/auditor/generate-revoke-basedb.sh
+++ b/src/auditor/generate-revoke-basedb.sh
@@ -369,8 +369,8 @@ taler-exchange-offline -c $CONF \
   download sign \
   enable-account `taler-config -c $CONF -s exchange-account-1 -o PAYTO_URI` \
   enable-auditor $AUDITOR_PUB $AUDITOR_URL "TESTKUDOS Auditor" \
-  wire-fee now iban TESTKUDOS:0.01 TESTKUDOS:0.01 TESTKUDOS:0.01 \
-  global-fee now TESTKUDOS:0.01 TESTKUDOS:0.01 TESTKUDOS:0.01 TESTKUDOS:0.01 
1h 1h 1year 5 \
+  wire-fee now iban TESTKUDOS:0.01 TESTKUDOS:0.01 \
+  global-fee now TESTKUDOS:0.01 TESTKUDOS:0.01 TESTKUDOS:0.01 1h 1year 5 \
   upload &> ${MY_TMP_DIR}/taler-exchange-offline.log
 
 echo -n "."
diff --git a/src/auditor/taler-helper-auditor-purses.c 
b/src/auditor/taler-helper-auditor-purses.c
index cfc345eb..7a011d3b 100644
--- a/src/auditor/taler-helper-auditor-purses.c
+++ b/src/auditor/taler-helper-auditor-purses.c
@@ -68,6 +68,11 @@ static json_t 
*report_purse_balance_insufficient_inconsistencies;
  */
 static struct TALER_Amount total_balance_insufficient_loss;
 
+/**
+ * Total amount purse decisions are delayed past deadline.
+ */
+static struct TALER_Amount total_delayed_decisions;
+
 /**
  * Array of reports about purses's not being closed inconsitencies.
  */
@@ -199,6 +204,52 @@ report_row_inconsistency (const char *table,
 }
 
 
+/**
+ * Obtain the purse fee for a purse created at @a time.
+ *
+ * @param atime when was the purse created
+ * @param[out] fee set to the purse fee
+ * @return #GNUNET_OK on success
+ */
+static enum GNUNET_GenericReturnValue
+get_purse_fee (struct GNUNET_TIME_Timestamp atime,
+               struct TALER_Amount *fee)
+{
+  struct TALER_MasterSignatureP master_sig;
+  struct GNUNET_TIME_Timestamp start_date;
+  struct GNUNET_TIME_Timestamp end_date;
+  struct TALER_GlobalFeeSet fees;
+  struct GNUNET_TIME_Relative ptimeout;
+  struct GNUNET_TIME_Relative hexp;
+  uint32_t pacl;
+
+  if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+      TALER_ARL_edb->get_global_fee (TALER_ARL_edb->cls,
+                                     atime,
+                                     &start_date,
+                                     &end_date,
+                                     &fees,
+                                     &ptimeout,
+                                     &hexp,
+                                     &pacl,
+                                     &master_sig))
+  {
+    char *diag;
+
+    GNUNET_asprintf (&diag,
+                     "purse fee unavailable at %s\n",
+                     GNUNET_TIME_timestamp2s (atime));
+    report_row_inconsistency ("purse-fee",
+                              atime.abs_time.abs_value_us,
+                              diag);
+    GNUNET_free (diag);
+    return GNUNET_SYSERR;
+  }
+  *fee = fees.purse;
+  return GNUNET_OK;
+}
+
+
 /* ***************************** Analyze purses ************************ */
 /* This logic checks the purses_requests, purse_deposits,
    purse_refunds, purse_merges and account_merges */
@@ -215,17 +266,37 @@ struct PurseSummary
   struct TALER_PurseContractPublicKeyP purse_pub;
 
   /**
-   * Balance of the purse from deposits (excludes
-   * deposit fees).
-   * Updated only in #handle_purse_deposits().
+   * Balance of the purse from deposits (includes purse fee, excludes deposit
+   * fees), as calculated by auditor.
    */
   struct TALER_Amount balance;
 
   /**
-   * Expected value of the purse.
+   * Expected value of the purse, excludes purse fee.
    */
   struct TALER_Amount total_value;
 
+  /**
+   * Purse balance according to exchange DB.
+   */
+  struct TALER_Amount exchange_balance;
+
+  /**
+   * Contract terms of the purse.
+   */
+  struct TALER_PrivateContractHashP h_contract_terms;
+
+  /**
+   * Merge timestamp (as per exchange DB).
+   */
+  struct GNUNET_TIME_Timestamp merge_timestamp;
+
+  /**
+   * Purse creation date.  This is when the merge
+   * fee is applied.
+   */
+  struct GNUNET_TIME_Timestamp creation_date;
+
   /**
    * Purse expiration date.
    */
@@ -328,6 +399,21 @@ setup_purse (struct PurseContext *pc,
   GNUNET_assert (GNUNET_OK ==
                  TALER_amount_set_zero (TALER_ARL_currency,
                                         &ps->balance));
+  /* get purse meta-data from exchange DB */
+  qs = TALER_ARL_edb->select_purse (TALER_ARL_edb->cls,
+                                    purse_pub,
+                                    &ps->creation_date,
+                                    &ps->expiration_date,
+                                    &ps->total_value,
+                                    &ps->exchange_balance,
+                                    &ps->h_contract_terms,
+                                    &ps->merge_timestamp);
+  if (0 >= qs)
+  {
+    GNUNET_free (ps);
+    pc->qs = qs;
+    return NULL;
+  }
   if (0 > (qs = load_auditor_purse_summary (ps)))
   {
     GNUNET_free (ps);
@@ -344,33 +430,76 @@ setup_purse (struct PurseContext *pc,
 
 
 /**
- * Check that the purse summary matches what the exchange database
- * thinks about the purse, and update our own state of the purse.
- *
- * Remove all purses that we are happy with from the DB.
+ * Function called on purse requests.
  *
- * @param cls our `struct PurseContext`
- * @param key hash of the purse public key
- * @param value a `struct PurseSummary`
- * @return #GNUNET_OK to process more entries
- */
+ * @param cls closure
+ * @param purse_pub public key of the purse
+ * @param merge_pub public key representing the merge capability
+ * @param purse_expiration when would an unmerged purse expire
+ * @param h_contract_terms contract associated with the purse
+ * @param age_limit the age limit for deposits into the purse
+ * @param target_amount amount to be put into the purse
+ * @param purse_sig signature of the purse over the initialization data
+ * @return #GNUNET_OK to continue to iterate
+   */
 static enum GNUNET_GenericReturnValue
-verify_purse_balance (void *cls,
-                      const struct GNUNET_HashCode *key,
-                      void *value)
+handle_purse_requested (
+  void *cls,
+  uint64_t rowid,
+  const struct TALER_PurseContractPublicKeyP *purse_pub,
+  const struct TALER_PurseMergePublicKeyP *merge_pub,
+  struct GNUNET_TIME_Timestamp purse_creation,
+  struct GNUNET_TIME_Timestamp purse_expiration,
+  const struct TALER_PrivateContractHashP *h_contract_terms,
+  uint32_t age_limit,
+  const struct TALER_Amount *target_amount,
+  const struct TALER_PurseContractSignatureP *purse_sig)
 {
   struct PurseContext *pc = cls;
-  struct PurseSummary *ps = value;
-  enum GNUNET_GenericReturnValue ret;
+  struct PurseSummary *ps;
+  struct GNUNET_HashCode key;
 
-  ret = GNUNET_OK;
-  // FIXME: implement!
-  GNUNET_assert (GNUNET_YES ==
-                 GNUNET_CONTAINER_multihashmap_remove (pc->purses,
-                                                       key,
-                                                       ps));
-  GNUNET_free (ps);
-  return ret;
+  if (GNUNET_OK !=
+      TALER_wallet_purse_create_verify (purse_expiration,
+                                        h_contract_terms,
+                                        merge_pub,
+                                        age_limit,
+                                        target_amount,
+                                        purse_pub,
+                                        purse_sig))
+  {
+    TALER_ARL_report (report_bad_sig_losses,
+                      GNUNET_JSON_PACK (
+                        GNUNET_JSON_pack_string ("operation",
+                                                 "purse-reqeust"),
+                        GNUNET_JSON_pack_uint64 ("row",
+                                                 rowid),
+                        TALER_JSON_pack_amount ("loss",
+                                                target_amount),
+                        GNUNET_JSON_pack_data_auto ("key_pub",
+                                                    purse_pub)));
+    TALER_ARL_amount_add (&total_bad_sig_loss,
+                          &total_bad_sig_loss,
+                          target_amount);
+  }
+  GNUNET_CRYPTO_hash (purse_pub,
+                      sizeof (*purse_pub),
+                      &key);
+  ps = GNUNET_new (struct PurseSummary);
+  ps->purse_pub = *purse_pub;
+  GNUNET_assert (GNUNET_OK ==
+                 TALER_amount_set_zero (TALER_ARL_currency,
+                                        &ps->balance));
+  ps->creation_date = purse_creation;
+  ps->expiration_date = purse_expiration;
+  ps->total_value = *target_amount;
+  ps->h_contract_terms = *h_contract_terms;
+  GNUNET_assert (GNUNET_OK ==
+                 GNUNET_CONTAINER_multihashmap_put (pc->purses,
+                                                    &key,
+                                                    ps,
+                                                    
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+  return GNUNET_OK;
 }
 
 
@@ -401,14 +530,12 @@ handle_purse_deposits (
   const struct TALER_DenominationPublicKey *denom_pub)
 {
   struct PurseContext *pc = cls;
+  struct TALER_Amount amount_minus_fee;
+  struct PurseSummary *ps;
   const char *base_url
     = (NULL == deposit->exchange_base_url)
     ? TALER_ARL_exchange_url
     : deposit->exchange_base_url;
-  enum GNUNET_DB_QueryStatus qs;
-  struct TALER_Amount amount_minus_fee;
-  struct TALER_Amount new_balance;
-  struct PurseSummary *rs;
   struct TALER_DenominationHashP h_denom_pub;
 
   /* should be monotonically increasing */
@@ -471,68 +598,42 @@ handle_purse_deposits (
     return GNUNET_OK;
   }
 
-  TALER_ARL_amount_add (&new_balance,
-                        auditor_balance,
-                        &amount_minus_fee);
-  qs = TALER_ARL_edb->set_purse_balance (TALER_ARL_edb->cls,
-                                         &deposit->purse_pub,
-                                         &new_balance);
-  GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != qs);
-  if (qs < 0)
-  {
-    GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
-    GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
-    pc->qs = qs;
-    return GNUNET_SYSERR;
-  }
-  if (TALER_WAMF_MODE_CREATE_WITH_PURSE_FEE !=
-      (flags & TALER_WAMF_MERGE_MODE_MASK))
-  {
-    /* This just created the purse, actual credit to
-       the reserve will be done in handle_account_merged() */
-    return GNUNET_OK;
-  }
-  if ( (NULL != deposit->exchange_base_url) &&
-       (0 != strcmp (deposit->exchange_base_url,
-                     TALER_ARL_exchange_url)) )
-  {
-    /* credited reserve is at another exchange, do NOT credit here! */
-    return GNUNET_OK;
-  }
-
-  rs = setup_purse (pc,
+  ps = setup_purse (pc,
                     &deposit->purse_pub);
-  if (NULL == rs)
+  if (NULL == ps)
   {
-    GNUNET_break (0);
+    if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == pc->qs)
+    {
+      report_row_inconsistency ("purse-deposit",
+                                rowid,
+                                "purse not found");
+    }
+    else
+    {
+      /* Database trouble!? */
+      GNUNET_break (0);
+    }
     return GNUNET_SYSERR;
   }
-  if ( (-1 != TALER_amount_cmp (&new_balance,
-                                purse_total)) &&
-       (-1 == TALER_amount_cmp (auditor_balance,
-                                purse_total)) )
-  {
-    /* new balance at or above purse_total
-       (and previous balance was below); thus
-       credit reserve with purse value! */
-    TALER_ARL_amount_add (&rs->balance,
-                          &rs->balance,
-                          purse_total);
-  }
+  TALER_ARL_amount_add (&ps->balance,
+                        &ps->balance,
+                        &amount_minus_fee);
+  TALER_ARL_amount_add (&balance.balance,
+                        &balance.balance,
+                        &amount_minus_fee);
   return GNUNET_OK;
 }
 
 
 /**
- * Function called with details about purse
- * merges that have been made, with
+ * Function called with details about purse merges that have been made, with
  * the goal of auditing the purse merge execution.
  *
  * @param cls closure
  * @param rowid unique serial ID for the deposit in our DB
  * @param partner_base_url where is the reserve, NULL for this exchange
  * @param amount total amount expected in the purse
- * @param balance current balance in the purse (according to the auditor)
+ * @param balance current balance in the purse
  * @param flags purse flags
  * @param merge_pub merge capability key
  * @param reserve_pub reserve the merge affects
@@ -557,97 +658,76 @@ handle_purse_merged (
 {
   struct PurseContext *pc = cls;
   struct PurseSummary *ps;
-  char *reserve_url;
 
   /* should be monotonically increasing */
   GNUNET_assert (rowid >= ppp.last_purse_merge_serial_id);
   ppp.last_purse_merge_serial_id = rowid + 1;
-  reserve_url
-    = TALER_reserve_make_payto (NULL == partner_base_url
+
+  {
+    char *reserve_url;
+
+    reserve_url
+      = TALER_reserve_make_payto (NULL == partner_base_url
                                 ? TALER_ARL_exchange_url
                                 : partner_base_url,
-                                reserve_pub);
-  if (GNUNET_OK !=
-      TALER_wallet_purse_merge_verify (reserve_url,
-                                       merge_timestamp,
-                                       purse_pub,
-                                       merge_pub,
-                                       merge_sig))
-  {
+                                  reserve_pub);
+    if (GNUNET_OK !=
+        TALER_wallet_purse_merge_verify (reserve_url,
+                                         merge_timestamp,
+                                         purse_pub,
+                                         merge_pub,
+                                         merge_sig))
+    {
+      GNUNET_free (reserve_url);
+      TALER_ARL_report (report_bad_sig_losses,
+                        GNUNET_JSON_PACK (
+                          GNUNET_JSON_pack_string ("operation",
+                                                   "merge-purse"),
+                          GNUNET_JSON_pack_uint64 ("row",
+                                                   rowid),
+                          TALER_JSON_pack_amount ("loss",
+                                                  amount),
+                          GNUNET_JSON_pack_data_auto ("key_pub",
+                                                      merge_pub)));
+      TALER_ARL_amount_add (&total_bad_sig_loss,
+                            &total_bad_sig_loss,
+                            amount);
+      return GNUNET_OK;
+    }
     GNUNET_free (reserve_url);
-    TALER_ARL_report (report_bad_sig_losses,
-                      GNUNET_JSON_PACK (
-                        GNUNET_JSON_pack_string ("operation",
-                                                 "merge-purse"),
-                        GNUNET_JSON_pack_uint64 ("row",
-                                                 rowid),
-                        TALER_JSON_pack_amount ("loss",
-                                                amount),
-                        GNUNET_JSON_pack_data_auto ("key_pub",
-                                                    merge_pub)));
-    TALER_ARL_amount_add (&total_bad_sig_loss,
-                          &total_bad_sig_loss,
-                          amount);
-    return GNUNET_OK;
-  }
-  GNUNET_free (reserve_url);
-  if (TALER_WAMF_MODE_CREATE_WITH_PURSE_FEE ==
-      (flags & TALER_WAMF_MERGE_MODE_MASK))
-  {
-    /* This just created the purse, actual credit to
-       the reserve will be done in handle_purse_deposits() */
-    return GNUNET_OK;
-  }
-  if ( (NULL != partner_base_url) &&
-       (0 != strcmp (partner_base_url,
-                     TALER_ARL_exchange_url)) )
-  {
-    /* credited reserve is at another exchange, do NOT credit here! */
-    return GNUNET_OK;
   }
+
   ps = setup_purse (pc,
                     purse_pub);
   if (NULL == ps)
   {
-    GNUNET_break (0);
+    if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == pc->qs)
+    {
+      report_row_inconsistency ("purse-merge",
+                                rowid,
+                                "purse not found");
+    }
+    else
+    {
+      /* Database trouble!? */
+      GNUNET_break (0);
+    }
     return GNUNET_SYSERR;
   }
-  if (-1 == TALER_amount_cmp (balance,
-                              amount))
-  {
-    struct TALER_Amount loss;
-
-    TALER_ARL_amount_subtract (&loss,
-                               amount,
-                               balance);
-    /* illegal merge, balance is still below total purse value */
-    TALER_ARL_report (report_purse_balance_insufficient_inconsistencies,
-                      GNUNET_JSON_PACK (
-                        GNUNET_JSON_pack_string ("operation",
-                                                 "merge-purse"),
-                        GNUNET_JSON_pack_uint64 ("row",
-                                                 rowid),
-                        TALER_JSON_pack_amount ("loss",
-                                                &loss),
-                        GNUNET_JSON_pack_data_auto ("purse_pub",
-                                                    purse_pub)));
-    TALER_ARL_amount_add (&total_balance_insufficient_loss,
-                          &total_balance_insufficient_loss,
-                          &loss);
-    return GNUNET_OK;
-  }
+  GNUNET_break (0 ==
+                GNUNET_TIME_timestamp_cmp (merge_timestamp,
+                                           ==,
+                                           ps->merge_timestamp));
   TALER_ARL_amount_add (&ps->balance,
                         &ps->balance,
                         amount);
-  // ps->a_expiration_date = FIXME: do we care? If so, set to what (so that 
the auditor no longer complains about the reserve not being closed)
   return GNUNET_OK;
 }
 
 
 /**
- * Function called with details about
- * account merge requests that have been made, with
- * the goal of auditing the account merge execution.
+ * Function called with details about account merge requests that have been
+ * made, with the goal of auditing the account merge execution.
  *
  * @param cls closure
  * @param rowid unique serial ID for the deposit in our DB
@@ -715,20 +795,265 @@ handle_account_merged (
                     purse_pub);
   if (NULL == ps)
   {
-    GNUNET_break (0);
+    if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == pc->qs)
+    {
+      report_row_inconsistency ("account-merge",
+                                rowid,
+                                "purse not found");
+    }
+    else
+    {
+      /* Database trouble!? */
+      GNUNET_break (0);
+    }
     return GNUNET_SYSERR;
   }
-
   TALER_ARL_amount_add (&balance.balance,
                         &balance.balance,
                         purse_fee);
   TALER_ARL_amount_add (&ps->balance,
                         &ps->balance,
-                        amount);
+                        purse_fee);
+  return GNUNET_OK;
+}
+
+
+/**
+ * Function called with details about purse decisions that have been made.
+ *
+ * @param cls closure
+ * @param rowid unique serial ID for the deposit in our DB
+ * @param purse_pub which purse was the decision made on
+ * @param refunded true if decision was to refund
+ * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
+ */
+static enum GNUNET_GenericReturnValue
+handle_purse_decision (
+  void *cls,
+  uint64_t rowid,
+  const struct TALER_PurseContractPublicKeyP *purse_pub,
+  bool refunded)
+{
+  struct PurseContext *pc = cls;
+  struct PurseSummary *ps;
+  struct GNUNET_HashCode key;
+  enum GNUNET_DB_QueryStatus qs;
+  struct TALER_Amount purse_fee;
+  struct TALER_Amount balance_without_purse_fee;
+
+  ps = setup_purse (pc,
+                    purse_pub);
+  if (NULL == ps)
+  {
+    if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == pc->qs)
+    {
+      report_row_inconsistency ("purse-decision",
+                                rowid,
+                                "purse not found");
+    }
+    else
+    {
+      /* Database trouble!? */
+      GNUNET_break (0);
+    }
+    return GNUNET_SYSERR;
+  }
+  if (GNUNET_OK !=
+      get_purse_fee (ps->creation_date,
+                     &purse_fee))
+  {
+    report_row_inconsistency ("purse-request",
+                              rowid,
+                              "purse fee unavailable");
+  }
+  if (0 >
+      TALER_amount_subtract (&balance_without_purse_fee,
+                             &ps->balance,
+                             &purse_fee))
+  {
+    report_row_inconsistency ("purse-request",
+                              rowid,
+                              "purse fee higher than balance");
+    TALER_amount_set_zero (TALER_ARL_currency,
+                           &balance_without_purse_fee);
+  }
+
+  if (refunded)
+  {
+    if (-1 != TALER_amount_cmp (&balance_without_purse_fee,
+                                &ps->total_value))
+    {
+      report_amount_arithmetic_inconsistency ("purse-decision: refund",
+                                              rowid,
+                                              &balance_without_purse_fee,
+                                              &ps->total_value,
+                                              0);
+    }
+  }
+  else
+  {
+    if (-1 == TALER_amount_cmp (&balance_without_purse_fee,
+                                &ps->total_value))
+    {
+      report_amount_arithmetic_inconsistency ("purse-decision: merge",
+                                              rowid,
+                                              &ps->total_value,
+                                              &balance_without_purse_fee,
+                                              0);
+      TALER_ARL_amount_add (&total_balance_insufficient_loss,
+                            &total_balance_insufficient_loss,
+                            &ps->total_value);
+    }
+  }
+
+  qs = TALER_ARL_adb->delete_purse_info (TALER_ARL_adb->cls,
+                                         purse_pub,
+                                         &TALER_ARL_master_pub);
+  GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != qs);
+  if (qs < 0)
+  {
+    GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
+    GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
+    pc->qs = qs;
+    return GNUNET_SYSERR;
+  }
+  GNUNET_CRYPTO_hash (purse_pub,
+                      sizeof (*purse_pub),
+                      &key);
+  GNUNET_assert (GNUNET_YES ==
+                 GNUNET_CONTAINER_multihashmap_remove (pc->purses,
+                                                       &key,
+                                                       ps));
+  GNUNET_free (ps);
+  return GNUNET_OK;
+}
+
+
+/**
+ * Function called on expired purses.
+ *
+ * @param cls closure
+ * @param purse_pub public key of the purse
+ * @param balance amount of money in the purse
+ * @param expiration_date when did the purse expire?
+ * @return #GNUNET_OK to continue to iterate
+ */
+static enum GNUNET_GenericReturnValue
+handle_purse_expired (
+  void *cls,
+  const struct TALER_PurseContractPublicKeyP *purse_pub,
+  const struct TALER_Amount *balance,
+  struct GNUNET_TIME_Timestamp expiration_date)
+{
+  struct PurseContext *pc = cls;
+
+  (void) pc;
+  TALER_ARL_report (report_purse_not_closed_inconsistencies,
+                    GNUNET_JSON_PACK (
+                      GNUNET_JSON_pack_data_auto ("purse_pub",
+                                                  purse_pub),
+                      TALER_JSON_pack_amount ("balance",
+                                              balance),
+                      TALER_JSON_pack_time_abs_human ("expired",
+                                                      
expiration_date.abs_time)));
+  TALER_ARL_amount_add (&total_delayed_decisions,
+                        &total_delayed_decisions,
+                        balance);
   return GNUNET_OK;
 }
 
 
+/**
+ * Check that the purse summary matches what the exchange database
+ * thinks about the purse, and update our own state of the purse.
+ *
+ * Remove all purses that we are happy with from the DB.
+ *
+ * @param cls our `struct PurseContext`
+ * @param key hash of the purse public key
+ * @param value a `struct PurseSummary`
+ * @return #GNUNET_OK to process more entries
+ */
+static enum GNUNET_GenericReturnValue
+verify_purse_balance (void *cls,
+                      const struct GNUNET_HashCode *key,
+                      void *value)
+{
+  struct PurseContext *pc = cls;
+  struct PurseSummary *ps = value;
+  enum GNUNET_GenericReturnValue ret;
+  enum GNUNET_DB_QueryStatus qs;
+
+  ret = GNUNET_OK;
+  if (internal_checks)
+  {
+    struct TALER_Amount pf;
+    struct TALER_Amount balance_without_purse_fee;
+
+    /* subtract purse fee from ps->balance to get actual balance we expect, as
+       we track the balance including purse fee, while the exchange subtracts
+       the purse fee early on. */
+    if (GNUNET_OK !=
+        get_purse_fee (ps->creation_date,
+                       &pf))
+    {
+      GNUNET_break (0);
+      report_row_inconsistency ("purse",
+                                0,
+                                "purse fee unavailable");
+    }
+    if (0 >
+        TALER_amount_subtract (&balance_without_purse_fee,
+                               &ps->balance,
+                               &pf))
+    {
+      report_row_inconsistency ("purse",
+                                0,
+                                "purse fee higher than balance");
+      TALER_amount_set_zero (TALER_ARL_currency,
+                             &balance_without_purse_fee);
+    }
+
+    if (0 != TALER_amount_cmp (&ps->exchange_balance,
+                               &balance_without_purse_fee))
+    {
+      report_amount_arithmetic_inconsistency ("purse-balance",
+                                              0,
+                                              &ps->exchange_balance,
+                                              &balance_without_purse_fee,
+                                              0);
+    }
+  }
+
+  if (ps->had_pi)
+    qs = TALER_ARL_adb->update_purse_info (TALER_ARL_adb->cls,
+                                           &ps->purse_pub,
+                                           &TALER_ARL_master_pub,
+                                           &ps->balance);
+  else
+    qs = TALER_ARL_adb->insert_purse_info (TALER_ARL_adb->cls,
+                                           &ps->purse_pub,
+                                           &TALER_ARL_master_pub,
+                                           &ps->balance,
+                                           ps->expiration_date);
+  GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != qs);
+  if (qs < 0)
+  {
+    GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
+    GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
+    pc->qs = qs;
+    return GNUNET_SYSERR;
+  }
+
+  GNUNET_assert (GNUNET_YES ==
+                 GNUNET_CONTAINER_multihashmap_remove (pc->purses,
+                                                       key,
+                                                       ps));
+  GNUNET_free (ps);
+  return ret;
+}
+
+
 /**
  * Analyze purses for being well-formed.
  *
@@ -762,9 +1087,10 @@ analyze_purses (void *cls)
   else
   {
     ppp_start = ppp;
-    // FIXME: add other values!
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                "Resuming purse audit at %llu/%llu/%llu\n",
+                "Resuming purse audit at %llu/%llu/%llu/%llu/%llu\n",
+                (unsigned long long) ppp.last_purse_request_serial_id,
+                (unsigned long long) ppp.last_purse_decision_serial_id,
                 (unsigned long long) ppp.last_purse_merge_serial_id,
                 (unsigned long long) ppp.last_purse_deposits_serial_id,
                 (unsigned long long) ppp.last_account_merge_serial_id);
@@ -780,6 +1106,18 @@ analyze_purses (void *cls)
   }
   pc.purses = GNUNET_CONTAINER_multihashmap_create (512,
                                                     GNUNET_NO);
+
+  qs = TALER_ARL_edb->select_purse_requests_above_serial_id (
+    TALER_ARL_edb->cls,
+    ppp.last_purse_request_serial_id,
+    &handle_purse_requested,
+    &pc);
+  if (qs < 0)
+  {
+    GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
+    return qs;
+  }
+
   qs = TALER_ARL_edb->select_purse_merges_above_serial_id (
     TALER_ARL_edb->cls,
     ppp.last_purse_merge_serial_id,
@@ -812,6 +1150,28 @@ analyze_purses (void *cls)
     return qs;
   }
 
+  qs = TALER_ARL_edb->select_all_purse_decisions_above_serial_id (
+    TALER_ARL_edb->cls,
+    ppp.last_purse_decision_serial_id,
+    &handle_purse_decision,
+    &pc);
+  if (qs < 0)
+  {
+    GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
+    return qs;
+  }
+
+  qs = TALER_ARL_adb->select_purse_expired (
+    TALER_ARL_adb->cls,
+    &TALER_ARL_master_pub,
+    &handle_purse_expired,
+    &pc);
+  if (qs < 0)
+  {
+    GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
+    return qs;
+  }
+
   GNUNET_CONTAINER_multihashmap_iterate (pc.purses,
                                          &verify_purse_balance,
                                          &pc);
@@ -853,7 +1213,9 @@ analyze_purses (void *cls)
     return qs;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Concluded purse audit step at %llu/%llu/%llu\n",
+              "Concluded purse audit step at %llu/%llu/%llu/%llu/%llu\n",
+              (unsigned long long) ppp.last_purse_request_serial_id,
+              (unsigned long long) ppp.last_purse_decision_serial_id,
               (unsigned long long) ppp.last_purse_merge_serial_id,
               (unsigned long long) ppp.last_purse_deposits_serial_id,
               (unsigned long long) ppp.last_account_merge_serial_id);
@@ -889,6 +1251,12 @@ run (void *cls,
   GNUNET_assert (GNUNET_OK ==
                  TALER_amount_set_zero (TALER_ARL_currency,
                                         &balance.balance));
+  GNUNET_assert (GNUNET_OK ==
+                 TALER_amount_set_zero (TALER_ARL_currency,
+                                        &total_balance_insufficient_loss));
+  GNUNET_assert (GNUNET_OK ==
+                 TALER_amount_set_zero (TALER_ARL_currency,
+                                        &total_delayed_decisions));
   GNUNET_assert (GNUNET_OK ==
                  TALER_amount_set_zero (TALER_ARL_currency,
                                         &total_arithmetic_delta_plus));
@@ -927,6 +1295,8 @@ run (void *cls,
       /* Globals (REVIEW!) */
       TALER_JSON_pack_amount ("total_balance_insufficient",
                               &total_balance_insufficient_loss),
+      TALER_JSON_pack_amount ("total_delayed_purse_decisions",
+                              &total_delayed_decisions),
       GNUNET_JSON_pack_array_steal (
         "purse_balance_insufficient_inconsistencies",
         report_purse_balance_insufficient_inconsistencies),
diff --git a/src/benchmark/taler-aggregator-benchmark.c 
b/src/benchmark/taler-aggregator-benchmark.c
index 869f0aae..bf9a3f3e 100644
--- a/src/benchmark/taler-aggregator-benchmark.c
+++ b/src/benchmark/taler-aggregator-benchmark.c
@@ -562,7 +562,6 @@ run (void *cls,
       ws = GNUNET_TIME_absolute_to_timestamp (GNUNET_TIME_year_to_time (y - 
1));
       we = GNUNET_TIME_absolute_to_timestamp (GNUNET_TIME_year_to_time (y));
       make_amount (0, 5, &fees.wire);
-      make_amount (0, 5, &fees.wad);
       make_amount (0, 5, &fees.closing);
       memset (&master_sig,
               0,
diff --git a/src/exchange-tools/taler-exchange-offline.c 
b/src/exchange-tools/taler-exchange-offline.c
index 60a39df9..26ddf738 100644
--- a/src/exchange-tools/taler-exchange-offline.c
+++ b/src/exchange-tools/taler-exchange-offline.c
@@ -1639,9 +1639,6 @@ upload_wire_fee (const char *exchange_url,
     TALER_JSON_spec_amount ("wire_fee",
                             currency,
                             &fees.wire),
-    TALER_JSON_spec_amount ("wad_fee",
-                            currency,
-                            &fees.wad),
     TALER_JSON_spec_amount ("closing_fee",
                             currency,
                             &fees.closing),
@@ -1741,16 +1738,12 @@ upload_global_fee (const char *exchange_url,
   struct GNUNET_TIME_Timestamp start_time;
   struct GNUNET_TIME_Timestamp end_time;
   struct GNUNET_TIME_Relative purse_timeout;
-  struct GNUNET_TIME_Relative kyc_timeout;
   struct GNUNET_TIME_Relative history_expiration;
   uint32_t purse_account_limit;
   struct GNUNET_JSON_Specification spec[] = {
     TALER_JSON_spec_amount ("history_fee",
                             currency,
                             &fees.history),
-    TALER_JSON_spec_amount ("kyc_fee",
-                            currency,
-                            &fees.kyc),
     TALER_JSON_spec_amount ("account_fee",
                             currency,
                             &fees.account),
@@ -1759,8 +1752,6 @@ upload_global_fee (const char *exchange_url,
                             &fees.purse),
     GNUNET_JSON_spec_relative_time ("purse_timeout",
                                     &purse_timeout),
-    GNUNET_JSON_spec_relative_time ("kyc_timeout",
-                                    &kyc_timeout),
     GNUNET_JSON_spec_relative_time ("history_expiration",
                                     &history_expiration),
     GNUNET_JSON_spec_uint32 ("purse_account_limit",
@@ -1801,7 +1792,6 @@ upload_global_fee (const char *exchange_url,
                                                end_time,
                                                &fees,
                                                purse_timeout,
-                                               kyc_timeout,
                                                history_expiration,
                                                purse_account_limit,
                                                &master_sig,
@@ -2752,7 +2742,7 @@ do_del_wire (char *const *args)
  *
  * @param args the array of command-line arguments to process next;
  *        args[0] must be the year, args[1] the wire method, args[2] the wire 
fee and args[3]
- *        the closing fee and args[4] the wad fee.
+ *        the closing fee.
  */
 static void
 do_set_wire_fee (char *const *args)
@@ -2776,7 +2766,6 @@ do_set_wire_fee (char *const *args)
        (NULL == args[1]) ||
        (NULL == args[2]) ||
        (NULL == args[3]) ||
-       (NULL == args[4]) ||
        ( (1 != sscanf (args[0],
                        "%u%c",
                        &year,
@@ -2788,13 +2777,10 @@ do_set_wire_fee (char *const *args)
                                 &fees.wire)) ||
        (GNUNET_OK !=
         TALER_string_to_amount (args[3],
-                                &fees.closing)) ||
-       (GNUNET_OK !=
-        TALER_string_to_amount (args[4],
-                                &fees.wad)) )
+                                &fees.closing)) )
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "You must use YEAR, METHOD, WIRE-FEE, CLOSING-FEE and WAD-FEE 
as arguments for this subcommand\n");
+                "You must use YEAR, METHOD, WIRE-FEE, and CLOSING-FEE as 
arguments for this subcommand\n");
     test_shutdown ();
     global_ret = EXIT_INVALIDARGUMENT;
     return;
@@ -2826,13 +2812,11 @@ do_set_wire_fee (char *const *args)
                                                   end_time),
                       TALER_JSON_pack_amount ("wire_fee",
                                               &fees.wire),
-                      TALER_JSON_pack_amount ("wad_fee",
-                                              &fees.wad),
                       TALER_JSON_pack_amount ("closing_fee",
                                               &fees.closing),
                       GNUNET_JSON_pack_data_auto ("master_sig",
                                                   &master_sig)));
-  next (args + 5);
+  next (args + 4);
 }
 
 
@@ -2840,9 +2824,9 @@ do_set_wire_fee (char *const *args)
  * Set global fees for the given year.
  *
  * @param args the array of command-line arguments to process next;
- *        args[0] must be the year, args[1] the history fee, args[2] the kyc 
fee, args[3]
- *        the account fee and args[4] the purse fee. These are followed by 
args[5] purse timeout,
- *        args[6] kyc timeout and args[7] history expiration. Last is args[8] 
the (free) purse account limit.
+ *        args[0] must be the year, args[1] the history fee, args[2]
+ *        the account fee and args[3] the purse fee. These are followed by 
args[4] purse timeout,
+ *        args[5] history expiration. Last is args[6] the (free) purse account 
limit.
  */
 static void
 do_set_global_fee (char *const *args)
@@ -2852,7 +2836,6 @@ do_set_global_fee (char *const *args)
   unsigned int year;
   struct TALER_GlobalFeeSet fees;
   struct GNUNET_TIME_Relative purse_timeout;
-  struct GNUNET_TIME_Relative kyc_timeout;
   struct GNUNET_TIME_Relative history_expiration;
   unsigned int purse_account_limit;
   struct GNUNET_TIME_Timestamp start_time;
@@ -2873,8 +2856,6 @@ do_set_global_fee (char *const *args)
        (NULL == args[4]) ||
        (NULL == args[5]) ||
        (NULL == args[6]) ||
-       (NULL == args[7]) ||
-       (NULL == args[8]) ||
        ( (1 != sscanf (args[0],
                        "%u%c",
                        &year,
@@ -2886,29 +2867,23 @@ do_set_global_fee (char *const *args)
                                 &fees.history)) ||
        (GNUNET_OK !=
         TALER_string_to_amount (args[2],
-                                &fees.kyc)) ||
-       (GNUNET_OK !=
-        TALER_string_to_amount (args[3],
                                 &fees.account)) ||
        (GNUNET_OK !=
-        TALER_string_to_amount (args[4],
+        TALER_string_to_amount (args[3],
                                 &fees.purse)) ||
        (GNUNET_OK !=
-        GNUNET_STRINGS_fancy_time_to_relative (args[5],
+        GNUNET_STRINGS_fancy_time_to_relative (args[4],
                                                &purse_timeout)) ||
        (GNUNET_OK !=
-        GNUNET_STRINGS_fancy_time_to_relative (args[6],
-                                               &kyc_timeout)) ||
-       (GNUNET_OK !=
-        GNUNET_STRINGS_fancy_time_to_relative (args[7],
+        GNUNET_STRINGS_fancy_time_to_relative (args[5],
                                                &history_expiration)) ||
-       (1 != sscanf (args[8],
+       (1 != sscanf (args[6],
                      "%u%c",
                      &purse_account_limit,
                      &dummy)) )
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "You must use YEAR, HISTORY-FEE, KYC-FEE, ACCOUNT-FEE, 
PURSE-FEE, PURSE-TIMEOUT, KYC-TIMEOUT, HISTORY-EXPIRATION and 
PURSE-ACCOUNT-LIMIT as arguments for this subcommand\n");
+                "You must use YEAR, HISTORY-FEE, ACCOUNT-FEE, PURSE-FEE, 
PURSE-TIMEOUT, HISTORY-EXPIRATION and PURSE-ACCOUNT-LIMIT as arguments for this 
subcommand\n");
     test_shutdown ();
     global_ret = EXIT_INVALIDARGUMENT;
     return;
@@ -2928,7 +2903,6 @@ do_set_global_fee (char *const *args)
                                           end_time,
                                           &fees,
                                           purse_timeout,
-                                          kyc_timeout,
                                           history_expiration,
                                           (uint32_t) purse_account_limit,
                                           &master_priv,
@@ -2941,23 +2915,19 @@ do_set_global_fee (char *const *args)
                                                   end_time),
                       TALER_JSON_pack_amount ("history_fee",
                                               &fees.history),
-                      TALER_JSON_pack_amount ("kyc_fee",
-                                              &fees.kyc),
                       TALER_JSON_pack_amount ("account_fee",
                                               &fees.account),
                       TALER_JSON_pack_amount ("purse_fee",
                                               &fees.purse),
                       GNUNET_JSON_pack_time_rel ("purse_timeout",
                                                  purse_timeout),
-                      GNUNET_JSON_pack_time_rel ("kyc_timeout",
-                                                 kyc_timeout),
                       GNUNET_JSON_pack_time_rel ("history_expiration",
                                                  history_expiration),
                       GNUNET_JSON_pack_uint64 ("purse_account_limit",
                                                (uint32_t) purse_account_limit),
                       GNUNET_JSON_pack_data_auto ("master_sig",
                                                   &master_sig)));
-  next (args + 9);
+  next (args + 7);
 }
 
 
@@ -4476,13 +4446,13 @@ work (void *cls)
     {
       .name = "wire-fee",
       .help =
-        "sign wire fees for the given year (year, wire method, wire fee, 
closing fee and wad fee must be given as arguments)",
+        "sign wire fees for the given year (year, wire method, wire fee, and 
closing fee must be given as arguments)",
       .cb = &do_set_wire_fee
     },
     {
       .name = "global-fee",
       .help =
-        "sign global fees for the given year (year, history fee, kyc fee, 
account fee, purse fee, purse timeout, kyc timeout, history expiration and the 
maximum number of free purses per account must be given as arguments)",
+        "sign global fees for the given year (year, history fee, account fee, 
purse fee, purse timeout, history expiration and the maximum number of free 
purses per account must be given as arguments)",
       .cb = &do_set_global_fee
     },
     {
diff --git a/src/exchange/taler-exchange-httpd_keys.c 
b/src/exchange/taler-exchange-httpd_keys.c
index a6ad9976..9b7f28bd 100644
--- a/src/exchange/taler-exchange-httpd_keys.c
+++ b/src/exchange/taler-exchange-httpd_keys.c
@@ -2426,7 +2426,6 @@ finish_keys_response (struct TEH_KeyStateHandle *ksh)
  * @param cls `struct TEH_KeyStateHandle *` we are building
  * @param fees the global fees we charge
  * @param purse_timeout when do purses time out
- * @param kyc_timeout when do reserves without KYC time out
  * @param history_expiration how long are account histories preserved
  * @param purse_account_limit how many purses are free per account
  * @param start_date from when are these fees valid (start date)
@@ -2439,7 +2438,6 @@ global_fee_info_cb (
   void *cls,
   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,
   struct GNUNET_TIME_Timestamp start_date,
@@ -2457,7 +2455,6 @@ global_fee_info_cb (
   gf->end_date = end_date;
   gf->fees = *fees;
   gf->purse_timeout = purse_timeout;
-  gf->kyc_timeout = kyc_timeout;
   gf->history_expiration = history_expiration;
   gf->purse_account_limit = purse_account_limit;
   gf->master_sig = *master_sig;
@@ -2476,8 +2473,6 @@ global_fee_info_cb (
         TALER_JSON_PACK_GLOBAL_FEES (fees),
         GNUNET_JSON_pack_time_rel ("history_expiration",
                                    history_expiration),
-        GNUNET_JSON_pack_time_rel ("account_kyc_timeout",
-                                   kyc_timeout),
         GNUNET_JSON_pack_time_rel ("purse_timeout",
                                    purse_timeout),
         GNUNET_JSON_pack_uint64 ("purse_account_limit",
diff --git a/src/exchange/taler-exchange-httpd_keys.h 
b/src/exchange/taler-exchange-httpd_keys.h
index 6d0cb5b5..01ba1f95 100644
--- a/src/exchange/taler-exchange-httpd_keys.h
+++ b/src/exchange/taler-exchange-httpd_keys.h
@@ -112,11 +112,6 @@ struct TEH_GlobalFee
    */
   struct GNUNET_TIME_Relative purse_timeout;
 
-  /**
-   * How long do we keep accounts without KYC?
-   */
-  struct GNUNET_TIME_Relative kyc_timeout;
-
   /**
    * What is the longest history we return?
    */
diff --git a/src/exchange/taler-exchange-httpd_management_global_fees.c 
b/src/exchange/taler-exchange-httpd_management_global_fees.c
index 37bb40d9..8203ddef 100644
--- a/src/exchange/taler-exchange-httpd_management_global_fees.c
+++ b/src/exchange/taler-exchange-httpd_management_global_fees.c
@@ -103,7 +103,6 @@ add_fee (void *cls,
   enum GNUNET_DB_QueryStatus qs;
   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;
 
@@ -113,7 +112,6 @@ add_fee (void *cls,
     afc->end_time,
     &fees,
     &purse_timeout,
-    &kyc_timeout,
     &history_expiration,
     &purse_account_limit);
   if (qs < 0)
@@ -155,7 +153,6 @@ add_fee (void *cls,
     afc->end_time,
     &afc->fees,
     afc->purse_timeout,
-    afc->kyc_timeout,
     afc->history_expiration,
     afc->purse_account_limit,
     &afc->master_sig);
@@ -190,9 +187,6 @@ TEH_handler_management_post_global_fees (
     TALER_JSON_spec_amount ("history_fee",
                             TEH_currency,
                             &afc.fees.history),
-    TALER_JSON_spec_amount ("kyc_fee",
-                            TEH_currency,
-                            &afc.fees.kyc),
     TALER_JSON_spec_amount ("account_fee",
                             TEH_currency,
                             &afc.fees.account),
@@ -201,8 +195,6 @@ TEH_handler_management_post_global_fees (
                             &afc.fees.purse),
     GNUNET_JSON_spec_relative_time ("purse_timeout",
                                     &afc.purse_timeout),
-    GNUNET_JSON_spec_relative_time ("kyc_timeout",
-                                    &afc.kyc_timeout),
     GNUNET_JSON_spec_relative_time ("history_expiration",
                                     &afc.history_expiration),
     GNUNET_JSON_spec_uint32 ("purse_account_limit",
@@ -229,7 +221,6 @@ TEH_handler_management_post_global_fees (
         afc.end_time,
         &afc.fees,
         afc.purse_timeout,
-        afc.kyc_timeout,
         afc.history_expiration,
         afc.purse_account_limit,
         &TEH_master_public_key,
diff --git a/src/exchange/taler-exchange-httpd_management_wire_fees.c 
b/src/exchange/taler-exchange-httpd_management_wire_fees.c
index 2a426213..dcfa87ef 100644
--- a/src/exchange/taler-exchange-httpd_management_wire_fees.c
+++ b/src/exchange/taler-exchange-httpd_management_wire_fees.c
@@ -170,9 +170,6 @@ TEH_handler_management_post_wire_fees (
     TALER_JSON_spec_amount ("closing_fee",
                             TEH_currency,
                             &afc.fees.closing),
-    TALER_JSON_spec_amount ("wad_fee",
-                            TEH_currency,
-                            &afc.fees.wad),
     GNUNET_JSON_spec_end ()
   };
 
diff --git a/src/exchange/taler-exchange-httpd_purses_create.c 
b/src/exchange/taler-exchange-httpd_purses_create.c
index 2bccd11f..f3da2c85 100644
--- a/src/exchange/taler-exchange-httpd_purses_create.c
+++ b/src/exchange/taler-exchange-httpd_purses_create.c
@@ -156,15 +156,15 @@ create_transaction (void *cls,
     uint32_t min_age;
 
     TEH_plugin->rollback (TEH_plugin->cls);
-    qs = TEH_plugin->select_purse_request (TEH_plugin->cls,
-                                           &pcc->pd.purse_pub,
-                                           &merge_pub,
-                                           &purse_expiration,
-                                           &h_contract_terms,
-                                           &min_age,
-                                           &target_amount,
-                                           &balance,
-                                           &purse_sig);
+    qs = TEH_plugin->get_purse_request (TEH_plugin->cls,
+                                        &pcc->pd.purse_pub,
+                                        &merge_pub,
+                                        &purse_expiration,
+                                        &h_contract_terms,
+                                        &min_age,
+                                        &target_amount,
+                                        &balance,
+                                        &purse_sig);
     if (qs < 0)
     {
       GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs);
diff --git a/src/exchange/taler-exchange-httpd_purses_deposit.c 
b/src/exchange/taler-exchange-httpd_purses_deposit.c
index 581abe90..dc1a256d 100644
--- a/src/exchange/taler-exchange-httpd_purses_deposit.c
+++ b/src/exchange/taler-exchange-httpd_purses_deposit.c
@@ -359,11 +359,13 @@ TEH_handler_purses_deposit (
 
   {
     enum GNUNET_DB_QueryStatus qs;
+    struct GNUNET_TIME_Timestamp create_timestamp;
     struct GNUNET_TIME_Timestamp merge_timestamp;
 
     qs = TEH_plugin->select_purse (
       TEH_plugin->cls,
       pcc.purse_pub,
+      &create_timestamp,
       &pcc.purse_expiration,
       &pcc.amount,
       &pcc.deposit_total,
diff --git a/src/exchange/taler-exchange-httpd_purses_get.c 
b/src/exchange/taler-exchange-httpd_purses_get.c
index 3261ed34..8384086b 100644
--- a/src/exchange/taler-exchange-httpd_purses_get.c
+++ b/src/exchange/taler-exchange-httpd_purses_get.c
@@ -303,9 +303,11 @@ TEH_handler_purses_get (struct TEH_RequestContext *rc,
 
   {
     enum GNUNET_DB_QueryStatus qs;
+    struct GNUNET_TIME_Timestamp create_timestamp;
 
     qs = TEH_plugin->select_purse (TEH_plugin->cls,
                                    &gc->purse_pub,
+                                   &create_timestamp,
                                    &gc->purse_expiration,
                                    &gc->amount,
                                    &gc->deposited,
diff --git a/src/exchange/taler-exchange-httpd_purses_merge.c 
b/src/exchange/taler-exchange-httpd_purses_merge.c
index c1582948..cd6f8547 100644
--- a/src/exchange/taler-exchange-httpd_purses_merge.c
+++ b/src/exchange/taler-exchange-httpd_purses_merge.c
@@ -168,15 +168,20 @@ reply_merge_success (struct MHD_Connection *connection,
   }
   else
   {
+#if WAD_NOT_IMPLEMENTED
+    /* FIXME: figure out partner, lookup wad fee by partner! */
     if (0 >
         TALER_amount_subtract (&merge_amount,
                                &pcc->target_amount,
-                               &pcc->wf->wad))
+                               &wad_fee))
     {
       GNUNET_assert (GNUNET_OK ==
                      TALER_amount_set_zero (TEH_currency,
                                             &merge_amount));
     }
+#else
+    merge_amount = pcc->target_amount;
+#endif
   }
   if (TALER_EC_NONE !=
       (ec = TALER_exchange_online_purse_merged_sign (
@@ -426,15 +431,15 @@ TEH_handler_purses_merge (
   }
 
   /* Fetch purse details */
-  qs = TEH_plugin->select_purse_request (TEH_plugin->cls,
-                                         pcc.purse_pub,
-                                         &pcc.merge_pub,
-                                         &pcc.purse_expiration,
-                                         &pcc.h_contract_terms,
-                                         &pcc.min_age,
-                                         &pcc.target_amount,
-                                         &pcc.balance,
-                                         &purse_sig);
+  qs = TEH_plugin->get_purse_request (TEH_plugin->cls,
+                                      pcc.purse_pub,
+                                      &pcc.merge_pub,
+                                      &pcc.purse_expiration,
+                                      &pcc.h_contract_terms,
+                                      &pcc.min_age,
+                                      &pcc.target_amount,
+                                      &pcc.balance,
+                                      &purse_sig);
   switch (qs)
   {
   case GNUNET_DB_STATUS_HARD_ERROR:
diff --git a/src/exchange/taler-exchange-httpd_reserves_purse.c 
b/src/exchange/taler-exchange-httpd_reserves_purse.c
index 79625a39..cc3ffeb1 100644
--- a/src/exchange/taler-exchange-httpd_reserves_purse.c
+++ b/src/exchange/taler-exchange-httpd_reserves_purse.c
@@ -252,7 +252,7 @@ purse_transaction (void *cls,
       uint32_t min_age;
 
       TEH_plugin->rollback (TEH_plugin->cls);
-      qs = TEH_plugin->select_purse_request (
+      qs = TEH_plugin->get_purse_request (
         TEH_plugin->cls,
         &rpc->pd.purse_pub,
         &merge_pub,
diff --git a/src/exchange/taler-exchange-httpd_wire.c 
b/src/exchange/taler-exchange-httpd_wire.c
index 7e5f0a91..34010462 100644
--- a/src/exchange/taler-exchange-httpd_wire.c
+++ b/src/exchange/taler-exchange-httpd_wire.c
@@ -322,8 +322,6 @@ add_wire_fee (void *cls,
         GNUNET_JSON_PACK (
           TALER_JSON_pack_amount ("wire_fee",
                                   &fees->wire),
-          TALER_JSON_pack_amount ("wad_fee",
-                                  &fees->wad),
           TALER_JSON_pack_amount ("closing_fee",
                                   &fees->closing),
           GNUNET_JSON_pack_timestamp ("start_date",
diff --git a/src/exchangedb/exchange-0001-part.sql 
b/src/exchangedb/exchange-0001-part.sql
index 4903b887..99883a27 100644
--- a/src/exchangedb/exchange-0001-part.sql
+++ b/src/exchangedb/exchange-0001-part.sql
@@ -813,8 +813,6 @@ CREATE TABLE IF NOT EXISTS wire_fee
   ,wire_fee_frac INT4 NOT NULL
   ,closing_fee_val INT8 NOT NULL
   ,closing_fee_frac INT4 NOT NULL
-  ,wad_fee_val INT8 NOT NULL
-  ,wad_fee_frac INT4 NOT NULL
   ,master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64)
   ,PRIMARY KEY (wire_method, start_date)
   );
@@ -836,14 +834,11 @@ CREATE TABLE IF NOT EXISTS global_fee
   ,end_date INT8 NOT NULL
   ,history_fee_val INT8 NOT NULL
   ,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)
diff --git a/src/exchangedb/pg_insert_records_by_table.c 
b/src/exchangedb/pg_insert_records_by_table.c
index 99173cc6..47b36831 100644
--- a/src/exchangedb/pg_insert_records_by_table.c
+++ b/src/exchangedb/pg_insert_records_by_table.c
@@ -1037,7 +1037,6 @@ irbt_cb_table_wire_fee (struct PostgresClosure *pg,
     GNUNET_PQ_query_param_timestamp (&td->details.wire_fee.end_date),
     TALER_PQ_query_param_amount (&td->details.wire_fee.fees.wire),
     TALER_PQ_query_param_amount (&td->details.wire_fee.fees.closing),
-    TALER_PQ_query_param_amount (&td->details.wire_fee.fees.wad),
     GNUNET_PQ_query_param_auto_from_type (&td->details.wire_fee.master_sig),
     GNUNET_PQ_query_param_end
   };
@@ -1083,16 +1082,12 @@ irbt_cb_table_global_fee (struct PostgresClosure *pg,
       &td->details.global_fee.end_date),
     TALER_PQ_query_param_amount (
       &td->details.global_fee.fees.history),
-    TALER_PQ_query_param_amount (
-      &td->details.global_fee.fees.kyc),
     TALER_PQ_query_param_amount (
       &td->details.global_fee.fees.account),
     TALER_PQ_query_param_amount (
       &td->details.global_fee.fees.purse),
     GNUNET_PQ_query_param_relative_time (
       &td->details.global_fee.purse_timeout),
-    GNUNET_PQ_query_param_relative_time (
-      &td->details.global_fee.kyc_timeout),
     GNUNET_PQ_query_param_relative_time (
       &td->details.global_fee.history_expiration),
     GNUNET_PQ_query_param_uint32 (
@@ -1110,19 +1105,16 @@ irbt_cb_table_global_fee (struct PostgresClosure *pg,
            ",end_date"
            ",history_fee_val"
            ",history_fee_frac"
-           ",kyc_fee_val"
-           ",kyc_fee_frac"
            ",account_fee_val"
            ",account_fee_frac"
            ",purse_fee_val"
            ",purse_fee_frac"
            ",purse_timeout"
-           ",kyc_timeout"
            ",history_expiration"
            ",purse_account_limit"
            ",master_sig"
            ") VALUES "
-           "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, 
$16);");
+           "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13);");
   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
                                              "insert_into_table_global_fee",
                                              params);
diff --git a/src/exchangedb/pg_lookup_records_by_table.c 
b/src/exchangedb/pg_lookup_records_by_table.c
index b7435bc2..e28edef0 100644
--- a/src/exchangedb/pg_lookup_records_by_table.c
+++ b/src/exchangedb/pg_lookup_records_by_table.c
@@ -1194,8 +1194,6 @@ lrbt_cb_table_wire_fee (void *cls,
                                    &td.details.wire_fee.fees.wire),
       TALER_PQ_RESULT_SPEC_AMOUNT ("closing_fee",
                                    &td.details.wire_fee.fees.closing),
-      TALER_PQ_RESULT_SPEC_AMOUNT ("wad_fee",
-                                   &td.details.wire_fee.fees.wad),
       GNUNET_PQ_result_spec_auto_from_type ("master_sig",
                                             &td.details.wire_fee.master_sig),
       GNUNET_PQ_result_spec_end
@@ -1250,9 +1248,6 @@ lrbt_cb_table_global_fee (void *cls,
       TALER_PQ_RESULT_SPEC_AMOUNT (
         "history_fee",
         &td.details.global_fee.fees.history),
-      TALER_PQ_RESULT_SPEC_AMOUNT (
-        "kyc_fee",
-        &td.details.global_fee.fees.kyc),
       TALER_PQ_RESULT_SPEC_AMOUNT (
         "account_fee",
         &td.details.global_fee.fees.account),
@@ -1262,9 +1257,6 @@ lrbt_cb_table_global_fee (void *cls,
       GNUNET_PQ_result_spec_relative_time (
         "purse_timeout",
         &td.details.global_fee.purse_timeout),
-      GNUNET_PQ_result_spec_relative_time (
-        "kyc_timeout",
-        &td.details.global_fee.kyc_timeout),
       GNUNET_PQ_result_spec_relative_time (
         "history_expiration",
         &td.details.global_fee.history_expiration),
@@ -2567,14 +2559,11 @@ TEH_PG_lookup_records_by_table (void *cls,
               ",end_date"
               ",history_fee_val"
               ",history_fee_frac"
-              ",kyc_fee_val"
-              ",kyc_fee_frac"
               ",account_fee_val"
               ",account_fee_frac"
               ",purse_fee_val"
               ",purse_fee_frac"
               ",purse_timeout"
-              ",kyc_timeout"
               ",history_expiration"
               ",purse_account_limit"
               ",master_sig"
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c 
b/src/exchangedb/plugin_exchangedb_postgres.c
index c4957c91..9f14cc28 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -1598,8 +1598,6 @@ prepare_statements (struct PostgresClosure *pg)
       ",wire_fee_frac"
       ",closing_fee_val"
       ",closing_fee_frac"
-      ",wad_fee_val"
-      ",wad_fee_frac"
       ",master_sig"
       " FROM wire_fee"
       " WHERE wire_method=$1"
@@ -1613,14 +1611,11 @@ prepare_statements (struct PostgresClosure *pg)
       ",end_date"
       ",history_fee_val"
       ",history_fee_frac"
-      ",kyc_fee_val"
-      ",kyc_fee_frac"
       ",account_fee_val"
       ",account_fee_frac"
       ",purse_fee_val"
       ",purse_fee_frac"
       ",purse_timeout"
-      ",kyc_timeout"
       ",history_expiration"
       ",purse_account_limit"
       ",master_sig"
@@ -1635,14 +1630,11 @@ prepare_statements (struct PostgresClosure *pg)
       ",end_date"
       ",history_fee_val"
       ",history_fee_frac"
-      ",kyc_fee_val"
-      ",kyc_fee_frac"
       ",account_fee_val"
       ",account_fee_frac"
       ",purse_fee_val"
       ",purse_fee_frac"
       ",purse_timeout"
-      ",kyc_timeout"
       ",history_expiration"
       ",purse_account_limit"
       ",master_sig"
@@ -1659,11 +1651,9 @@ prepare_statements (struct PostgresClosure *pg)
       ",wire_fee_frac"
       ",closing_fee_val"
       ",closing_fee_frac"
-      ",wad_fee_val"
-      ",wad_fee_frac"
       ",master_sig"
       ") VALUES "
-      "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10);"),
+      "($1, $2, $3, $4, $5, $6, $7, $8);"),
     /* Used in #postgres_insert_global_fee */
     GNUNET_PQ_make_prepare (
       "insert_global_fee",
@@ -1672,19 +1662,16 @@ prepare_statements (struct PostgresClosure *pg)
       ",end_date"
       ",history_fee_val"
       ",history_fee_frac"
-      ",kyc_fee_val"
-      ",kyc_fee_frac"
       ",account_fee_val"
       ",account_fee_frac"
       ",purse_fee_val"
       ",purse_fee_frac"
       ",purse_timeout"
-      ",kyc_timeout"
       ",history_expiration"
       ",purse_account_limit"
       ",master_sig"
       ") VALUES "
-      "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15);"),
+      "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12);"),
     /* Used in #postgres_store_wire_transfer_out */
     GNUNET_PQ_make_prepare (
       "insert_wire_out",
@@ -1953,8 +1940,6 @@ prepare_statements (struct PostgresClosure *pg)
       ",wire_fee_frac"
       ",closing_fee_val"
       ",closing_fee_frac"
-      ",wad_fee_val"
-      ",wad_fee_frac"
       ",start_date"
       ",end_date"
       ",master_sig"
@@ -2057,8 +2042,6 @@ prepare_statements (struct PostgresClosure *pg)
       ",wire_fee_frac"
       ",closing_fee_val"
       ",closing_fee_frac"
-      ",wad_fee_val"
-      ",wad_fee_frac"
       " FROM wire_fee"
       " WHERE wire_method=$1"
       " AND end_date > $2"
@@ -2069,14 +2052,11 @@ prepare_statements (struct PostgresClosure *pg)
       "SELECT"
       " history_fee_val"
       ",history_fee_frac"
-      ",kyc_fee_val"
-      ",kyc_fee_frac"
       ",account_fee_val"
       ",account_fee_frac"
       ",purse_fee_val"
       ",purse_fee_frac"
       ",purse_timeout"
-      ",kyc_timeout"
       ",history_expiration"
       ",purse_account_limit"
       " FROM global_fee"
@@ -2259,6 +2239,7 @@ prepare_statements (struct PostgresClosure *pg)
       "select_purse",
       "SELECT "
       " merge_pub"
+      ",purse_creation"
       ",purse_expiration"
       ",h_contract_terms"
       ",amount_with_fee_val"
@@ -2269,9 +2250,9 @@ prepare_statements (struct PostgresClosure *pg)
       " FROM purse_requests"
       " LEFT JOIN purse_merges USING (purse_pub)"
       " WHERE purse_pub=$1;"),
-    /* Used in #postgres_select_purse_request */
+    /* Used in #postgres_get_purse_request */
     GNUNET_PQ_make_prepare (
-      "select_purse_request",
+      "get_purse_request",
       "SELECT "
       " merge_pub"
       ",purse_expiration"
@@ -6289,8 +6270,6 @@ postgres_get_wire_fee (void *cls,
                                      end_date),
     TALER_PQ_RESULT_SPEC_AMOUNT ("wire_fee",
                                  &fees->wire),
-    TALER_PQ_RESULT_SPEC_AMOUNT ("wad_fee",
-                                 &fees->wad),
     TALER_PQ_RESULT_SPEC_AMOUNT ("closing_fee",
                                  &fees->closing),
     GNUNET_PQ_result_spec_auto_from_type ("master_sig",
@@ -6314,7 +6293,6 @@ postgres_get_wire_fee (void *cls,
  * @param[out] end_date when does the fee end being valid
  * @param[out] fees how high are the wire fees
  * @param[out] purse_timeout set to how long we keep unmerged purses
- * @param[out] kyc_timeout set to how long we keep accounts without KYC
  * @param[out] history_expiration set to how long we keep account histories
  * @param[out] purse_account_limit set to the number of free purses per account
  * @param[out] master_sig signature over the above by the exchange master key
@@ -6327,7 +6305,6 @@ postgres_get_global_fee (void *cls,
                          struct GNUNET_TIME_Timestamp *end_date,
                          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,
                          struct TALER_MasterSignatureP *master_sig)
@@ -6344,16 +6321,12 @@ postgres_get_global_fee (void *cls,
                                      end_date),
     TALER_PQ_RESULT_SPEC_AMOUNT ("history_fee",
                                  &fees->history),
-    TALER_PQ_RESULT_SPEC_AMOUNT ("kyc_fee",
-                                 &fees->kyc),
     TALER_PQ_RESULT_SPEC_AMOUNT ("account_fee",
                                  &fees->account),
     TALER_PQ_RESULT_SPEC_AMOUNT ("purse_fee",
                                  &fees->purse),
     GNUNET_PQ_result_spec_relative_time ("purse_timeout",
                                          purse_timeout),
-    GNUNET_PQ_result_spec_relative_time ("kyc_timeout",
-                                         kyc_timeout),
     GNUNET_PQ_result_spec_relative_time ("history_expiration",
                                          history_expiration),
     GNUNET_PQ_result_spec_uint32 ("purse_account_limit",
@@ -6417,7 +6390,6 @@ global_fees_cb (void *cls,
   {
     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;
     struct GNUNET_TIME_Timestamp start_date;
@@ -6430,16 +6402,12 @@ global_fees_cb (void *cls,
                                        &end_date),
       TALER_PQ_RESULT_SPEC_AMOUNT ("history_fee",
                                    &fees.history),
-      TALER_PQ_RESULT_SPEC_AMOUNT ("kyc_fee",
-                                   &fees.kyc),
       TALER_PQ_RESULT_SPEC_AMOUNT ("account_fee",
                                    &fees.account),
       TALER_PQ_RESULT_SPEC_AMOUNT ("purse_fee",
                                    &fees.purse),
       GNUNET_PQ_result_spec_relative_time ("purse_timeout",
                                            &purse_timeout),
-      GNUNET_PQ_result_spec_relative_time ("kyc_timeout",
-                                           &kyc_timeout),
       GNUNET_PQ_result_spec_relative_time ("history_expiration",
                                            &history_expiration),
       GNUNET_PQ_result_spec_uint32 ("purse_account_limit",
@@ -6460,7 +6428,6 @@ global_fees_cb (void *cls,
     gctx->cb (gctx->cb_cls,
               &fees,
               purse_timeout,
-              kyc_timeout,
               history_expiration,
               purse_account_limit,
               start_date,
@@ -6535,7 +6502,6 @@ postgres_insert_wire_fee (void *cls,
     GNUNET_PQ_query_param_timestamp (&end_date),
     TALER_PQ_query_param_amount (&fees->wire),
     TALER_PQ_query_param_amount (&fees->closing),
-    TALER_PQ_query_param_amount (&fees->wad),
     GNUNET_PQ_query_param_auto_from_type (master_sig),
     GNUNET_PQ_query_param_end
   };
@@ -6597,7 +6563,6 @@ postgres_insert_wire_fee (void *cls,
  * @param end_date when does the fees end being valid
  * @param fees how high is are the global fees
  * @param purse_timeout when do purses time out
- * @param kyc_timeout when do reserves without KYC time out
  * @param history_expiration how long are account histories preserved
  * @param purse_account_limit how many purses are free per account
  * @param master_sig signature over the above by the exchange master key
@@ -6609,7 +6574,6 @@ postgres_insert_global_fee (void *cls,
                             struct GNUNET_TIME_Timestamp end_date,
                             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_MasterSignatureP *master_sig)
@@ -6619,11 +6583,9 @@ postgres_insert_global_fee (void *cls,
     GNUNET_PQ_query_param_timestamp (&start_date),
     GNUNET_PQ_query_param_timestamp (&end_date),
     TALER_PQ_query_param_amount (&fees->history),
-    TALER_PQ_query_param_amount (&fees->kyc),
     TALER_PQ_query_param_amount (&fees->account),
     TALER_PQ_query_param_amount (&fees->purse),
     GNUNET_PQ_query_param_relative_time (&purse_timeout),
-    GNUNET_PQ_query_param_relative_time (&kyc_timeout),
     GNUNET_PQ_query_param_relative_time (&history_expiration),
     GNUNET_PQ_query_param_uint32 (&purse_account_limit),
     GNUNET_PQ_query_param_auto_from_type (master_sig),
@@ -6635,7 +6597,6 @@ postgres_insert_global_fee (void *cls,
   struct GNUNET_TIME_Timestamp ed;
   enum GNUNET_DB_QueryStatus qs;
   struct GNUNET_TIME_Relative pt;
-  struct GNUNET_TIME_Relative kt;
   struct GNUNET_TIME_Relative he;
   uint32_t pal;
 
@@ -6645,7 +6606,6 @@ postgres_insert_global_fee (void *cls,
                                 &ed,
                                 &wx,
                                 &pt,
-                                &kt,
                                 &he,
                                 &pal,
                                 &sig);
@@ -6679,9 +6639,6 @@ postgres_insert_global_fee (void *cls,
     if ( (GNUNET_TIME_relative_cmp (purse_timeout,
                                     !=,
                                     pt)) ||
-         (GNUNET_TIME_relative_cmp (kyc_timeout,
-                                    !=,
-                                    kt)) ||
          (GNUNET_TIME_relative_cmp (history_expiration,
                                     !=,
                                     he)) )
@@ -8001,6 +7958,127 @@ postgres_select_purse_decisions_above_serial_id (
 }
 
 
+/**
+ * Closure for #all_purse_decision_serial_helper_cb().
+ */
+struct AllPurseDecisionSerialContext
+{
+
+  /**
+   * Callback to call.
+   */
+  TALER_EXCHANGEDB_AllPurseDecisionCallback cb;
+
+  /**
+   * Closure for @e cb.
+   */
+  void *cb_cls;
+
+  /**
+   * Plugin context.
+   */
+  struct PostgresClosure *pg;
+
+  /**
+   * Status code, set to #GNUNET_SYSERR on hard errors.
+   */
+  enum GNUNET_GenericReturnValue status;
+};
+
+
+/**
+ * Helper function to be called with the results of a SELECT statement
+ * that has returned @a num_results results.
+ *
+ * @param cls closure of type `struct PurseRefundSerialContext`
+ * @param result the postgres result
+ * @param num_results the number of results in @a result
+ */
+static void
+all_purse_decision_serial_helper_cb (void *cls,
+                                     PGresult *result,
+                                     unsigned int num_results)
+{
+  struct AllPurseDecisionSerialContext *dsc = cls;
+
+  for (unsigned int i = 0; i<num_results; i++)
+  {
+    struct TALER_PurseContractPublicKeyP purse_pub;
+    bool refunded;
+    uint64_t rowid;
+    struct GNUNET_PQ_ResultSpec rs[] = {
+      GNUNET_PQ_result_spec_auto_from_type ("purse_pub",
+                                            &purse_pub),
+      GNUNET_PQ_result_spec_bool ("refunded",
+                                  &refunded),
+      GNUNET_PQ_result_spec_uint64 ("purse_decision_serial_id",
+                                    &rowid),
+      GNUNET_PQ_result_spec_end
+    };
+    enum GNUNET_GenericReturnValue ret;
+
+    if (GNUNET_OK !=
+        GNUNET_PQ_extract_result (result,
+                                  rs,
+                                  i))
+    {
+      GNUNET_break (0);
+      dsc->status = GNUNET_SYSERR;
+      return;
+    }
+    ret = dsc->cb (dsc->cb_cls,
+                   rowid,
+                   &purse_pub,
+                   refunded);
+    GNUNET_PQ_cleanup_result (rs);
+    if (GNUNET_OK != ret)
+      break;
+  }
+}
+
+
+/**
+ * Select purse decisions above @a serial_id in monotonically increasing
+ * order.
+ *
+ * @param cls closure
+ * @param serial_id highest serial ID to exclude (select strictly larger)
+ * @param cb function to call on each result
+ * @param cb_cls closure for @a cb
+ * @return transaction status code
+ */
+static enum GNUNET_DB_QueryStatus
+postgres_select_all_purse_decisions_above_serial_id (
+  void *cls,
+  uint64_t serial_id,
+  TALER_EXCHANGEDB_AllPurseDecisionCallback cb,
+  void *cb_cls)
+{
+  struct PostgresClosure *pg = cls;
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_uint64 (&serial_id),
+    GNUNET_PQ_query_param_end
+  };
+  struct AllPurseDecisionSerialContext dsc = {
+    .cb = cb,
+    .cb_cls = cb_cls,
+    .pg = pg,
+    .status = GNUNET_OK
+  };
+  enum GNUNET_DB_QueryStatus qs;
+
+  qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
+                                             
"audit_get_all_purse_decision_incr",
+                                             params,
+                                             &
+                                             
all_purse_decision_serial_helper_cb,
+                                             &dsc);
+  if (GNUNET_OK != dsc.status)
+    return GNUNET_DB_STATUS_HARD_ERROR;
+  return qs;
+}
+
+
 /**
  * Closure for #purse_refund_coin_helper_cb().
  */
@@ -9895,8 +9973,6 @@ get_wire_fees_cb (void *cls,
                                    &fees.wire),
       TALER_PQ_RESULT_SPEC_AMOUNT ("closing_fee",
                                    &fees.closing),
-      TALER_PQ_RESULT_SPEC_AMOUNT ("wad_fee",
-                                   &fees.wad),
       GNUNET_PQ_result_spec_timestamp ("start_date",
                                        &start_date),
       GNUNET_PQ_result_spec_timestamp ("end_date",
@@ -10297,8 +10373,6 @@ wire_fee_by_time_helper (void *cls,
                                    &fs.wire),
       TALER_PQ_RESULT_SPEC_AMOUNT ("closing_fee",
                                    &fs.closing),
-      TALER_PQ_RESULT_SPEC_AMOUNT ("wad_fee",
-                                   &fs.wad),
       GNUNET_PQ_result_spec_end
     };
 
@@ -10394,11 +10468,6 @@ struct GlobalFeeLookupContext
    */
   struct GNUNET_TIME_Relative *purse_timeout;
 
-  /**
-   * Set to timeout of accounts without kyc.
-   */
-  struct GNUNET_TIME_Relative *kyc_timeout;
-
   /**
    * Set to history expiration for reserves.
    */
@@ -10436,22 +10505,17 @@ global_fee_by_time_helper (void *cls,
   {
     struct TALER_GlobalFeeSet fs;
     struct GNUNET_TIME_Relative purse_timeout;
-    struct GNUNET_TIME_Relative kyc_timeout;
     struct GNUNET_TIME_Relative history_expiration;
     uint32_t purse_account_limit;
     struct GNUNET_PQ_ResultSpec rs[] = {
       TALER_PQ_RESULT_SPEC_AMOUNT ("history_fee",
                                    &fs.history),
-      TALER_PQ_RESULT_SPEC_AMOUNT ("kyc_fee",
-                                   &fs.kyc),
       TALER_PQ_RESULT_SPEC_AMOUNT ("account_fee",
                                    &fs.account),
       TALER_PQ_RESULT_SPEC_AMOUNT ("purse_fee",
                                    &fs.purse),
       GNUNET_PQ_result_spec_relative_time ("purse_timeout",
                                            &purse_timeout),
-      GNUNET_PQ_result_spec_relative_time ("kyc_timeout",
-                                           &kyc_timeout),
       GNUNET_PQ_result_spec_relative_time ("history_expiration",
                                            &history_expiration),
       GNUNET_PQ_result_spec_uint32 ("purse_account_limit",
@@ -10475,7 +10539,6 @@ global_fee_by_time_helper (void *cls,
     {
       *wlc->fees = fs;
       *wlc->purse_timeout = purse_timeout;
-      *wlc->kyc_timeout = kyc_timeout;
       *wlc->history_expiration = history_expiration;
       *wlc->purse_account_limit = purse_account_limit;
       continue;
@@ -10487,9 +10550,6 @@ global_fee_by_time_helper (void *cls,
          (GNUNET_TIME_relative_cmp (purse_timeout,
                                     !=,
                                     *wlc->purse_timeout)) ||
-         (GNUNET_TIME_relative_cmp (kyc_timeout,
-                                    !=,
-                                    *wlc->kyc_timeout)) ||
          (GNUNET_TIME_relative_cmp (history_expiration,
                                     !=,
                                     *wlc->history_expiration)) )
@@ -10514,7 +10574,6 @@ global_fee_by_time_helper (void *cls,
  *             different global fee exists within this time
  *             period, an 'invalid' amount is returned.
  * @param[out] purse_timeout set to when unmerged purses expire
- * @param[out] kyc_timeout set to when reserves without kyc expire
  * @param[out] history_expiration set to when we expire reserve histories
  * @param[out] purse_account_limit set to number of free purses
  * @return transaction status code
@@ -10526,7 +10585,6 @@ postgres_lookup_global_fee_by_time (
   struct GNUNET_TIME_Timestamp end_time,
   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)
 {
@@ -10539,7 +10597,6 @@ postgres_lookup_global_fee_by_time (
   struct GlobalFeeLookupContext wlc = {
     .fees = fees,
     .purse_timeout = purse_timeout,
-    .kyc_timeout = kyc_timeout,
     .history_expiration = history_expiration,
     .purse_account_limit = purse_account_limit,
     .pg = pg
@@ -11355,7 +11412,7 @@ postgres_insert_contract (
  * @return transaction status code
  */
 static enum GNUNET_DB_QueryStatus
-postgres_select_purse_request (
+postgres_get_purse_request (
   void *cls,
   const struct TALER_PurseContractPublicKeyP *purse_pub,
   struct TALER_PurseMergePublicKeyP *merge_pub,
@@ -11389,7 +11446,7 @@ postgres_select_purse_request (
     GNUNET_PQ_result_spec_end
   };
   return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
-                                                   "select_purse_request",
+                                                   "get_purse_request",
                                                    params,
                                                    rs);
 }
@@ -11464,15 +11521,15 @@ postgres_insert_purse_request (
     struct TALER_Amount balance;
     struct TALER_PurseContractSignatureP purse_sig2;
 
-    qs = postgres_select_purse_request (pg,
-                                        purse_pub,
-                                        &merge_pub2,
-                                        &purse_expiration2,
-                                        &h_contract_terms2,
-                                        &age_limit2,
-                                        &amount2,
-                                        &balance,
-                                        &purse_sig2);
+    qs = postgres_get_purse_request (pg,
+                                     purse_pub,
+                                     &merge_pub2,
+                                     &purse_expiration2,
+                                     &h_contract_terms2,
+                                     &age_limit2,
+                                     &amount2,
+                                     &balance,
+                                     &purse_sig2);
     if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
     {
       GNUNET_break (0);
@@ -11542,6 +11599,7 @@ postgres_expire_purse (
  *
  * @param cls the @e cls of this struct with the plugin-specific state
  * @param purse_pub public key of the new purse
+ * @param[out] purse_creation set to time when the purse was created
  * @param[out] purse_expiration set to time when the purse will expire
  * @param[out] amount set to target amount (with fees) to be put into the purse
  * @param[out] deposited set to actual amount put into the purse so far
@@ -11553,6 +11611,7 @@ static enum GNUNET_DB_QueryStatus
 postgres_select_purse (
   void *cls,
   const struct TALER_PurseContractPublicKeyP *purse_pub,
+  struct GNUNET_TIME_Timestamp *purse_creation,
   struct GNUNET_TIME_Timestamp *purse_expiration,
   struct TALER_Amount *amount,
   struct TALER_Amount *deposited,
@@ -11567,6 +11626,8 @@ postgres_select_purse (
   struct GNUNET_PQ_ResultSpec rs[] = {
     GNUNET_PQ_result_spec_timestamp ("purse_expiration",
                                      purse_expiration),
+    GNUNET_PQ_result_spec_timestamp ("purse_creation",
+                                     purse_creation),
     TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee",
                                  amount),
     TALER_PQ_RESULT_SPEC_AMOUNT ("balance",
@@ -13042,6 +13103,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
     = &postgres_select_history_requests_above_serial_id;
   plugin->select_purse_decisions_above_serial_id
     = &postgres_select_purse_decisions_above_serial_id;
+  plugin->select_all_purse_decisions_above_serial_id
+    = &postgres_select_all_purse_decisions_above_serial_id;
   plugin->select_purse_deposits_by_purse
     = &postgres_select_purse_deposits_by_purse;
   plugin->select_refreshes_above_serial_id
@@ -13136,8 +13199,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
     = &postgres_select_contract_by_purse;
   plugin->insert_purse_request
     = &postgres_insert_purse_request;
-  plugin->select_purse_request
-    = &postgres_select_purse_request;
+  plugin->get_purse_request
+    = &postgres_get_purse_request;
   plugin->expire_purse
     = &postgres_expire_purse;
   plugin->select_purse
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
index 77f3dab2..eb990412 100644
--- a/src/exchangedb/test_exchangedb.c
+++ b/src/exchangedb/test_exchangedb.c
@@ -819,9 +819,6 @@ test_wire_fees (void)
   GNUNET_assert (GNUNET_OK ==
                  TALER_string_to_amount (CURRENCY ":2.424242",
                                          &fees.closing));
-  GNUNET_assert (GNUNET_OK ==
-                 TALER_string_to_amount (CURRENCY ":3.424242",
-                                         &fees.wad));
   GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
                               &master_sig,
                               sizeof (master_sig));
diff --git a/src/include/taler_auditordb_plugin.h 
b/src/include/taler_auditordb_plugin.h
index 129b5171..709a956c 100644
--- a/src/include/taler_auditordb_plugin.h
+++ b/src/include/taler_auditordb_plugin.h
@@ -604,6 +604,23 @@ typedef enum GNUNET_GenericReturnValue
   const struct TALER_AUDITORDB_DepositConfirmation *dc);
 
 
+/**
+ * Function called on expired purses.
+ *
+ * @param cls closure
+ * @param purse_pub public key of the purse
+ * @param balance amount of money in the purse
+ * @param expiration_date when did the purse expire?
+ * @return #GNUNET_OK to continue to iterate
+ */
+typedef enum GNUNET_GenericReturnValue
+(*TALER_AUDITORDB_ExpiredPurseCallback)(
+  void *cls,
+  const struct TALER_PurseContractPublicKeyP *purse_pub,
+  const struct TALER_Amount *balance,
+  struct GNUNET_TIME_Timestamp expiration_date);
+
+
 /**
  * @brief The plugin API, returned from the plugin's "init" function.
  * The argument given to "init" is simply a configuration handle.
@@ -1220,7 +1237,7 @@ struct TALER_AUDITORDB_Plugin
    * @param purse_pub public key of the purse
    * @param master_pub master public key of the exchange
    * @param balance balance of the purse
-   * @param expiration_date expiration date of the reserve
+   * @param expiration_date expiration date of the purse
    * @return transaction status code
    */
   enum GNUNET_DB_QueryStatus
@@ -1245,7 +1262,7 @@ struct TALER_AUDITORDB_Plugin
   enum GNUNET_DB_QueryStatus
   (*update_purse_info)(
     void *cls,
-    const struct TALER_ReservePublicKeyP *reserve_pub,
+    const struct TALER_PurseContractPublicKeyP *purse_pub,
     const struct TALER_MasterPublicKeyP *master_pub,
     const struct TALER_Amount *balance);
 
@@ -1254,7 +1271,7 @@ struct TALER_AUDITORDB_Plugin
    * Get information about a purse.
    *
    * @param cls the @e cls of this struct with the plugin-specific state
-   * @param reserve_pub public key of the reserve
+   * @param purse_pub public key of the purse
    * @param master_pub master public key of the exchange
    * @param[out] rowid which row did we get the information from
    * @param[out] balance set to balance of the purse
@@ -1271,6 +1288,38 @@ struct TALER_AUDITORDB_Plugin
     struct GNUNET_TIME_Timestamp *expiration_date);
 
 
+  /**
+   * Delete information about a purse.
+   *
+   * @param cls the @e cls of this struct with the plugin-specific state
+   * @param purse_pub public key of the reserve
+   * @param master_pub master public key of the exchange
+   * @return transaction status code
+   */
+  enum GNUNET_DB_QueryStatus
+  (*delete_purse_info)(
+    void *cls,
+    const struct TALER_PurseContractPublicKeyP *purse_pub,
+    const struct TALER_MasterPublicKeyP *master_pub);
+
+
+  /**
+   * Get information about expired purses.
+   *
+   * @param cls the @e cls of this struct with the plugin-specific state
+   * @param master_pub master public key of the exchange
+   * @param cb function to call on expired purses
+   * @param cb_cls closure for @a cb
+   * @return transaction status code
+   */
+  enum GNUNET_DB_QueryStatus
+  (*select_purse_expired)(
+    void *cls,
+    const struct TALER_MasterPublicKeyP *master_pub,
+    TALER_AUDITORDB_ExpiredPurseCallback cb,
+    void *cb_cls);
+
+
   /**
    * Delete information about a purse.
    *
diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h
index df992c6e..73b92fe8 100644
--- a/src/include/taler_crypto_lib.h
+++ b/src/include/taler_crypto_lib.h
@@ -792,12 +792,6 @@ struct TALER_WireFeeSetNBOP
    */
   struct TALER_AmountNBO closing;
 
-  /**
-   * The fee the exchange charges for cross-exchange
-   * P2P payments.
-   */
-  struct TALER_AmountNBO wad;
-
 };
 
 
@@ -809,28 +803,20 @@ struct TALER_GlobalFeeSetNBOP
 {
 
   /**
-   * The fee the exchange charges for returning the
-   * history of a reserve or account.
+   * The fee the exchange charges for returning the history of a reserve or
+   * account.
    */
   struct TALER_AmountNBO history;
 
   /**
-   * The fee the exchange charges for performing a
-   * KYC check on a reserve to turn it into an account
-   * that can be used for P2P payments.
-   */
-  struct TALER_AmountNBO kyc;
-
-  /**
-   * The fee the exchange charges for keeping
-   * an account or reserve open for a year.
+   * 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.
+   * The fee the exchange charges if a purse is abandoned and this was not
+   * covered by the account limit.
    */
   struct TALER_AmountNBO purse;
 };
@@ -874,15 +860,13 @@ struct TALER_DenomFeeSet
 
 
 /**
- * Set of the fees applying for a given
- * time-range and wire method.
+ * Set of the fees applying for a given time-range and wire method.
  */
 struct TALER_WireFeeSet
 {
 
   /**
-   * The fee the exchange charges for wiring funds
-   * to a merchant.
+   * The fee the exchange charges for wiring funds to a merchant.
    */
   struct TALER_Amount wire;
 
@@ -892,12 +876,6 @@ struct TALER_WireFeeSet
    */
   struct TALER_Amount closing;
 
-  /**
-   * The fee the exchange charges for cross-exchange
-   * P2P payments.
-   */
-  struct TALER_Amount wad;
-
 };
 
 
@@ -914,13 +892,6 @@ struct TALER_GlobalFeeSet
    */
   struct TALER_Amount history;
 
-  /**
-   * The fee the exchange charges for performing a
-   * KYC check on a reserve to turn it into an account
-   * that can be used for P2P payments.
-   */
-  struct TALER_Amount kyc;
-
   /**
    * The fee the exchange charges for keeping
    * an account or reserve open for a year.
@@ -2771,7 +2742,7 @@ TALER_CRYPTO_helper_esign_disconnect (
 void
 TALER_wallet_purse_create_sign (
   struct GNUNET_TIME_Timestamp purse_expiration,
-  struct TALER_PrivateContractHashP *h_contract_terms,
+  const struct TALER_PrivateContractHashP *h_contract_terms,
   const struct TALER_PurseMergePublicKeyP *merge_pub,
   uint32_t min_age,
   const struct TALER_Amount *amount,
@@ -2794,7 +2765,7 @@ TALER_wallet_purse_create_sign (
 enum GNUNET_GenericReturnValue
 TALER_wallet_purse_create_verify (
   struct GNUNET_TIME_Timestamp purse_expiration,
-  struct TALER_PrivateContractHashP *h_contract_terms,
+  const struct TALER_PrivateContractHashP *h_contract_terms,
   const struct TALER_PurseMergePublicKeyP *merge_pub,
   uint32_t min_age,
   const struct TALER_Amount *amount,
@@ -5052,7 +5023,6 @@ TALER_exchange_offline_wire_fee_verify (
  * @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
@@ -5064,7 +5034,6 @@ TALER_exchange_offline_global_fee_sign (
   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,
@@ -5078,7 +5047,6 @@ TALER_exchange_offline_global_fee_sign (
  * @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
@@ -5091,7 +5059,6 @@ TALER_exchange_offline_global_fee_verify (
   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,
diff --git a/src/include/taler_exchange_service.h 
b/src/include/taler_exchange_service.h
index 6268f45a..aa9a5b60 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -230,11 +230,6 @@ struct TALER_EXCHANGE_GlobalFee
    */
   struct GNUNET_TIME_Relative purse_timeout;
 
-  /**
-   * Accounts without KYC will be closed after this time.
-   */
-  struct GNUNET_TIME_Relative kyc_timeout;
-
   /**
    * Account history is limited to this timeframe.
    */
@@ -4530,7 +4525,6 @@ struct TALER_EXCHANGE_ManagementSetGlobalFeeHandle;
  * @param validity_end end date for the provided wire fees
  * @param fees the wire fees for this time period
  * @param purse_timeout when do purses time out
- * @param kyc_timeout when do reserves without KYC time out
  * @param history_expiration how long are account histories preserved
  * @param purse_account_limit how many purses are free per account
  * @param master_sig signature affirming the wire fees;
@@ -4547,7 +4541,6 @@ TALER_EXCHANGE_management_set_global_fees (
   struct GNUNET_TIME_Timestamp validity_end,
   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_MasterSignatureP *master_sig,
diff --git a/src/include/taler_exchangedb_plugin.h 
b/src/include/taler_exchangedb_plugin.h
index 4965a27b..706a2d5a 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -481,7 +481,6 @@ struct TALER_EXCHANGEDB_TableData
       struct GNUNET_TIME_Timestamp end_date;
       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;
       struct TALER_MasterSignatureP master_sig;
@@ -2356,7 +2355,7 @@ typedef enum GNUNET_GenericReturnValue
  * @param cls closure
  * @param rowid unique serial ID for the deposit in our DB
  * @param purse_pub public key of the purse
- * @param reserve_pub public key of the target reserve, NULL if not known
+ * @param reserve_pub public key of the target reserve, NULL if not known / 
refunded
  * @param purse_value what is the (target) value of the purse
  * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
  */
@@ -2369,6 +2368,24 @@ typedef enum GNUNET_GenericReturnValue
   const struct TALER_Amount *purse_value);
 
 
+/**
+ * Function called with details about purse decisions that have been made, with
+ * the goal of auditing the purse's execution.
+ *
+ * @param cls closure
+ * @param rowid unique serial ID for the deposit in our DB
+ * @param purse_pub public key of the purse
+ * @param refunded true if decision was to refund
+ * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
+ */
+typedef enum GNUNET_GenericReturnValue
+(*TALER_EXCHANGEDB_AllPurseDecisionCallback)(
+  void *cls,
+  uint64_t rowid,
+  const struct TALER_PurseContractPublicKeyP *purse_pub,
+  bool refunded);
+
+
 /**
  * Function called with details about purse refunds that have been made, with
  * the goal of auditing the purse refund's execution.
@@ -2644,7 +2661,6 @@ typedef void
  * @param cls closure
  * @param fees the global fees we charge
  * @param purse_timeout when do purses time out
- * @param kyc_timeout when do reserves without KYC time out
  * @param history_expiration how long are account histories preserved
  * @param purse_account_limit how many purses are free per account
  * @param start_date from when are these fees valid (start date)
@@ -2657,7 +2673,6 @@ typedef void
   void *cls,
   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,
   struct GNUNET_TIME_Timestamp start_date,
@@ -2993,6 +3008,34 @@ typedef void
   bool done);
 
 
+/**
+ * Function called on purse requests.
+ *
+ * @param cls closure
+ * @param purse_pub public key of the purse
+ * @param merge_pub public key representing the merge capability
+ * @param purse_creation when was the purse created?
+ * @param purse_expiration when would an unmerged purse expire
+ * @param h_contract_terms contract associated with the purse
+ * @param age_limit the age limit for deposits into the purse
+ * @param target_amount amount to be put into the purse
+ * @param purse_sig signature of the purse over the initialization data
+ * @return #GNUNET_OK to continue to iterate
+   */
+typedef enum GNUNET_GenericReturnValue
+(*TALER_EXCHANGEDB_PurseRequestCallback)(
+  void *cls,
+  uint64_t rowid,
+  const struct TALER_PurseContractPublicKeyP *purse_pub,
+  const struct TALER_PurseMergePublicKeyP *merge_pub,
+  struct GNUNET_TIME_Timestamp purse_creation,
+  struct GNUNET_TIME_Timestamp purse_expiration,
+  const struct TALER_PrivateContractHashP *h_contract_terms,
+  uint32_t age_limit,
+  const struct TALER_Amount *target_amount,
+  const struct TALER_PurseContractSignatureP *purse_sig);
+
+
 /**
  * Function called with information about the exchange's denomination keys.
  * Note that the 'master' field in @a issue will not yet be initialized when
@@ -4218,7 +4261,6 @@ struct TALER_EXCHANGEDB_Plugin
    * @param end_date when does the fees end being valid
    * @param fees how high is are the global fees
    * @param purse_timeout when do purses time out
-   * @param kyc_timeout when do reserves without KYC time out
    * @param history_expiration how long are account histories preserved
    * @param purse_account_limit how many purses are free per account
    * @param master_sig signature over the above by the exchange master key
@@ -4230,7 +4272,6 @@ struct TALER_EXCHANGEDB_Plugin
                        struct GNUNET_TIME_Timestamp end_date,
                        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,
 
@@ -4268,7 +4309,6 @@ struct TALER_EXCHANGEDB_Plugin
    * @param[out] end_date when does the fee end being valid
    * @param[out] fees how high are the global fees
    * @param[out] purse_timeout when do purses time out
-   * @param[out] kyc_timeout when do reserves without KYC time out
    * @param[out] history_expiration how long are account histories preserved
    * @param[out] purse_account_limit how many purses are free per account
    * @param[out] master_sig signature over the above by the exchange master key
@@ -4281,7 +4321,6 @@ struct TALER_EXCHANGEDB_Plugin
                     struct GNUNET_TIME_Timestamp *end_date,
                     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,
                     struct TALER_MasterSignatureP *master_sig);
@@ -4594,6 +4633,25 @@ struct TALER_EXCHANGEDB_Plugin
                                      TALER_EXCHANGEDB_DepositCallback cb,
                                      void *cb_cls);
 
+
+  /**
+   * Function called to return meta data about a purses
+   * above a certain serial ID.
+   *
+   * @param cls the @e cls of this struct with the plugin-specific state
+   * @param serial_id number to select requests by
+   * @param cb function to call on each request
+   * @param cb_cls closure for @a cb
+   * @return transaction status code
+   */
+  enum GNUNET_DB_QueryStatus
+  (*select_purse_requests_above_serial_id)(
+    void *cls,
+    uint64_t serial_id,
+    TALER_EXCHANGEDB_PurseRequestCallback cb,
+    void *cb_cls);
+
+
   /**
    * Select purse deposits above @a serial_id in monotonically increasing
    * order.
@@ -4686,6 +4744,24 @@ struct TALER_EXCHANGEDB_Plugin
     void *cb_cls);
 
 
+  /**
+   * Select all purse refunds above @a serial_id in monotonically increasing
+   * order.
+   *
+   * @param cls closure
+   * @param serial_id highest serial ID to exclude (select strictly larger)
+   * @param cb function to call on each result
+   * @param cb_cls closure for @a cb
+   * @return transaction status code
+   */
+  enum GNUNET_DB_QueryStatus
+  (*select_all_purse_decisions_above_serial_id)(
+    void *cls,
+    uint64_t serial_id,
+    TALER_EXCHANGEDB_AllPurseDecisionCallback cb,
+    void *cb_cls);
+
+
   /**
    * Select coins deposited into a purse.
    *
@@ -5315,7 +5391,6 @@ struct TALER_EXCHANGEDB_Plugin
    *             different global fee exists within this time
    *             period, an 'invalid' amount is returned.
    * @param[out] purse_timeout set to when unmerged purses expire
-   * @param[out] kyc_timeout set to when reserves without kyc expire
    * @param[out] history_expiration set to when we expire reserve histories
    * @param[out] purse_account_limit set to number of free purses
    * @return transaction status code
@@ -5327,7 +5402,6 @@ struct TALER_EXCHANGEDB_Plugin
     struct GNUNET_TIME_Timestamp end_time,
     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);
 
@@ -5647,6 +5721,7 @@ struct TALER_EXCHANGEDB_Plugin
    *
    * @param cls the @e cls of this struct with the plugin-specific state
    * @param purse_pub public key of the new purse
+   * @param[out] purse_creation set to time when the purse was created
    * @param[out] purse_expiration set to time when the purse will expire
    * @param[out] amount set to target amount (with fees) to be put into the 
purse
    * @param[out] deposited set to actual amount put into the purse so far
@@ -5658,6 +5733,7 @@ struct TALER_EXCHANGEDB_Plugin
   (*select_purse)(
     void *cls,
     const struct TALER_PurseContractPublicKeyP *purse_pub,
+    struct GNUNET_TIME_Timestamp *purse_creation,
     struct GNUNET_TIME_Timestamp *purse_expiration,
     struct TALER_Amount *amount,
     struct TALER_Amount *deposited,
@@ -5681,7 +5757,7 @@ struct TALER_EXCHANGEDB_Plugin
    * @return transaction status code
    */
   enum GNUNET_DB_QueryStatus
-  (*select_purse_request)(
+  (*get_purse_request)(
     void *cls,
     const struct TALER_PurseContractPublicKeyP *purse_pub,
     struct TALER_PurseMergePublicKeyP *merge_pub,
diff --git a/src/include/taler_json_lib.h b/src/include/taler_json_lib.h
index 443cbdb7..12526e95 100644
--- a/src/include/taler_json_lib.h
+++ b/src/include/taler_json_lib.h
@@ -366,7 +366,6 @@ TALER_JSON_spec_amount_any_nbo (const char *name,
  * @param[out] gfs a `struct TALER_GlobalFeeSet` to initialize
  */
 #define TALER_JSON_SPEC_GLOBAL_FEES(currency,gfs) \
-  TALER_JSON_spec_amount ("kyc_fee", (currency), &(gfs)->kyc), \
   TALER_JSON_spec_amount ("history_fee", (currency), &(gfs)->history),   \
   TALER_JSON_spec_amount ("account_fee", (currency), &(gfs)->account),   \
   TALER_JSON_spec_amount ("purse_fee", (currency), &(gfs)->purse)
@@ -377,7 +376,6 @@ TALER_JSON_spec_amount_any_nbo (const char *name,
  * @param gfs a `struct TALER_GlobalFeeSet` to pack
  */
 #define TALER_JSON_PACK_GLOBAL_FEES(gfs) \
-  TALER_JSON_pack_amount ("kyc_fee", &(gfs)->kyc),   \
   TALER_JSON_pack_amount ("history_fee", &(gfs)->history),     \
   TALER_JSON_pack_amount ("account_fee", &(gfs)->account),     \
   TALER_JSON_pack_amount ("purse_fee", &(gfs)->purse)
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h
index a964ba4a..aa475bd3 100644
--- a/src/include/taler_testing_lib.h
+++ b/src/include/taler_testing_lib.h
@@ -2324,7 +2324,6 @@ TALER_TESTING_cmd_auditor_add_denom_sig (const char 
*label,
  * @param wire_method wire method to set wire fees for
  * @param wire_fee the wire fee to affirm
  * @param closing_fee the closing fee to affirm
- * @param wad_fee wad fee to charge
  * @param expected_http_status expected HTTP status from exchange
  * @param bad_sig should we use a bogus signature?
  * @return the command
@@ -2334,7 +2333,6 @@ TALER_TESTING_cmd_set_wire_fee (const char *label,
                                 const char *wire_method,
                                 const char *wire_fee,
                                 const char *closing_fee,
-                                const char *wad_fee,
                                 unsigned int expected_http_status,
                                 bool bad_sig);
 
@@ -2408,15 +2406,13 @@ TALER_TESTING_cmd_exec_offline_sign_keys (const char 
*label,
  * @param config_filename configuration filename.
  * @param wire_fee the wire fee to affirm (for the current year)
  * @param closing_fee the closing fee to affirm (for the current year)
- * @param wad_fee the wad fee to affirm
  * @return the command
  */
 struct TALER_TESTING_Command
 TALER_TESTING_cmd_exec_offline_sign_fees (const char *label,
                                           const char *config_filename,
                                           const char *wire_fee,
-                                          const char *closing_fee,
-                                          const char *wad_fee);
+                                          const char *closing_fee);
 
 
 /**
@@ -2425,11 +2421,9 @@ TALER_TESTING_cmd_exec_offline_sign_fees (const char 
*label,
  * @param label command label.
  * @param config_filename configuration filename.
  * @param history_fee the history fee to charge (for the current year)
- * @param kyc_fee the KYC fee to charge (for the current year)
  * @param account_fee the account fee to charge (for the current year)
  * @param purse_fee the purse fee to charge (for the current year)
  * @param purse_timeout when do purses time out
- * @param kyc_timeout when does the KYC time out
  * @param history_expiration when does an account history expire
  * @param num_purses number of (free) active purses per account
  * @return the command
@@ -2439,11 +2433,9 @@ TALER_TESTING_cmd_exec_offline_sign_global_fees (
   const char *label,
   const char *config_filename,
   const char *history_fee,
-  const char *kyc_fee,
   const char *account_fee,
   const char *purse_fee,
   struct GNUNET_TIME_Relative purse_timeout,
-  struct GNUNET_TIME_Relative kyc_timeout,
   struct GNUNET_TIME_Relative history_expiration,
   unsigned int num_purses);
 
diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c
index 707e5cf5..d6e12cc1 100644
--- a/src/lib/exchange_api_handle.c
+++ b/src/lib/exchange_api_handle.c
@@ -529,8 +529,6 @@ parse_global_fee (struct TALER_EXCHANGE_GlobalFee *gf,
                                 &gf->end_date),
     GNUNET_JSON_spec_relative_time ("purse_timeout",
                                     &gf->purse_timeout),
-    GNUNET_JSON_spec_relative_time ("account_kyc_timeout",
-                                    &gf->kyc_timeout),
     GNUNET_JSON_spec_relative_time ("history_expiration",
                                     &gf->history_expiration),
     GNUNET_JSON_spec_uint32 ("purse_account_limit",
@@ -563,7 +561,6 @@ parse_global_fee (struct TALER_EXCHANGE_GlobalFee *gf,
           gf->end_date,
           &gf->fees,
           gf->purse_timeout,
-          gf->kyc_timeout,
           gf->history_expiration,
           gf->purse_account_limit,
           &key_data->master_pub,
diff --git a/src/lib/exchange_api_management_set_global_fee.c 
b/src/lib/exchange_api_management_set_global_fee.c
index b600c8cb..c8fae5c1 100644
--- a/src/lib/exchange_api_management_set_global_fee.c
+++ b/src/lib/exchange_api_management_set_global_fee.c
@@ -130,7 +130,6 @@ TALER_EXCHANGE_management_set_global_fees (
   struct GNUNET_TIME_Timestamp validity_end,
   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_MasterSignatureP *master_sig,
@@ -164,16 +163,12 @@ TALER_EXCHANGE_management_set_global_fees (
                                 validity_end),
     TALER_JSON_pack_amount ("history_fee",
                             &fees->history),
-    TALER_JSON_pack_amount ("kyc_fee",
-                            &fees->kyc),
     TALER_JSON_pack_amount ("account_fee",
                             &fees->account),
     TALER_JSON_pack_amount ("purse_fee",
                             &fees->purse),
     GNUNET_JSON_pack_time_rel ("purse_timeout",
                                purse_timeout),
-    GNUNET_JSON_pack_time_rel ("kyc_timeout",
-                               kyc_timeout),
     GNUNET_JSON_pack_time_rel ("history_expiration",
                                history_expiration),
     GNUNET_JSON_pack_uint64 ("purse_account_limit",
diff --git a/src/lib/exchange_api_management_set_wire_fee.c 
b/src/lib/exchange_api_management_set_wire_fee.c
index 5951b6e2..72526116 100644
--- a/src/lib/exchange_api_management_set_wire_fee.c
+++ b/src/lib/exchange_api_management_set_wire_fee.c
@@ -163,8 +163,6 @@ TALER_EXCHANGE_management_set_wire_fees (
                                 validity_end),
     TALER_JSON_pack_amount ("closing_fee",
                             &fees->closing),
-    TALER_JSON_pack_amount ("wad_fee",
-                            &fees->wad),
     TALER_JSON_pack_amount ("wire_fee",
                             &fees->wire));
   eh = TALER_EXCHANGE_curl_easy_get_ (swfh->url);
diff --git a/src/lib/exchange_api_wire.c b/src/lib/exchange_api_wire.c
index 3079064c..995a0933 100644
--- a/src/lib/exchange_api_wire.c
+++ b/src/lib/exchange_api_wire.c
@@ -145,8 +145,6 @@ parse_fees (json_t *fees)
                                      &wa->master_sig),
         TALER_JSON_spec_amount_any ("wire_fee",
                                     &wa->fees.wire),
-        TALER_JSON_spec_amount_any ("wad_fee",
-                                    &wa->fees.wad),
         TALER_JSON_spec_amount_any ("closing_fee",
                                     &wa->fees.closing),
         GNUNET_JSON_spec_timestamp ("start_date",
diff --git a/src/testing/test_auditor_api.c b/src/testing/test_auditor_api.c
index 305d31a0..10e54766 100644
--- a/src/testing/test_auditor_api.c
+++ b/src/testing/test_auditor_api.c
@@ -651,7 +651,6 @@ run (void *cls,
     TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
                                               config_file,
                                               "EUR:0.01",
-                                              "EUR:0.01",
                                               "EUR:0.01"),
     TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
                                    MHD_HTTP_NO_CONTENT,
diff --git a/src/testing/test_exchange_api.c b/src/testing/test_exchange_api.c
index f30701c3..dd39ee94 100644
--- a/src/testing/test_exchange_api.c
+++ b/src/testing/test_exchange_api.c
@@ -1248,8 +1248,6 @@ run (void *cls,
         "EUR:0.01",
         "EUR:0.01",
         "EUR:0.01",
-        "EUR:0.01",
-        GNUNET_TIME_UNIT_MINUTES,
         GNUNET_TIME_UNIT_MINUTES,
         GNUNET_TIME_UNIT_DAYS,
         1),
@@ -1258,7 +1256,6 @@ run (void *cls,
       TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
                                                 config_file,
                                                 "EUR:0.01",
-                                                "EUR:0.01",
                                                 "EUR:0.01"),
       TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
                                                   1),
diff --git a/src/testing/test_exchange_api_keys_cherry_picking.c 
b/src/testing/test_exchange_api_keys_cherry_picking.c
index 4f0c4048..4d61ed2e 100644
--- a/src/testing/test_exchange_api_keys_cherry_picking.c
+++ b/src/testing/test_exchange_api_keys_cherry_picking.c
@@ -69,7 +69,6 @@ run (void *cls,
     TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
                                               config_file,
                                               "EUR:0.01",
-                                              "EUR:0.01",
                                               "EUR:0.01"),
     TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
                                               config_file),
diff --git a/src/testing/test_exchange_management_api.c 
b/src/testing/test_exchange_management_api.c
index 2bf0af3b..3195b5a1 100644
--- a/src/testing/test_exchange_management_api.c
+++ b/src/testing/test_exchange_management_api.c
@@ -85,35 +85,30 @@ run (void *cls,
                                     "foo-method",
                                     "EUR:1",
                                     "EUR:5",
-                                    "EUR:3",
                                     MHD_HTTP_NO_CONTENT,
                                     false),
     TALER_TESTING_cmd_set_wire_fee ("set-fee-conflicting",
                                     "foo-method",
                                     "EUR:1",
                                     "EUR:1",
-                                    "EUR:3",
                                     MHD_HTTP_CONFLICT,
                                     false),
     TALER_TESTING_cmd_set_wire_fee ("set-fee-bad-signature",
                                     "bar-method",
                                     "EUR:1",
                                     "EUR:1",
-                                    "EUR:3",
                                     MHD_HTTP_FORBIDDEN,
                                     true),
     TALER_TESTING_cmd_set_wire_fee ("set-fee-other-method",
                                     "bar-method",
                                     "EUR:1",
                                     "EUR:1",
-                                    "EUR:3",
                                     MHD_HTTP_NO_CONTENT,
                                     false),
     TALER_TESTING_cmd_set_wire_fee ("set-fee-idempotent",
                                     "bar-method",
                                     "EUR:1",
                                     "EUR:1",
-                                    "EUR:3",
                                     MHD_HTTP_NO_CONTENT,
                                     false),
     TALER_TESTING_cmd_wire_add ("add-wire-account",
diff --git a/src/testing/test_exchange_p2p.c b/src/testing/test_exchange_p2p.c
index 222cd3d4..27d47bfd 100644
--- a/src/testing/test_exchange_p2p.c
+++ b/src/testing/test_exchange_p2p.c
@@ -474,15 +474,12 @@ run (void *cls,
     TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-wire-fees",
                                               config_file,
                                               "EUR:0.01",
-                                              "EUR:0.01",
                                               "EUR:0.01"),
     TALER_TESTING_cmd_exec_offline_sign_global_fees 
("offline-sign-global-fees",
                                                      config_file,
                                                      "EUR:0.01",
                                                      "EUR:0.01",
                                                      "EUR:0.01",
-                                                     "EUR:0.01",
-                                                     GNUNET_TIME_UNIT_MINUTES,
                                                      GNUNET_TIME_UNIT_MINUTES,
                                                      GNUNET_TIME_UNIT_DAYS,
                                                      1),
diff --git a/src/testing/test_kyc_api.c b/src/testing/test_kyc_api.c
index 0933956c..8ab4cffc 100644
--- a/src/testing/test_kyc_api.c
+++ b/src/testing/test_kyc_api.c
@@ -407,15 +407,12 @@ run (void *cls,
     TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
                                               CONFIG_FILE,
                                               "EUR:0.01",
-                                              "EUR:0.01",
                                               "EUR:0.01"),
     TALER_TESTING_cmd_exec_offline_sign_global_fees 
("offline-sign-global-fees",
                                                      CONFIG_FILE,
                                                      "EUR:0.01",
                                                      "EUR:0.01",
                                                      "EUR:0.01",
-                                                     "EUR:0.01",
-                                                     GNUNET_TIME_UNIT_MINUTES,
                                                      GNUNET_TIME_UNIT_MINUTES,
                                                      GNUNET_TIME_UNIT_DAYS,
                                                      1),
diff --git a/src/testing/test_taler_exchange_aggregator.c 
b/src/testing/test_taler_exchange_aggregator.c
index 05e8805c..bee7e37e 100644
--- a/src/testing/test_taler_exchange_aggregator.c
+++ b/src/testing/test_taler_exchange_aggregator.c
@@ -99,7 +99,6 @@ run (void *cls,
     TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
                                               config_filename,
                                               "EUR:0.01",
-                                              "EUR:0.01",
                                               "EUR:0.01"),
     // check no aggregation happens on a empty database
     CMD_EXEC_AGGREGATOR ("run-aggregator-on-empty-db",
diff --git a/src/testing/test_taler_exchange_wirewatch.c 
b/src/testing/test_taler_exchange_wirewatch.c
index 95274de4..eecb4fd6 100644
--- a/src/testing/test_taler_exchange_wirewatch.c
+++ b/src/testing/test_taler_exchange_wirewatch.c
@@ -85,7 +85,6 @@ run (void *cls,
     TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
                                               config_filename,
                                               "EUR:0.01",
-                                              "EUR:0.01",
                                               "EUR:0.01"),
     TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
                                    MHD_HTTP_NO_CONTENT,
diff --git a/src/testing/testing_api_cmd_offline_sign_global_fees.c 
b/src/testing/testing_api_cmd_offline_sign_global_fees.c
index 7c903225..db391625 100644
--- a/src/testing/testing_api_cmd_offline_sign_global_fees.c
+++ b/src/testing/testing_api_cmd_offline_sign_global_fees.c
@@ -51,11 +51,6 @@ struct OfflineSignState
    */
   const char *history_fee_s;
 
-  /**
-   * The KYC fee to sign.
-   */
-  const char *kyc_fee_s;
-
   /**
    * The account fee to sign.
    */
@@ -71,11 +66,6 @@ struct OfflineSignState
    */
   struct GNUNET_TIME_Relative purse_timeout;
 
-  /**
-   * How long does a user have to complete the KYC?
-   */
-  struct GNUNET_TIME_Relative kyc_timeout;
-
   /**
    * How long do we keep the history?
    */
@@ -104,7 +94,6 @@ offlinesign_run (void *cls,
   char num_purses[12];
   char history_expiration[32];
   char purse_timeout[32];
-  char kyc_timeout[32];
 
   GNUNET_snprintf (num_purses,
                    sizeof (num_purses),
@@ -120,11 +109,6 @@ offlinesign_run (void *cls,
                    "%s",
                    GNUNET_TIME_relative2s (ks->purse_timeout,
                                            false));
-  GNUNET_snprintf (kyc_timeout,
-                   sizeof (kyc_timeout),
-                   "%s",
-                   GNUNET_TIME_relative2s (ks->kyc_timeout,
-                                           false));
   ks->offlinesign_proc
     = GNUNET_OS_start_process (
         GNUNET_OS_INHERIT_STD_ALL,
@@ -136,11 +120,9 @@ offlinesign_run (void *cls,
         "global-fee",
         "now",
         ks->history_fee_s,
-        ks->kyc_fee_s,
         ks->account_fee_s,
         ks->purse_fee_s,
         purse_timeout,
-        kyc_timeout,
         history_expiration,
         num_purses,
         "upload",
@@ -215,11 +197,9 @@ TALER_TESTING_cmd_exec_offline_sign_global_fees (
   const char *label,
   const char *config_filename,
   const char *history_fee,
-  const char *kyc_fee,
   const char *account_fee,
   const char *purse_fee,
   struct GNUNET_TIME_Relative purse_timeout,
-  struct GNUNET_TIME_Relative kyc_timeout,
   struct GNUNET_TIME_Relative history_expiration,
   unsigned int num_purses)
 {
@@ -228,11 +208,9 @@ TALER_TESTING_cmd_exec_offline_sign_global_fees (
   ks = GNUNET_new (struct OfflineSignState);
   ks->config_filename = config_filename;
   ks->history_fee_s = history_fee;
-  ks->kyc_fee_s = kyc_fee;
   ks->account_fee_s = account_fee;
   ks->purse_fee_s = purse_fee;
   ks->purse_timeout = purse_timeout;
-  ks->kyc_timeout = kyc_timeout;
   ks->history_expiration = history_expiration;
   ks->num_purses = num_purses;
   {
diff --git a/src/testing/testing_api_cmd_offline_sign_wire_fees.c 
b/src/testing/testing_api_cmd_offline_sign_wire_fees.c
index 55746ebc..0fccbcd0 100644
--- a/src/testing/testing_api_cmd_offline_sign_wire_fees.c
+++ b/src/testing/testing_api_cmd_offline_sign_wire_fees.c
@@ -51,11 +51,6 @@ struct OfflineSignState
    */
   const char *wire_fee_s;
 
-  /**
-   * The wad fee to sign.
-   */
-  const char *wad_fee_s;
-
   /**
    * The closing fee to sign.
    */
@@ -91,7 +86,6 @@ offlinesign_run (void *cls,
         "x-taler-bank",
         ks->wire_fee_s,
         ks->closing_fee_s,
-        ks->wad_fee_s,
         "upload",
         NULL);
   if (NULL == ks->offlinesign_proc)
@@ -163,15 +157,13 @@ struct TALER_TESTING_Command
 TALER_TESTING_cmd_exec_offline_sign_fees (const char *label,
                                           const char *config_filename,
                                           const char *wire_fee,
-                                          const char *closing_fee,
-                                          const char *wad_fee)
+                                          const char *closing_fee)
 {
   struct OfflineSignState *ks;
 
   ks = GNUNET_new (struct OfflineSignState);
   ks->config_filename = config_filename;
   ks->wire_fee_s = wire_fee;
-  ks->wad_fee_s = wad_fee;
   ks->closing_fee_s = closing_fee;
   {
     struct TALER_TESTING_Command cmd = {
diff --git a/src/testing/testing_api_cmd_set_wire_fee.c 
b/src/testing/testing_api_cmd_set_wire_fee.c
index 8eb99387..ed3448ac 100644
--- a/src/testing/testing_api_cmd_set_wire_fee.c
+++ b/src/testing/testing_api_cmd_set_wire_fee.c
@@ -60,11 +60,6 @@ struct WireFeeState
    */
   const char *closing_fee;
 
-  /**
-   * Wad fee amount to use.
-   */
-  const char *wad_fee;
-
   /**
    * Expected HTTP response code.
    */
@@ -140,9 +135,6 @@ wire_add_run (void *cls,
   if ( (GNUNET_OK !=
         TALER_string_to_amount (ds->closing_fee,
                                 &fees.closing)) ||
-       (GNUNET_OK !=
-        TALER_string_to_amount (ds->wad_fee,
-                                &fees.wad)) ||
        (GNUNET_OK !=
         TALER_string_to_amount (ds->wire_fee,
                                 &fees.wire)) )
@@ -217,7 +209,6 @@ TALER_TESTING_cmd_set_wire_fee (const char *label,
                                 const char *wire_method,
                                 const char *wire_fee,
                                 const char *closing_fee,
-                                const char *wad_fee,
                                 unsigned int expected_http_status,
                                 bool bad_sig)
 {
@@ -229,7 +220,6 @@ TALER_TESTING_cmd_set_wire_fee (const char *label,
   ds->wire_method = wire_method;
   ds->wire_fee = wire_fee;
   ds->closing_fee = closing_fee;
-  ds->wad_fee = wad_fee;
   {
     struct TALER_TESTING_Command cmd = {
       .cls = ds,
diff --git a/src/util/offline_signatures.c b/src/util/offline_signatures.c
index 108c665e..b316c8ba 100644
--- a/src/util/offline_signatures.c
+++ b/src/util/offline_signatures.c
@@ -839,15 +839,6 @@ struct TALER_MasterGlobalFeePS
    */
   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
@@ -878,7 +869,6 @@ TALER_exchange_offline_global_fee_sign (
   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,
@@ -890,7 +880,6 @@ TALER_exchange_offline_global_fee_sign (
     .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)
   };
@@ -909,7 +898,6 @@ TALER_exchange_offline_global_fee_verify (
   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,
@@ -921,7 +909,6 @@ TALER_exchange_offline_global_fee_verify (
     .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)
   };
diff --git a/src/util/util.c b/src/util/util.c
index f715456d..2b8c9d95 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -82,8 +82,6 @@ TALER_global_fee_set_hton (struct TALER_GlobalFeeSetNBOP *nbo,
 {
   TALER_amount_hton (&nbo->history,
                      &fees->history);
-  TALER_amount_hton (&nbo->kyc,
-                     &fees->kyc);
   TALER_amount_hton (&nbo->account,
                      &fees->account);
   TALER_amount_hton (&nbo->purse,
@@ -97,8 +95,6 @@ TALER_global_fee_set_ntoh (struct TALER_GlobalFeeSet *fees,
 {
   TALER_amount_ntoh (&fees->history,
                      &nbo->history);
-  TALER_amount_ntoh (&fees->kyc,
-                     &nbo->kyc);
   TALER_amount_ntoh (&fees->account,
                      &nbo->account);
   TALER_amount_ntoh (&fees->purse,
@@ -114,8 +110,6 @@ TALER_wire_fee_set_hton (struct TALER_WireFeeSetNBOP *nbo,
                      &fees->wire);
   TALER_amount_hton (&nbo->closing,
                      &fees->closing);
-  TALER_amount_hton (&nbo->wad,
-                     &fees->wad);
 }
 
 
@@ -127,8 +121,6 @@ TALER_wire_fee_set_ntoh (struct TALER_WireFeeSet *fees,
                      &nbo->wire);
   TALER_amount_ntoh (&fees->closing,
                      &nbo->closing);
-  TALER_amount_ntoh (&fees->wad,
-                     &nbo->wad);
 }
 
 
@@ -142,10 +134,6 @@ TALER_global_fee_set_cmp (const struct TALER_GlobalFeeSet 
*f1,
                           &f2->history);
   if (0 != ret)
     return ret;
-  ret = TALER_amount_cmp (&f1->kyc,
-                          &f2->kyc);
-  if (0 != ret)
-    return ret;
   ret = TALER_amount_cmp (&f1->account,
                           &f2->account);
   if (0 != ret)
@@ -172,10 +160,6 @@ TALER_wire_fee_set_cmp (const struct TALER_WireFeeSet *f1,
                           &f2->closing);
   if (0 != ret)
     return ret;
-  ret = TALER_amount_cmp (&f1->wad,
-                          &f2->wad);
-  if (0 != ret)
-    return ret;
   return 0;
 }
 
diff --git a/src/util/wallet_signatures.c b/src/util/wallet_signatures.c
index 19291439..6c8124d0 100644
--- a/src/util/wallet_signatures.c
+++ b/src/util/wallet_signatures.c
@@ -821,7 +821,7 @@ GNUNET_NETWORK_STRUCT_END
 void
 TALER_wallet_purse_create_sign (
   struct GNUNET_TIME_Timestamp purse_expiration,
-  struct TALER_PrivateContractHashP *h_contract_terms,
+  const struct TALER_PrivateContractHashP *h_contract_terms,
   const struct TALER_PurseMergePublicKeyP *merge_pub,
   uint32_t min_age,
   const struct TALER_Amount *amount,
@@ -848,7 +848,7 @@ TALER_wallet_purse_create_sign (
 enum GNUNET_GenericReturnValue
 TALER_wallet_purse_create_verify (
   struct GNUNET_TIME_Timestamp purse_expiration,
-  struct TALER_PrivateContractHashP *h_contract_terms,
+  const struct TALER_PrivateContractHashP *h_contract_terms,
   const struct TALER_PurseMergePublicKeyP *merge_pub,
   uint32_t min_age,
   const struct TALER_Amount *amount,

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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