summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--src/backend/taler-merchant-httpd_pay.c3
-rw-r--r--src/backend/taler-merchant-httpd_track-deposit.c3
-rw-r--r--src/backend/taler-merchant-httpd_track-transaction.c5
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c18
-rw-r--r--src/include/taler_merchantdb_plugin.h4
6 files changed, 33 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index e20e0252..66175091 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,2 +1,6 @@
+Tue Jun 7 15:17:45 CEST 2016
+ Store signing key used by exchange in DB. Might be useful
+ in the future when we implement GC for the backenddb. -CG
+
Wed Jun 1 17:27:36 CEST 2016
Releasing taler-merchant-0.0.0. -CG
diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c
index f32d3dbb..a46f3223 100644
--- a/src/backend/taler-merchant-httpd_pay.c
+++ b/src/backend/taler-merchant-httpd_pay.c
@@ -323,6 +323,7 @@ abort_deposit (struct PayContext *pc)
* @param http_status HTTP response code, #MHD_HTTP_OK
* (200) for successful deposit; 0 if the exchange's reply is bogus (fails
* to follow the protocol)
+ * @param sign_key which key did the exchange use to sign the @a proof
* @param proof the received JSON reply,
* should be kept as proof (and, in case of errors, be forwarded to
* the customer)
@@ -330,6 +331,7 @@ abort_deposit (struct PayContext *pc)
static void
deposit_cb (void *cls,
unsigned int http_status,
+ const struct TALER_ExchangePublicKeyP *sign_key,
const json_t *proof)
{
struct DepositConfirmation *dc = cls;
@@ -379,6 +381,7 @@ deposit_cb (void *cls,
&dc->coin_pub,
&dc->amount_with_fee,
&dc->deposit_fee,
+ sign_key,
proof))
{
GNUNET_break (0);
diff --git a/src/backend/taler-merchant-httpd_track-deposit.c b/src/backend/taler-merchant-httpd_track-deposit.c
index 5e2cf4f0..8568681d 100644
--- a/src/backend/taler-merchant-httpd_track-deposit.c
+++ b/src/backend/taler-merchant-httpd_track-deposit.c
@@ -229,6 +229,7 @@ check_deposit (void *cls,
*
* @param cls closure
* @param http_status HTTP status code we got, 0 on exchange protocol violation
+ * @param exchange_pub public key of the exchange used to sign @a json
* @param json original json reply (may include signatures, those have then been
* validated already)
* @param wtid extracted wire transfer identifier, or NULL if the exchange could
@@ -241,6 +242,7 @@ check_deposit (void *cls,
static void
wire_deposit_cb (void *cls,
unsigned int http_status,
+ const struct TALER_ExchangePublicKeyP *exchange_pub,
const json_t *json,
const struct GNUNET_HashCode *h_wire,
const struct TALER_Amount *total_amount,
@@ -267,6 +269,7 @@ wire_deposit_cb (void *cls,
db->store_transfer_to_proof (db->cls,
rctx->uri,
&rctx->wtid,
+ exchange_pub,
json))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
diff --git a/src/backend/taler-merchant-httpd_track-transaction.c b/src/backend/taler-merchant-httpd_track-transaction.c
index e75d92aa..33ad90f2 100644
--- a/src/backend/taler-merchant-httpd_track-transaction.c
+++ b/src/backend/taler-merchant-httpd_track-transaction.c
@@ -299,6 +299,7 @@ trace_coins (struct TrackTransactionContext *tctx);
*
* @param cls closure
* @param http_status HTTP status code we got, 0 on exchange protocol violation
+ * @param exchange_pub public key of the exchange used for signing
* @param json original json reply (may include signatures, those have then been
* validated already)
* @param wtid extracted wire transfer identifier, or NULL if the exchange could
@@ -311,6 +312,7 @@ trace_coins (struct TrackTransactionContext *tctx);
static void
wire_deposits_cb (void *cls,
unsigned int http_status,
+ const struct TALER_ExchangePublicKeyP *exchange_pub,
const json_t *json,
const struct GNUNET_HashCode *h_wire,
const struct TALER_Amount *total_amount,
@@ -336,6 +338,7 @@ wire_deposits_cb (void *cls,
db->store_transfer_to_proof (db->cls,
tctx->exchange_uri,
&tctx->current_wtid,
+ exchange_pub,
json))
{
/* Not good, but not fatal either, log error and continue */
@@ -380,6 +383,7 @@ wire_deposits_cb (void *cls,
*
* @param cls closure with a `struct TrackCoinContext`
* @param http_status HTTP status code we got, 0 on exchange protocol violation
+ * @param exchange_pub public key of the exchange used for signing @a json
* @param json original json reply (may include signatures, those have then been
* validated already)
* @param wtid wire transfer identifier used by the exchange, NULL if exchange did not
@@ -390,6 +394,7 @@ wire_deposits_cb (void *cls,
static void
wtid_cb (void *cls,
unsigned int http_status,
+ const struct TALER_ExchangePublicKeyP *exchange_pub,
const json_t *json,
const struct TALER_WireTransferIdentifierRawP *wtid,
struct GNUNET_TIME_Absolute execution_time,
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index 052851ab..836be57c 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -175,6 +175,7 @@ postgres_initialize (void *cls)
",deposit_fee_val INT8 NOT NULL"
",deposit_fee_frac INT4 NOT NULL"
",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)"
");");
@@ -182,6 +183,7 @@ postgres_initialize (void *cls)
"CREATE TABLE IF NOT EXISTS merchant_proofs ("
" exchange_uri VARCHAR NOT NULL"
",wtid BYTEA CHECK (LENGTH(wtid)=32)"
+ ",signkey_pub BYTEA NOT NULL CHECK (LENGTH(signkey_pub)=32)"
",proof BYTEA NOT NULL"
",PRIMARY KEY (wtid, exchange_uri)"
");");
@@ -229,9 +231,10 @@ postgres_initialize (void *cls)
",deposit_fee_val"
",deposit_fee_frac"
",deposit_fee_curr"
+ ",signkey_pub"
",exchange_proof) 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_transfer",
"INSERT INTO merchant_transfers"
@@ -245,9 +248,10 @@ postgres_initialize (void *cls)
"INSERT INTO merchant_proofs"
"(exchange_uri"
",wtid"
+ ",signkey_pub"
",proof) VALUES "
- "($1, $2, $3)",
- 3);
+ "($1, $2, $3, $4)",
+ 4);
/* Setup prepared "SELECT" statements */
PG_PREPARE (pg,
@@ -382,6 +386,7 @@ postgres_store_transaction (void *cls,
* @param coin_pub public key of the coin
* @param amount_with_fee amount the exchange will deposit for this coin
* @param deposit_fee fee the exchange will charge for this coin
+ * @param signkey_pub public key used by the exchange for @a exchange_proof
* @param exchange_proof proof from exchange that coin was accepted
* @return #GNUNET_OK on success, #GNUNET_SYSERR upon error
*/
@@ -391,6 +396,7 @@ postgres_store_deposit (void *cls,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_Amount *amount_with_fee,
const struct TALER_Amount *deposit_fee,
+ const struct TALER_ExchangePublicKeyP *signkey_pub,
const json_t *exchange_proof)
{
struct PostgresClosure *pg = cls;
@@ -402,6 +408,7 @@ postgres_store_deposit (void *cls,
GNUNET_PQ_query_param_auto_from_type (coin_pub),
TALER_PQ_query_param_amount (amount_with_fee),
TALER_PQ_query_param_amount (deposit_fee),
+ GNUNET_PQ_query_param_auto_from_type (signkey_pub),
TALER_PQ_query_param_json (exchange_proof),
GNUNET_PQ_query_param_end
};
@@ -474,6 +481,7 @@ postgres_store_coin_to_transfer (void *cls,
* @param cls closure
* @param exchange_uri URI of the exchange
* @param wtid identifier of the wire transfer
+ * @param signkey_pub public key used by the exchange for @a exchange_proof
* @param exchange_proof proof from exchange about what the deposit was for
* @return #GNUNET_OK on success, #GNUNET_SYSERR upon error
*/
@@ -481,6 +489,7 @@ static int
postgres_store_transfer_to_proof (void *cls,
const char *exchange_uri,
const struct TALER_WireTransferIdentifierRawP *wtid,
+ const struct TALER_ExchangePublicKeyP *signkey_pub,
const json_t *exchange_proof)
{
struct PostgresClosure *pg = cls;
@@ -490,6 +499,7 @@ postgres_store_transfer_to_proof (void *cls,
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_string (exchange_uri),
GNUNET_PQ_query_param_auto_from_type (wtid),
+ GNUNET_PQ_query_param_auto_from_type (signkey_pub),
TALER_PQ_query_param_json (exchange_proof),
GNUNET_PQ_query_param_end
};
diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h
index 8ce021a1..63e60e78 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -176,6 +176,7 @@ struct TALER_MERCHANTDB_Plugin
* @param coin_pub public key of the coin
* @param amount_with_fee amount the exchange will deposit for this coin
* @param deposit_fee fee the exchange will charge for this coin
+ * @param signkey_pub public key used by the exchange for @a exchange_proof
* @param exchange_proof proof from exchange that coin was accepted
* @return #GNUNET_OK on success, #GNUNET_SYSERR upon error
*/
@@ -185,6 +186,7 @@ struct TALER_MERCHANTDB_Plugin
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_Amount *amount_with_fee,
const struct TALER_Amount *deposit_fee,
+ const struct TALER_ExchangePublicKeyP *signkey_pub,
const json_t *exchange_proof);
@@ -212,6 +214,7 @@ struct TALER_MERCHANTDB_Plugin
* @param cls closure
* @param exchange_uri from which exchange did we get the @a exchange_proof
* @param wtid identifier of the wire transfer
+ * @param signkey_pub public key used by the exchange for @a exchange_proof
* @param exchange_proof proof from exchange about what the deposit was for
* @return #GNUNET_OK on success, #GNUNET_SYSERR upon error
*/
@@ -219,6 +222,7 @@ struct TALER_MERCHANTDB_Plugin
(*store_transfer_to_proof) (void *cls,
const char *exchange_uri,
const struct TALER_WireTransferIdentifierRawP *wtid,
+ const struct TALER_ExchangePublicKeyP *signkey_pub,
const json_t *exchange_proof);