gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-merchant] branch master updated (832838e -> 60c5ee7)


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated (832838e -> 60c5ee7)
Date: Fri, 10 Feb 2017 14:22:51 +0100

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

marcello pushed a change to branch master
in repository merchant.

    from 832838e  contract->proposal
     new ccb8c16  First steps in renaming
     new 6d97959  Renaming proposal data db operations
     new 7097ceb  Removing obsolete /map requests and renaming 
contract->proposal/order, within lib.
     new 36d68f9  First run about renaming in lib's testcase.
     new d9a1d78  renaming: proposal logic ported
     new 75bca5f  Removing h_contract from /pay handler.
     new e05bb67  Removing _map.c from repo
     new dc5b4f7  Garbage removal
     new 6ec3850  Typo
     new 5b9a806  Renaming the DB and /history.
     new f226b8f  Updating notes.
     new dfdaec2  Fix backenddb tests after renaming
     new 3051f7f  Renaming /track/transaction handler to the point where it 
depends on a few exchange-lib's renamings.
     new 7216095  renaming (a little part of) /track/transfer handler
     new 17e344a  Renaming in /track/transaction handler.
     new 1dc680a  Huge renaming about removing transaction_id use
     new 5bc8e40  More fixes on renaming, mostly in db.
     new 9e8f9c9  Fix backenddb
     new 60c5ee7  Fixing testcases according to the renaming occurred in the 
protocol.  Please note, comments do NOT match code, /proposal uses the POST 
method, and tracking API are NOT tested yet.

The 19 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:
 RENAMING_NOTES.txt                                 |   7 +
 doc/version.texi                                   |   2 +-
 src/backend/Makefile.am                            |   5 +-
 src/backend/taler-merchant-httpd.c                 |  20 +-
 src/backend/taler-merchant-httpd_history.c         |  14 +-
 src/backend/taler-merchant-httpd_map.c             | 241 -----------
 src/backend/taler-merchant-httpd_pay.c             | 118 ++++--
 ...d_propose.c => taler-merchant-httpd_proposal.c} | 170 ++++++--
 ...d_propose.h => taler-merchant-httpd_proposal.h} |  35 +-
 .../taler-merchant-httpd_track-transaction.c       | 104 ++---
 src/backend/taler-merchant-httpd_track-transfer.c  |  22 +-
 src/backenddb/plugin_merchantdb_postgres.c         | 221 +++++-----
 src/backenddb/test_merchantdb.c                    |  82 ++--
 src/include/taler_merchant_service.h               | 148 ++++---
 src/include/taler_merchantdb_plugin.h              |  69 ++--
 src/lib/Makefile.am                                |   5 +-
 src/lib/merchant_api_contract.c                    | 239 -----------
 src/lib/merchant_api_map.c                         | 230 -----------
 src/lib/merchant_api_pay.c                         |  19 +-
 src/lib/merchant_api_proposal.c                    | 364 +++++++++++++++++
 src/lib/merchant_api_track_transaction.c           |  11 +-
 src/lib/merchant_api_track_transfer.c              |   3 +-
 src/lib/test_merchant_api.c                        | 443 +++++++++------------
 src/tests/Makefile.am                              |  25 --
 src/tests/deposit_permission.sample                |  31 --
 src/tests/deposit_permission_backend.sample        |  36 --
 src/tests/deposit_permission_edate_backend.sample  |  37 --
 src/tests/merchant.priv                            |   1 -
 src/tests/test_contract.c                          | 341 ----------------
 src/tests/test_contract_README                     |  10 -
 src/tests/test_pay_README                          |  26 --
 31 files changed, 1170 insertions(+), 1909 deletions(-)
 create mode 100644 RENAMING_NOTES.txt
 delete mode 100644 src/backend/taler-merchant-httpd_map.c
 rename src/backend/{taler-merchant-httpd_propose.c => 
taler-merchant-httpd_proposal.c} (59%)
 rename src/backend/{taler-merchant-httpd_propose.h => 
taler-merchant-httpd_proposal.h} (51%)
 delete mode 100644 src/lib/merchant_api_contract.c
 delete mode 100644 src/lib/merchant_api_map.c
 create mode 100644 src/lib/merchant_api_proposal.c
 delete mode 100644 src/tests/Makefile.am
 delete mode 100644 src/tests/deposit_permission.sample
 delete mode 100644 src/tests/deposit_permission_backend.sample
 delete mode 100644 src/tests/deposit_permission_edate_backend.sample
 delete mode 100644 src/tests/merchant.priv
 delete mode 100644 src/tests/test_contract.c
 delete mode 100644 src/tests/test_contract_README
 delete mode 100644 src/tests/test_pay_README

diff --git a/RENAMING_NOTES.txt b/RENAMING_NOTES.txt
new file mode 100644
index 0000000..50697ef
--- /dev/null
+++ b/RENAMING_NOTES.txt
@@ -0,0 +1,7 @@
+Files to be cleaned from the 'h/H_contract' presence.
+
+- merchant service include
+- pay lib
+- track-lib: references to H_contract to be removed.
+  especially when the logic reads JSON responses.
+- lib testcase
diff --git a/doc/version.texi b/doc/version.texi
index 13bfa00..0b47203 100644
--- a/doc/version.texi
+++ b/doc/version.texi
@@ -1,4 +1,4 @@
address@hidden UPDATED 8 January 2017
address@hidden UPDATED 27 January 2017
 @set UPDATED-MONTH January 2017
 @set EDITION 0.2.0
 @set VERSION 0.2.0
diff --git a/src/backend/Makefile.am b/src/backend/Makefile.am
index 9a5b2d6..c635ef0 100644
--- a/src/backend/Makefile.am
+++ b/src/backend/Makefile.am
@@ -19,12 +19,11 @@ taler_merchant_httpd_SOURCES = \
   taler-merchant-httpd_mhd.c taler-merchant-httpd_mhd.h \
   taler-merchant-httpd_auditors.c taler-merchant-httpd_auditors.h \
   taler-merchant-httpd_exchanges.c taler-merchant-httpd_exchanges.h \
-  taler-merchant-httpd_propose.c taler-merchant-httpd_propose.h \
+  taler-merchant-httpd_proposal.c taler-merchant-httpd_proposal.h \
   taler-merchant-httpd_pay.c taler-merchant-httpd_pay.h \
   taler-merchant-httpd_history.c taler-merchant-httpd_history.h \
   taler-merchant-httpd_track-transaction.c 
taler-merchant-httpd_track-transaction.h \
-  taler-merchant-httpd_track-transfer.c taler-merchant-httpd_track-transfer.h \
-  taler-merchant-httpd_map.c taler-merchant-httpd_map.h
+  taler-merchant-httpd_track-transfer.c taler-merchant-httpd_track-transfer.h
 
 
 taler_merchant_httpd_LDADD = \
diff --git a/src/backend/taler-merchant-httpd.c 
b/src/backend/taler-merchant-httpd.c
index e571ee6..b5632b0 100644
--- a/src/backend/taler-merchant-httpd.c
+++ b/src/backend/taler-merchant-httpd.c
@@ -35,7 +35,7 @@
 #include "taler-merchant-httpd_mhd.h"
 #include "taler-merchant-httpd_auditors.h"
 #include "taler-merchant-httpd_exchanges.h"
-#include "taler-merchant-httpd_propose.h"
+#include "taler-merchant-httpd_proposal.h"
 #include "taler-merchant-httpd_pay.h"
 #include "taler-merchant-httpd_track-transaction.h"
 #include "taler-merchant-httpd_track-transfer.h"
