merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit fe973b29bba8a6f46989743e4263a23e473735b8
parent 52e82c8e9a1a988f075db0c74126744fca548173
Author: Marcello Stanisci <marcello.stanisci@inria.fr>
Date:   Wed, 12 Oct 2016 23:11:54 +0200

merchant's key in transactions table

Diffstat:
Msrc/backend/taler-merchant-httpd_pay.c | 1+
Msrc/backenddb/plugin_merchantdb_postgres.c | 12+++++++++---
Msrc/backenddb/test_merchantdb.c | 8++++++++
Msrc/include/taler_merchantdb_plugin.h | 2++
4 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c @@ -1131,6 +1131,7 @@ MH_handler_pay (struct TMH_RequestHandler *rh, if (GNUNET_OK != db->store_transaction (db->cls, pc->transaction_id, + &pc->mi->pubkey, pc->chosen_exchange, &pc->h_contract, &pc->mi->h_wire, diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c @@ -155,8 +155,9 @@ postgres_initialize (void *cls) /* Setup tables */ PG_EXEC (pg, "CREATE TABLE IF NOT EXISTS merchant_transactions (" - " transaction_id INT8 PRIMARY KEY" + " transaction_id INT8 UNIQUE" ",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" @@ -164,6 +165,7 @@ postgres_initialize (void *cls) ",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)" ");"); PG_EXEC (pg, "CREATE TABLE IF NOT EXISTS merchant_deposits (" @@ -211,6 +213,7 @@ postgres_initialize (void *cls) "INSERT INTO merchant_transactions" "(transaction_id" ",exchange_uri" + ",merchant_pub" ",h_contract" ",h_wire" ",timestamp" @@ -219,8 +222,8 @@ postgres_initialize (void *cls) ",total_amount_frac" ",total_amount_curr" ") VALUES " - "($1, $2, $3, $4, $5, $6, $7, $8, $9)", - 9); + "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", + 10); PG_PREPARE (pg, "insert_deposit", "INSERT INTO merchant_deposits" @@ -347,6 +350,7 @@ postgres_initialize (void *cls) * * @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 h_wire hash of our wire details @@ -358,6 +362,7 @@ postgres_initialize (void *cls) static int postgres_store_transaction (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_wire, @@ -372,6 +377,7 @@ postgres_store_transaction (void *cls, struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&transaction_id), 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), diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c @@ -110,6 +110,12 @@ static struct TALER_CoinSpendPublicKeyP coin_pub; static struct TALER_ExchangePublicKeyP signkey_pub; /** + * Public Key of the merchant. Set to some random value. + * Used as merchant instances now do store their keys. + */ +static struct TALER_MerchantPublicKeyP merchant_pub; + +/** * Wire transfer identifier. Set to some random value. */ static struct TALER_WireTransferIdentifierRawP wtid; @@ -297,6 +303,7 @@ run (void *cls) RND_BLK (&h_wire); RND_BLK (&transaction_id); RND_BLK (&signkey_pub); + RND_BLK (&merchant_pub); RND_BLK (&wtid); timestamp = GNUNET_TIME_absolute_get(); GNUNET_TIME_round_abs (&timestamp); @@ -324,6 +331,7 @@ run (void *cls) FAILIF (GNUNET_OK != plugin->store_transaction (plugin->cls, transaction_id, + &merchant_pub, EXCHANGE_URI, &h_contract, &h_wire, diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h @@ -151,6 +151,7 @@ struct TALER_MERCHANTDB_Plugin * * @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 h_wire hash of our wire details @@ -162,6 +163,7 @@ struct TALER_MERCHANTDB_Plugin int (*store_transaction) (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_wire,