@@ -164,13 +164,9 @@ url_handler (void *cls,
       { "/", MHD_HTTP_METHOD_GET, "text/plain",
         "Hello, I'm a merchant's Taler backend. This HTTP server is not for 
humans.\n", 0,
         &TMH_MHD_handler_static_response, MHD_HTTP_OK },
-      { "/contract", MHD_HTTP_METHOD_POST, "application/json",
+      { "/proposal", MHD_HTTP_METHOD_POST, "application/json",
         NULL, 0,
-        &MH_handler_propose, MHD_HTTP_OK },
-      { "/contract/propose", NULL, "text/plain",
-        "Only POST is allowed", 0,
-        &TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
-
+        &MH_handler_proposal_put, MHD_HTTP_OK },
       { "/pay", MHD_HTTP_METHOD_POST, "application/json",
         NULL, 0,
         &MH_handler_pay, MHD_HTTP_OK },
@@ -192,9 +188,13 @@ url_handler (void *cls,
       { "/history", MHD_HTTP_METHOD_GET, "text/plain",
         "Only GET is allowed", 0,
         &MH_handler_history, MHD_HTTP_OK},
-      { "/contract/lookup", MHD_HTTP_METHOD_GET, "text/plain",
+      { "/proposal", MHD_HTTP_METHOD_GET, "text/plain",
         "Only GET is allowed", 0,
-        &MH_handler_map_out, MHD_HTTP_OK},
+        &MH_handler_proposal_lookup, MHD_HTTP_OK},
+      { "/proposal", NULL, "text/plain",
+        "Only GET/POST are allowed", 0,
+        &TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
+
       {NULL, NULL, NULL, NULL, 0, 0 }
     };
   static struct TMH_RequestHandler h404 =
@@ -723,7 +723,7 @@ run (void *cls,
                                  NULL);
   GNUNET_assert (GNUNET_OK ==
                  GNUNET_log_setup ("taler-merchant-httpd",
-                                   "INFO",
+                                   "DEBUG",
                                    NULL));
   if (GNUNET_SYSERR ==
       TMH_EXCHANGES_init (config))
diff --git a/src/backend/taler-merchant-httpd_history.c 
b/src/backend/taler-merchant-httpd_history.c
index 40b7806..4a96d2a 100644
--- a/src/backend/taler-merchant-httpd_history.c
+++ b/src/backend/taler-merchant-httpd_history.c
@@ -26,14 +26,12 @@
 #include "taler-merchant-httpd_responses.h"
 
 /**
- * Function called with information about a transaction. Checks whether the
- * returned tuple
+ * Function called with information about a transaction.
  *
  * @param cls closure
- * @param transaction_id of the contract
  * @param merchant_pub merchant's public key
  * @param exchange_uri URI of the exchange
- * @param h_contract hash of the contract
+ * @param transaction_id proposal's transaction id
  * @param h_wire hash of our wire details
  * @param timestamp time of the confirmation
  * @param refund refund deadline
@@ -42,10 +40,9 @@
 
 static void
 history_cb (void *cls,
-            uint64_t transaction_id,
            const struct TALER_MerchantPublicKeyP *merchant_pub,
             const char *exchange_uri,
-            const struct GNUNET_HashCode *h_contract,
+            const struct GNUNET_HashCode *h_proposal_data,
             const struct GNUNET_HashCode *h_wire,
             struct GNUNET_TIME_Absolute timestamp,
             struct GNUNET_TIME_Absolute refund,
@@ -55,10 +52,9 @@ history_cb (void *cls,
   json_t *entry;
 
   GNUNET_break (NULL !=
-               (entry = json_pack ("{s:I, s:s, s:o, s:o, s:o}",
-                                   "transaction_id", transaction_id,
+               (entry = json_pack ("{s:o, s:s, s:s, s:o}",
+                                   "h_proposal_data", 
GNUNET_JSON_from_data_auto (h_proposal_data),
                                    "exchange", exchange_uri,
-                                   "h_contract", GNUNET_JSON_from_data_auto 
(h_contract),
                                    "timestamp", GNUNET_JSON_from_time_abs 
(timestamp),
                                    "total_amount",
                                    TALER_JSON_from_amount (total_amount))));
diff --git a/src/backend/taler-merchant-httpd_map.c 
b/src/backend/taler-merchant-httpd_map.c
deleted file mode 100644
index 8eb9d80..0000000
--- a/src/backend/taler-merchant-httpd_map.c
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
-  This file is part of TALER
-  (C) 2014, 2015, 2016 INRIA
-
-  TALER is free software; you can redistribute it and/or modify it under the
-  terms of the GNU Affero General Public License as published by the Free 
Software
-  Foundation; either version 3, or (at your option) any later version.
-
-  TALER is distributed in the hope that it will be useful, but WITHOUT ANY
-  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-  A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License along with
-  TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
-*/
-/**
- * @file backend/taler-merchant-httpd_map.c
- * @brief Provides the frontend the mean to store plain contracts in database
- * @author Marcello Stanisci
- */
-#include "platform.h"
-#include <jansson.h>
-#include <taler/taler_signatures.h>
-#include <taler/taler_json_lib.h>
-#include "taler-merchant-httpd.h"
-#include "taler-merchant-httpd_responses.h"
-#include "taler-merchant-httpd_parsing.h"
-
-/**
- * Information we keep for individual calls
- * to requests that parse JSON, but keep no other state.
- */
-struct TMH_JsonParseContext
-{
-
-  /**
-   * This field MUST be first.
-   * FIXME: Explain why!
-   */
-  struct TM_HandlerContext hc;
-
-  /**
-   * Placeholder for #TMH_PARSE_post_json() to keep its internal state.
-   */
-  void *json_parse_context;
-};
-
-/**
- * Custom cleanup routine for a `struct TMH_JsonParseContext`.
- *
- * @param hc the `struct TMH_JsonParseContext` to clean up.
- */
-static void
-json_parse_cleanup (struct TM_HandlerContext *hc)
-{
-  struct TMH_JsonParseContext *jpc = (struct TMH_JsonParseContext *) hc;
-
-  TMH_PARSE_post_cleanup_callback (jpc->json_parse_context);
-  GNUNET_free (jpc);
-}
-
-
-/**
- * Manage a /map/in request. Store in db a plain text contract
- * and its hashcode.
- *
- * @param rh context of the handler
- * @param connection the MHD connection to handle
- * @param[in,out] connection_cls the connection's closure (can be updated)
- * @param upload_data upload data
- * @param[in,out] upload_data_size number of bytes (left) in @a upload_data
- * @return MHD result code
- */
-int
-MH_handler_map_in (struct TMH_RequestHandler *rh,
-                   struct MHD_Connection *connection,
-                   void **connection_cls,
-                   const char *upload_data,
-                   size_t *upload_data_size)
-{
-
-  int res;
-  json_t *root;
-  json_t *contract;
-  struct GNUNET_HashCode h_contract;
-  struct GNUNET_HashCode tmp;
-  struct TMH_JsonParseContext *ctx;
-  struct MHD_Response *response;
-
-/* Fetch body */
-
-  struct GNUNET_JSON_Specification spec[] = {
-    GNUNET_JSON_spec_json ("contract", &contract),
-    GNUNET_JSON_spec_fixed_auto ("h_contract", &h_contract),
-    GNUNET_JSON_spec_end ()
-  };
-
-  if (NULL == *connection_cls)
-  {
-    ctx = GNUNET_new (struct TMH_JsonParseContext);
-    ctx->hc.cc = &json_parse_cleanup;
-    *connection_cls = ctx;
-  }
-  else
-  {
-    ctx = *connection_cls;
-  }
-
-  res = TMH_PARSE_post_json (connection,
-                             &ctx->json_parse_context,
-                             upload_data,
-                             upload_data_size,
-                             &root);
-  if (GNUNET_SYSERR == res)
-    return MHD_NO;
-  /* the POST's body has to be further fetched */
-  if ((GNUNET_NO == res) || (NULL == root))
-    return MHD_YES;
-
-  res = TMH_PARSE_json_data (connection,
-                             root,
-                             spec);
-  if (GNUNET_NO == res)
-  {
-    json_decref (root);
-    return MHD_YES;
-  }
-  if (GNUNET_SYSERR == res)
-  {
-    json_decref (root);
-    return TMH_RESPONSE_reply_internal_error (connection,
-                                             TALER_EC_NONE,
-                                             "Impossible to parse JSON");
-  }
-
-  /* Sanity checks */
-  if (GNUNET_SYSERR ==
-      TALER_JSON_hash (contract,
-                       &tmp))
-    return TMH_RESPONSE_reply_invalid_json (connection); 
-
-  /**
-   * Check hashes match. This check does NOT detect invalid
-   * contracts though.
-   */
-
-  if (0 != memcmp (&tmp,
-                   &h_contract,
-                   sizeof (struct GNUNET_HashCode)))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                "'h_contract' does not match 'contract'\n");
-    return TMH_RESPONSE_reply_json_pack
-             (connection,
-              MHD_HTTP_UNPROCESSABLE_ENTITY,
-              "{s:I, s:s}",
-              "code", (json_int_t) TALER_EC_MAP_IN_UNMATCHED_HASH,
-              "error", "field 'h_contract' is not hash of 'contract'");
-  }
-
-  /* Store body */
-  if (GNUNET_OK != db->store_map (db->cls,
-                                  &h_contract,
-                                  contract))
-  {
-    return TMH_RESPONSE_reply_internal_error (connection,
-                                              TALER_EC_MAP_IN_STORE_DB_ERROR,
-                                              "Could not store data into db");
-  }
-
- response = MHD_create_response_from_buffer (0, NULL, MHD_RESPMEM_PERSISTENT); 
- return MHD_queue_response (connection, MHD_HTTP_OK, response);
-
-}
-
-
-/**
- * Manage a /map/out request. Query the db and returns a plain
- * text contract associated with the hashcode given as input
- *
- * @param rh context of the handler
- * @param connection the MHD connection to handle
- * @param[in,out] connection_cls the connection's closure (can be updated)
- * @param upload_data upload data
- * @param[in,out] upload_data_size number of bytes (left) in @a upload_data
- * @return MHD result code
- */
-int
-MH_handler_map_out (struct TMH_RequestHandler *rh,
-                    struct MHD_Connection *connection,
-                    void **connection_cls,
-                    const char *upload_data,
-                    size_t *upload_data_size)
-{
-  const char *h_contract_enc;
-  struct GNUNET_HashCode h_contract;
-  int res;
-  json_t *contract;
-
-  h_contract_enc = MHD_lookup_connection_value (connection,
-                                                MHD_GET_ARGUMENT_KIND,
-                                                "h_contract");
-  if (NULL == h_contract_enc)
-    return TMH_RESPONSE_reply_arg_missing (connection,
-                                          TALER_EC_PARAMETER_MISSING,
-                                           "h_contract");
-
-  if (GNUNET_OK != GNUNET_STRINGS_string_to_data (h_contract_enc,
-                                                  strlen (h_contract_enc),
-                                                  &h_contract, 
-                                                  sizeof (h_contract)))
-  {
-    GNUNET_break_op (0);
-    return TMH_RESPONSE_reply_bad_request (connection,
-                                           TALER_EC_PARAMETER_MALFORMED,
-                                           "Could not decode hashcode into 
binary form"); 
-  }
-
-  res = db->find_contract (db->cls,
-                           &contract,
-                           &h_contract);
-
-  if (GNUNET_SYSERR == res)
-  {
-    return TMH_RESPONSE_reply_internal_error (connection,
-                                              
TALER_EC_MAP_OUT_GET_FROM_DB_ERROR,
-                                              "Could not retrieve data from 
db");
-  }
-
-  if (GNUNET_NO == res)
-  {
-    return TMH_RESPONSE_reply_not_found (connection, 
-                                         TALER_EC_MAP_OUT_CONTRACT_UNKNOWN,
-                                         "contract");
-  }
-
-  return TMH_RESPONSE_reply_json (connection,
-                                  contract,
-                                  MHD_HTTP_OK); 
-}
-/* end of taler-merchant-httpd_history.c */
diff --git a/src/backend/taler-merchant-httpd_pay.c 
b/src/backend/taler-merchant-httpd_pay.c
index f981074..de8649a 100644
--- a/src/backend/taler-merchant-httpd_pay.c
+++ b/src/backend/taler-merchant-httpd_pay.c
@@ -159,7 +159,7 @@ struct PayContext
   /**
    * Transaction ID given in @e root.
    */
-  uint64_t transaction_id;
+  const char *order_id;
 
   /**
    * Maximum fee the merchant is willing to pay, from @e root.
@@ -193,7 +193,7 @@ struct PayContext
   /**
    * "H_contract" from @e root.
    */
-  struct GNUNET_HashCode h_contract;
+  struct GNUNET_HashCode h_proposal_data;
 
   /**
    * Wire transfer deadline. How soon would the merchant like the
@@ -395,9 +395,13 @@ deposit_cb (void *cls,
     return;
   }
   /* store result to DB */
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Storing successful payment for h_proposal_data '%s'\n",
+              GNUNET_h2s (&pc->h_proposal_data));
+
   if (GNUNET_OK !=
       db->store_deposit (db->cls,
-                        pc->transaction_id,
+                        &pc->h_proposal_data,
                         &pc->mi->pubkey,
                         &dc->coin_pub,
                         &dc->amount_with_fee,
@@ -422,7 +426,7 @@ deposit_cb (void *cls,
 
   mr.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_PAYMENT_OK);
   mr.purpose.size = htonl (sizeof (mr));
-  mr.h_contract = pc->h_contract;
+  mr.h_proposal_data = pc->h_proposal_data;
 
   GNUNET_CRYPTO_eddsa_sign (&mi->privkey.eddsa_priv,
                             &mr.purpose,
@@ -430,10 +434,10 @@ deposit_cb (void *cls,
   resume_pay_with_response (pc,
                             MHD_HTTP_OK,
                             TMH_RESPONSE_make_json_pack ("{s:s, s:o}",
-                                                         "merchant_sig",
+                                                         "sig",
                                                         json_string_value 
(GNUNET_JSON_from_data_auto (&sig)),
-                                                         "h_contract",
-                                                         GNUNET_JSON_from_data 
(&pc->h_contract,
+                                                         "h_proposal_data",
+                                                         GNUNET_JSON_from_data 
(&pc->h_proposal_data,
                                                                                
 sizeof (struct GNUNET_HashCode))));
 }
 
@@ -704,12 +708,11 @@ process_pay_with_exchange (void *cls,
                                      &dc->amount_with_fee,
                                      pc->wire_transfer_deadline,
                                      pc->mi->j_wire,
-                                     &pc->h_contract,
+                                     &pc->h_proposal_data,
                                      &dc->coin_pub,
                                      &dc->ub_sig,
                                      &dc->denom,
                                      pc->timestamp,
-                                     pc->transaction_id,
                                      &pc->mi->pubkey,
                                      pc->refund_deadline,
                                      &dc->coin_sig,
@@ -773,7 +776,7 @@ handle_pay_timeout (void *cls)
  */
 static void
 check_coin_paid (void *cls,
-                 uint64_t transaction_id,
+                 const struct GNUNET_HashCode *h_proposal_data,
                  const struct TALER_CoinSpendPublicKeyP *coin_pub,
                  const struct TALER_Amount *amount_with_fee,
                  const struct TALER_Amount *deposit_fee,
@@ -782,7 +785,9 @@ check_coin_paid (void *cls,
   struct PayContext *pc = cls;
   unsigned int i;
 
-  if (pc->transaction_id != transaction_id)
+  if (0 != memcmp (&pc->h_proposal_data,
+                   h_proposal_data,
+                   sizeof (struct GNUNET_HashCode)))
   {
     GNUNET_break (0);
     return;
@@ -811,7 +816,6 @@ check_coin_paid (void *cls,
  * @param transaction_id of the contract
  * @param merchant_pub merchant's public key
  * @param exchange_uri URI of the exchange
- * @param h_contract hash of the contract
  * @param h_xwire hash of our wire details
  * @param timestamp time of the confirmation
  * @param refund refund deadline
@@ -819,10 +823,9 @@ check_coin_paid (void *cls,
  */
 static void
 check_transaction_exists (void *cls,
-                         uint64_t transaction_id,
                          const struct TALER_MerchantPublicKeyP *merchant_pub,
                          const char *exchange_uri,
-                         const struct GNUNET_HashCode *h_contract,
+                         const struct GNUNET_HashCode *h_proposal_data,
                          const struct GNUNET_HashCode *h_xwire,
                          struct GNUNET_TIME_Absolute timestamp,
                          struct GNUNET_TIME_Absolute refund,
@@ -830,9 +833,9 @@ check_transaction_exists (void *cls,
 {
   struct PayContext *pc = cls;
 
-  if ( (0 == memcmp (h_contract,
-                    &pc->h_contract,
-                    sizeof (struct GNUNET_HashCode))) &&
+  if ( (0 == memcmp (h_proposal_data,
+                    &pc->h_proposal_data,
+                     sizeof (struct GNUNET_HashCode))) &&
        (0 == memcmp (h_xwire,
                     &pc->mi->h_wire,
                     sizeof (struct GNUNET_HashCode))) &&
@@ -855,6 +858,33 @@ get_instance (struct json_t *json);
 
 
 /**
+ * Just a stub used to double-check if a transaction
+ * has been correctly inserted into db.
+ *
+ * @param cls closure
+ * @param transaction_id of the contract
+ * @param merchant's public key
+ * @param exchange_uri URI of the exchange
+ * @param h_contract hash of the contract
+ * @param h_wire hash of our wire details
+ * @param timestamp time of the confirmation
+ * @param refund refund deadline
+ * @param total_amount total amount we receive for the contract after fees
+ */
+static void
+transaction_double_check (void *cls,
+                         const struct TALER_MerchantPublicKeyP *merchant_pub,
+                          const char *exchange_uri,
+                          const struct GNUNET_HashCode *h_proposal_data,
+                          const struct GNUNET_HashCode *h_wire,
+                          struct GNUNET_TIME_Absolute timestamp,
+                          struct GNUNET_TIME_Absolute refund,
+                          const struct TALER_Amount *total_amount)
+{
+  return;
+}                
+
+/**
  * Accomplish this payment.
  *
  * @param rh context of the handler
@@ -941,19 +971,18 @@ MH_handler_pay (struct TMH_RequestHandler *rh,
     json_t *coin;
     unsigned int coins_index;
     struct TALER_MerchantSignatureP merchant_sig;
-    struct TALER_ContractPS cp;
+    struct TALER_ProposalDataPS pdps;
     const char *chosen_exchange;
     struct GNUNET_JSON_Specification spec[] = {
       TALER_JSON_spec_amount ("amount", &pc->amount),
       GNUNET_JSON_spec_json ("coins", &coins),
-      GNUNET_JSON_spec_fixed_auto ("H_contract", &pc->h_contract),
+      GNUNET_JSON_spec_fixed_auto ("h_proposal_data", &pc->h_proposal_data),
       TALER_JSON_spec_amount ("max_fee", &pc->max_fee),
       GNUNET_JSON_spec_fixed_auto ("merchant_sig", &merchant_sig),
       GNUNET_JSON_spec_string ("exchange", &chosen_exchange),
       GNUNET_JSON_spec_absolute_time ("refund_deadline", &pc->refund_deadline),
       GNUNET_JSON_spec_absolute_time ("pay_deadline", &pc->pay_deadline),
       GNUNET_JSON_spec_absolute_time ("timestamp", &pc->timestamp),
-      GNUNET_JSON_spec_uint64 ("transaction_id", &pc->transaction_id),
       GNUNET_JSON_spec_end()
     };
 
@@ -988,12 +1017,33 @@ MH_handler_pay (struct TMH_RequestHandler *rh,
     pc->chosen_exchange = GNUNET_strdup (chosen_exchange);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                "Parsed JSON for /pay.\n");
-    cp.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_CONTRACT);
-    cp.purpose.size = htonl (sizeof (struct TALER_ContractPS));
-    cp.h_contract = pc->h_contract;
+    pdps.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_CONTRACT);
+    pdps.purpose.size = htonl (sizeof (pdps));
+    pdps.hash = pc->h_proposal_data;
+
+    struct GNUNET_HashCode dummy;
+
+    GNUNET_CRYPTO_hash (&merchant_sig.eddsa_sig,
+                        sizeof (merchant_sig.eddsa_sig),
+                        &dummy);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Verifying signature '%s'\n",
+                GNUNET_h2s (&dummy));
+
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "of hashed data '%s'\n",
+                GNUNET_h2s (&pc->h_proposal_data));
+
+    GNUNET_CRYPTO_hash (&pc->mi->privkey.eddsa_priv,
+                        sizeof (pc->mi->privkey.eddsa_priv),
+                        &dummy);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "with private key '%s'\n",
+                GNUNET_h2s (&dummy));
+
     if (GNUNET_OK !=
        GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_CONTRACT,
-                                   &cp.purpose,
+                                   &pdps.purpose,
                                    &merchant_sig.eddsa_sig,
                                    &pc->mi->pubkey.eddsa_pub))
     {
@@ -1108,7 +1158,7 @@ MH_handler_pay (struct TMH_RequestHandler *rh,
   /* Check if this payment attempt has already succeeded */
   if (GNUNET_SYSERR ==
       db->find_payments (db->cls,
-                        pc->transaction_id,
+                        &pc->h_proposal_data,
                          &pc->mi->pubkey,
                         &check_coin_paid,
                         pc))
@@ -1139,7 +1189,7 @@ MH_handler_pay (struct TMH_RequestHandler *rh,
   /* Check if transaction is already known, if not store it. */
   if (GNUNET_SYSERR ==
       db->find_transaction (db->cls,
-                           pc->transaction_id,
+                           &pc->h_proposal_data,
                            &pc->mi->pubkey,
                            &check_transaction_exists,
                             pc))
@@ -1160,7 +1210,9 @@ MH_handler_pay (struct TMH_RequestHandler *rh,
   }
   if (GNUNET_NO == pc->transaction_exits)
   {
-    /* #4521 goes here: Check if the customer respects pay_deadline */
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Dealing with new transaction '%s'\n",
+                GNUNET_h2s (&pc->h_proposal_data));
     now = GNUNET_TIME_absolute_get ();
     if (now.abs_value_us > pc->pay_deadline.abs_value_us)
     {
@@ -1177,12 +1229,14 @@ MH_handler_pay (struct TMH_RequestHandler *rh,
                                              "The time to pay for this 
contract has expired.");
     }
 
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Storing transaction '%s'\n",
+                GNUNET_h2s (&pc->h_proposal_data));
     if (GNUNET_OK !=
         db->store_transaction (db->cls,
-                               pc->transaction_id,
+                               &pc->h_proposal_data,
                                &pc->mi->pubkey,
                                pc->chosen_exchange,
-                               &pc->h_contract,
                                &pc->mi->h_wire,
                                pc->timestamp,
                                pc->refund_deadline,
@@ -1194,6 +1248,12 @@ MH_handler_pay (struct TMH_RequestHandler *rh,
                                                
TALER_EC_PAY_DB_STORE_TRANSACTION_ERROR,
                                                "Merchant database error");
     }
+  if (GNUNET_OK != db->find_transaction (db->cls,
+                                         &pc->h_proposal_data,
+                                        &pc->mi->pubkey,
+                                         &transaction_double_check,
+                                         NULL))
+    GNUNET_break (0);                                         
   }
 
   MHD_suspend_connection (connection);
diff --git a/src/backend/taler-merchant-httpd_propose.c 
b/src/backend/taler-merchant-httpd_proposal.c
similarity index 59%
rename from src/backend/taler-merchant-httpd_propose.c
rename to src/backend/taler-merchant-httpd_proposal.c
index ed222c9..6e45b2d 100644
--- a/src/backend/taler-merchant-httpd_propose.c
+++ b/src/backend/taler-merchant-httpd_proposal.c
@@ -120,15 +120,11 @@ get_instance (struct json_t *json);
 
 
 /**
- * Manage a contract request. In practical terms, it adds the fields
- * 'exchanges', 'merchant_pub', and 'H_wire' to the contract 'proposition'
- * gotten from the frontend. Finally, it adds (outside of the
- * contract) a signature of the (hashed stringification) of the
- * contract (and the hashed stringification of this contract as well
- * to aid diagnostics) to the final bundle, which is then send back to
- * the frontend.
+ * Generate a proposal, given its order. In practical terms, it adds the
+ * fields  'exchanges', 'merchant_pub', and 'H_wire' to the order gotten
+ * from the frontend. Finally, it signs this data, and returns it to the
+ * frontend.
  *
- * @param rh context of the handler
  * @param connection the MHD connection to handle
  * @param[in,out] connection_cls the connection's closure (can be updated)
  * @param upload_data upload data
@@ -136,23 +132,24 @@ get_instance (struct json_t *json);
  * @return MHD result code
  */
 int
-MH_handler_propose (struct TMH_RequestHandler *rh,
-                    struct MHD_Connection *connection,
-                    void **connection_cls,
-                    const char *upload_data,
-                    size_t *upload_data_size)
+MH_handler_proposal_put (struct TMH_RequestHandler *rh,
+                         struct MHD_Connection *connection,
+                         void **connection_cls,
+                         const char *upload_data,
+                         size_t *upload_data_size)
 {
 
   json_t *root;
-  json_t *jcontract;
+  json_t *order;
   int res;
   struct MerchantInstance *mi;
   struct TMH_JsonParseContext *ctx;
-  struct TALER_ContractPS contract;
-  struct GNUNET_CRYPTO_EddsaSignature contract_sig;
+  struct TALER_ProposalDataPS pdps;
+  struct GNUNET_CRYPTO_EddsaSignature merchant_sig;
   struct TALER_Amount total;
   struct TALER_Amount max_fee;
-  uint64_t transaction_id;
+  const char *order_id;
+  struct GNUNET_HashCode h_oid;
   json_t *products;
   json_t *merchant;
   struct GNUNET_TIME_Absolute timestamp;
@@ -161,9 +158,9 @@ MH_handler_propose (struct TMH_RequestHandler *rh,
   struct GNUNET_JSON_Specification spec[] = {
     TALER_JSON_spec_amount ("amount", &total),
     TALER_JSON_spec_amount ("max_fee", &max_fee),
-    GNUNET_JSON_spec_uint64 ("transaction_id", &transaction_id),
+    GNUNET_JSON_spec_string ("order_id", &order_id),
     /* The following entries we don't actually need, except to check that
-       the contract is well-formed */
+       the order is well-formed */
     GNUNET_JSON_spec_json ("products", &products),
     GNUNET_JSON_spec_json ("merchant", &merchant),
     GNUNET_JSON_spec_absolute_time ("timestamp", &timestamp),
@@ -194,18 +191,18 @@ MH_handler_propose (struct TMH_RequestHandler *rh,
   if ((GNUNET_NO == res) || (NULL == root))
     return MHD_YES;
 
-  jcontract = json_object_get (root,
-                              "contract");
-  if (NULL == jcontract)
+  order = json_object_get (root,
+                           "order");
+  if (NULL == order)
   {
     json_decref (root);
     return TMH_RESPONSE_reply_arg_missing (connection,
                                           TALER_EC_PARAMETER_MISSING,
-                                          "contract");
+                                          "order");
   }
   /* extract fields we need to sign separately */
   res = TMH_PARSE_json_data (connection,
-                             jcontract,
+                             order,
                              spec);
   if (GNUNET_NO == res)
   {
@@ -217,7 +214,7 @@ MH_handler_propose (struct TMH_RequestHandler *rh,
     json_decref (root);
     return TMH_RESPONSE_reply_internal_error (connection,
                                              TALER_EC_NONE,
-                                             "Impossible to parse contract");
+                                             "Impossible to parse the order");
   }
   /* check contract is well-formed */
   if (GNUNET_OK != check_products (products))
@@ -226,7 +223,7 @@ MH_handler_propose (struct TMH_RequestHandler *rh,
     json_decref (root);
     return TMH_RESPONSE_reply_arg_invalid (connection,
                                           TALER_EC_PARAMETER_MALFORMED,
-                                          "contract:products");
+                                          "order:products");
   }
 
   mi = get_instance (merchant);
@@ -243,39 +240,130 @@ MH_handler_propose (struct TMH_RequestHandler *rh,
               "Signing contract on behalf of instance '%s'\n",
               mi->id);
   /* add fields to the contract that the backend should provide */
-  json_object_set (jcontract,
+  json_object_set (order,
                    "exchanges",
                    trusted_exchanges);
-  json_object_set (jcontract,
+  json_object_set (order,
                    "auditors",
                    j_auditors);
-  json_object_set_new (jcontract,
+  json_object_set_new (order,
                        "H_wire",
                       GNUNET_JSON_from_data_auto (&mi->h_wire));
-  json_object_set_new (jcontract,
+  json_object_set_new (order,
                        "merchant_pub",
                       GNUNET_JSON_from_data_auto (&mi->pubkey));
 
-  /* create contract signature */
-  contract.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_CONTRACT);
-  contract.purpose.size = htonl (sizeof (contract));
+  /* create proposal signature */
+  pdps.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_CONTRACT);
+  pdps.purpose.size = htonl (sizeof (pdps));
   GNUNET_assert (GNUNET_OK ==
-                 TALER_JSON_hash (jcontract,
-                                  &contract.h_contract));
+                 TALER_JSON_hash (order,
+                                  &pdps.hash));
+
+  /*FIXME: do NOT keep in production, private key logged!*/
+  struct GNUNET_HashCode dummy;
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Signing h_proposal_data '%s'\n",
+              GNUNET_h2s (&pdps.hash));
+
+  GNUNET_CRYPTO_hash (&mi->privkey.eddsa_priv,
+                      sizeof (mi->privkey.eddsa_priv),
+                      &dummy);
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "with private key '%s'\n",
+              GNUNET_h2s (&dummy));
+
   GNUNET_CRYPTO_eddsa_sign (&mi->privkey.eddsa_priv,
-                            &contract.purpose,
-                            &contract_sig);
+                            &pdps.purpose,
+                            &merchant_sig);
+
+   GNUNET_CRYPTO_hash (&merchant_sig,
+                      sizeof (merchant_sig),
+                      &dummy);
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "generating signature '%s'\n",
+              GNUNET_h2s (&dummy)); 
+
+  GNUNET_CRYPTO_hash (order_id,
+                      strlen (order_id),
+                      &h_oid);
+  if (GNUNET_OK !=
+      db->insert_proposal_data (db->cls,
+                                &h_oid,
+                                order))
+    return TMH_RESPONSE_reply_internal_error (connection,
+                                              TALER_EC_PROPOSAL_STORE_DB_ERROR,
+                                              "db error: could not store this 
proposal's data into db");
+  
 
-  /* return final response */
   res = TMH_RESPONSE_reply_json_pack (connection,
                                       MHD_HTTP_OK,
                                       "{s:O, s:o s:o}",
-                                      "contract", jcontract,
-                                      "merchant_sig", 
GNUNET_JSON_from_data_auto (&contract_sig),
-                                      "H_contract", GNUNET_JSON_from_data_auto 
(&contract.h_contract));
+                                      "data", order,
+                                      "sig", GNUNET_JSON_from_data_auto 
(&merchant_sig),
+                                      "hash", GNUNET_JSON_from_data_auto 
(&pdps.hash));
   GNUNET_JSON_parse_free (spec);
   json_decref (root);
   return res;
 }
 
+/**
+ * Manage a GET /proposal request. Query the db and returns the
+ * proposal's data related to the transaction id given as the URL's
+ * parameter.
+ *
+ * @param rh context of the handler
+ * @param connection the MHD connection to handle
+ * @param[in,out] connection_cls the connection's closure (can be updated)
+ * @param upload_data upload data
+ * @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @return MHD result code
+ */
+int
+MH_handler_proposal_lookup (struct TMH_RequestHandler *rh,
+                            struct MHD_Connection *connection,
+                            void **connection_cls,
+                            const char *upload_data,
+                            size_t *upload_data_size)
+{
+  const char *order_id;
+  struct GNUNET_HashCode h_oid;
+  int res;
+  json_t *proposal_data;
+
+  order_id = MHD_lookup_connection_value (connection,
+                                          MHD_GET_ARGUMENT_KIND,
+                                          "order_id");
+  if (NULL == order_id)
+    return TMH_RESPONSE_reply_arg_missing (connection,
+                                          TALER_EC_PARAMETER_MISSING,
+                                           "order_id");
+  GNUNET_CRYPTO_hash (order_id,
+                      strlen (order_id),
+                      &h_oid);
+
+  res = db->find_proposal_data (db->cls,
+                                &proposal_data,
+                                &h_oid);
+  if (GNUNET_NO == res)
+    return TMH_RESPONSE_reply_not_found (connection, 
+                                         TALER_EC_PROPOSAL_LOOKUP_NOT_FOUND,
+                                         "unknown transaction id");
+
+  if (GNUNET_SYSERR == res)
+    return TMH_RESPONSE_reply_internal_error (connection,
+                                              
TALER_EC_PROPOSAL_LOOKUP_DB_ERROR,
+                                              "An error occurred while 
retrieving proposal data from db");
+
+  
+  return TMH_RESPONSE_reply_json (connection,
+                                  proposal_data,
+                                  MHD_HTTP_OK); 
+
+
+}
+
+
 /* end of taler-merchant-httpd_contract.c */
diff --git a/src/backend/taler-merchant-httpd_propose.h 
b/src/backend/taler-merchant-httpd_proposal.h
similarity index 51%
rename from src/backend/taler-merchant-httpd_propose.h
rename to src/backend/taler-merchant-httpd_proposal.h
index ad3e1dc..fe5b319 100644
--- a/src/backend/taler-merchant-httpd_propose.h
+++ b/src/backend/taler-merchant-httpd_proposal.h
@@ -24,9 +24,11 @@
 #include "taler-merchant-httpd.h"
 
 /**
- * Manage a contract request
+ * Generate a proposal, given its order. In practical terms, it adds the
+ * fields  'exchanges', 'merchant_pub', and 'H_wire' to the order gotten
+ * from the frontend. Finally, it signs this data, and returns it to the
+ * frontend.
  *
- * @param rh context of the handler
  * @param connection the MHD connection to handle
  * @param[in,out] connection_cls the connection's closure (can be updated)
  * @param upload_data upload data
@@ -34,10 +36,29 @@
  * @return MHD result code
  */
 int
-MH_handler_propose (struct TMH_RequestHandler *rh,
-                     struct MHD_Connection *connection,
-                     void **connection_cls,
-                     const char *upload_data,
-                     size_t *upload_data_size);
+MH_handler_proposal_put (struct TMH_RequestHandler *rh,
+                         struct MHD_Connection *connection,
+                         void **connection_cls,
+                         const char *upload_data,
+                         size_t *upload_data_size);
+
 
+/**
+ * Manage a GET /proposal request. Query the db and returns the
+ * proposal's data related to the transaction id given as the URL's
+ * parameter.
+ *
+ * @param rh context of the handler
+ * @param connection the MHD connection to handle
+ * @param[in,out] connection_cls the connection's closure (can be updated)
+ * @param upload_data upload data
+ * @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @return MHD result code
+ */
+int
+MH_handler_proposal_lookup (struct TMH_RequestHandler *rh,
+                            struct MHD_Connection *connection,
+                            void **connection_cls,
+                            const char *upload_data,
+                            size_t *upload_data_size);
 #endif
diff --git a/src/backend/taler-merchant-httpd_track-transaction.c 
b/src/backend/taler-merchant-httpd_track-transaction.c
index edf323f..0e48b3c 100644
--- a/src/backend/taler-merchant-httpd_track-transaction.c
+++ b/src/backend/taler-merchant-httpd_track-transaction.c
@@ -185,11 +185,6 @@ struct TrackTransactionContext
   struct GNUNET_HashCode h_wire;
 
   /**
-   * Hash of the contract.
-   */
-  struct GNUNET_HashCode h_contract;
-
-  /**
    * Timestamp of the transaction.
    */
   struct GNUNET_TIME_Absolute timestamp;
@@ -207,7 +202,12 @@ struct TrackTransactionContext
   /**
    * Transaction this request is about.
    */
-  uint64_t transaction_id;
+  const char *transaction_id;
+
+  /**
+   *  Proposal's hashcode.
+   */
+  struct GNUNET_HashCode h_proposal_data;
 
   /**
    * Response code to return upon resume.
@@ -354,14 +354,14 @@ wire_deposits_cb (void *cls,
                   const struct TALER_Amount *total_amount,
                   unsigned int details_length,
                   const struct TALER_TrackTransferDetails *details)
-{
-  struct TrackTransactionContext *tctx = cls;
-  struct TrackCoinContext *tcc;
-  unsigned int i;
+    {
+      struct TrackTransactionContext *tctx = cls;
+      struct TrackCoinContext *tcc;
+      unsigned int i;
 
-  tctx->wdh = NULL;
-  if (MHD_HTTP_OK != http_status)
-  {
+      tctx->wdh = NULL;
+      if (MHD_HTTP_OK != http_status)
+      {
     resume_track_transaction_with_response
       (tctx,
        MHD_HTTP_FAILED_DEPENDENCY,
@@ -402,7 +402,7 @@ wire_deposits_cb (void *cls,
 
       if (GNUNET_OK !=
           db->store_coin_to_transfer (db->cls,
-                                      details[i].transaction_id,
+                                      &details[i].h_proposal_data,
                                       &details[i].coin_pub,
                                       &tctx->current_wtid))
       {
@@ -568,9 +568,8 @@ trace_coins (struct TrackTransactionContext *tctx)
     tcc->dwh = TALER_EXCHANGE_track_transaction (tctx->eh,
                                                  &tctx->mi->privkey,
                                                  &tctx->h_wire,
-                                                 &tctx->h_contract,
+                                                 &tctx->h_proposal_data,
                                                  &tcc->coin_pub,
-                                                 tctx->transaction_id,
                                                  &wtid_cb,
                                                  tcc);
     return;
@@ -721,6 +720,7 @@ handle_track_transaction_timeout (void *cls)
 
 /**
  * Function called with information about a transaction.
+ * Its duty is to fill up the "context" for the whole operation.
  *
  * @param cls closure
  * @param transaction_id of the contract
@@ -734,10 +734,9 @@ handle_track_transaction_timeout (void *cls)
  */
 static void
 transaction_cb (void *cls,
-                uint64_t transaction_id,
                const struct TALER_MerchantPublicKeyP *merchant_pub,
                 const char *exchange_uri,
-                const struct GNUNET_HashCode *h_contract,
+                const struct GNUNET_HashCode *h_proposal_data,
                 const struct GNUNET_HashCode *h_wire,
                 struct GNUNET_TIME_Absolute timestamp,
                 struct GNUNET_TIME_Absolute refund,
@@ -745,9 +744,8 @@ transaction_cb (void *cls,
 {
   struct TrackTransactionContext *tctx = cls;
 
-  tctx->transaction_id = transaction_id;
+  tctx->h_proposal_data = *h_proposal_data;
   tctx->exchange_uri = GNUNET_strdup (exchange_uri);
-  tctx->h_contract = *h_contract;
   tctx->h_wire = *h_wire;
   tctx->timestamp = timestamp;
   tctx->refund_deadline = refund;
@@ -774,7 +772,7 @@ transaction_cb (void *cls,
  */
 static void
 transfer_cb (void *cls,
-             uint64_t transaction_id,
+             const struct GNUNET_HashCode *h_proposal_data,
              const struct TALER_CoinSpendPublicKeyP *coin_pub,
              const struct TALER_WireTransferIdentifierRawP *wtid,
              struct GNUNET_TIME_Absolute execution_time,
@@ -804,7 +802,7 @@ transfer_cb (void *cls,
  */
 static void
 coin_cb (void *cls,
-         uint64_t transaction_id,
+         const struct GNUNET_HashCode *h_proposal_data,
          const struct TALER_CoinSpendPublicKeyP *coin_pub,
          const struct TALER_Amount *amount_with_fee,
          const struct TALER_Amount *deposit_fee,
@@ -822,10 +820,10 @@ coin_cb (void *cls,
                                tctx->tcc_tail,
                                tcc);
   GNUNET_break (GNUNET_SYSERR !=
-                db->find_transfers_by_id (db->cls,
-                                          transaction_id,
-                                          &transfer_cb,
-                                          tcc));
+                db->find_transfers_by_hash (db->cls,
+                                            h_proposal_data,
+                                            &transfer_cb,
+                                            tcc));
 }
 
 /**
@@ -846,11 +844,13 @@ MH_handler_track_transaction (struct TMH_RequestHandler 
*rh,
                               size_t *upload_data_size)
 {
   struct TrackTransactionContext *tctx;
-  unsigned long long transaction_id;
-  const char *str;
+  const char *order_id;
   const char *instance;
   int ret;
   struct GNUNET_HashCode h_instance;
+  struct GNUNET_HashCode h_order_id;
+  struct GNUNET_HashCode h_proposal_data;
+  struct json_t *proposal_data;
 
   if (NULL == *connection_cls)
   {
@@ -895,13 +895,13 @@ MH_handler_track_transaction (struct TMH_RequestHandler 
*rh,
                 "Not sure why we are here, should be suspended\n");
     return MHD_YES; /* still work in progress */
   }
-  str = MHD_lookup_connection_value (connection,
-                                     MHD_GET_ARGUMENT_KIND,
-                                     "id");
-  if (NULL == str)
+  order_id = MHD_lookup_connection_value (connection,
+                                          MHD_GET_ARGUMENT_KIND,
+                                          "order_id");
+  if (NULL == order_id)
     return TMH_RESPONSE_reply_arg_missing (connection,
                                            TALER_EC_PARAMETER_MISSING,
-                                          "id");
+                                          "order_id");
   instance = MHD_lookup_connection_value (connection,
                                           MHD_GET_ARGUMENT_KIND,
                                           "instance");
@@ -910,22 +910,35 @@ MH_handler_track_transaction (struct TMH_RequestHandler 
*rh,
   GNUNET_CRYPTO_hash (instance,
                       strlen (instance),
                       &h_instance);
+  GNUNET_CRYPTO_hash (order_id,
+                      strlen (order_id),
+                      &h_order_id);
+
+
+
   tctx->mi = GNUNET_CONTAINER_multihashmap_get (by_id_map,
                                                 &h_instance);
   if (NULL == tctx->mi)
     return TMH_RESPONSE_reply_not_found (connection,
                                         
TALER_EC_TRACK_TRANSACTION_INSTANCE_UNKNOWN,
                                         "unknown instance");
-  if (1 !=
-      sscanf (str,
-              "%llu",
-              &transaction_id))
-    return TMH_RESPONSE_reply_arg_invalid (connection,
-                                          TALER_EC_PARAMETER_MALFORMED,
-                                           "id");
+
+  if (GNUNET_YES != db->find_proposal_data (db->cls,
+                                            &proposal_data,
+                                            &h_order_id))
+
+    return TMH_RESPONSE_reply_not_found (connection,
+                                        TALER_EC_PROPOSAL_LOOKUP_NOT_FOUND,
+                                        "Given order_id doesn't map to any 
proposal");
+  TALER_JSON_hash (proposal_data,
+                   &h_proposal_data);
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Trying to track h_proposal_data '%s'\n",
+              GNUNET_h2s (&h_proposal_data));
 
   ret = db->find_transaction (db->cls,
-                              transaction_id,
+                              &h_proposal_data,
                              &tctx->mi->pubkey,
                               &transaction_cb,
                               tctx);
@@ -933,10 +946,12 @@ MH_handler_track_transaction (struct TMH_RequestHandler 
*rh,
   {
     return TMH_RESPONSE_reply_not_found (connection,
                                         
TALER_EC_TRACK_TRANSACTION_TRANSACTION_UNKNOWN,
-                                         "id");
+                                         "h_proposal_data is unknown");
   }
   if ( (GNUNET_SYSERR == ret) ||
-       (tctx->transaction_id != (uint64_t) transaction_id) ||
+       (0 != memcmp (&tctx->h_proposal_data,
+                     &h_proposal_data,
+                     sizeof (struct GNUNET_HashCode))) ||
        (NULL == tctx->exchange_uri) )
   {
     GNUNET_break (0);
@@ -945,7 +960,7 @@ MH_handler_track_transaction (struct TMH_RequestHandler *rh,
                                               "Database error");
   }
   ret = db->find_payments (db->cls,
-                           transaction_id,
+                           &h_proposal_data,
                            &tctx->mi->pubkey,
                            &coin_cb,
                            tctx);
@@ -978,5 +993,4 @@ MH_handler_track_transaction (struct TMH_RequestHandler *rh,
   return MHD_YES;
 }
 
-
 /* end of taler-merchant-httpd_track-transaction.c */
diff --git a/src/backend/taler-merchant-httpd_track-transfer.c 
b/src/backend/taler-merchant-httpd_track-transfer.c
index e6c08d6..6f4d49a 100644
--- a/src/backend/taler-merchant-httpd_track-transfer.c
+++ b/src/backend/taler-merchant-httpd_track-transfer.c
@@ -175,7 +175,7 @@ resume_track_transfer_with_response (struct 
TrackTransferContext *rctx,
   rctx->response_code = response_code;
   rctx->response = response;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Resuming /track/transaction handling as exchange interaction is 
done (%u)\n",
+              "Resuming /track/transfer handling as exchange interaction is 
done (%u)\n",
               response_code);
   if (NULL != rctx->timeout_task)
   {
@@ -215,7 +215,7 @@ track_transfer_cleanup (struct TM_HandlerContext *hc)
  */
 static void
 check_transfer (void *cls,
-                uint64_t transaction_id,
+                const struct GNUNET_HashCode *h_proposal_data,
                 const struct TALER_CoinSpendPublicKeyP *coin_pub,
                 const struct TALER_Amount *amount_with_fee,
                 const struct TALER_Amount *deposit_fee,
@@ -237,14 +237,14 @@ check_transfer (void *cls,
     rctx->check_transfer_result = GNUNET_SYSERR;
     /* Build the `TrackTransferConflictDetails` */
     rctx->response
-      = TMH_RESPONSE_make_json_pack ("{s:I, s:s, s:o, s:I, s:o, s:o, s:I, s:o, 
s:o}",
+      = TMH_RESPONSE_make_json_pack ("{s:I, s:s, s:o, s:I, s:o, s:o, s:s, s:o, 
s:o}",
                                      "code", (json_int_t) 
TALER_EC_TRACK_TRANSFER_CONFLICTING_REPORTS,
                                      "hint", "disagreement about deposit 
valuation",
                                      "exchange_deposit_proof", exchange_proof,
                                      "conflict_offset", (json_int_t) 
rctx->current_offset,
                                      "exchange_transfer_proof", 
rctx->original_response,
                                      "coin_pub", GNUNET_JSON_from_data_auto 
(coin_pub),
-                                     "transaction_id", (json_int_t) 
transaction_id,
+                                     "h_proposal_data", 
GNUNET_JSON_from_data_auto (&ttd->h_proposal_data),
                                      "amount_with_fee", TALER_JSON_from_amount 
(amount_with_fee),
                                      "deposit_fee", TALER_JSON_from_amount 
(deposit_fee));
     return;
@@ -327,12 +327,12 @@ wire_transfer_cb (void *cls,
     rctx->current_offset = i;
     rctx->current_detail = &details[i];
     rctx->check_transfer_result = GNUNET_NO;
-    ret = db->find_payments_by_id_and_coin (db->cls,
-                                            details[i].transaction_id,
-                                            &rctx->mi->pubkey,
-                                            &details[i].coin_pub,
-                                            &check_transfer,
-                                            rctx);
+    ret = db->find_payments_by_hash_and_coin (db->cls,
+                                              &details[i].h_proposal_data,
+                                              &rctx->mi->pubkey,
+                                              &details[i].coin_pub,
+                                              &check_transfer,
+                                              rctx);
     if (GNUNET_SYSERR == ret)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -384,7 +384,7 @@ wire_transfer_cb (void *cls,
     /* Response is consistent with the /deposit we made, remember
        it for future reference */
     ret = db->store_coin_to_transfer (db->cls,
-                                      details[i].transaction_id,
+                                      &details[i].h_proposal_data,
                                       &details[i].coin_pub,
                                       &rctx->wtid);
     if (GNUNET_OK != ret)
diff --git a/src/backenddb/plugin_merchantdb_postgres.c 
b/src/backenddb/plugin_merchantdb_postgres.c
index 193c0a6..6a8bb46 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -145,7 +145,7 @@ postgres_drop_tables (void *cls)
   PG_EXEC_INDEX (pg, "DROP TABLE merchant_deposits;");
   PG_EXEC_INDEX (pg, "DROP TABLE merchant_transactions;");
   PG_EXEC_INDEX (pg, "DROP TABLE merchant_proofs;");
-  PG_EXEC_INDEX (pg, "DROP TABLE merchant_contract_maps;");
+  PG_EXEC_INDEX (pg, "DROP TABLE merchant_proposal_data;");
   return GNUNET_OK;
 }
 
@@ -163,31 +163,30 @@ postgres_initialize (void *cls)
 
   /* Setup tables */
   PG_EXEC (pg,
-           "CREATE TABLE IF NOT EXISTS merchant_contract_maps ("
-           "h_contract BYTEA NOT NULL CHECK (LENGTH(h_contract)=64)"
-           ",plain_contract BYTEA NOT NULL"
-          ",PRIMARY KEY (h_contract)"
+           "CREATE TABLE IF NOT EXISTS merchant_proposal_data ("
+           "h_order_id BYTEA NOT NULL"
+           ",proposal_data BYTEA NOT NULL"
+          ",PRIMARY KEY (h_order_id)"
            ");");
 
   PG_EXEC (pg,
            "CREATE TABLE IF NOT EXISTS merchant_transactions ("
-           " transaction_id INT8"
+           " h_proposal_data BYTEA NOT NULL"
            ",exchange_uri VARCHAR NOT NULL"
           ",merchant_pub BYTEA NOT NULL CHECK (LENGTH(merchant_pub)=32)"
-           ",h_contract BYTEA NOT NULL CHECK (LENGTH(h_contract)=64)"
            ",h_wire BYTEA NOT NULL CHECK (LENGTH(h_wire)=64)"
            ",timestamp INT8 NOT NULL"
            ",refund_deadline INT8 NOT NULL"
            ",total_amount_val INT8 NOT NULL"
            ",total_amount_frac INT4 NOT NULL"
            ",total_amount_curr VARCHAR(" TALER_CURRENCY_LEN_STR ") NOT NULL"
-          ",PRIMARY KEY (transaction_id, merchant_pub)"
+          ",PRIMARY KEY (h_proposal_data, merchant_pub)"
            ");");
   PG_EXEC (pg,
            "CREATE TABLE IF NOT EXISTS merchant_deposits ("
-          " transaction_id INT8"
+          " h_proposal_data BYTEA NOT NULL"
           ",merchant_pub BYTEA NOT NULL CHECK (LENGTH(merchant_pub)=32)"
-          ",FOREIGN KEY (transaction_id, merchant_pub) REFERENCES 
merchant_transactions (transaction_id, merchant_pub)"
+          ",FOREIGN KEY (h_proposal_data, merchant_pub) REFERENCES 
merchant_transactions (h_proposal_data, merchant_pub)"
            ",coin_pub BYTEA NOT NULL CHECK (LENGTH(coin_pub)=32)"
            ",amount_with_fee_val INT8 NOT NULL"
            ",amount_with_fee_frac INT4 NOT NULL"
@@ -197,7 +196,7 @@ postgres_initialize (void *cls)
            ",deposit_fee_curr VARCHAR(" TALER_CURRENCY_LEN_STR ") NOT NULL"
            ",signkey_pub BYTEA NOT NULL CHECK (LENGTH(signkey_pub)=32)"
            ",exchange_proof BYTEA NOT NULL"
-           ",PRIMARY KEY (transaction_id, coin_pub)"
+           ",PRIMARY KEY (h_proposal_data, coin_pub)"
            ");");
   PG_EXEC (pg,
            "CREATE TABLE IF NOT EXISTS merchant_proofs ("
@@ -213,10 +212,10 @@ postgres_initialize (void *cls)
      Hence those cannot be foreign keys into deposits/transactions! */
   PG_EXEC (pg,
            "CREATE TABLE IF NOT EXISTS merchant_transfers ("
-           " transaction_id INT8"
+           " h_proposal_data BYTEA NOT NULL"
            ",coin_pub BYTEA NOT NULL CHECK (LENGTH(coin_pub)=32)"
            ",wtid BYTEA NOT NULL CHECK (LENGTH(wtid)=32)"
-           ",PRIMARY KEY (transaction_id, coin_pub)"
+           ",PRIMARY KEY (h_proposal_data, coin_pub)"
            ");");
   PG_EXEC_INDEX (pg,
                  "CREATE INDEX IF NOT EXISTS merchant_transfers_by_coin"
@@ -229,10 +228,9 @@ postgres_initialize (void *cls)
   PG_PREPARE (pg,
               "insert_transaction",
               "INSERT INTO merchant_transactions"
-              "(transaction_id"
+              "(h_proposal_data"
               ",exchange_uri"
              ",merchant_pub"
-              ",h_contract"
               ",h_wire"
               ",timestamp"
               ",refund_deadline"
@@ -240,12 +238,12 @@ postgres_initialize (void *cls)
               ",total_amount_frac"
               ",total_amount_curr"
               ") VALUES "
-              "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
-              10);
+              "($1, $2, $3, $4, $5, $6, $7, $8, $9)",
+              9);
   PG_PREPARE (pg,
               "insert_deposit",
               "INSERT INTO merchant_deposits"
-              "(transaction_id"
+              "(h_proposal_data"
              ",merchant_pub"
               ",coin_pub"
               ",amount_with_fee_val"
@@ -261,7 +259,7 @@ postgres_initialize (void *cls)
   PG_PREPARE (pg,
               "insert_transfer",
               "INSERT INTO merchant_transfers"
-              "(transaction_id"
+              "(h_proposal_data"
               ",coin_pub"
               ",wtid) VALUES "
               "($1, $2, $3)",
@@ -278,28 +276,27 @@ postgres_initialize (void *cls)
               5);
 
   PG_PREPARE (pg,
-              "insert_map",
-              "INSERT INTO merchant_contract_maps"
-              "(h_contract"
-              ",plain_contract)"
+              "insert_proposal_data",
+              "INSERT INTO merchant_proposal_data"
+              "(h_order_id"
+              ",proposal_data)"
               " VALUES "
               "($1, $2)",
               2);
 
   PG_PREPARE (pg,
-              "find_contract",
-              "SELECT plain_contract FROM merchant_contract_maps"
+              "find_proposal_data",
+              "SELECT proposal_data FROM merchant_proposal_data"
               " WHERE"
-              " h_contract=$1",
+              " h_order_id=$1",
               1);
 
   PG_PREPARE (pg,
               "find_transactions_by_date",
               "SELECT"
-              " transaction_id"
+              " h_proposal_data"
              ",merchant_pub"
               ",exchange_uri"
-              ",h_contract"
               ",h_wire"
               ",timestamp"
               ",refund_deadline"
@@ -315,7 +312,6 @@ postgres_initialize (void *cls)
               "find_transaction",
               "SELECT"
               " exchange_uri"
-              ",h_contract"
               ",h_wire"
               ",timestamp"
               ",refund_deadline"
@@ -323,7 +319,7 @@ postgres_initialize (void *cls)
               ",total_amount_frac"
               ",total_amount_curr"
               " FROM merchant_transactions"
-              " WHERE transaction_id=$1"
+              " WHERE h_proposal_data=$1"
              " AND merchant_pub=$2",
               2);
   PG_PREPARE (pg,
@@ -338,7 +334,7 @@ postgres_initialize (void *cls)
               ",deposit_fee_curr"
               ",exchange_proof"
               " FROM merchant_deposits"
-              " WHERE transaction_id=$1"
+              " WHERE h_proposal_data=$1"
               " AND merchant_pub=$2",
               2);
   PG_PREPARE (pg,
@@ -352,12 +348,12 @@ postgres_initialize (void *cls)
               ",deposit_fee_curr"
               ",exchange_proof"
               " FROM merchant_deposits"
-              " WHERE transaction_id=$1"
+              " WHERE h_proposal_data=$1"
               " AND merchant_pub=$2"
               " AND coin_pub=$3",
               3);
   PG_PREPARE (pg,
-              "find_transfers_by_transaction_id",
+              "find_transfers_by_hash",
               "SELECT"
               " coin_pub"
               ",wtid"
@@ -365,12 +361,12 @@ postgres_initialize (void *cls)
               ",merchant_proofs.proof"
               " FROM merchant_transfers"
               "   JOIN merchant_proofs USING (wtid)"
-              " WHERE transaction_id=$1",
+              " WHERE h_proposal_data=$1",
               1);
   PG_PREPARE (pg,
               "find_deposits_by_wtid",
               "SELECT"
-              " merchant_transfers.transaction_id"
+              " merchant_transfers.h_proposal_data"
               ",merchant_transfers.coin_pub"
               ",merchant_deposits.amount_with_fee_val"
               ",merchant_deposits.amount_with_fee_frac"
@@ -381,7 +377,7 @@ postgres_initialize (void *cls)
               ",merchant_deposits.exchange_proof"
               " FROM merchant_transfers"
               "   JOIN merchant_deposits"
-              "     ON (merchant_deposits.transaction_id = 
merchant_transfers.transaction_id"
+              "     ON (merchant_deposits.h_proposal_data = 
merchant_transfers.h_proposal_data"
               "       AND"
               "         merchant_deposits.coin_pub = 
merchant_transfers.coin_pub)"
               " WHERE wtid=$1",
@@ -398,46 +394,46 @@ postgres_initialize (void *cls)
 }
 
 /**
- * Retrieve plain contract given its hashcode
+ * Retrieve proposal data given its transaction id's hashcode
  *
  * @param cls closure
- * @param h_contract hashcode of the contract to retrieve
- * @param contract where to store the retrieved contract
+ * @param h_transaction_id hashcode of the transaction id mentioned in this
+ * proposal data
+ * @param proposal_data where to store the retrieved proposal data
  * @return #GNUNET_OK on success, #GNUNET_NO if no contract is
  * found, #GNUNET_SYSERR upon error
  */
 static int
-postgres_find_contract (void *cls,
-                        json_t **contract,
-                        struct GNUNET_HashCode *h_contract)
+postgres_find_proposal_data (void *cls,
+                             json_t **proposal_data,
+                             struct GNUNET_HashCode *h_transaction_id)
 {
   struct PostgresClosure *pg = cls;
   PGresult *result;
   unsigned int i;
 
   struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_auto_from_type (h_contract),
+    GNUNET_PQ_query_param_auto_from_type (h_transaction_id),
     GNUNET_PQ_query_param_end
   };
 
   result = GNUNET_PQ_exec_prepared (pg->conn,
-                                    "find_contract",
+                                    "find_proposal_data",
                                     params);
   i = PQntuples (result);
   if (1 < i)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Mupltiple contracts share the same hashcode.\n");
+                "Mupltiple proposal data share the same hashcode.\n");
     return GNUNET_SYSERR;
   }
 
   if (0 == i)
     return GNUNET_NO;
 
-  /* FIXME, figure out how to pass back json_t's */
   struct GNUNET_PQ_ResultSpec rs[] = {
-    TALER_PQ_result_spec_json ("plain_contract",
-                               contract),
+    TALER_PQ_result_spec_json ("proposal_data",
+                               proposal_data),
     GNUNET_PQ_result_spec_end
   };
   if (GNUNET_OK !=
@@ -455,30 +451,31 @@ postgres_find_contract (void *cls,
 
 
 /**
- * Insert a hash to contract map into the database
+ * Insert proposal data and its transaction id's hashcode into db
  *
  * @param cls closure
- * @param h_contract hashcode of @a contract
- * @param contract contract to store
+ * @param h_transaction_id hashcode of the transaction id mentioned in this
+ * proposal data
+ * @param proposal_data proposal data to store
  * @return #GNUNET_OK on success, #GNUNET_SYSERR upon error
  */
 static int
-postgres_store_map (void *cls,
-                    struct GNUNET_HashCode *h_contract,
-                    const json_t *contract)
+postgres_insert_proposal_data (void *cls,
+                               struct GNUNET_HashCode *h_transaction_id,
+                               const json_t *proposal_data)
 {
   struct PostgresClosure *pg = cls;
   PGresult *result;
   int ret;
 
   struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_auto_from_type (h_contract),
-    TALER_PQ_query_param_json (contract),
+    GNUNET_PQ_query_param_auto_from_type (h_transaction_id),
+    TALER_PQ_query_param_json (proposal_data),
     GNUNET_PQ_query_param_end
   };
 
   result = GNUNET_PQ_exec_prepared (pg->conn,
-                                    "insert_map",
+                                    "insert_proposal_data",
                                     params);
 
   /**
@@ -507,10 +504,9 @@ postgres_store_map (void *cls,
  * Insert transaction data into the database.
  *
  * @param cls closure
- * @param transaction_id of the contract
+ * @param transaction_id of the proposal
  * @param merchant_pub merchant's public key
  * @param exchange_uri URI of the exchange
- * @param h_contract hash of the contract
  * @param h_wire hash of our wire details
  * @param timestamp time of the confirmation
  * @param refund refund deadline
@@ -519,10 +515,9 @@ postgres_store_map (void *cls,
  */
 static int
 postgres_store_transaction (void *cls,
-                            uint64_t transaction_id,
+                            const struct GNUNET_HashCode *h_proposal_data,
                            const struct TALER_MerchantPublicKeyP *merchant_pub,
                             const char *exchange_uri,
-                            const struct GNUNET_HashCode *h_contract,
                             const struct GNUNET_HashCode *h_wire,
                             struct GNUNET_TIME_Absolute timestamp,
                             struct GNUNET_TIME_Absolute refund,
@@ -533,10 +528,9 @@ postgres_store_transaction (void *cls,
   int ret;
 
   struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_uint64 (&transaction_id),
+    GNUNET_PQ_query_param_auto_from_type (h_proposal_data),
     GNUNET_PQ_query_param_string (exchange_uri),
     GNUNET_PQ_query_param_auto_from_type (merchant_pub),
-    GNUNET_PQ_query_param_auto_from_type (h_contract),
     GNUNET_PQ_query_param_auto_from_type (h_wire),
     GNUNET_PQ_query_param_absolute_time (&timestamp),
     GNUNET_PQ_query_param_absolute_time (&refund),
@@ -544,6 +538,10 @@ postgres_store_transaction (void *cls,
     GNUNET_PQ_query_param_end
   };
 
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Storing transaction with h_proposal_data '%s'\n",
+              GNUNET_h2s (h_proposal_data));
+
   result = GNUNET_PQ_exec_prepared (pg->conn,
                                     "insert_transaction",
                                     params);
@@ -576,7 +574,7 @@ postgres_store_transaction (void *cls,
  */
 static int
 postgres_store_deposit (void *cls,
-                        uint64_t transaction_id,
+                        const struct GNUNET_HashCode *h_proposal_data,
                         const struct TALER_MerchantPublicKeyP *merchant_pub,
                         const struct TALER_CoinSpendPublicKeyP *coin_pub,
                         const struct TALER_Amount *amount_with_fee,
@@ -589,7 +587,7 @@ postgres_store_deposit (void *cls,
   int ret;
 
   struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_uint64 (&transaction_id),
+    GNUNET_PQ_query_param_auto_from_type (h_proposal_data),
     GNUNET_PQ_query_param_auto_from_type (merchant_pub),
     GNUNET_PQ_query_param_auto_from_type (coin_pub),
     TALER_PQ_query_param_amount (amount_with_fee),
@@ -599,6 +597,9 @@ postgres_store_deposit (void *cls,
     GNUNET_PQ_query_param_end
   };
 
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "storing payment for h_proposal_data '%s'\n",
+              GNUNET_h2s (h_proposal_data));
   result = GNUNET_PQ_exec_prepared (pg->conn,
                                     "insert_deposit",
                                     params);
@@ -629,7 +630,7 @@ postgres_store_deposit (void *cls,
  */
 static int
 postgres_store_coin_to_transfer (void *cls,
-                                 uint64_t transaction_id,
+                                 const struct GNUNET_HashCode *h_proposal_data,
                                  const struct TALER_CoinSpendPublicKeyP 
*coin_pub,
                                  const struct TALER_WireTransferIdentifierRawP 
*wtid)
 {
@@ -638,7 +639,7 @@ postgres_store_coin_to_transfer (void *cls,
   int ret;
 
   struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_uint64 (&transaction_id),
+    GNUNET_PQ_query_param_auto_from_type (h_proposal_data),
     GNUNET_PQ_query_param_auto_from_type (coin_pub),
     GNUNET_PQ_query_param_auto_from_type (wtid),
     GNUNET_PQ_query_param_end
@@ -752,21 +753,19 @@ postgres_find_transactions_by_date (void *cls,
   {
     struct TALER_MerchantPublicKeyP merchant_pub;
     char *exchange_uri;
-    struct GNUNET_HashCode h_contract;
     struct GNUNET_HashCode h_wire;
     struct GNUNET_TIME_Absolute timestamp;
     struct GNUNET_TIME_Absolute refund_deadline;
     struct TALER_Amount total_amount;
-    uint64_t transaction_id;
+    struct GNUNET_HashCode h_proposal_data;
+
     struct GNUNET_PQ_ResultSpec rs[] = {
       GNUNET_PQ_result_spec_string ("exchange_uri",
                                     &exchange_uri),
-      GNUNET_PQ_result_spec_uint64 ("transaction_id",
-                                    &transaction_id),
+      GNUNET_PQ_result_spec_auto_from_type ("h_proposal_data",
+                                    &h_proposal_data),
       GNUNET_PQ_result_spec_auto_from_type ("merchant_pub",
                                             &merchant_pub),
-      GNUNET_PQ_result_spec_auto_from_type ("h_contract",
-                                            &h_contract),
       GNUNET_PQ_result_spec_auto_from_type ("h_wire",
                                             &h_wire),
       GNUNET_PQ_result_spec_absolute_time ("timestamp",
@@ -788,10 +787,9 @@ postgres_find_transactions_by_date (void *cls,
       return GNUNET_SYSERR;
     }
     cb (cb_cls,
-        transaction_id,
        &merchant_pub,
         exchange_uri,
-        &h_contract,
+        &h_proposal_data,
         &h_wire,
         timestamp,
         refund_deadline,
@@ -816,7 +814,7 @@ postgres_find_transactions_by_date (void *cls,
  */
 static int
 postgres_find_transaction (void *cls,
-                           uint64_t transaction_id,
+                           const struct GNUNET_HashCode *h_proposal_data,
                           const struct TALER_MerchantPublicKeyP *merchant_pub,
                            TALER_MERCHANTDB_TransactionCallback cb,
                            void *cb_cls)
@@ -824,11 +822,15 @@ postgres_find_transaction (void *cls,
   struct PostgresClosure *pg = cls;
   PGresult *result;
   struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_uint64 (&transaction_id),
+    GNUNET_PQ_query_param_auto_from_type (h_proposal_data),
     GNUNET_PQ_query_param_auto_from_type (merchant_pub),
     GNUNET_PQ_query_param_end
   };
 
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Finding transaction for h_proposal_data '%s'\n",
+              GNUNET_h2s (h_proposal_data));
+
   result = GNUNET_PQ_exec_prepared (pg->conn,
                                     "find_transaction",
                                     params);
@@ -840,6 +842,10 @@ postgres_find_transaction (void *cls,
   }
   if (0 == PQntuples (result))
   {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Could NOT find transaction for h_proposal_data '%s'\n",
+                GNUNET_h2s (h_proposal_data));
+
     PQclear (result);
     return GNUNET_NO;
   }
@@ -852,7 +858,6 @@ postgres_find_transaction (void *cls,
 
   {
     char *exchange_uri;
-    struct GNUNET_HashCode h_contract;
     struct GNUNET_HashCode h_wire;
     struct GNUNET_TIME_Absolute timestamp;
     struct GNUNET_TIME_Absolute refund_deadline;
@@ -860,8 +865,6 @@ postgres_find_transaction (void *cls,
     struct GNUNET_PQ_ResultSpec rs[] = {
       GNUNET_PQ_result_spec_string ("exchange_uri",
                                     &exchange_uri),
-      GNUNET_PQ_result_spec_auto_from_type ("h_contract",
-                                            &h_contract),
       GNUNET_PQ_result_spec_auto_from_type ("h_wire",
                                             &h_wire),
       GNUNET_PQ_result_spec_absolute_time ("timestamp",
@@ -883,10 +886,9 @@ postgres_find_transaction (void *cls,
       return GNUNET_SYSERR;
     }
     cb (cb_cls,
-        transaction_id,
        merchant_pub,
         exchange_uri,
-        &h_contract,
+        h_proposal_data,
         &h_wire,
         timestamp,
         refund_deadline,
@@ -911,7 +913,7 @@ postgres_find_transaction (void *cls,
  */
 static int
 postgres_find_payments (void *cls,
-                        uint64_t transaction_id,
+                        const struct GNUNET_HashCode *h_proposal_data,
                        const struct TALER_MerchantPublicKeyP *merchant_pub,
                         TALER_MERCHANTDB_CoinDepositCallback cb,
                         void *cb_cls)
@@ -921,10 +923,13 @@ postgres_find_payments (void *cls,
   unsigned int i;
 
   struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_uint64 (&transaction_id),
+    GNUNET_PQ_query_param_auto_from_type (h_proposal_data),
     GNUNET_PQ_query_param_auto_from_type (merchant_pub),
     GNUNET_PQ_query_param_end
   };
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "finding payment for h_proposal_data '%s'\n",
+              GNUNET_h2s (h_proposal_data));
   result = GNUNET_PQ_exec_prepared (pg->conn,
                                     "find_deposits",
                                     params);
@@ -969,7 +974,7 @@ postgres_find_payments (void *cls,
       return GNUNET_SYSERR;
     }
     cb (cb_cls,
-        transaction_id,
+        h_proposal_data,
         &coin_pub,
         &amount_with_fee,
         &deposit_fee,
@@ -998,19 +1003,19 @@ postgres_find_payments (void *cls,
  *         #GNUNET_SYSERR on hard errors
  */
 static int
-postgres_find_payments_by_id_and_coin (void *cls,
-                                       uint64_t transaction_id,
-                                       const struct TALER_MerchantPublicKeyP 
*merchant_pub,
-                                       const struct TALER_CoinSpendPublicKeyP 
*coin_pub,
-                                       TALER_MERCHANTDB_CoinDepositCallback cb,
-                                       void *cb_cls)
+postgres_find_payments_by_hash_and_coin (void *cls,
+                                         const struct GNUNET_HashCode 
*h_proposal_data,
+                                         const struct TALER_MerchantPublicKeyP 
*merchant_pub,
+                                         const struct 
TALER_CoinSpendPublicKeyP *coin_pub,
+                                         TALER_MERCHANTDB_CoinDepositCallback 
cb,
+                                         void *cb_cls)
 {
   struct PostgresClosure *pg = cls;
   PGresult *result;
   unsigned int i;
 
   struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_uint64 (&transaction_id),
+    GNUNET_PQ_query_param_auto_from_type (h_proposal_data),
     GNUNET_PQ_query_param_auto_from_type (merchant_pub),
     GNUNET_PQ_query_param_auto_from_type (coin_pub),
     GNUNET_PQ_query_param_end
@@ -1057,7 +1062,7 @@ postgres_find_payments_by_id_and_coin (void *cls,
       return GNUNET_SYSERR;
     }
     cb (cb_cls,
-        transaction_id,
+        h_proposal_data,
         coin_pub,
         &amount_with_fee,
         &deposit_fee,
@@ -1087,21 +1092,21 @@ postgres_find_payments_by_id_and_coin (void *cls,
  *         #GNUNET_SYSERR on hard errors
  */
 static int
-postgres_find_transfers_by_id (void *cls,
-                               uint64_t transaction_id,
-                               TALER_MERCHANTDB_TransferCallback cb,
-                               void *cb_cls)
+postgres_find_transfers_by_hash (void *cls,
+                                 const struct GNUNET_HashCode *h_proposal_data,
+                                 TALER_MERCHANTDB_TransferCallback cb,
+                                 void *cb_cls)
 {
   struct PostgresClosure *pg = cls;
   PGresult *result;
   unsigned int i;
 
   struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_uint64 (&transaction_id),
+    GNUNET_PQ_query_param_auto_from_type (h_proposal_data),
     GNUNET_PQ_query_param_end
   };
   result = GNUNET_PQ_exec_prepared (pg->conn,
-                                    "find_transfers_by_transaction_id",
+                                    "find_transfers_by_hash",
                                     params);
   if (PGRES_TUPLES_OK != PQresultStatus (result))
   {
@@ -1144,7 +1149,7 @@ postgres_find_transfers_by_id (void *cls,
       return GNUNET_SYSERR;
     }
     cb (cb_cls,
-        transaction_id,
+        h_proposal_data,
         &coin_pub,
         &wtid,
         execution_time,
@@ -1197,15 +1202,15 @@ postgres_find_deposits_by_wtid (void *cls,
 
   for (i=0;i<PQntuples (result);i++)
   {
-    uint64_t transaction_id;
+    struct GNUNET_HashCode h_proposal_data;
     struct TALER_CoinSpendPublicKeyP coin_pub;
     struct TALER_Amount amount_with_fee;
     struct TALER_Amount deposit_fee;
     json_t *exchange_proof;
 
     struct GNUNET_PQ_ResultSpec rs[] = {
-      GNUNET_PQ_result_spec_uint64 ("transaction_id",
-                                    &transaction_id),
+      GNUNET_PQ_result_spec_auto_from_type ("h_proposal_data",
+                                            &h_proposal_data),
       GNUNET_PQ_result_spec_auto_from_type ("coin_pub",
                                             &coin_pub),
       TALER_PQ_result_spec_amount ("amount_with_fee",
@@ -1227,7 +1232,7 @@ postgres_find_deposits_by_wtid (void *cls,
       return GNUNET_SYSERR;
     }
     cb (cb_cls,
-        transaction_id,
+        &h_proposal_data,
         &coin_pub,
         &amount_with_fee,
         &deposit_fee,
@@ -1361,13 +1366,13 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
   plugin->store_transfer_to_proof = &postgres_store_transfer_to_proof;
   plugin->find_transaction = &postgres_find_transaction;
   plugin->find_transactions_by_date = &postgres_find_transactions_by_date;
-  plugin->find_payments_by_id_and_coin = 
&postgres_find_payments_by_id_and_coin;
+  plugin->find_payments_by_hash_and_coin = 
&postgres_find_payments_by_hash_and_coin;
   plugin->find_payments = &postgres_find_payments;
-  plugin->find_transfers_by_id = &postgres_find_transfers_by_id;
+  plugin->find_transfers_by_hash = &postgres_find_transfers_by_hash;
   plugin->find_deposits_by_wtid = &postgres_find_deposits_by_wtid;
   plugin->find_proof_by_wtid = &postgres_find_proof_by_wtid;
-  plugin->store_map = &postgres_store_map;
-  plugin->find_contract = &postgres_find_contract;
+  plugin->insert_proposal_data = &postgres_insert_proposal_data;
+  plugin->find_proposal_data = &postgres_find_proposal_data;
 
   return plugin;
 }
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index d30b7f5..b74549d 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -60,9 +60,9 @@ static int result;
 static struct TALER_MERCHANTDB_Plugin *plugin;
 
 /**
- * Hash of the contract.  Set to some random value.
+ * Hash of the (fictitious) transaction id.  Set to some random value.
  */
-static struct GNUNET_HashCode h_contract;
+static struct GNUNET_HashCode h_transaction_id;
 
 /**
  * Hash of the wire transfer address.  Set to some random value.
@@ -72,7 +72,12 @@ static struct GNUNET_HashCode h_wire;
 /**
  * Transaction ID.
  */
-static uint64_t transaction_id;
+char *transaction_id;
+
+/**
+ * Proposal's hash
+ */
+struct GNUNET_HashCode h_proposal_data;
 
 /**
  * Time of the transaction.
@@ -135,6 +140,12 @@ static json_t *transfer_proof;
  */
 static json_t *contract;
 
+/**
+ * Mock proposal data, not need to be well-formed
+ */
+static json_t *proposal_data;
+
+
 
 /**
  * Function called with information about a transaction.
@@ -143,7 +154,6 @@ static json_t *contract;
  * @param transaction_id of the contract
  * @param merchant_pub public key of the merchant
  * @param exchange_uri URI of the exchange
- * @param h_contract hash of the contract
  * @param h_wire hash of our wire details
  * @param timestamp time of the confirmation
  * @param refund_deadline refund deadline
@@ -151,25 +161,23 @@ static json_t *contract;
  */
 static void
 transaction_cb (void *cls,
-                uint64_t atransaction_id,
                const struct TALER_MerchantPublicKeyP *amerchant_pub,
                 const char *aexchange_uri,
-                const struct GNUNET_HashCode *ah_contract,
+                const struct GNUNET_HashCode *ah_proposal_data,
                 const struct GNUNET_HashCode *ah_wire,
                 struct GNUNET_TIME_Absolute atimestamp,
                 struct GNUNET_TIME_Absolute arefund_deadline,
                 const struct TALER_Amount *atotal_amount)
 {
 #define CHECK(a) do { if (! (a)) { GNUNET_break (0); result = 3; } } while (0)
-  CHECK (atransaction_id == transaction_id);
   CHECK (0 == memcmp (amerchant_pub,
                       &merchant_pub,
                      sizeof (struct TALER_MerchantPublicKeyP)));
+  CHECK (0 == memcmp (ah_proposal_data,
+                      &h_proposal_data,
+                      sizeof (struct GNUNET_HashCode)));
   CHECK (0 == strcmp (aexchange_uri,
                       EXCHANGE_URI));
-  CHECK (0 == memcmp (ah_contract,
-                      &h_contract,
-                      sizeof (struct GNUNET_HashCode)));
   CHECK (0 == memcmp (ah_wire,
                       &h_wire,
                       sizeof (struct GNUNET_HashCode)));
@@ -188,7 +196,6 @@ transaction_cb (void *cls,
  * @param transaction_id of the contract
  * @param merchant_pub merchant's public key
  * @param exchange_uri URI of the exchange
- * @param h_contract hash of the contract
  * @param h_wire hash of our wire details
  * @param timestamp time of the confirmation
  * @param refund refund deadline
@@ -197,10 +204,9 @@ transaction_cb (void *cls,
 
 static void
 history_cb (void *cls,
-            uint64_t transaction_id,
            const struct TALER_MerchantPublicKeyP *merchant_pub,
             const char *exchange_uri,
-            const struct GNUNET_HashCode *h_contract,
+            const struct GNUNET_HashCode *h_proposal_data,
             const struct GNUNET_HashCode *h_wire,
             struct GNUNET_TIME_Absolute timestamp,
             struct GNUNET_TIME_Absolute refund,
@@ -222,13 +228,15 @@ history_cb (void *cls,
  */
 static void
 deposit_cb (void *cls,
-            uint64_t atransaction_id,
+            const struct GNUNET_HashCode *ah_proposal_data,
             const struct TALER_CoinSpendPublicKeyP *acoin_pub,
             const struct TALER_Amount *aamount_with_fee,
             const struct TALER_Amount *adeposit_fee,
             const json_t *aexchange_proof)
 {
-  CHECK (atransaction_id == transaction_id);
+  CHECK ((0 == memcmp (ah_proposal_data,
+                       &h_proposal_data,
+                       sizeof (struct GNUNET_HashCode))));
   CHECK (0 == memcmp (acoin_pub,
                       &coin_pub,
                       sizeof (struct TALER_CoinSpendPublicKeyP)));
@@ -260,13 +268,16 @@ deposit_cb (void *cls,
  */
 static void
 transfer_cb (void *cls,
-             uint64_t atransaction_id,
+             const struct GNUNET_HashCode *ah_proposal_data,
              const struct TALER_CoinSpendPublicKeyP *acoin_pub,
              const struct TALER_WireTransferIdentifierRawP *awtid,
              struct GNUNET_TIME_Absolute execution_time,
              const json_t *exchange_proof)
 {
-  CHECK (atransaction_id == transaction_id);
+  CHECK (0 == memcmp (ah_proposal_data,
+                      &h_proposal_data,
+                      sizeof (struct GNUNET_HashCode)));
+
   CHECK (0 == memcmp (acoin_pub,
                       &coin_pub,
                       sizeof (struct TALER_CoinSpendPublicKeyP)));
@@ -323,9 +334,12 @@ run (void *cls)
   }
 
   /* Prepare data for 'store_payment()' */
-  RND_BLK (&h_contract);
   RND_BLK (&h_wire);
-  RND_BLK (&transaction_id);
+  RND_BLK (&h_proposal_data);
+  transaction_id = "test_ID";
+  GNUNET_CRYPTO_hash (transaction_id,
+                      strlen (transaction_id),
+                      &h_transaction_id);
   RND_BLK (&signkey_pub);
   RND_BLK (&merchant_pub);
   RND_BLK (&wtid);
@@ -353,32 +367,32 @@ run (void *cls)
                                       "test",
                                       json_string ("backenddb test B")));
   contract = json_object ();
+  proposal_data = json_object ();
 
   FAILIF (GNUNET_OK !=
-          plugin->store_map (plugin->cls,
-                             &h_contract,
-                             contract));
+          plugin->insert_proposal_data (plugin->cls,
+                                        &h_transaction_id,
+                                        proposal_data));
 
   json_t *out;
 
   FAILIF (GNUNET_OK !=
-          plugin->find_contract (plugin->cls,
-                                 &out,
-                                 &h_contract));
+          plugin->find_proposal_data (plugin->cls,
+                                      &out, // plain data
+                                      &h_transaction_id));
 
   FAILIF (GNUNET_OK !=
           plugin->store_transaction (plugin->cls,
-                                     transaction_id,
+                                     &h_proposal_data,
                                     &merchant_pub,
                                      EXCHANGE_URI,
-                                     &h_contract,
                                      &h_wire,
                                      timestamp,
                                      refund_deadline,
                                      &amount_with_fee));
   FAILIF (GNUNET_OK !=
           plugin->store_deposit (plugin->cls,
-                                 transaction_id,
+                                 &h_proposal_data,
                                 &merchant_pub,
                                  &coin_pub,
                                  &amount_with_fee,
@@ -387,7 +401,7 @@ run (void *cls)
                                  deposit_proof));
   FAILIF (GNUNET_OK !=
           plugin->store_coin_to_transfer (plugin->cls,
-                                          transaction_id,
+                                          &h_proposal_data,
                                           &coin_pub,
                                           &wtid));
   FAILIF (GNUNET_OK !=
@@ -399,7 +413,7 @@ run (void *cls)
                                            transfer_proof));
   FAILIF (GNUNET_OK !=
           plugin->find_transaction (plugin->cls,
-                                    transaction_id,
+                                    &h_proposal_data,
                                    &merchant_pub,
                                     &transaction_cb,
                                     NULL));
@@ -413,13 +427,13 @@ run (void *cls)
 
   FAILIF (GNUNET_OK !=
           plugin->find_payments (plugin->cls,
-                                 transaction_id,
+                                 &h_proposal_data,
                                  &merchant_pub,
                                  &deposit_cb,
                                  NULL));
   FAILIF (GNUNET_OK !=
-          plugin->find_transfers_by_id (plugin->cls,
-                                        transaction_id,
+          plugin->find_transfers_by_hash (plugin->cls,
+                                        &h_proposal_data,
                                         &transfer_cb,
                                         NULL));
   FAILIF (GNUNET_OK !=
@@ -462,7 +476,7 @@ main (int argc,
     GNUNET_break (0);
     return -1;
   }
-  GNUNET_log_setup (argv[0], "INFO", NULL);
+  GNUNET_log_setup (argv[0], "DEBUG", NULL);
   plugin_name++;
   (void) GNUNET_asprintf (&testname,
                           "test-merchantdb-%s",
diff --git a/src/include/taler_merchant_service.h 
b/src/include/taler_merchant_service.h
index 0ed6856..61919d0 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -30,66 +30,18 @@
 
 /* ********************* /map/{in,out} *********************** */
 
-struct TALER_MERCHANT_MapOutOperation;
+/* *********************  /proposal *********************** */
 
-typedef void
-(*TALER_MERCHANT_MapOperationCallback) (void *cls,
-                                        unsigned int http_status,
-                                        const json_t *body);
 
 /**
- * Issue a /map/out request to the backend.
- *
- * @param ctx execution context
- * @param backend_uri base URL of the merchant backend
- * @param h_contract hashcode of `contract`
- * @param map_in_cb callback which will work the response gotten from the 
backend
- * @param map_in_cb_cls closure to pass to @a history_cb
- * @return handle for this operation, NULL upon errors
+ * Handle to a PUT /proposal operation
  */
-struct TALER_MERCHANT_MapOperation *
-TALER_MERCHANT_map_out (struct GNUNET_CURL_Context *ctx,
-                        const char *backend_uri,
-                        const struct GNUNET_HashCode *h_contract,
-                        TALER_MERCHANT_MapOperationCallback map_cb,
-                        void *map_cb_cls);
+struct TALER_MERCHANT_ProposalOperation;
 
 /**
- * Issue a /map/in request to the backend.
- *
- * @param ctx execution context
- * @param backend_uri base URL of the merchant backend
- * @param contract contract to store
- * @param h_contract hashcode of `contract`
- * @param map_in_cb callback which will work the response gotten from the 
backend
- * @param map_in_cb_cls closure to pass to @a history_cb
- * @return handle for this operation, NULL upon errors
+ * Handle to a GET /proposal operation
  */
-struct TALER_MERCHANT_MapOperation *
-TALER_MERCHANT_map_in (struct GNUNET_CURL_Context *ctx,
-                       const char *backend_uri,
-                       const json_t *contract,
-                       const struct GNUNET_HashCode *h_contract,
-                       TALER_MERCHANT_MapOperationCallback map_cb,
-                       void *map_cb_cls);
-
-/**
- * Cancel a /map/in request.
- *
- * @param mio handle to the request to be canceled
- */
-void
-TALER_MERCHANT_map_cancel (struct TALER_MERCHANT_MapOperation *mo);
-
-
-/* *********************  /contract *********************** */
-
-
-/**
- * @brief Handle to a /contract operation at a merchant's backend.
- */
-struct TALER_MERCHANT_ContractOperation;
-
+struct TALER_MERCHANT_ProposalLookupOperation;
 
 /**
  * Callbacks of this type are used to serve the result of submitting a
@@ -99,48 +51,90 @@ struct TALER_MERCHANT_ContractOperation;
  * @param http_status HTTP response code, 200 indicates success;
  *                    0 if the backend's reply is bogus (fails to follow the 
protocol)
  * @param ec taler-specific error code 
- * @param obj the full received JSON reply, or
- *            error details if the request failed
- * @param contract completed contract, NULL on error
+ * @param obj raw JSON reply, or error details if the request failed
+ * @param proposal_data completed contract, NULL on error
  * @param sig merchant's signature over the contract, NULL on error
- * @param h_contract hash of the contract, NULL on error
+ * @param hash proposal data's hashcode, NULL on error
  */
 typedef void
-(*TALER_MERCHANT_ContractCallback) (void *cls,
+(*TALER_MERCHANT_ProposalCallback) (void *cls,
                                     unsigned int http_status,
                                    enum TALER_ErrorCode ec,
                                     const json_t *obj,
-                                    const json_t *contract,
+                                    const json_t *proposal_data,
                                     const struct TALER_MerchantSignatureP *sig,
-                                    const struct GNUNET_HashCode *h_contract);
+                                    const struct GNUNET_HashCode *hash);
 
 
 /**
- * Request backend to sign a contract (and add fields like wire transfer
- * details).
+ * Callback called to work a GET /proposal response.
+ *
+ * @param cls closure
+ * @param http_status HTTP status code of the request
+ * @param body JSON containing the response's payload.
+ * In case of errors, it contains the appropriate error encoding.
+ */
+typedef void
+(*TALER_MERCHANT_ProposalLookupOperationCallback) (void *cls,
+                                                   unsigned int http_status,
+                                                   const json_t *body);
+
+/**
+ * PUT an order to the backend and receives the related proposal.
  *
  * @param ctx execution context
- * @param backend_uri base URI of the backend
- * @param contract prototype of the contract
- * @param contract_cb the callback to call when a reply for this request is 
available
- * @param contract_cb_cls closure for @a contract_cb
+ * @param backend_uri URI of the backend
+ * @param order basic information about this purchase, to be extended by the
+ * backend
+ * @param proposal_cb the callback to call when a reply for this request is 
available
+ * @param proposal_cb_cls closure for @a proposal_cb
  * @return a handle for this request
  */
-struct TALER_MERCHANT_ContractOperation *
-TALER_MERCHANT_contract_sign (struct GNUNET_CURL_Context *ctx,
-                              const char *backend_uri,
-                              const json_t *contract,
-                              TALER_MERCHANT_ContractCallback contract_cb,
-                              void *contract_cb_cls);
+struct TALER_MERCHANT_ProposalOperation *
+TALER_MERCHANT_order_put (struct GNUNET_CURL_Context *ctx,
+                          const char *backend_uri,
+                          const json_t *order,
+                          TALER_MERCHANT_ProposalCallback proposal_cb,
+                          void *proposal_cb_cls);
+
+
+/**
+ * Cancel a PUT /proposal request.  This function cannot be used
+ * on a request handle if a response is already served for it.
+ *
+ * @param po the proposal operation request handle
+ */
+void
+TALER_MERCHANT_proposal_cancel (struct TALER_MERCHANT_ProposalOperation *po);
 
 
 /**
- * Cancel a /contract request.
+ * Calls the GET /proposal API at the backend.  That is,
+ * retrieve a proposal data by providing its transaction id.
  *
- * @param co the contract operation handle
+ * @param ctx execution context
+ * @param backend_uri base URL of the merchant backend
+ * @param transaction_id transaction id used to perform the lookup
+ * @param plo_cb callback which will work the response gotten from the backend
+ * @param plo_cb_cls closure to pass to @a history_cb
+ * @return handle for this operation, NULL upon errors
+ */
+struct TALER_MERCHANT_ProposalLookupOperation *
+TALER_MERCHANT_proposal_lookup (struct GNUNET_CURL_Context *ctx,
+                                const char *backend_uri,
+                                const char *transaction_id,
+                                TALER_MERCHANT_ProposalLookupOperationCallback 
plo_cb,
+                                void *plo_cb_cls);
+
+
+/**
+ * Cancel a GET /proposal request.
+ *
+ * @param plo handle to the request to be canceled
  */
 void
-TALER_MERCHANT_contract_sign_cancel (struct TALER_MERCHANT_ContractOperation 
*co);
+TALER_MERCHANT_proposal_lookup_cancel (struct 
TALER_MERCHANT_ProposalLookupOperation *plo);
+
 
 
 /* *********************  /pay *********************** */
@@ -244,7 +238,6 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx,
                           const char *merchant_uri,
                           const char *instance,
                            const struct GNUNET_HashCode *h_contract,
-                           uint64_t transaction_id,
                            const struct TALER_Amount *amount,
                            const struct TALER_Amount *max_fee,
                            const struct TALER_MerchantPublicKeyP *merchant_pub,
@@ -337,7 +330,6 @@ TALER_MERCHANT_pay_frontend (struct GNUNET_CURL_Context 
*ctx,
                              const struct GNUNET_HashCode *h_contract,
                             const struct TALER_Amount *amount,
                             const struct TALER_Amount *max_fee,
-                             uint64_t transaction_id,
                              const struct TALER_MerchantSignatureP 
*merchant_sig,
                              struct GNUNET_TIME_Absolute refund_deadline,
                              struct GNUNET_TIME_Absolute pay_deadline,
@@ -526,7 +518,7 @@ struct TALER_MERCHANT_TrackTransactionHandle *
 TALER_MERCHANT_track_transaction (struct GNUNET_CURL_Context *ctx,
                                   const char *backend_uri,
                                   const char *instance,
-                                  uint64_t transaction_id,
+                                  const char *order_id,
                                   TALER_MERCHANT_TrackTransactionCallback 
track_transaction_cb,
                                   void *track_transaction_cb_cls);
 
diff --git a/src/include/taler_merchantdb_plugin.h 
b/src/include/taler_merchantdb_plugin.h
index 3923fde..06f1c56 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -35,10 +35,9 @@ struct TALER_MERCHANTDB_Plugin;
  * Function called with information about a transaction.
  *
  * @param cls closure
- * @param transaction_id of the contract
  * @param merchant_pub merchant's public key
  * @param exchange_uri URI of the exchange
- * @param h_contract hash of the contract
+ * @param transaction_id proposal's transaction id
  * @param h_wire hash of our wire details
  * @param timestamp time of the confirmation
  * @param refund refund deadline
@@ -46,10 +45,9 @@ struct TALER_MERCHANTDB_Plugin;
  */
 typedef void
 (*TALER_MERCHANTDB_TransactionCallback)(void *cls,
-                                        uint64_t transaction_id,
                                        const struct TALER_MerchantPublicKeyP 
*merchant_pub,
                                         const char *exchange_uri,
-                                        const struct GNUNET_HashCode 
*h_contract,
+                                        const struct GNUNET_HashCode 
*h_proposal_data,
                                         const struct GNUNET_HashCode *h_wire,
                                         struct GNUNET_TIME_Absolute timestamp,
                                         struct GNUNET_TIME_Absolute refund,
@@ -69,7 +67,7 @@ typedef void
  */
 typedef void
 (*TALER_MERCHANTDB_CoinDepositCallback)(void *cls,
-                                        uint64_t transaction_id,
+                                        const struct GNUNET_HashCode 
*h_proposal_data,
                                         const struct TALER_CoinSpendPublicKeyP 
*coin_pub,
                                         const struct TALER_Amount 
*amount_with_fee,
                                         const struct TALER_Amount *deposit_fee,
@@ -95,7 +93,7 @@ typedef void
  */
 typedef void
 (*TALER_MERCHANTDB_TransferCallback)(void *cls,
-                                     uint64_t transaction_id,
+                                     const struct GNUNET_HashCode 
*h_proposal_data,
                                      const struct TALER_CoinSpendPublicKeyP 
*coin_pub,
                                      const struct 
TALER_WireTransferIdentifierRawP *wtid,
                                      struct GNUNET_TIME_Absolute 
execution_time,
@@ -150,32 +148,36 @@ struct TALER_MERCHANTDB_Plugin
 
 
   /**
-   * Insert a hash to contract map into the database
+   * Insert proposal data and its transaction id's hashcode into db
    *
    * @param cls closure
-   * @param h_contract hashcode of @a contract
-   * @param contract contract to store
+   * @param h_transaction_id hashcode of the transaction id mentioned in this
+   * proposal data
+   * @param proposal_data proposal data to store
    * @return #GNUNET_OK on success, #GNUNET_SYSERR upon error
    */
   int
-  (*store_map) (void *cls,
-                struct GNUNET_HashCode *h_contract,
-                const json_t *contract);
+  (*insert_proposal_data) (void *cls,
+                           struct GNUNET_HashCode *h_transaction_id,
+                           const json_t *proposal_data);
+
 
 
   /**
-   * Retrieve plain contract given its hashcode
+   * Retrieve proposal data given its transaction id's hashcode
    *
    * @param cls closure
-   * @param h_contract hashcode of the contract to retrieve
-   * @param contract where to store the retrieved contract
+   * @param h_transaction_id hashcode of the transaction id mentioned in this
+   * proposal data
+   * @param proposal_data where to store the retrieved proposal data
    * @return #GNUNET_OK on success, #GNUNET_NO if no contract is
    * found, #GNUNET_SYSERR upon error
    */
   int
-  (*find_contract) (void *cls,
-                    json_t **contract,
-                    struct GNUNET_HashCode *h_contract);
+  (*find_proposal_data) (void *cls,
+                         json_t **proposal_data,
+                         struct GNUNET_HashCode *h_transaction_id);
+
 
   /**
    * Insert transaction data into the database.
@@ -193,10 +195,9 @@ struct TALER_MERCHANTDB_Plugin
    */
   int
   (*store_transaction) (void *cls,
-                        uint64_t transaction_id,
+                        const struct GNUNET_HashCode *h_proposal_data,
                        const struct TALER_MerchantPublicKeyP *merchant_pub,
                         const char *exchange_uri,
-                        const struct GNUNET_HashCode *h_contract,
                         const struct GNUNET_HashCode *h_wire,
                         struct GNUNET_TIME_Absolute timestamp,
                         struct GNUNET_TIME_Absolute refund,
@@ -218,7 +219,7 @@ struct TALER_MERCHANTDB_Plugin
    */
   int
   (*store_deposit) (void *cls,
-                    uint64_t transaction_id,
+                    const struct GNUNET_HashCode *h_proposal_data,
                     const struct TALER_MerchantPublicKeyP *merchant_pub,
                     const struct TALER_CoinSpendPublicKeyP *coin_pub,
                     const struct TALER_Amount *amount_with_fee,
@@ -240,7 +241,7 @@ struct TALER_MERCHANTDB_Plugin
    */
   int
   (*store_coin_to_transfer) (void *cls,
-                             uint64_t transaction_id,
+                             const struct GNUNET_HashCode *h_proposal_data,
                              const struct TALER_CoinSpendPublicKeyP *coin_pub,
                              const struct TALER_WireTransferIdentifierRawP 
*wtid);
 
@@ -294,7 +295,7 @@ struct TALER_MERCHANTDB_Plugin
    */
   int
   (*find_transaction) (void *cls,
-                       uint64_t transaction_id,
+                       const struct GNUNET_HashCode *h_proposal_data,
                       const struct TALER_MerchantPublicKeyP *merchant_pub,
                        TALER_MERCHANTDB_TransactionCallback cb,
                        void *cb_cls);
@@ -314,7 +315,7 @@ struct TALER_MERCHANTDB_Plugin
    */
   int
   (*find_payments) (void *cls,
-                    uint64_t transaction_id,
+                    const struct GNUNET_HashCode *h_proposal_data,
                     const struct TALER_MerchantPublicKeyP *merchant_pub,
                     TALER_MERCHANTDB_CoinDepositCallback cb,
                     void *cb_cls);
@@ -333,12 +334,12 @@ struct TALER_MERCHANTDB_Plugin
    *         #GNUNET_SYSERR on hard errors
    */
   int
-  (*find_payments_by_id_and_coin) (void *cls,
-                                   uint64_t transaction_id,
-                                   const struct TALER_MerchantPublicKeyP 
*merchant_pub,
-                                   const struct TALER_CoinSpendPublicKeyP 
*coin_pub,
-                                   TALER_MERCHANTDB_CoinDepositCallback cb,
-                                   void *cb_cls);
+  (*find_payments_by_hash_and_coin) (void *cls,
+                                     const struct GNUNET_HashCode 
*h_proposal_data,
+                                     const struct TALER_MerchantPublicKeyP 
*merchant_pub,
+                                     const struct TALER_CoinSpendPublicKeyP 
*coin_pub,
+                                     TALER_MERCHANTDB_CoinDepositCallback cb,
+                                     void *cb_cls);
 
 
   /**
@@ -356,10 +357,10 @@ struct TALER_MERCHANTDB_Plugin
    *         #GNUNET_SYSERR on hard errors
    */
   int
-  (*find_transfers_by_id) (void *cls,
-                           uint64_t transaction_id,
-                           TALER_MERCHANTDB_TransferCallback cb,
-                           void *cb_cls);
+  (*find_transfers_by_hash) (void *cls,
+                             const struct GNUNET_HashCode *h_proposal_data,
+                             TALER_MERCHANTDB_TransferCallback cb,
+                             void *cb_cls);
 
 
   /**
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index d862365..1e4a7cb 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -14,12 +14,11 @@ libtalermerchant_la_LDFLAGS = \
   -no-undefined
 
 libtalermerchant_la_SOURCES = \
-  merchant_api_contract.c \
+  merchant_api_proposal.c \
   merchant_api_pay.c \
   merchant_api_track_transaction.c \
   merchant_api_track_transfer.c \
-  merchant_api_history.c \
-  merchant_api_map.c
+  merchant_api_history.c
 
 libtalermerchant_la_LIBADD = \
   -ltalerexchange \
diff --git a/src/lib/merchant_api_contract.c b/src/lib/merchant_api_contract.c
deleted file mode 100644
index c5db8d3..0000000
--- a/src/lib/merchant_api_contract.c
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
-  This file is part of TALER
-  Copyright (C) 2014, 2015, 2016 GNUnet e.V. and INRIA
-
-  TALER is free software; you can redistribute it and/or modify it under the
-  terms of the GNU Lesser General Public License as published by the Free 
Software
-  Foundation; either version 2.1, or (at your option) any later version.
-
-  TALER is distributed in the hope that it will be useful, but WITHOUT ANY
-  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-  A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more 
details.
-
-  You should have received a copy of the GNU Lesser General Public License 
along with
-  TALER; see the file COPYING.LGPL.  If not, see
-  <http://www.gnu.org/licenses/>
-*/
-/**
- * @file lib/merchant_api_contract.c
- * @brief Implementation of the /contract request of the merchant's HTTP API
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include <curl/curl.h>
-#include <jansson.h>
-#include <microhttpd.h> /* just for HTTP status codes */
-#include <gnunet/gnunet_util_lib.h>
-#include <gnunet/gnunet_curl_lib.h>
-#include "taler_merchant_service.h"
-#include <taler/taler_json_lib.h>
-#include <taler/taler_signatures.h>
-
-
-/**
- * @brief A Contract Operation Handle
- */
-struct TALER_MERCHANT_ContractOperation
-{
-
-  /**
-   * The url for this request.
-   */
-  char *url;
-
-  /**
-   * JSON encoding of the request to POST.
-   */
-  char *json_enc;
-
-  /**
-   * Handle for the request.
-   */
-  struct GNUNET_CURL_Job *job;
-
-  /**
-   * Function to call with the result.
-   */
-  TALER_MERCHANT_ContractCallback cb;
-
-  /**
-   * Closure for @a cb.
-   */
-  void *cb_cls;
-
-  /**
-   * Reference to the execution context.
-   */
-  struct GNUNET_CURL_Context *ctx;
-};
-
-
-/**
- * Function called when we're done processing the
- * HTTP /contract request.
- *
- * @param cls the `struct TALER_MERCHANT_Pay`
- * @param response_code HTTP response code, 0 on error
- * @param json response body, NULL if not in JSON
- */
-static void
-handle_contract_finished (void *cls,
-                          long response_code,
-                          const json_t *json)
-{
-  struct TALER_MERCHANT_ContractOperation *co = cls;
-  json_t *contract;
-  const struct TALER_MerchantSignatureP *sigp;
-  const struct GNUNET_HashCode *h_contractp;
-  struct TALER_MerchantSignatureP sig;
-  struct GNUNET_HashCode h_contract;
-
-  co->job = NULL;
-  contract = NULL;
-  sigp = NULL;
-  h_contractp = NULL;
-  switch (response_code)
-  {
-    case 0:
-      break;
-    case MHD_HTTP_OK:
-    {
-      struct GNUNET_JSON_Specification spec[] = {
-        GNUNET_JSON_spec_json ("contract", &contract),
-        GNUNET_JSON_spec_fixed_auto ("merchant_sig", &sig),
-        GNUNET_JSON_spec_fixed_auto ("H_contract", &h_contract),
-        GNUNET_JSON_spec_end()
-      };
-  
-      if (GNUNET_OK !=
-          GNUNET_JSON_parse (json,
-                             spec,
-                             NULL, NULL))
-      {
-        GNUNET_break_op (0);
-        response_code = 0;
-        break;
-      }
-      h_contractp = &h_contract;
-      sigp = &sig;
-    }
-      break;
-    case MHD_HTTP_BAD_REQUEST:
-      /* This should never happen, either us or the merchant is buggy
-         (or API version conflict); just pass JSON reply to the application */
-      break;
-    case MHD_HTTP_FORBIDDEN:
-      break;
-    case MHD_HTTP_UNAUTHORIZED:
-      /* Nothing really to verify, merchant says one of the signatures is
-         invalid; as we checked them, this should never happen, we
-         should pass the JSON reply to the application */
-      break;
-    case MHD_HTTP_NOT_FOUND:
-      /* Nothing really to verify, this should never
-         happen, we should pass the JSON reply to the application */
-      break;
-    case MHD_HTTP_INTERNAL_SERVER_ERROR:
-      /* Server had an internal issue; we should retry, but this API
-         leaves this to the application */
-      break;
-    default:
-      /* unexpected response code */
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  "Unexpected response code %u\n",
-                  (unsigned int) response_code);
-      GNUNET_break (0);
-      response_code = 0;
-  }
-  co->cb (co->cb_cls,
-          response_code,
-         TALER_JSON_get_error_code (json),
-          json,
-          contract,
-          sigp,
-          h_contractp);
-  if (NULL != contract)
-    json_decref (contract);
-}
-
-
-/**
- * Request backend to sign a contract (and add fields like wire transfer
- * details).
- *
- * @param ctx execution context
- * @param backend_uri URI of the backend
- * @param contract prototype of the contract
- * @param contract_cb the callback to call when a reply for this request is 
available
- * @param contract_cb_cls closure for @a contract_cb
- * @return a handle for this request
- */
-struct TALER_MERCHANT_ContractOperation *
-TALER_MERCHANT_contract_sign (struct GNUNET_CURL_Context *ctx,
-                              const char *backend_uri,
-                              const json_t *contract,
-                              TALER_MERCHANT_ContractCallback contract_cb,
-                              void *contract_cb_cls)
-{
-  struct TALER_MERCHANT_ContractOperation *co;
-  json_t *req;
-  CURL *eh;
-
-  co = GNUNET_new (struct TALER_MERCHANT_ContractOperation);
-  co->ctx = ctx;
-  co->cb = contract_cb;
-  co->cb_cls = contract_cb_cls;
-  GNUNET_asprintf (&co->url,
-                   "%s%s",
-                   backend_uri,
-                   "/contract");
-
-  req = json_pack ("{s:O}",
-                   "contract", (json_t *) contract);
-  eh = curl_easy_init ();
-  GNUNET_assert (NULL != (co->json_enc =
-                          json_dumps (req,
-                                      JSON_COMPACT)));
-  json_decref (req);
-  GNUNET_assert (CURLE_OK ==
-                 curl_easy_setopt (eh,
-                                   CURLOPT_URL,
-                                   co->url));
-  GNUNET_assert (CURLE_OK ==
-                 curl_easy_setopt (eh,
-                                   CURLOPT_POSTFIELDS,
-                                   co->json_enc));
-  GNUNET_assert (CURLE_OK ==
-                 curl_easy_setopt (eh,
-                                   CURLOPT_POSTFIELDSIZE,
-                                   strlen (co->json_enc)));
-  co->job = GNUNET_CURL_job_add (ctx,
-                                 eh,
-                                 GNUNET_YES,
-                                 &handle_contract_finished,
-                                 co);
-  return co;
-}
-
-
-/**
- * Cancel a /contract request.  This function cannot be used
- * on a request handle if a response is already served for it.
- *
- * @param co the contract operation request handle
- */
-void
-TALER_MERCHANT_contract_sign_cancel (struct TALER_MERCHANT_ContractOperation 
*co)
-{
-  if (NULL != co->job)
-  {
-    GNUNET_CURL_job_cancel (co->job);
-    co->job = NULL;
-  }
-  GNUNET_free (co->url);
-  GNUNET_free (co->json_enc);
-  GNUNET_free (co);
-}
-
-
-/* end of merchant_api_contract.c */
diff --git a/src/lib/merchant_api_map.c b/src/lib/merchant_api_map.c
deleted file mode 100644
index d1aaf5a..0000000
--- a/src/lib/merchant_api_map.c
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
-  This file is part of TALER
-  Copyright (C) 2014, 2015, 2016 GNUnet e.V. and INRIA
-
-  TALER is free software; you can redistribute it and/or modify it under the
-  terms of the GNU Lesser General Public License as published by the Free 
Software
-  Foundation; either version 2.1, or (at your option) any later version.
-
-  TALER is distributed in the hope that it will be useful, but WITHOUT ANY
-  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-  A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more 
details.
-
-  You should have received a copy of the GNU Lesser General Public License 
along with
-  TALER; see the file COPYING.LGPL.  If not, see
-  <http://www.gnu.org/licenses/>
-*/
-/**
- * @file lib/merchant_api_map.c
- * @brief Implementation of the /map/{in,out} request of the merchant's HTTP 
API
- * @author Marcello Stanisci
- */
-#include "platform.h"
-#include <curl/curl.h>
-#include <jansson.h>
-#include <microhttpd.h> /* just for HTTP status codes */
-#include <gnunet/gnunet_util_lib.h>
-#include <gnunet/gnunet_curl_lib.h>
-#include "taler_merchant_service.h"
-#include <taler/taler_json_lib.h>
-
-
-/**
- * This structure acts like a "handle" for both /map/in and
- * /map/out operations, as they only differ about the 'json_enc'
- * field (which is just left NULL when not needed).
- */
-struct TALER_MERCHANT_MapOperation
-{
-  /**
-   * Full URI, includes "/map/in".
-   */
-  char *url;
-
-  /**
-   * Request's body.  Left NULL in case of /map/out.
-   */
-  char *json_enc;
-
-  /**
-   * Handle for the request.
-   */
-  struct GNUNET_CURL_Job *job;
-
-  /**
-   * Function to call with the result.
-   */
-  TALER_MERCHANT_MapOperationCallback cb;
-
-  /**
-   * Closure for @a cb.
-   */
-  void *cb_cls;
-
-  /**
-   * Reference to the execution context.
-   */
-  struct GNUNET_CURL_Context *ctx;
-
-};
-
-
-/**
- * Cancel a /map/{in,out} request.
- *
- * @param mio handle to the request to be canceled
- */
-void
-TALER_MERCHANT_map_cancel (struct TALER_MERCHANT_MapOperation *mo)
-{
-  if (NULL != mo->job)
-  {
-    GNUNET_CURL_job_cancel (mo->job);
-    mo->job = NULL;
-  }
-  GNUNET_free (mo->url);
-  GNUNET_free_non_null (mo->json_enc);
-  GNUNET_free (mo);
-}
-
-
-/**
- * Function called when we're done processing the HTTP /map/{in,out} request.
- *
- * @param cls the `struct TALER_MERCHANT_MapInOperation`
- * @param response_code HTTP response code, 0 on error
- * @param json response body, should be NULL
- */
-static void
-handle_map_finished (void *cls,
-                     long response_code,
-                     const json_t *json)
-{
-  struct TALER_MERCHANT_MapOperation *mo = cls;
-
-  /**
-   * As no data is supposed to be extracted from this
-   * call, we just invoke the provided callback from here.
-   */
-  mo->cb (mo->cb_cls,
-          response_code,
-          json);
-}
-
-/**
- * Issue a /map/out request to the backend.
- *
- * @param ctx execution context
- * @param backend_uri base URL of the merchant backend
- * @param h_contract hashcode of `contract`
- * @param map_in_cb callback which will work the response gotten from the 
backend
- * @param map_in_cb_cls closure to pass to @a history_cb
- * @return handle for this operation, NULL upon errors
- */
-struct TALER_MERCHANT_MapOperation *
-TALER_MERCHANT_map_out (struct GNUNET_CURL_Context *ctx,
-                        const char *backend_uri,
-                        const struct GNUNET_HashCode *h_contract,
-                        TALER_MERCHANT_MapOperationCallback map_cb,
-                        void *map_cb_cls)
-{
-  struct TALER_MERCHANT_MapOperation *mo;
-  CURL *eh;
-  char *hash_enc;
-
-  mo = GNUNET_new (struct TALER_MERCHANT_MapOperation);
-  mo->ctx = ctx;
-  mo->cb = map_cb;
-  mo->cb_cls = map_cb_cls;
-
-  hash_enc = GNUNET_STRINGS_data_to_string_alloc (h_contract,
-                                                  sizeof (struct 
GNUNET_HashCode));
-  GNUNET_asprintf (&mo->url,
-                   "%s/map/out?h_contract=%s",
-                   backend_uri,
-                   hash_enc);
-  eh = curl_easy_init ();
-  if (CURLE_OK != curl_easy_setopt (eh,
-                                    CURLOPT_URL,
-                                    mo->url))
-  {
-    GNUNET_break (0);  
-    return NULL;
-  }
-
-  if (NULL == (mo->job = GNUNET_CURL_job_add (ctx,
-                                              eh,
-                                              GNUNET_YES,
-                                              &handle_map_finished,
-                                              mo)))
-  {
-    GNUNET_break (0);
-    return NULL;
-  }
-  return mo;
-}
-
-/**
- * Issue a /map/in request to the backend.
- *
- * @param ctx execution context
- * @param backend_uri base URL of the merchant backend
- * @param contract contract to store
- * @param h_contract hashcode of `contract`
- * @param map_in_cb callback which will work the response gotten from the 
backend
- * @param map_in_cb_cls closure to pass to @a history_cb
- * @return handle for this operation, NULL upon errors
- */
-struct TALER_MERCHANT_MapOperation *
-TALER_MERCHANT_map_in (struct GNUNET_CURL_Context *ctx,
-                       const char *backend_uri,
-                       const json_t *contract,
-                       const struct GNUNET_HashCode *h_contract,
-                       TALER_MERCHANT_MapOperationCallback map_cb,
-                       void *map_cb_cls)
-{
-  struct TALER_MERCHANT_MapOperation *mo;
-  CURL *eh;
-  json_t *req;
-  
-  mo = GNUNET_new (struct TALER_MERCHANT_MapOperation);
-  mo->ctx = ctx;
-  mo->cb = map_cb;
-  mo->cb_cls = map_cb_cls;
-
-  GNUNET_asprintf (&mo->url,
-                   "%s%s",
-                   backend_uri,
-                   "/map/in");
-
-  // build final json
-  req = json_pack ("{s:o, s:o}",
-                   "contract", contract,
-                   "h_contract", GNUNET_JSON_from_data_auto (h_contract));
-
-  GNUNET_assert (NULL !=
-                  (mo->json_enc = json_dumps (req, JSON_COMPACT))
-                );
-
-  json_decref (req);
-  eh = curl_easy_init ();
-
-  GNUNET_assert (CURLE_OK ==
-                 curl_easy_setopt (eh,
-                                   CURLOPT_URL,
-                                   mo->url));
-  GNUNET_assert (CURLE_OK ==
-                 curl_easy_setopt (eh,
-                                   CURLOPT_POSTFIELDS,
-                                   mo->json_enc));
-  GNUNET_assert (CURLE_OK ==
-                 curl_easy_setopt (eh,
-                                   CURLOPT_POSTFIELDSIZE,
-                                   strlen (mo->json_enc)));
-  mo->job = GNUNET_CURL_job_add (ctx,
-                                 eh,
-                                 GNUNET_YES,
-                                 &handle_map_finished,
-                                 mo);
-  return mo;
-}
diff --git a/src/lib/merchant_api_pay.c b/src/lib/merchant_api_pay.c
index 5475ec7..76c247a 100644
--- a/src/lib/merchant_api_pay.c
+++ b/src/lib/merchant_api_pay.c
@@ -278,8 +278,7 @@ struct TALER_MERCHANT_Pay *
 TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx,
                           const char *merchant_uri,
                           const char *instance,
-                           const struct GNUNET_HashCode *h_contract,
-                           uint64_t transaction_id,
+                           const struct GNUNET_HashCode *h_proposal_data,
                           const struct TALER_Amount *amount,
                           const struct TALER_Amount *max_fee,
                            const struct TALER_MerchantPublicKeyP *merchant_pub,
@@ -304,11 +303,10 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context 
*ctx,
 
   dr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_DEPOSIT);
   dr.purpose.size = htonl (sizeof (struct TALER_DepositRequestPS));
-  dr.h_contract = *h_contract;
+  dr.h_proposal_data = *h_proposal_data;
   dr.h_wire = *h_wire;
   dr.timestamp = GNUNET_TIME_absolute_hton (timestamp);
   dr.refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline);
-  dr.transaction_id = GNUNET_htonll (transaction_id);
   dr.merchant = *merchant_pub;
   for (i=0;i<num_coins;i++)
   {
@@ -346,10 +344,9 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx,
   return TALER_MERCHANT_pay_frontend (ctx,
                                      merchant_uri,
                                       instance,
-                                     h_contract,
+                                     h_proposal_data,
                                       amount,
                                      max_fee,
-                                     transaction_id,
                                      merchant_sig,
                                      refund_deadline,
                                      pay_deadline,
@@ -392,10 +389,9 @@ struct TALER_MERCHANT_Pay *
 TALER_MERCHANT_pay_frontend (struct GNUNET_CURL_Context *ctx,
                             const char *merchant_uri,
                             const char *instance,
-                             const struct GNUNET_HashCode *h_contract,
+                             const struct GNUNET_HashCode *h_proposal_data,
                             const struct TALER_Amount *amount,
                             const struct TALER_Amount *max_fee,
-                             uint64_t transaction_id,
                              const struct TALER_MerchantSignatureP 
*merchant_sig,
                              struct GNUNET_TIME_Absolute refund_deadline,
                              struct GNUNET_TIME_Absolute pay_deadline,
@@ -561,14 +557,13 @@ TALER_MERCHANT_pay_frontend (struct GNUNET_CURL_Context 
*ctx,
     }
   } /* end of sanity check */
 
-  pay_obj = json_pack ("{s:o," /* H_contract */
-                       " s:I, s:o," /* transaction id, timestamp */
+  pay_obj = json_pack ("{s:o," /* h_proposal_data */
+                       " s:o," /* timestamp */
                        " s:o, s:o," /* refund_deadline, pay_deadline */
                        " s:s," /* exchange */
                        " s:o, s:o," /* coins, max_fee */
                        " s:o, s:o}",/* amount, signature */
-                       "H_contract", GNUNET_JSON_from_data_auto (h_contract),
-                       "transaction_id", (json_int_t) transaction_id,
+                       "h_proposal_data", GNUNET_JSON_from_data_auto 
(h_proposal_data),
                        "timestamp", GNUNET_JSON_from_time_abs (timestamp),
                        "refund_deadline", GNUNET_JSON_from_time_abs 
(refund_deadline),
                        "pay_deadline", GNUNET_JSON_from_time_abs 
(pay_deadline),
diff --git a/src/lib/merchant_api_proposal.c b/src/lib/merchant_api_proposal.c
new file mode 100644
index 0000000..60b38d9
--- /dev/null
+++ b/src/lib/merchant_api_proposal.c
@@ -0,0 +1,364 @@
+/*
+  This file is part of TALER
+  Copyright (C) 2014, 2015, 2016 GNUnet e.V. and INRIA
+
+  TALER is free software; you can redistribute it and/or modify it under the
+  terms of the GNU Lesser General Public License as published by the Free 
Software
+  Foundation; either version 2.1, or (at your option) any later version.
+
+  TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+  A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more 
details.
+
+  You should have received a copy of the GNU Lesser General Public License 
along with
+  TALER; see the file COPYING.LGPL.  If not, see
+  <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file lib/merchant_api_proposal.c
+ * @brief Implementation of the /proposal PUT and GET
+ * @author Christian Grothoff
+ * @author Marcello Stanisci
+ */
+#include "platform.h"
+#include <curl/curl.h>
+#include <jansson.h>
+#include <microhttpd.h> /* just for HTTP status codes */
+#include <gnunet/gnunet_util_lib.h>
+#include <gnunet/gnunet_curl_lib.h>
+#include "taler_merchant_service.h"
+#include <taler/taler_json_lib.h>
+#include <taler/taler_signatures.h>
+
+
+/**
+ * @brief A Contract Operation Handle
+ */
+struct TALER_MERCHANT_ProposalOperation
+{
+
+  /**
+   * The url for this request.
+   */
+  char *url;
+
+  /**
+   * JSON encoding of the request to POST.
+   */
+  char *json_enc;
+
+  /**
+   * Handle for the request.
+   */
+  struct GNUNET_CURL_Job *job;
+
+  /**
+   * Function to call with the result.
+   */
+  TALER_MERCHANT_ProposalCallback cb;
+
+  /**
+   * Closure for @a cb.
+   */
+  void *cb_cls;
+
+  /**
+   * Reference to the execution context.
+   */
+  struct GNUNET_CURL_Context *ctx;
+};
+
+/**
+ * Structure representing a GET /proposal operation.
+ */
+struct TALER_MERCHANT_ProposalLookupOperation
+{
+  /**
+   * Full URI, includes "/proposal".
+   */
+  char *url;
+
+  /**
+   * Handle for the request.
+   */
+  struct GNUNET_CURL_Job *job;
+
+  /**
+   * Function to call with the result.
+   */
+  TALER_MERCHANT_ProposalLookupOperationCallback cb;
+
+  /**
+   * Closure for @a cb.
+   */
+  void *cb_cls;
+
+  /**
+   * Reference to the execution context.
+   */
+  struct GNUNET_CURL_Context *ctx;
+
+};
+
+
+/**
+ * Function called when we're done processing the
+ * HTTP PUT /proposal request.
+ *
+ * @param cls the `struct TALER_MERCHANT_ProposalOperation`
+ * @param response_code HTTP response code, 0 on error
+ * @param json response body, NULL if not in JSON
+ */
+static void
+handle_proposal_finished (void *cls,
+                          long response_code,
+                          const json_t *json)
+{
+  struct TALER_MERCHANT_ProposalOperation *po = cls;
+  json_t *proposal_data;
+  const struct TALER_MerchantSignatureP *sigp;
+  const struct GNUNET_HashCode *hashp;
+  struct TALER_MerchantSignatureP sig;
+  struct GNUNET_HashCode hash;
+
+  po->job = NULL;
+  proposal_data = NULL;
+  sigp = NULL;
+  hashp = NULL;
+  switch (response_code)
+  {
+    case 0:
+      break;
+    case MHD_HTTP_OK:
+    {
+      struct GNUNET_JSON_Specification spec[] = {
+        GNUNET_JSON_spec_json ("data", &proposal_data),
+        GNUNET_JSON_spec_fixed_auto ("sig", &sig),
+        GNUNET_JSON_spec_fixed_auto ("hash", &hash),
+        GNUNET_JSON_spec_end()
+      };
+  
+      if (GNUNET_OK !=
+          GNUNET_JSON_parse (json,
+                             spec,
+                             NULL, NULL))
+      {
+        GNUNET_break_op (0);
+        response_code = 0;
+        break;
+      }
+      hashp = &hash;
+      sigp = &sig;
+    }
+      break;
+    case MHD_HTTP_BAD_REQUEST:
+      /* This should never happen, either us or the merchant is buggy
+         (or API version conflict); just pass JSON reply to the application */
+      break;
+    case MHD_HTTP_FORBIDDEN:
+      break;
+    case MHD_HTTP_UNAUTHORIZED:
+      /* Nothing really to verify, merchant says one of the signatures is
+         invalid; as we checked them, this should never happen, we
+         should pass the JSON reply to the application */
+      break;
+    case MHD_HTTP_NOT_FOUND:
+      /* Nothing really to verify, this should never
+         happen, we should pass the JSON reply to the application */
+      break;
+    case MHD_HTTP_INTERNAL_SERVER_ERROR:
+      /* Server had an internal issue; we should retry, but this API
+         leaves this to the application */
+      break;
+    default:
+      /* unexpected response code */
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  "Unexpected response code %u\n",
+                  (unsigned int) response_code);
+      GNUNET_break (0);
+      response_code = 0;
+  }
+  po->cb (po->cb_cls,
+          response_code,
+         TALER_JSON_get_error_code (json),
+          json,
+          proposal_data,
+          sigp,
+          hashp);
+  if (NULL != proposal_data)
+    json_decref (proposal_data);
+}
+
+
+/**
+ * PUT an order to the backend and receives the related proposal.
+ *
+ * @param ctx execution context
+ * @param backend_uri URI of the backend
+ * @param order basic information about this purchase, to be extended by the
+ * backend
+ * @param proposal_cb the callback to call when a reply for this request is
+ * available
+ * @param proposal_cb_cls closure for @a proposal_cb
+ * @return a handle for this request
+ */
+struct TALER_MERCHANT_ProposalOperation *
+TALER_MERCHANT_order_put (struct GNUNET_CURL_Context *ctx,
+                          const char *backend_uri,
+                          const json_t *order,
+                          TALER_MERCHANT_ProposalCallback proposal_cb,
+                          void *proposal_cb_cls)
+{
+  struct TALER_MERCHANT_ProposalOperation *po;
+  json_t *req;
+  CURL *eh;
+
+  po = GNUNET_new (struct TALER_MERCHANT_ProposalOperation);
+  po->ctx = ctx;
+  po->cb = proposal_cb;
+  po->cb_cls = proposal_cb_cls;
+  GNUNET_asprintf (&po->url,
+                   "%s%s",
+                   backend_uri,
+                   "/proposal");
+
+  req = json_pack ("{s:O}",
+                   "order", (json_t *) order);
+  eh = curl_easy_init ();
+  GNUNET_assert (NULL != (po->json_enc =
+                          json_dumps (req,
+                                      JSON_COMPACT)));
+  json_decref (req);
+  GNUNET_assert (CURLE_OK ==
+                 curl_easy_setopt (eh,
+                                   CURLOPT_URL,
+                                   po->url));
+  /* FIXME: as for the specs, POST becomes PUT */
+  GNUNET_assert (CURLE_OK ==
+                 curl_easy_setopt (eh,
+                                   CURLOPT_POSTFIELDS,
+                                   po->json_enc));
+  GNUNET_assert (CURLE_OK ==
+                 curl_easy_setopt (eh,
+                                   CURLOPT_POSTFIELDSIZE,
+                                   strlen (po->json_enc)));
+  po->job = GNUNET_CURL_job_add (ctx,
+                                 eh,
+                                 GNUNET_YES,
+                                 &handle_proposal_finished,
+                                 po);
+  return po;
+}
+
+/**
+ * Function called when we're done processing the GET /proposal request.
+ *
+ * @param cls the `struct TALER_MERCHANT_ProposalLookupOperation`
+ * @param response_code HTTP response code, 0 on error
+ * @param json response body, should be NULL
+ */
+static void
+handle_proposal_lookup_finished (void *cls,
+                                 long response_code,
+                                 const json_t *json)
+{
+  struct TALER_MERCHANT_ProposalLookupOperation *plo = cls;
+
+  /**
+   * As no data is supposed to be extracted from this
+   * call, we just invoke the provided callback.
+   */
+  plo->cb (plo->cb_cls,
+           response_code,
+           json);
+}
+
+/**
+ * Calls the GET /proposal API at the backend.  That is,
+ * retrieve a proposal data by providing its transaction id.
+ *
+ * @param ctx execution context
+ * @param backend_uri base URL of the merchant backend
+ * @param transaction_id transaction id used to perform the lookup
+ * @param plo_cb callback which will work the response gotten from the backend
+ * @param plo_cb_cls closure to pass to @a history_cb
+ * @return handle for this operation, NULL upon errors
+ */
+struct TALER_MERCHANT_ProposalLookupOperation *
+TALER_MERCHANT_proposal_lookup (struct GNUNET_CURL_Context *ctx,
+                                const char *backend_uri,
+                                const char *order_id,
+                                TALER_MERCHANT_ProposalLookupOperationCallback 
plo_cb,
+                                void *plo_cb_cls)
+{
+  struct TALER_MERCHANT_ProposalLookupOperation *plo;
+  CURL *eh;
+
+  plo = GNUNET_new (struct TALER_MERCHANT_ProposalLookupOperation);
+  plo->ctx = ctx;
+  plo->cb = plo_cb;
+  plo->cb_cls = plo_cb_cls;
+
+  GNUNET_asprintf (&plo->url,
+                   "%s/proposal?order_id=%s",
+                   backend_uri,
+                   order_id);
+  eh = curl_easy_init ();
+  if (CURLE_OK != curl_easy_setopt (eh,
+                                    CURLOPT_URL,
+                                    plo->url))
+  {
+    GNUNET_break (0);  
+    return NULL;
+  }
+
+  if (NULL == (plo->job = GNUNET_CURL_job_add (ctx,
+                                               eh,
+                                               GNUNET_YES,
+                                               
&handle_proposal_lookup_finished,
+                                               plo)))
+  {
+    GNUNET_break (0);
+    return NULL;
+  }
+  return plo;
+
+}
+
+/**
+ * Cancel a PUT /proposal request.  This function cannot be used
+ * on a request handle if a response is already served for it.
+ *
+ * @param po the proposal operation request handle
+ */
+void
+TALER_MERCHANT_proposal_cancel (struct TALER_MERCHANT_ProposalOperation *po)
+{
+  if (NULL != po->job)
+  {
+    GNUNET_CURL_job_cancel (po->job);
+    po->job = NULL;
+  }
+  GNUNET_free (po->url);
+  GNUNET_free (po->json_enc);
+  GNUNET_free (po);
+}
+
+/**
+ * Cancel a GET /proposal request.
+ *
+ * @param plo handle to the request to be canceled
+ */
+void
+TALER_MERCHANT_proposal_lookup_cancel (struct 
TALER_MERCHANT_ProposalLookupOperation *plo)
+{
+  if (NULL != plo->job)
+  {
+    GNUNET_CURL_job_cancel (plo->job);
+    plo->job = NULL;
+  }
+  GNUNET_free (plo->url);
+  GNUNET_free (plo);
+}
+
+/* end of merchant_api_contract.c */
diff --git a/src/lib/merchant_api_track_transaction.c 
b/src/lib/merchant_api_track_transaction.c
index cb86441..787e28c 100644
--- a/src/lib/merchant_api_track_transaction.c
+++ b/src/lib/merchant_api_track_transaction.c
@@ -201,7 +201,7 @@ handle_track_transaction_finished (void *cls,
     /* Nothing really to verify, this should never
        happen, we should pass the JSON reply to the application */
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "track transaction URI not found\n");
+                "Did not find any data\n");
     break;
   case MHD_HTTP_INTERNAL_SERVER_ERROR:
     /* Server had an internal issue; we should retry, but this API
@@ -240,7 +240,7 @@ struct TALER_MERCHANT_TrackTransactionHandle *
 TALER_MERCHANT_track_transaction (struct GNUNET_CURL_Context *ctx,
                                   const char *backend_uri,
                                   const char *instance,
-                                  uint64_t transaction_id,
+                                  const char *order_id,
                                   TALER_MERCHANT_TrackTransactionCallback 
track_transaction_cb,
                                   void *track_transaction_cb_cls)
 {
@@ -252,10 +252,13 @@ TALER_MERCHANT_track_transaction (struct 
GNUNET_CURL_Context *ctx,
   tdo->cb = track_transaction_cb;
   tdo->cb_cls = track_transaction_cb_cls;
   GNUNET_asprintf (&tdo->url,
-                   "%s/track/transaction?id=%llu&instance=%s",
+                   "%s/track/transaction?order_id=%s&instance=%s",
                    backend_uri,
-                   (unsigned long long) transaction_id,
+                   order_id,
                    instance);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Requesting URI '%s'\n",
+              tdo->url);
   eh = curl_easy_init ();
   GNUNET_assert (CURLE_OK ==
                  curl_easy_setopt (eh,
diff --git a/src/lib/merchant_api_track_transfer.c 
b/src/lib/merchant_api_track_transfer.c
index ee6c979..10e6981 100644
--- a/src/lib/merchant_api_track_transfer.c
+++ b/src/lib/merchant_api_track_transfer.c
@@ -118,8 +118,7 @@ check_track_transfer_response_ok (struct 
TALER_MERCHANT_TrackTransferHandle *wdh
       struct TALER_TrackTransferDetails *detail = &details[i];
       struct json_t *detail_j = json_array_get (details_j, i);
       struct GNUNET_JSON_Specification spec_detail[] = {
-        GNUNET_JSON_spec_fixed_auto ("H_contract", &detail->h_contract),
-        GNUNET_JSON_spec_uint64 ("transaction_id", &detail->transaction_id),
+        GNUNET_JSON_spec_fixed_auto ("h_proposal_data", 
&detail->h_proposal_data),
         GNUNET_JSON_spec_fixed_auto ("coin_pub", &detail->coin_pub),
         TALER_JSON_spec_amount ("deposit_value", &detail->coin_value),
         TALER_JSON_spec_amount ("deposit_fee", &detail->coin_fee),
diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c
index f2081c2..a69e4c9 100644
--- a/src/lib/test_merchant_api.c
+++ b/src/lib/test_merchant_api.c
@@ -17,6 +17,7 @@
  * @file merchant/test_merchant_api.c
  * @brief testcase to test merchant's HTTP API interface
  * @author Christian Grothoff
+ * @author Marcello Stanisci
  */
 #include "platform.h"
 #include <taler/taler_exchange_service.h>
@@ -51,9 +52,9 @@
 #define BANK_PORT 8083
 
 /**
- * Max size allowed for a contract
+ * Max size allowed for an order.
  */
-#define CONTRACT_MAX_SIZE 1000
+#define ORDER_MAX_SIZE 1000
 
 #define RND_BLK(ptr)                                                    \
   GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, ptr, sizeof (*ptr))
@@ -132,16 +133,9 @@ enum OpCode
   OC_END = 0,
 
   /**
-   * Ask the backend to store a contract and its hashcode into
-   * the database.
+   * Issue a GET /proposal to the backend.
    */
-  OC_MAP_IN,
-
-  /**
-   * Ask the backend to retrieve a contract from the database, according
-   * to its hashcode.
-   */
-  OC_MAP_OUT,
+  OC_PROPOSAL_LOOKUP,
 
   /**
    * Add funds to a reserve by (faking) incoming wire transfer.
@@ -159,9 +153,9 @@ enum OpCode
   OC_WITHDRAW_SIGN,
 
   /**
-   * Get backend to sign a contract.
+   * Issue a PUT /proposal to the backend.
    */
-  OC_CONTRACT,
+  OC_PROPOSAL,
 
   /**
    * Pay with coins.
@@ -318,19 +312,19 @@ struct Command
     } admin_add_incoming;
 
     /**
-     * Information for both #OC_MAP_{IN,OUT} command.
+     * Information for OC_PROPOSAL_LOOKUP command.
      */
     struct
     {
 
       /**
-       * Reference to a contract we need to hash and store.
+       * Reference to the proposal we want to lookup.
        */
-      const char *contract_reference;
+      const char *proposal_reference;
 
-      struct TALER_MERCHANT_MapOperation *mo;
+      struct TALER_MERCHANT_ProposalLookupOperation *plo;
 
-    } map;
+    } proposal_lookup;
 
     /**
      * Information for a #OC_WITHDRAW_STATUS command.
@@ -405,39 +399,41 @@ struct Command
     } reserve_withdraw;
 
     /**
-     * Information for an #OC_CONTRACT command.
+     * Information for an #OC_PROPOSAL command.
      */
     struct
     {
 
       /**
-       * Contract proposal (without merchant_pub, exchanges or H_wire).
+       * The order.
        * It's dynamically generated because we need different transaction_id
        * for different merchant instances.
        */
-      char proposal[CONTRACT_MAX_SIZE];
+      char order[ORDER_MAX_SIZE];
 
       /**
-       * Handle to the active /contract operation, or NULL.
+       * Handle to the active PUT /proposal operation, or NULL.
        */
-      struct TALER_MERCHANT_ContractOperation *co;
+      struct TALER_MERCHANT_ProposalOperation *po;
 
       /**
        * Full contract in JSON, set by the /contract operation.
+       * FIXME: verify in the code that this bit is actually proposal
+       * data and not the whole proposal.
        */
-      json_t *contract;
+      json_t *proposal_data;
 
       /**
-       * Signature, set by the /contract operation.
+       * Proposal's signature.
        */
       struct TALER_MerchantSignatureP merchant_sig;
 
       /**
-       * Hash of the full contract, set by the /contract operation.
+       * Proposal data's hashcode.
        */
-      struct GNUNET_HashCode h_contract;
+      struct GNUNET_HashCode hash;
 
-    } contract;
+    } proposal;
 
     /**
      * Information for a #OC_PAY command.
@@ -483,9 +479,9 @@ struct Command
       struct TALER_MERCHANT_Pay *ph;
 
       /**
-       * Set to the transaction ID of the respective contract.
+       * Hashcode of the proposal data associated to this payment.
        */
-      uint64_t transaction_id;
+      struct GNUNET_HashCode h_proposal_data;
 
       /**
        * Merchant's public key
@@ -542,6 +538,9 @@ struct Command
 
       /**
        * #OC_PAY command which we expect in the result.
+       * Since we are tracking a bank transaction, we want to know
+       * which (Taler) deposit is associated with the bank
+       * transaction being tracked now.
        */
       char *expected_pay_ref;
 
@@ -1015,8 +1014,7 @@ reserve_withdraw_cb (void *cls,
 
 
 /**
- * Callbacks of this type are used to serve the result of submitting a
- * /contract request to a merchant.
+ * Callback that works PUT /proposal's output.
  *
  * @param cls closure
  * @param http_status HTTP response code, 200 indicates success;
@@ -1024,33 +1022,34 @@ reserve_withdraw_cb (void *cls,
  * @param ec taler-specific error code
  * @param obj the full received JSON reply, or
  *            error details if the request failed
- * @param contract completed contract, NULL on error
+ * @param proposal_data the order + additional information provided by the
+ * backend, NULL on error.
  * @param sig merchant's signature over the contract, NULL on error
  * @param h_contract hash of the contract, NULL on error
  */
 static void
-contract_cb (void *cls,
+proposal_cb (void *cls,
              unsigned int http_status,
             enum TALER_ErrorCode ec,
              const json_t *obj,
-             const json_t *contract,
+             const json_t *proposal_data,
              const struct TALER_MerchantSignatureP *sig,
-             const struct GNUNET_HashCode *h_contract)
+             const struct GNUNET_HashCode *hash)
 {
   struct InterpreterState *is = cls;
   struct Command *cmd = &is->commands[is->ip];
 
-  cmd->details.contract.co = NULL;
+  cmd->details.proposal.po = NULL;
   switch (http_status)
   {
   case MHD_HTTP_OK:
-    cmd->details.contract.contract = json_incref ((json_t *) contract);
-    cmd->details.contract.merchant_sig = *sig;
-    cmd->details.contract.h_contract = *h_contract;
+    cmd->details.proposal.proposal_data = json_incref ((json_t *) 
proposal_data);
+    cmd->details.proposal.merchant_sig = *sig;
+    cmd->details.proposal.hash = *hash;
     break;
   default:
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "/contract responded with unexpected status code %u in step 
%u\n",
+                "unexpected status code from /proposal: %u. Step %u\n",
                 http_status,
                 is->ip);
     json_dumpf (obj, stderr, 0);
@@ -1082,7 +1081,7 @@ pay_cb (void *cls,
   struct Command *cmd = &is->commands[is->ip];
   struct PaymentResponsePS mr;
   struct GNUNET_CRYPTO_EddsaSignature sig;
-  struct GNUNET_HashCode h_contract;
+  struct GNUNET_HashCode h_proposal_data;
   const char *error_name;
   unsigned int error_line;
 
@@ -1101,8 +1100,8 @@ pay_cb (void *cls,
   {
     /* Check signature */
     struct GNUNET_JSON_Specification spec[] = {
-      GNUNET_JSON_spec_fixed_auto ("merchant_sig", &sig),
-      GNUNET_JSON_spec_fixed_auto ("h_contract", &h_contract),
+      GNUNET_JSON_spec_fixed_auto ("sig", &sig),
+      GNUNET_JSON_spec_fixed_auto ("h_proposal_data", &h_proposal_data),
       GNUNET_JSON_spec_end ()
     };
     if (GNUNET_OK !=
@@ -1121,7 +1120,7 @@ pay_cb (void *cls,
     }
     mr.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_PAYMENT_OK);
     mr.purpose.size = htonl (sizeof (mr));
-    mr.h_contract = h_contract;
+    mr.h_proposal_data = h_proposal_data;
     if (GNUNET_OK !=
         GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_PAYMENT_OK,
                                     &mr.purpose,
@@ -1212,18 +1211,31 @@ track_transfer_cb (void *cls,
       unsigned int i;
       int found;
 
+      /**
+       * Retrieve the deposit operation that is supposed
+       * to have been paid by the wtid used in this operation.
+       * After that, check if that operation is actually mentioned
+       * in the returned data.
+       */
       ref = find_command (is,
                           cmd->details.track_transfer.expected_pay_ref);
       GNUNET_assert (NULL != ref);
       found = GNUNET_NO;
+
+      /**
+       * Iterating over the details makes little sense now,
+       * as each payment involves exatcly one coin.
+       */
       for (i=0;i<details_length;i++)
       {
         struct TALER_Amount amount_with_fee;
         struct TALER_Amount amount_without_fee;
         struct TALER_Amount deposit_fee;
         const struct Command *cref;
+        const struct Command *proposal_ref;
         struct TALER_CoinSpendPublicKeyP coin_pub;
 
+        /* Extract */
         GNUNET_assert (GNUNET_OK ==
                        TALER_string_to_amount 
(ref->details.pay.amount_without_fee,
                                                &amount_without_fee));
@@ -1235,20 +1247,28 @@ track_transfer_cb (void *cls,
                                               &amount_with_fee,
                                               &amount_without_fee));
 
+        /* Find coin ('s public key) associated with the retrieved
+           deposit. Yes, one deposit - one coin. */
        cref = find_command (is,
                              ref->details.pay.coin_ref);
+        proposal_ref = find_command (is,
+                                     ref->details.pay.contract_ref);
         GNUNET_assert (NULL != cref);
+        GNUNET_assert (NULL != proposal_ref);
        switch (cref->oc)
        {
        case OC_WITHDRAW_SIGN:
-          GNUNET_CRYPTO_eddsa_key_get_public 
(&cref->details.reserve_withdraw.coin_priv.eddsa_priv,
-                                              &coin_pub.eddsa_pub);
+          GNUNET_CRYPTO_eddsa_key_get_public
+            (&cref->details.reserve_withdraw.coin_priv.eddsa_priv,
+             &coin_pub.eddsa_pub);
          break;
        default:
          GNUNET_assert (0);
        }
 
-        if ( (details[i].transaction_id == ref->details.pay.transaction_id) &&
+        if ( (0 == memcmp (&details[i].h_proposal_data,
+                           &proposal_ref->details.proposal.hash,
+                           sizeof (struct GNUNET_HashCode))) &&
              (0 == TALER_amount_cmp (&details[i].coin_value,
                                      &amount_with_fee)) &&
              (0 == TALER_amount_cmp (&details[i].coin_fee,
@@ -1274,21 +1294,21 @@ track_transfer_cb (void *cls,
 }
 
 /**
- * Callback for /map/in issued at backend. Just check
+ * Callback for GET /proposal issued at backend. Just check
  * whether response code is as expected.
  *
  * @param cls closure
  * @param http_status HTTP status code we got
  */
 static void
-map_cb (void *cls,
-        unsigned int http_status,
-        const json_t *json)
+proposal_lookup_cb (void *cls,
+                    unsigned int http_status,
+                    const json_t *json)
 {
   struct InterpreterState *is = cls;
   struct Command *cmd = &is->commands[is->ip];
   
-  cmd->details.map.mo = NULL;
+  cmd->details.proposal_lookup.plo = NULL;
 
   if (cmd->expected_response_code != http_status)
     fail (is);
@@ -1481,71 +1501,44 @@ interpreter_run (void *cls)
              cmd->oc);
   switch (cmd->oc)
   {
-  case OC_END:
-    result = GNUNET_OK;
-    if (instance_idx + 1 == ninstances)
-    {
-      GNUNET_SCHEDULER_shutdown ();
+    case OC_END:
+      result = GNUNET_OK;
+      if (instance_idx + 1 == ninstances)
+      {
+        GNUNET_SCHEDULER_shutdown ();
+        return;
+      }
+      is->ip = 0;
+      instance_idx++;
+      instance = instances[instance_idx];
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                  "Switching instance: '%s'\n",
+                  instance);
+  
+      is->task = GNUNET_SCHEDULER_add_now (interpreter_run,
+                                           is);
       return;
-    }
-    is->ip = 0;
-    instance_idx++;
-    instance = instances[instance_idx];
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "Switching instance: '%s'\n",
-                instance);
 
-    is->task = GNUNET_SCHEDULER_add_now (interpreter_run,
-                                         is);
-    return;
-
-  case OC_MAP_IN:
-  case OC_MAP_OUT:
-  {
-    struct GNUNET_HashCode h_proposal;
-    json_error_t error;
-    json_t *proposal; 
-
-    GNUNET_assert (NULL != cmd->details.map.contract_reference);
-    ref = find_command (is, cmd->details.map.contract_reference);
-    GNUNET_assert (NULL != ref);
-
-    /**
-     * WARNING, make sure what is hashed here, is exactly the same
-     * contract hashed then by /map/in handler.
-     */
-    proposal = json_loads (ref->details.contract.proposal,
-                           JSON_REJECT_DUPLICATES,
-                           &error);
-
-    GNUNET_assert (GNUNET_SYSERR !=
-                   TALER_JSON_hash (proposal, &h_proposal));
-
-    if (OC_MAP_IN == cmd->oc)
+    case OC_PROPOSAL_LOOKUP:
     {
-
-      if (MHD_HTTP_UNPROCESSABLE_ENTITY == cmd->expected_response_code)
-        RND_BLK (&h_proposal);
-
+      const char *order_id;
+  
+      GNUNET_assert (NULL != cmd->details.proposal_lookup.proposal_reference);
+      ref = find_command (is, cmd->details.proposal_lookup.proposal_reference);
+      GNUNET_assert (NULL != ref);
+  
+      order_id =
+        json_string_value (json_object_get 
(ref->details.proposal.proposal_data,
+                                            "order_id"));
       GNUNET_assert (NULL !=
-                      (cmd->details.map.mo
-                       = TALER_MERCHANT_map_in (ctx,
-                                                MERCHANT_URI,
-                                                proposal,
-                                                &h_proposal,
-                                                map_cb,
-                                                is)));
+                      (cmd->details.proposal_lookup.plo
+                       = TALER_MERCHANT_proposal_lookup (ctx,
+                                                         MERCHANT_URI,
+                                                         order_id,
+                                                         proposal_lookup_cb,
+                                                         is)));
     }
-   else
-     GNUNET_assert (NULL !=
-                     (cmd->details.map.mo 
-                      = TALER_MERCHANT_map_out (ctx,
-                                                MERCHANT_URI,
-                                                &h_proposal,
-                                                map_cb,
-                                                is)));
   
-  }
     return;
 
   case OC_ADMIN_ADD_INCOMING:
@@ -1704,14 +1697,14 @@ interpreter_run (void *cls)
       return;
     }
     return;
-  case OC_CONTRACT:
+  case OC_PROPOSAL:
     {
-      json_t *proposal;
+      json_t *order;
       json_error_t error;
 
-      proposal = json_loads (cmd->details.contract.proposal,
-                             JSON_REJECT_DUPLICATES,
-                             &error);
+      order = json_loads (cmd->details.proposal.order,
+                          JSON_REJECT_DUPLICATES,
+                          &error);
       if (NULL != instance)
       {
 
@@ -1721,61 +1714,62 @@ interpreter_run (void *cls)
         json_object_set_new (merchant,
                              "instance",
                              json_string (instance));
-        json_object_set (proposal, "merchant", merchant);
+        json_object_set (order, "merchant", merchant);
       }
-      if (NULL == proposal)
+      if (NULL == order)
       {
         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                    "Failed to parse proposal `%s' at command #%u: %s at %u\n",
-                    cmd->details.contract.proposal,
+                    "Failed to parse the order `%s' at command #%u: %s at 
%u\n",
+                    cmd->details.proposal.order,
                     is->ip,
                     error.text,
                     (unsigned int) error.column);
         fail (is);
         return;
       }
-      cmd->details.contract.co
-        = TALER_MERCHANT_contract_sign (ctx,
-                                        MERCHANT_URI,
-                                        proposal,
-                                        &contract_cb,
-                                        is);
-      if (NULL == cmd->details.contract.co)
+      cmd->details.proposal.po
+        = TALER_MERCHANT_order_put (ctx,
+                                    MERCHANT_URI,
+                                    order,
+                                    &proposal_cb,
+                                    is);
+      json_decref (order);
+      if (NULL == cmd->details.proposal.po)
       {
         GNUNET_break (0);
-        json_decref (proposal);
         fail (is);
         return;
       }
-      json_decref (proposal);
       return;
     }
   case OC_PAY:
     {
       struct TALER_MERCHANT_PayCoin pc;
-      uint64_t transaction_id;
+      const char *order_id;
       struct GNUNET_TIME_Absolute refund_deadline;
       struct GNUNET_TIME_Absolute pay_deadline;
       struct GNUNET_TIME_Absolute timestamp;
       struct GNUNET_HashCode h_wire;
       struct TALER_MerchantPublicKeyP merchant_pub;
       struct TALER_MerchantSignatureP merchant_sig;
-      struct GNUNET_HashCode h_contract;
       struct TALER_Amount total_amount;
       struct TALER_Amount max_fee;
       const char *error_name;
       unsigned int error_line;
 
-      /* get amount */
+      /* get proposal */
       ref = find_command (is,
                           cmd->details.pay.contract_ref);
       GNUNET_assert (NULL != ref);
-      merchant_sig = ref->details.contract.merchant_sig;
-      GNUNET_assert (NULL != ref->details.contract.contract);
+      merchant_sig = ref->details.proposal.merchant_sig;
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Depositing I on '%s'\n",
+                  GNUNET_h2s (&ref->details.proposal.hash));
+      GNUNET_assert (NULL != ref->details.proposal.proposal_data);
       {
         /* Get information that need to be replied in the deposit permission */
         struct GNUNET_JSON_Specification spec[] = {
-          GNUNET_JSON_spec_uint64 ("transaction_id", &transaction_id),
+          GNUNET_JSON_spec_string ("order_id", &order_id),
           GNUNET_JSON_spec_absolute_time ("refund_deadline", &refund_deadline),
           GNUNET_JSON_spec_absolute_time ("pay_deadline", &pay_deadline),
           GNUNET_JSON_spec_absolute_time ("timestamp", &timestamp),
@@ -1787,7 +1781,7 @@ interpreter_run (void *cls)
         };
 
         if (GNUNET_OK !=
-            GNUNET_JSON_parse (ref->details.contract.contract,
+            GNUNET_JSON_parse (ref->details.proposal.proposal_data,
                                spec,
                                &error_name,
                                &error_line))
@@ -1800,26 +1794,22 @@ interpreter_run (void *cls)
           fail (is);
           return;
         }
-        cmd->details.pay.transaction_id = transaction_id;
         cmd->details.pay.merchant_pub = merchant_pub;
       }
 
-      TALER_JSON_hash (ref->details.contract.contract,
-                      &h_contract);
-
-      /* initialize 'pc' (FIXME: to do in a loop later...) */
       {
+        const struct Command *coin_ref;
        memset (&pc, 0, sizeof (pc));
-       ref = find_command (is,
-                           cmd->details.pay.coin_ref);
+       coin_ref = find_command (is,
+                                cmd->details.pay.coin_ref);
        GNUNET_assert (NULL != ref);
-       switch (ref->oc)
+       switch (coin_ref->oc)
        {
        case OC_WITHDRAW_SIGN:
-         pc.coin_priv = ref->details.reserve_withdraw.coin_priv;
-         pc.denom_pub = ref->details.reserve_withdraw.pk->key;
-         pc.denom_sig = ref->details.reserve_withdraw.sig;
-          pc.denom_value = ref->details.reserve_withdraw.pk->value;
+         pc.coin_priv = coin_ref->details.reserve_withdraw.coin_priv;
+         pc.denom_pub = coin_ref->details.reserve_withdraw.pk->key;
+         pc.denom_sig = coin_ref->details.reserve_withdraw.sig;
+          pc.denom_value = coin_ref->details.reserve_withdraw.pk->value;
          break;
        default:
          GNUNET_assert (0);
@@ -1849,12 +1839,16 @@ interpreter_run (void *cls)
          return;
        }
       }
+
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Depositing II on '%s'\n",
+                  GNUNET_h2s (&ref->details.proposal.hash));
+
       cmd->details.pay.ph
        = TALER_MERCHANT_pay_wallet (ctx,
                                     MERCHANT_URI,
                                      instance,
-                                    &h_contract,
-                                    transaction_id,
+                                    &ref->details.proposal.hash,
                                     &total_amount,
                                     &max_fee,
                                     &merchant_pub,
@@ -1955,17 +1949,25 @@ interpreter_run (void *cls)
                                      is);
     return;
   case OC_TRACK_TRANSACTION:
+  {
+    const struct Command *proposal_ref;
+    const char *order_id;
+
     ref = find_command (is,
                         cmd->details.track_transaction.pay_ref);
     GNUNET_assert (NULL != ref);
-    /*FIXME check/assert return code */
+    proposal_ref = find_command (is,
+                                 ref->details.pay.contract_ref);
+    order_id = json_string_value (json_object_get 
(proposal_ref->details.proposal.proposal_data,
+                                        "order_id"));
     cmd->details.track_transaction.tth =
       TALER_MERCHANT_track_transaction (ctx,
                                         MERCHANT_URI,
-                                        instance, /* got it NULL, right now */
-                                        ref->details.pay.transaction_id,
+                                        instance,
+                                        order_id,
                                         &track_transaction_cb,
                                         is);
+  }
     return;
   case OC_HISTORY:
 
@@ -2033,15 +2035,14 @@ do_shutdown (void *cls)
     case OC_END:
       GNUNET_assert (0);
       break;
-    case OC_MAP_IN:
-    case OC_MAP_OUT:
-      if (NULL != cmd->details.map.mo)
+    case OC_PROPOSAL_LOOKUP:
+      if (NULL != cmd->details.proposal_lookup.plo)
       {
         GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                     "Command %u (%s) did not complete\n",
                     i,
                     cmd->label);
-        TALER_MERCHANT_map_cancel (cmd->details.map.mo);
+        TALER_MERCHANT_proposal_lookup_cancel 
(cmd->details.proposal_lookup.plo);
       }
         break;
 
@@ -2083,20 +2084,20 @@ do_shutdown (void *cls)
         cmd->details.reserve_withdraw.sig.rsa_signature = NULL;
       }
       break;
-    case OC_CONTRACT:
-      if (NULL != cmd->details.contract.co)
+    case OC_PROPOSAL:
+      if (NULL != cmd->details.proposal.po)
       {
         GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                     "Command %u (%s) did not complete\n",
                     i,
                     cmd->label);
-        TALER_MERCHANT_contract_sign_cancel (cmd->details.contract.co);
-        cmd->details.contract.co = NULL;
+        TALER_MERCHANT_proposal_cancel (cmd->details.proposal.po);
+        cmd->details.proposal.po = NULL;
       }
-      if (NULL != cmd->details.contract.contract)
+      if (NULL != cmd->details.proposal.proposal_data)
       {
-        json_decref (cmd->details.contract.contract);
-        cmd->details.contract.contract = NULL;
+        json_decref (cmd->details.proposal.proposal_data);
+        cmd->details.proposal.proposal_data = NULL;
       }
       break;
     case OC_PAY:
@@ -2278,14 +2279,14 @@ run (void *cls)
       .expected_response_code = MHD_HTTP_OK,
       .details.reserve_status.reserve_reference = "create-reserve-1",
       .details.reserve_status.expected_balance = "EUR:0" },
-    /* Create contract */
-    { .oc = OC_CONTRACT,
-      .label = "create-contract-1",
+    /* Create proposal */
+    { .oc = OC_PROPOSAL,
+      .label = "create-proposal-1",
       .expected_response_code = MHD_HTTP_OK,
-      .details.contract.proposal = "{\
+      .details.proposal.order = "{\
                   \"max_fee\":\
                      {\"currency\":\"EUR\", \"value\":0, 
\"fraction\":50000000},\
-                  \"transaction_id\":1,\
+                  \"order_id\":\"1\",\
                   \"timestamp\":\"\\/Date(42)\\/\",\
                   \"refund_deadline\":\"\\/Date(0)\\/\",\
                   \"pay_deadline\":\"\\/Date(9999999999)\\/\",\
@@ -2296,26 +2297,20 @@ run (void *cls)
     { .oc = OC_PAY,
       .label = "deposit-simple",
       .expected_response_code = MHD_HTTP_OK,
-      .details.pay.contract_ref = "create-contract-1",
+      .details.pay.contract_ref = "create-proposal-1",
       .details.pay.coin_ref = "withdraw-coin-1",
       .details.pay.amount_with_fee = "EUR:5",
       .details.pay.amount_without_fee = "EUR:4.99" },
 
-    /* Store contract-1 */
-    {
-      .oc = OC_MAP_IN, 
-      .label = "store-contract-1",
-      .expected_response_code = MHD_HTTP_OK,
-      .details.map.contract_reference = "create-contract-1" },
 
     /* Create another contract */
-    { .oc = OC_CONTRACT,
-      .label = "create-contract-2",
+    { .oc = OC_PROPOSAL,
+      .label = "create-proposal-2",
       .expected_response_code = MHD_HTTP_OK,
-      .details.contract.proposal = "{\
+      .details.proposal.order = "{\
                   \"max_fee\":\
                      {\"currency\":\"EUR\", \"value\":0, 
\"fraction\":50000000},\
-                  \"transaction_id\":2,\
+                  \"order_id\":\"2\",\
                   \"timestamp\":\"\\/Date(42)\\/\",\
                   \"refund_deadline\":\"\\/Date(0)\\/\",\
                   \"pay_deadline\":\"\\/Date(9999999999)\\/\",\
@@ -2328,7 +2323,7 @@ run (void *cls)
     { .oc = OC_PAY,
       .label = "deposit-double-2",
       .expected_response_code = MHD_HTTP_FORBIDDEN,
-      .details.pay.contract_ref = "create-contract-2",
+      .details.pay.contract_ref = "create-proposal-2",
       .details.pay.coin_ref = "withdraw-coin-1",
       .details.pay.amount_with_fee = "EUR:5",
       .details.pay.amount_without_fee = "EUR:4.99" },
@@ -2341,14 +2336,6 @@ run (void *cls)
       .details.admin_add_incoming.transfer_details = "{ \"uuid\": 2}",
       .details.admin_add_incoming.amount = "EUR:1" },
 
-    /* Store contract-1 */
-    {
-      .oc = OC_MAP_IN, 
-      .label = "store-contract-2",
-      .expected_response_code = MHD_HTTP_OK,
-      .details.map.contract_reference = "create-contract-2",
-    },
-
     /* Add another 4.01 EUR to reserve #2 */
     { .oc = OC_ADMIN_ADD_INCOMING,
       .label = "create-reserve-2b",
@@ -2367,10 +2354,10 @@ run (void *cls)
 
     /* Fetch contract-1 */
     {
-      .oc = OC_MAP_OUT, 
-      .label = "fetch-contract-2",
+      .oc = OC_PROPOSAL_LOOKUP, 
+      .label = "fetch-proposal-2",
       .expected_response_code = MHD_HTTP_OK,
-      .details.map.contract_reference = "create-contract-2" },
+      .details.proposal_lookup.proposal_reference = "create-proposal-2" },
 
     /* Check nothing happened on the bank side so far */
     { .oc = OC_CHECK_BANK_TRANSFERS_EMPTY,
@@ -2407,41 +2394,15 @@ run (void *cls)
       .details.track_transfer.expected_pay_ref = "deposit-simple"
     },
 
-    /* Trace transaction to WTID */
-    { .oc = OC_TRACK_TRANSACTION,
-      .label = "track-transaction-1",
-      .expected_response_code = MHD_HTTP_OK,
-      .details.track_transaction.pay_ref = "deposit-simple",
-      .details.track_transaction.expected_transfer_ref = 
"check_bank_transfer-499c"
-    },
-    { .oc = OC_TRACK_TRANSACTION,
-      .label = "track-transaction-1-again",
-      .expected_response_code = MHD_HTTP_OK,
-      .details.track_transaction.pay_ref = "deposit-simple",
-      .details.track_transaction.expected_transfer_ref = 
"check_bank_transfer-499c"
-    },
-
     /* Pay again successfully on 2nd contract */
     { .oc = OC_PAY,
       .label = "deposit-simple-2",
       .expected_response_code = MHD_HTTP_OK,
-      .details.pay.contract_ref = "create-contract-2",
+      .details.pay.contract_ref = "create-proposal-2",
       .details.pay.coin_ref = "withdraw-coin-2",
       .details.pay.amount_with_fee = "EUR:5",
       .details.pay.amount_without_fee = "EUR:4.99" },
 
-    /* Check "failure" to trace transaction to WTID before aggregator */
-    { .oc = OC_TRACK_TRANSACTION,
-      .label = "track-transaction-2-found",
-      .expected_response_code = MHD_HTTP_ACCEPTED,
-      .details.track_transaction.pay_ref = "deposit-simple-2"
-    },
-    { .oc = OC_TRACK_TRANSACTION,
-      .label = "track-transaction-2-found-again",
-      .expected_response_code = MHD_HTTP_ACCEPTED,
-      .details.track_transaction.pay_ref = "deposit-simple-2"
-    },
-
     /* Run transfers. */
     { .oc = OC_RUN_AGGREGATOR,
       .label = "run-aggregator-2" },
@@ -2458,20 +2419,6 @@ run (void *cls)
     { .oc = OC_CHECK_BANK_TRANSFERS_EMPTY,
       .label = "check_bank_empty" },
 
-    /* This time, invert the order in which we do the tracing */
-    /* Trace transaction to WTID */
-    { .oc = OC_TRACK_TRANSACTION,
-      .label = "track-transaction-2",
-      .expected_response_code = MHD_HTTP_OK,
-      .details.track_transaction.pay_ref = "deposit-simple-2",
-      .details.track_transaction.expected_transfer_ref = 
"check_bank_transfer-499c-2"
-    },
-    { .oc = OC_TRACK_TRANSACTION,
-      .label = "track-transaction-2-again", .expected_response_code = 
MHD_HTTP_OK,
-      .details.track_transaction.pay_ref = "deposit-simple-2",
-      .details.track_transaction.expected_transfer_ref = 
"check_bank_transfer-499c-2"
-    },
-
     /* Trace the WTID back to the original transaction */
     { .oc = OC_TRACK_TRANSFER,
       .label = "track-transfer-2",
@@ -2501,34 +2448,7 @@ run (void *cls)
       .details.history.date.abs_value_us = 43 * 1000LL * 1000LL,
       .details.history.nresult = 0
     },
-    /* Retrieve via /map/out a contract NOT stored previously. */
-    {
-      .oc = OC_MAP_OUT, 
-      .label = "fetch-contract-not-found",
-      .expected_response_code = MHD_HTTP_NOT_FOUND,
-      .details.map.contract_reference = "create-contract-3" },
-
-    /* Create another contract, NOT to be stored. */
-    { .oc = OC_CONTRACT,
-      .label = "create-contract-3",
-      .expected_response_code = MHD_HTTP_OK,
-      .details.contract.proposal = "{\
-                  \"max_fee\":\
-                     {\"currency\":\"EUR\", \"value\":0, \"fraction\":10000},\
-                  \"transaction_id\":3,\
-                  \"timestamp\":\"\\/Date(42)\\/\",\
-                  \"refund_deadline\":\"\\/Date(0)\\/\",\
-                  \"pay_deadline\":\"\\/Date(0)\\/\",\
-                  \"amount\":{\"currency\":\"EUR\", \"value\":1, 
\"fraction\":0},\
-                  \"products\":\
-                     [ {\"description\":\"bogus\", \"value\":\"{EUR:1}\"} ] }" 
},
 
-    /* Try to store a contract passing a bogus hashcode. */
-    {
-      .oc = OC_MAP_IN, 
-      .label = "store-contract-bogus",
-      .expected_response_code = MHD_HTTP_UNPROCESSABLE_ENTITY,
-      .details.map.contract_reference = "create-contract-3" },
     /* end of testcase */
     { .oc = OC_END }
   };
@@ -2687,6 +2607,7 @@ main (int argc,
                                        "taler-merchant-httpd",
                                        "taler-merchant-httpd",
                                        "-c", "test_merchant_api.conf",
+                                       "-L", "DEBUG",
                                        NULL);
   if (NULL == merchantd)
   {
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
deleted file mode 100644
index 1428589..0000000
--- a/src/tests/Makefile.am
+++ /dev/null
@@ -1,25 +0,0 @@
-# This Makefile.am is in the public domain
-AM_CPPFLAGS = -I$(top_srcdir)/src/include -I$(top_srcdir)/src/backend-lib/
-
-bin_PROGRAMS = \
-  test-contract
-
-#merchant_contract_test_CFLAGS = \
-#  -Wl,--verbose
-
-test_contract_SOURCES = \
-  test_contract.c \
-  ../backend/merchant.c \
-  ../backend-lib/merchant_db.c ../backend-lib/merchant_db.h
-
-test_contract_LDADD = \
-  $(LIBGCRYPT_LIBS) \
-  -ltalerutil \
-  -ljansson \
-  -lgnunetutil \
-  -ltalerexchange \
-  -ltalerpq \
-  -lgnunetpostgres \
-  -lpq \
-  $(top_srcdir)/src/backend-lib/libtalermerchant.la \
-  -lpthread
diff --git a/src/tests/deposit_permission.sample 
b/src/tests/deposit_permission.sample
deleted file mode 100644
index 668d004..0000000
--- a/src/tests/deposit_permission.sample
+++ /dev/null
@@ -1,31 +0,0 @@
-{
-    "transaction_id" : 1,
-    "timestamp": "\/Date(1447334003)\/",
-    "H_wire": 
"V1F0F5AWSNX60E6TXZEYDZRE84J8HMBGXEM09AEVV3N97MM75P6JQRSWR5KQVC1RBBF2SRXY7P10H0ZM0VETWPFAJJRBVJSXNMDWTYR",
-    "merchant_pub": "BQ0TMTBV2XEJ8G2PXA9KRDD5WDT5EV29KPVS6J9RBQJCS8BCPQ70",
-    "exchange": "localexchange",
-    "coins": [
-        {
-            "f": {
-                "value": 0,
-                "fraction": 100000,
-                "currency": "KUDOS"
-            },
-            "coin_pub": "AH86D5WV9G6RT0A3CHYJW598BNMH8848GAKYTEH1JX6X2BKZWTX0",
-            "denom_pub": 
"51R7ARKCD5HJTTV5F4G0M818E9SP280A40G2GVH04CR30HHG74SM8GSM6D33EGSR84R46E246H23GCHK690M4G9R8GS4CD9S8GRMCDSP64T34GA56GV34DA3851M6H9S6MWK8H9K8D13CD1M85344GSP61244GT28N132HA56N1MCHA56513AD2160RK2CSN6D23AGJ56X33AGSM68W4CH1S88WK4D1H68SMACHJ88TM2CA28MRM4D248GS4ADHR8GSM4C2364V38E1N88S30HA564TKJE1N750KGC9R6RTKJE2370R4AC268D0MACHN6N242D1N68TKAC1M65234DJ26CRK4D9M8MSK6C9J64R32D1R70VKEE25852MCG9N84W32GJ68914CD1J691M6GA360S3GCHP8GWK8HHH68TK8CSK70S4AE9N712K0H9K6X34AC9354520818CM
 [...]
-            "ub_sig": 
"51SPJSSDESGPR80A40M74WV140520818ECG26C9J8D1MCHHJ84S34H1K8H1M6HHN60V3GH9S84R3GH9K6MVM6GSM70RKCDT188VM4CHM74RM8GSN6GSKEHHS6CT44H9Q8CWKCD1P68SK2G9S8GR34D1P60T4CCJ67523EDJ28S1KJD9N8H330CT58RS38CSM8H346GT58N13CGJ16GS34CHQ6GT42CSS6CTM4C9H8N1KCG9G74T36C1K8GT44E1N8RRK0D218GV46G9R6CT4CHA4890M6H1H8GV34E1Q8N244DHM8CRK2H1R8CV3ADA37113JDHR88W36E9R61242GT5752KEE9R84WK8H9G8GT34GT26S2MAE1P70RMAGSK74W30C1J60S32GSK64WKAC218MWM6GHM8S332DSN70SM2DHR6H146E228CTM8D135452081918G2J2G0",
-            "coin_sig": 
"MFTHC54GFYHA3CGKHC8SSDSTYX8YMEJDNQA7AEY5M7JBK3WPDQ9NCJ54ZSPQRZ4QCJC0CPREP0XRWH9JQ509ENSEXWKNNM5FEVRG238"
-        },
-        {
-            "f": {
-                "value": 0,
-                "fraction": 100000,
-                "currency": "KUDOS"
-            },
-            "coin_pub": "MQY067A8AGG90TSH11C8JNRW8P1R669JAAQX4V2HGFHGJ2WY4ZA0",
-            "denom_pub": 
"51R7ARKCD5HJTTV5F4G0M818E9SP280A40G2GVH04CR30HHG74SM8GSM6D33EGSR84R46E246H23GCHK690M4G9R8GS4CD9S8GRMCDSP64T34GA56GV34DA3851M6H9S6MWK8H9K8D13CD1M85344GSP61244GT28N132HA56N1MCHA56513AD2160RK2CSN6D23AGJ56X33AGSM68W4CH1S88WK4D1H68SMACHJ88TM2CA28MRM4D248GS4ADHR8GSM4C2364V38E1N88S30HA564TKJE1N750KGC9R6RTKJE2370R4AC268D0MACHN6N242D1N68TKAC1M65234DJ26CRK4D9M8MSK6C9J64R32D1R70VKEE25852MCG9N84W32GJ68914CD1J691M6GA360S3GCHP8GWK8HHH68TK8CSK70S4AE9N712K0H9K6X34AC9354520818CM
 [...]
-            "ub_sig": 
"51SPJSSDESGPR80A40M74WV140520818ECG26H1J60R4AHHG6N1KEC268N23ECT664VKAGSJ8GRK4CA56H2KAH1H8CS4AHA188SKJE266RR3EDA58N148DSS74TM6CA58N24AC9K6X1M4C9Q6RW48CT674SMCE2264V42CSH8D336GSQ84SM6CT564TKECSR8MRMAGHG8GW3JEA56WT32D9S8H334DJ564SK8GSS60WM6E1P8S346H238GRM8DSN6MR36C256GVM8H9M6WV30C246X0MCH9R84TK2D1M70V44CA260VKJGHN6RR4ACT488R3GCA46MW3GDHK6GWMAHHP6S242H9G6D134D9N8RV32DSJ8GSKGC1J6RTK2GHQ8H0K2DHH6WT38GSH74WM4EA574RKEE1M6D0M4DHK8MW4ACT68CT4CE236H236GH35452081918G2J2G0",
-            "coin_sig": 
"K9S5273GT4QKF5Y9FYJ62BV710WGEFE1DSXV75A37X272ADWBCV0ERZV9TF2VYTCSH1837R3F7A39R5QEPCC0NYW3JQ5S70X8MJG008"
-        }
-    ]
-}
diff --git a/src/tests/deposit_permission_backend.sample 
b/src/tests/deposit_permission_backend.sample
deleted file mode 100644
index a2e6058..0000000
--- a/src/tests/deposit_permission_backend.sample
+++ /dev/null
@@ -1,36 +0,0 @@
-{
-    "transaction_id" : 1,
-    "timestamp": "\/Date(1447334003)\/",
-    "H_wire": 
"V1F0F5AWSNX60E6TXZEYDZRE84J8HMBGXEM09AEVV3N97MM75P6JQRSWR5KQVC1RBBF2SRXY7P10H0ZM0VETWPFAJJRBVJSXNMDWTYR",
-    "merchant_pub": "BQ0TMTBV2XEJ8G2PXA9KRDD5WDT5EV29KPVS6J9RBQJCS8BCPQ70",
-    "exchange": "demo.taler.net",
-    "coins": [
-        {
-            "f": {
-                "value": 0,
-                "fraction": 100000,
-                "currency": "KUDOS"
-            },
-            "coin_pub": "AH86D5WV9G6RT0A3CHYJW598BNMH8848GAKYTEH1JX6X2BKZWTX0",
-            "denom_pub": 
"51R7ARKCD5HJTTV5F4G0M818E9SP280A40G2GVH04CR30HHG74SM8GSM6D33EGSR84R46E246H23GCHK690M4G9R8GS4CD9S8GRMCDSP64T34GA56GV34DA3851M6H9S6MWK8H9K8D13CD1M85344GSP61244GT28N132HA56N1MCHA56513AD2160RK2CSN6D23AGJ56X33AGSM68W4CH1S88WK4D1H68SMACHJ88TM2CA28MRM4D248GS4ADHR8GSM4C2364V38E1N88S30HA564TKJE1N750KGC9R6RTKJE2370R4AC268D0MACHN6N242D1N68TKAC1M65234DJ26CRK4D9M8MSK6C9J64R32D1R70VKEE25852MCG9N84W32GJ68914CD1J691M6GA360S3GCHP8GWK8HHH68TK8CSK70S4AE9N712K0H9K6X34AC9354520818CM
 [...]
-            "ub_sig": 
"51SPJSSDESGPR80A40M74WV140520818ECG26C9J8D1MCHHJ84S34H1K8H1M6HHN60V3GH9S84R3GH9K6MVM6GSM70RKCDT188VM4CHM74RM8GSN6GSKEHHS6CT44H9Q8CWKCD1P68SK2G9S8GR34D1P60T4CCJ67523EDJ28S1KJD9N8H330CT58RS38CSM8H346GT58N13CGJ16GS34CHQ6GT42CSS6CTM4C9H8N1KCG9G74T36C1K8GT44E1N8RRK0D218GV46G9R6CT4CHA4890M6H1H8GV34E1Q8N244DHM8CRK2H1R8CV3ADA37113JDHR88W36E9R61242GT5752KEE9R84WK8H9G8GT34GT26S2MAE1P70RMAGSK74W30C1J60S32GSK64WKAC218MWM6GHM8S332DSN70SM2DHR6H146E228CTM8D135452081918G2J2G0",
-            "coin_sig": 
"MFTHC54GFYHA3CGKHC8SSDSTYX8YMEJDNQA7AEY5M7JBK3WPDQ9NCJ54ZSPQRZ4QCJC0CPREP0XRWH9JQ509ENSEXWKNNM5FEVRG238"
-        },
-        {
-            "f": {
-                "value": 0,
-                "fraction": 100000,
-                "currency": "KUDOS"
-            },
-            "coin_pub": "MQY067A8AGG90TSH11C8JNRW8P1R669JAAQX4V2HGFHGJ2WY4ZA0",
-            "denom_pub": 
"51R7ARKCD5HJTTV5F4G0M818E9SP280A40G2GVH04CR30HHG74SM8GSM6D33EGSR84R46E246H23GCHK690M4G9R8GS4CD9S8GRMCDSP64T34GA56GV34DA3851M6H9S6MWK8H9K8D13CD1M85344GSP61244GT28N132HA56N1MCHA56513AD2160RK2CSN6D23AGJ56X33AGSM68W4CH1S88WK4D1H68SMACHJ88TM2CA28MRM4D248GS4ADHR8GSM4C2364V38E1N88S30HA564TKJE1N750KGC9R6RTKJE2370R4AC268D0MACHN6N242D1N68TKAC1M65234DJ26CRK4D9M8MSK6C9J64R32D1R70VKEE25852MCG9N84W32GJ68914CD1J691M6GA360S3GCHP8GWK8HHH68TK8CSK70S4AE9N712K0H9K6X34AC9354520818CM
 [...]
-            "ub_sig": 
"51SPJSSDESGPR80A40M74WV140520818ECG26H1J60R4AHHG6N1KEC268N23ECT664VKAGSJ8GRK4CA56H2KAH1H8CS4AHA188SKJE266RR3EDA58N148DSS74TM6CA58N24AC9K6X1M4C9Q6RW48CT674SMCE2264V42CSH8D336GSQ84SM6CT564TKECSR8MRMAGHG8GW3JEA56WT32D9S8H334DJ564SK8GSS60WM6E1P8S346H238GRM8DSN6MR36C256GVM8H9M6WV30C246X0MCH9R84TK2D1M70V44CA260VKJGHN6RR4ACT488R3GCA46MW3GDHK6GWMAHHP6S242H9G6D134D9N8RV32DSJ8GSKGC1J6RTK2GHQ8H0K2DHH6WT38GSH74WM4EA574RKEE1M6D0M4DHK8MW4ACT68CT4CE236H236GH35452081918G2J2G0",
-            "coin_sig": 
"K9S5273GT4QKF5Y9FYJ62BV710WGEFE1DSXV75A37X272ADWBCV0ERZV9TF2VYTCSH1837R3F7A39R5QEPCC0NYW3JQ5S70X8MJG008"
-        }
-    ],
-    "max_fee": {
-        "value": 3,
-        "fraction": 8,
-        "currency": "KUDOS"
-    }
-}
diff --git a/src/tests/deposit_permission_edate_backend.sample 
b/src/tests/deposit_permission_edate_backend.sample
deleted file mode 100644
index 1b185b4..0000000
--- a/src/tests/deposit_permission_edate_backend.sample
+++ /dev/null
@@ -1,37 +0,0 @@
-{
-    "transaction_id" : 1,
-    "timestamp": "\/Date(1447334003)\/",
-    "edate": "\/Date(1447334003)\/",
-    "H_wire": 
"V1F0F5AWSNX60E6TXZEYDZRE84J8HMBGXEM09AEVV3N97MM75P6JQRSWR5KQVC1RBBF2SRXY7P10H0ZM0VETWPFAJJRBVJSXNMDWTYR",
-    "merchant_pub": "BQ0TMTBV2XEJ8G2PXA9KRDD5WDT5EV29KPVS6J9RBQJCS8BCPQ70",
-    "exchange": "demo.taler.net",
-    "coins": [
-        {
-            "f": {
-                "value": 0,
-                "fraction": 100000,
-                "currency": "KUDOS"
-            },
-            "coin_pub": "AH86D5WV9G6RT0A3CHYJW598BNMH8848GAKYTEH1JX6X2BKZWTX0",
-            "denom_pub": 
"51R7ARKCD5HJTTV5F4G0M818E9SP280A40G2GVH04CR30HHG74SM8GSM6D33EGSR84R46E246H23GCHK690M4G9R8GS4CD9S8GRMCDSP64T34GA56GV34DA3851M6H9S6MWK8H9K8D13CD1M85344GSP61244GT28N132HA56N1MCHA56513AD2160RK2CSN6D23AGJ56X33AGSM68W4CH1S88WK4D1H68SMACHJ88TM2CA28MRM4D248GS4ADHR8GSM4C2364V38E1N88S30HA564TKJE1N750KGC9R6RTKJE2370R4AC268D0MACHN6N242D1N68TKAC1M65234DJ26CRK4D9M8MSK6C9J64R32D1R70VKEE25852MCG9N84W32GJ68914CD1J691M6GA360S3GCHP8GWK8HHH68TK8CSK70S4AE9N712K0H9K6X34AC9354520818CM
 [...]
-            "ub_sig": 
"51SPJSSDESGPR80A40M74WV140520818ECG26C9J8D1MCHHJ84S34H1K8H1M6HHN60V3GH9S84R3GH9K6MVM6GSM70RKCDT188VM4CHM74RM8GSN6GSKEHHS6CT44H9Q8CWKCD1P68SK2G9S8GR34D1P60T4CCJ67523EDJ28S1KJD9N8H330CT58RS38CSM8H346GT58N13CGJ16GS34CHQ6GT42CSS6CTM4C9H8N1KCG9G74T36C1K8GT44E1N8RRK0D218GV46G9R6CT4CHA4890M6H1H8GV34E1Q8N244DHM8CRK2H1R8CV3ADA37113JDHR88W36E9R61242GT5752KEE9R84WK8H9G8GT34GT26S2MAE1P70RMAGSK74W30C1J60S32GSK64WKAC218MWM6GHM8S332DSN70SM2DHR6H146E228CTM8D135452081918G2J2G0",
-            "coin_sig": 
"MFTHC54GFYHA3CGKHC8SSDSTYX8YMEJDNQA7AEY5M7JBK3WPDQ9NCJ54ZSPQRZ4QCJC0CPREP0XRWH9JQ509ENSEXWKNNM5FEVRG238"
-        },
-        {
-            "f": {
-                "value": 0,
-                "fraction": 100000,
-                "currency": "KUDOS"
-            },
-            "coin_pub": "MQY067A8AGG90TSH11C8JNRW8P1R669JAAQX4V2HGFHGJ2WY4ZA0",
-            "denom_pub": 
"51R7ARKCD5HJTTV5F4G0M818E9SP280A40G2GVH04CR30HHG74SM8GSM6D33EGSR84R46E246H23GCHK690M4G9R8GS4CD9S8GRMCDSP64T34GA56GV34DA3851M6H9S6MWK8H9K8D13CD1M85344GSP61244GT28N132HA56N1MCHA56513AD2160RK2CSN6D23AGJ56X33AGSM68W4CH1S88WK4D1H68SMACHJ88TM2CA28MRM4D248GS4ADHR8GSM4C2364V38E1N88S30HA564TKJE1N750KGC9R6RTKJE2370R4AC268D0MACHN6N242D1N68TKAC1M65234DJ26CRK4D9M8MSK6C9J64R32D1R70VKEE25852MCG9N84W32GJ68914CD1J691M6GA360S3GCHP8GWK8HHH68TK8CSK70S4AE9N712K0H9K6X34AC9354520818CM
 [...]
-            "ub_sig": 
"51SPJSSDESGPR80A40M74WV140520818ECG26H1J60R4AHHG6N1KEC268N23ECT664VKAGSJ8GRK4CA56H2KAH1H8CS4AHA188SKJE266RR3EDA58N148DSS74TM6CA58N24AC9K6X1M4C9Q6RW48CT674SMCE2264V42CSH8D336GSQ84SM6CT564TKECSR8MRMAGHG8GW3JEA56WT32D9S8H334DJ564SK8GSS60WM6E1P8S346H238GRM8DSN6MR36C256GVM8H9M6WV30C246X0MCH9R84TK2D1M70V44CA260VKJGHN6RR4ACT488R3GCA46MW3GDHK6GWMAHHP6S242H9G6D134D9N8RV32DSJ8GSKGC1J6RTK2GHQ8H0K2DHH6WT38GSH74WM4EA574RKEE1M6D0M4DHK8MW4ACT68CT4CE236H236GH35452081918G2J2G0",
-            "coin_sig": 
"K9S5273GT4QKF5Y9FYJ62BV710WGEFE1DSXV75A37X272ADWBCV0ERZV9TF2VYTCSH1837R3F7A39R5QEPCC0NYW3JQ5S70X8MJG008"
-        }
-    ],
-    "max_fee": {
-        "value": 3,
-        "fraction": 8,
-        "currency": "KUDOS"
-    }
-}
diff --git a/src/tests/merchant.priv b/src/tests/merchant.priv
deleted file mode 100644
index 2101f67..0000000
--- a/src/tests/merchant.priv
+++ /dev/null
@@ -1 +0,0 @@
-���{�|�ic�?"��򊄏`J0�pkvTW��
\ No newline at end of file
diff --git a/src/tests/test_contract.c b/src/tests/test_contract.c
deleted file mode 100644
index ce75234..0000000
--- a/src/tests/test_contract.c
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
-  This file is part of TALER
-  Copyright (C) 2014, 2015, 2016 INRIA
-
-  TALER is free software; you can redistribute it and/or modify it under the
-  terms of the GNU General Public License as published by the Free Software
-  Foundation; either version 3, or (at your option) any later version.
-
-  TALER is distributed in the hope that it will be useful, but WITHOUT ANY
-  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-  A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License along with
-  TALER; see the file COPYING.GPL.  If not, see <http://www.gnu.org/licenses/>
-*/
-
-/**
-* @file src/tests/test_contract.c
-* @brief test for various merchant's capabilities
-* @author Marcello Stanisci
-*/
-
-#include "platform.h"
-#include <jansson.h>
-#include <gnunet/gnunet_util_lib.h>
-#include <taler/taler_util.h>
-#include "merchant.h"
-#include "merchant_db.h"
-#include <taler_merchant_lib.h>
-
-PGconn *db_conn;
-
-static int dry;
-struct GNUNET_CRYPTO_EddsaPrivateKey *privkey;
-char *keyfile;
-static int result;
-static struct MERCHANT_WIREFORMAT_Sepa *wire;
-
-extern
-struct MERCHANT_WIREFORMAT_Sepa *
-TALER_MERCHANT_parse_wireformat_sepa (const struct GNUNET_CONFIGURATION_Handle 
*cfg);
-
-
-/**
- * Shutdown task (magically invoked when the application is being
- * quit)
- *
- * @param cls NULL
- * @param tc scheduler task context
- */
-static void
-do_shutdown (void *cls,
-             const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-
-  if (NULL != db_conn)
-    {
-      TALER_MERCHANTDB_disconnect (db_conn);
-      db_conn = NULL;
-    }
-}
-
-
-extern uint32_t
-TALER_MERCHANTDB_contract_get_values (PGconn *conn,
-                                      const struct GNUNET_HashCode *h_contract,
-                                      uint64_t *nounce,
-                                      struct GNUNET_TIME_Absolute 
*wire_transfer_deadline);
-
-
-/**
- * Main function that will be run by the scheduler.
- *
- * @param cls closure
- * @param args remaining command-line arguments
- * @param cfgfile name of the configuration file used (for saving, can be 
NULL!)
- * @param config configuration
- */
-static void
-run (void *cls, char *const *args, const char *cfgfile,
-     const struct GNUNET_CONFIGURATION_Handle *config)
-
-{
-  json_t *j_fake_contract;
-  json_t *j_details;
-  json_t *j_exchanges;
-  json_t *j_item;
-  json_t *j_amount;
-  json_t *j_tax_amount;
-  json_t *j_item_price;
-  json_t *j_max_fee;
-  json_t *j_teatax;
-  json_t *j_id; // trans id
-  json_t *j_pid; // product id
-  json_t *j_quantity;
-  json_t *j_delloc;
-  json_t *j_merchant;
-  json_t *j_merchant_jurisdiction;
-  json_t *j_merchant_zipcode;
-  json_t *j_lnames;
-  json_t *j_deldate;
-  char *desc;
-  struct TALER_Amount amount;
-  int64_t t_id;
-  int64_t p_id;
-  struct Contract contract;
-  struct GNUNET_TIME_Absolute wire_transfer_deadline;
-  struct GNUNET_TIME_Absolute now;
-  uint64_t nounce;
-  struct GNUNET_HashCode h_contract_str;
-  char *aa;
-  const char *fancy_time;
-  uint32_t ret;
-
-  db_conn = NULL;
-  keyfile = NULL;
-  privkey = NULL;
-  wire = NULL;
-
-
-  db_conn = TALER_MERCHANTDB_connect (config);
-  if (GNUNET_OK != TALER_MERCHANTDB_initialize (db_conn, GNUNET_NO))
-  {
-    printf ("no db init'd\n");
-    result = GNUNET_SYSERR;
-  }
-  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (config,
-                                                            "merchant",
-                                                            "KEYFILE",
-                                                            &keyfile))
-  {
-    printf ("no keyfile entry in cfg file\n");
-    result = GNUNET_SYSERR;
-  }
-
-  privkey = GNUNET_CRYPTO_eddsa_key_create_from_file (keyfile);
-  wire = TALER_MERCHANT_parse_wireformat_sepa (config);
-  GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
-
-  /**
-  * 'Root' object of the contract, leaving some holes to bi filled
-  * up by the merchant library.
-  *
-  */
-
-  /* Amount */
-  TALER_amount_get_zero ("EUR", &amount);
-  j_amount = TALER_json_from_amount (&amount);
-
-  /* Transaction ID*/
-  //t_id = (int32_t) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, 
UINT64_MAX);
-  t_id = 321;
-
-  if (t_id < 0)
-     j_id = json_integer ((-1) * t_id);
-  else
-     j_id = json_integer (t_id);
-
-  /**
-  * Holes:
-  *
-  * - 'h_wire'
-  * - 'timestamp'
-  *
-  */
-
-  /**
-  *
-  * Preparing the 'details' sub-object: an array of 'item' objects
-  * plus some juridical and delivery-aware informations
-  *
-  */
-
-  /**
-  *
-  * Preparing a 'item' sub-object
-  */
-
-  /* Description */
-  desc = "Fake purchase";
-
-  j_max_fee = TALER_json_from_amount (&amount);
-  /* Quantity: OPTIONAL FIELD */
-  j_quantity = json_integer (3);
-
-  /* item price: OPTIONAL FIELD*/
-  j_item_price = TALER_json_from_amount (&amount);
-
-  /* Product ID */
-  p_id = (int32_t) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, 
UINT64_MAX);
-
-  if (p_id < 0)
-     j_pid = json_integer ((-1) * p_id);
-  else
-     j_pid = json_integer (p_id);
-
-  /* Taxes: array of "tax_name" : {tax amount} */
-  j_tax_amount = TALER_json_from_amount (&amount);
-  j_teatax = json_pack ("{s:o}",
-                        "teatax", j_tax_amount);
-
-  if (NULL == (j_item = json_pack ("{s:s, s:I, s:o, s:[o]}",
-                      "description", desc,
-                     "quantity", json_integer_value (j_quantity),
-                     "itemprice", j_item_price,
-                     "taxes", j_teatax)))
-  {
-    printf ("error in packing [j_item: %p]\n", j_item);
-    return;
-  }
-
-  /* End of 'item' object definition */
-
-  /* Delivery date: OPTIONAL FIELD */
-  now = GNUNET_TIME_absolute_get ();
-  TALER_round_abs_time (&now);
-//  deldate = GNUNET_TIME_absolute_add (now, GNUNET_TIME_UNIT_WEEKS);
-  j_deldate = TALER_json_from_abs (now);
-
-  /* Delivery location: OPTIONAL FIELD */
-  j_delloc = json_string ("MALTK"); /* just a 'tag' which points to some well 
defined location */
-
-
-  /* Merchant jurisdiction: OPTIONAL FIELD (with its fields from 3rd to the 
last being optional)
-  * for another optional field */
-  j_merchant_zipcode = json_integer (9468);
-  j_merchant_jurisdiction = json_pack ("{s:s, s:s, s:s, s:s, s:s, s:I}",
-                                       "country", "Test Country",
-                                      "city", "Test City",
-                                      "state", "NA",
-                                      "region", "NA",
-                                      "province", "NA",
-                                      "ZIP code", json_integer_value 
(j_merchant_zipcode));
-
-  /* Merchant details */
-  j_merchant = json_pack ("{s:s, s:s, s:o}",
-                          "address", "UALMP",
-                         "name", "test merchant",
-                         "jurisdiction", j_merchant_jurisdiction);
-
-
-  /* L-names mapping */
-  j_lnames = json_pack ("[{s:s}, {s:s}]",
-                        "MALTK", "Test Address 1",
-                       "UALMP", "Second Test Address");
-
-
-
-  j_details = json_pack ("{s:I, s:o, s:o, s:o, s:o, s:o}",
-                        "product_id", json_integer_value (j_pid),
-                         "items", j_item,
-                        "delivery date", j_deldate,
-                        "delivery location", j_delloc,
-                        "merchant", j_merchant,
-                        "L-names", j_lnames);
-
-  /* Faking out the exchanges' list */
-  j_exchanges = json_pack ("[{s:s}]",
-                       "demo.taler.net",
-                      "Q1WVGRGC1F4W7RYC6M23AEGFEXQEHQ730K3GG0B67VPHQSRR75H0");
-
-  j_fake_contract = json_pack ("{s:o, s:o, s:I, s:o, s:o}",
-                               "amount", j_amount,
-                               "max fee", j_max_fee,
-                              "trans_id", json_integer_value (j_id),
-                              "exchanges", j_exchanges,
-                              "details", j_details);
-  #if 0
-  str = json_dumps (j_fake_contract, JSON_INDENT(2) | JSON_PRESERVE_ORDER);
-  printf ("%s\n", str);
-  return;
-  #endif
-
-  nounce = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_NONCE, UINT64_MAX);
-
-  ret = MERCHANT_handle_contract (j_fake_contract,
-                                  db_conn,
-                                  &contract,
-                                 now,
-                                 now,
-                                 now,
-                                 now,
-                                 &aa,
-                                 nounce);
-  if (ret == GNUNET_NO)
-  {
-    printf ("Failed, contract already in DB\n");
-    return;
-  }
-  else
-    printf ("handling contract fine\n");
-
-
-  printf ("contract string : %s\n", aa);
-
-  GNUNET_CRYPTO_hash (aa, strlen (aa) + 1, &h_contract_str);
-  if (GNUNET_SYSERR ==
-      TALER_MERCHANTDB_contract_get_values (db_conn,
-                                            &h_contract_str,
-                                            &nounce,
-                                            &wire_transfer_deadline))
-  {
-    printf ("no hash found\n");
-  }
-  else
-  {
-
-    fancy_time = GNUNET_STRINGS_absolute_time_to_string 
(wire_transfer_deadline);
-    printf ("hash found!, nounce is : %llu\n", nounce);
-    printf ("hash found!, wire transfer time is : %s\n", fancy_time);
-  }
-}
-
-
-/**
- * The main function of the test tool
- *
- * @param argc number of arguments from the command line
- * @param argv command line arguments
- * @return 0 ok, 1 on error
- */
-int
-main (int argc, char *const *argv)
-{
-
-  static const struct GNUNET_GETOPT_CommandLineOption options[] = {
-    {'t', "temp", NULL,
-     gettext_noop ("Use temporary database tables"), GNUNET_NO,
-     &GNUNET_GETOPT_set_one, &dry},
-     GNUNET_GETOPT_OPTION_END
-    };
-
-
-  if (GNUNET_OK !=
-      GNUNET_PROGRAM_run (argc, argv,
-                          "merchant-contract-test",
-                          "Test for contracts mgmt",
-                          options, &run, NULL))
-    return 3;
-  return (GNUNET_OK == result) ? 0 : 1;
-}
diff --git a/src/tests/test_contract_README b/src/tests/test_contract_README
deleted file mode 100644
index 9fd337c..0000000
--- a/src/tests/test_contract_README
+++ /dev/null
@@ -1,10 +0,0 @@
-- In order to test the "/contract" facility of the merchant,
-  just issue
-
-  - curl http://merchant-url/generate_taler_contract.php?cli_debug=yes
-    (this form tests the whole communication between frontend and backend)
-
-  - curl http://merchant-url/generate_taler_contract.php?backend_test=no
-    (this form test only the contract proposition generation of the frontend,
-     so it doesn't further connect to the backend to get the proposition JSON
-     enhanced)
diff --git a/src/tests/test_pay_README b/src/tests/test_pay_README
deleted file mode 100644
index 1704d6b..0000000
--- a/src/tests/test_pay_README
+++ /dev/null
@@ -1,26 +0,0 @@
-The merchant's "/pay" facility can be tested either directly by querying the
-backend or by querying the frontend (which in turn will query the backend).
-Each file *.sample is sample JSON to POST to both components (with the 
'_backend'
-named version being dedicated to just the backend).
-
-Note: the sample 'deposit_permission_edate_backend.sample' contains the 
optional
-'edate' field to the deposit permission (that field indicates the tollerated 
delay
-by this merchant to receive funds relative to this payment)
-
-The frontend test admits two versions of queries, as in the following examples:
-
-  * curl -H 'Content-type: application/json' address@hidden \
-    http://merchant-url/pay.php?cli_debug=yes
-
-    (this form tests the whole communication between frontend and backend)
-
-  * curl address@hidden http://merchant-url/pay.php?backend_test=no
-
-    (this form tests only the deposit permission enhancement made by the
-    frontend, so it doesn't further connect to the backend to actually POST
-    that data. By default, the frontend doesn't add the 'edate' field, so it
-    is necessary to uncomment the related line of code to test this feature)
-
-Finally, to POST to the backend, issue
-  * curl -H 'Content-type: application/json' address@hidden 
http://backend-url/pay
- 

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



reply via email to

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