aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-01-28 15:35:41 +0100
committerChristian Grothoff <christian@grothoff.org>2015-01-28 15:35:41 +0100
commite19f1906a3363f0f49553d35d95429c92bec29d4 (patch)
treeb5c644a5600e1f629bc7dd72d2f88461f4ad5526
parent7f171e69b27d48f02acd8c79e3a173a448be7ebd (diff)
downloadexchange-e19f1906a3363f0f49553d35d95429c92bec29d4.tar.gz
exchange-e19f1906a3363f0f49553d35d95429c92bec29d4.zip
avoid using struct Deposit in response
-rw-r--r--src/mint/mint.h64
-rw-r--r--src/mint/mint_db.h71
-rw-r--r--src/mint/taler-mint-httpd_db.c16
-rw-r--r--src/mint/taler-mint-httpd_db.h2
-rw-r--r--src/mint/taler-mint-httpd_responses.c21
-rw-r--r--src/mint/taler-mint-httpd_responses.h21
6 files changed, 121 insertions, 74 deletions
diff --git a/src/mint/mint.h b/src/mint/mint.h
index a0309e9ea..13719e625 100644
--- a/src/mint/mint.h
+++ b/src/mint/mint.h
@@ -91,70 +91,6 @@ struct CollectableBlindcoin
91}; 91};
92 92
93 93
94/**
95 * Specification for a /deposit operation.
96 */
97struct Deposit
98{
99 /**
100 * Information about the coin that is being deposited.
101 */
102 struct TALER_CoinPublicInfo coin;
103
104 /**
105 * ECDSA signature affirming that the customer intends
106 * this coin to be deposited at the merchant identified
107 * by @e h_wire in relation to the contract identified
108 * by @e h_contract.
109 */
110 struct GNUNET_CRYPTO_EcdsaSignature csig;
111
112 /**
113 * Public key of the merchant. Enables later identification
114 * of the merchant in case of a need to rollback transactions.
115 */
116 struct GNUNET_CRYPTO_EddsaPublicKey merchant_pub;
117
118 /**
119 * Hash over the contract between merchant and customer
120 * (remains unknown to the Mint).
121 */
122 struct GNUNET_HashCode h_contract;
123
124 /**
125 * Hash of the (canonical) representation of @e wire, used
126 * to check the signature on the request. Generated by
127 * the mint from the detailed wire data provided by the
128 * merchant.
129 */
130 struct GNUNET_HashCode h_wire;
131
132 /**
133 * Detailed wire information for executing the transaction.
134 */
135 const json_t *wire;
136
137 /**
138 * Merchant-generated transaction ID to detect duplicate
139 * transactions.
140 */
141 uint64_t transaction_id;
142
143 /**
144 * Fraction of the coin's remaining value to be deposited.
145 * The coin is identified by @e coin_pub.
146 */
147 struct TALER_Amount amount;
148
149 /**
150 * Type of the deposit (also purpose of the signature). Either
151 * #TALER_SIGNATURE_DEPOSIT or #TALER_SIGNATURE_INCREMENTAL_DEPOSIT.
152 */
153 uint32_t purpose; // FIXME: bad type, use ENUM!
154
155
156};
157
158 94
159 95
160 96
diff --git a/src/mint/mint_db.h b/src/mint/mint_db.h
index 5ed5db96c..b38b82b94 100644
--- a/src/mint/mint_db.h
+++ b/src/mint/mint_db.h
@@ -27,7 +27,6 @@
27#include <microhttpd.h> 27#include <microhttpd.h>
28#include <gnunet/gnunet_util_lib.h> 28#include <gnunet/gnunet_util_lib.h>
29#include "taler_util.h" 29#include "taler_util.h"
30#include "taler-mint-httpd_db.h"
31#include "mint.h" 30#include "mint.h"
32 31
33 32
@@ -329,11 +328,79 @@ int
329TALER_MINT_DB_prepare_deposits (PGconn *db_conn); 328TALER_MINT_DB_prepare_deposits (PGconn *db_conn);
330 329
331 330
331
332/**
333 * Specification for a /deposit operation.
334 */
335struct Deposit
336{
337 /**
338 * Information about the coin that is being deposited.
339 */
340 struct TALER_CoinPublicInfo coin;
341
342 /**
343 * ECDSA signature affirming that the customer intends
344 * this coin to be deposited at the merchant identified
345 * by @e h_wire in relation to the contract identified
346 * by @e h_contract.
347 */
348 struct GNUNET_CRYPTO_EcdsaSignature csig;
349
350 /**
351 * Public key of the merchant. Enables later identification
352 * of the merchant in case of a need to rollback transactions.
353 */
354 struct GNUNET_CRYPTO_EddsaPublicKey merchant_pub;
355
356 /**
357 * Hash over the contract between merchant and customer
358 * (remains unknown to the Mint).
359 */
360 struct GNUNET_HashCode h_contract;
361
362 /**
363 * Hash of the (canonical) representation of @e wire, used
364 * to check the signature on the request. Generated by
365 * the mint from the detailed wire data provided by the
366 * merchant.
367 */
368 struct GNUNET_HashCode h_wire;
369
370 /**
371 * Detailed wire information for executing the transaction.
372 */
373 const json_t *wire;
374
375 /**
376 * Merchant-generated transaction ID to detect duplicate
377 * transactions.
378 */
379 uint64_t transaction_id;
380
381 /**
382 * Fraction of the coin's remaining value to be deposited.
383 * The coin is identified by @e coin_pub.
384 */
385 struct TALER_Amount amount;
386
387 /**
388 * Type of the deposit (also purpose of the signature). Either
389 * #TALER_SIGNATURE_DEPOSIT or #TALER_SIGNATURE_INCREMENTAL_DEPOSIT.
390 */
391 uint32_t purpose; // FIXME: bad type, use ENUM!
392
393
394};
395
396
332int 397int
333TALER_MINT_DB_insert_deposit (PGconn *db_conn, 398TALER_MINT_DB_insert_deposit (PGconn *db_conn,
334 const struct Deposit *deposit); 399 const struct Deposit *deposit);
335 400
336 401
402// FIXME: with fractional deposits, we need more than
403// just the coin key to lookup deposits...
337int 404int
338TALER_MINT_DB_get_deposit (PGconn *db_conn, 405TALER_MINT_DB_get_deposit (PGconn *db_conn,
339 const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub, 406 const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub,
@@ -341,6 +408,8 @@ TALER_MINT_DB_get_deposit (PGconn *db_conn,
341 408
342 409
343 410
411
412
344/** 413/**
345 * Get the thread-local database-handle. 414 * Get the thread-local database-handle.
346 * Connect to the db if the connection does not exist yet. 415 * Connect to the db if the connection does not exist yet.
diff --git a/src/mint/taler-mint-httpd_db.c b/src/mint/taler-mint-httpd_db.c
index 1fa42f8de..6949da22d 100644
--- a/src/mint/taler-mint-httpd_db.c
+++ b/src/mint/taler-mint-httpd_db.c
@@ -72,7 +72,13 @@ TALER_MINT_db_execute_deposit (struct MHD_Connection *connection,
72 if (0 == memcmp (&existing_deposit, 72 if (0 == memcmp (&existing_deposit,
73 deposit, 73 deposit,
74 sizeof (struct Deposit))) 74 sizeof (struct Deposit)))
75 return TALER_MINT_reply_deposit_success (connection, deposit); 75 return TALER_MINT_reply_deposit_success (connection,
76 &deposit->coin.coin_pub,
77 &deposit->h_wire,
78 &deposit->h_contract,
79 deposit->transaction_id,
80 &deposit->merchant_pub,
81 &deposit->amount);
76 // FIXME: in the future, check if there's enough credits 82 // FIXME: in the future, check if there's enough credits
77 // left on the coin. For now: refuse 83 // left on the coin. For now: refuse
78 // FIXME: return more information here 84 // FIXME: return more information here
@@ -136,7 +142,13 @@ TALER_MINT_db_execute_deposit (struct MHD_Connection *connection,
136 } 142 }
137 // FIXME: check commit return value! 143 // FIXME: check commit return value!
138 TALER_MINT_DB_commit (db_conn); 144 TALER_MINT_DB_commit (db_conn);
139 return TALER_MINT_reply_deposit_success (connection, deposit); 145 return TALER_MINT_reply_deposit_success (connection,
146 &deposit->coin.coin_pub,
147 &deposit->h_wire,
148 &deposit->h_contract,
149 deposit->transaction_id,
150 &deposit->merchant_pub,
151 &deposit->amount);
140} 152}
141 153
142 154
diff --git a/src/mint/taler-mint-httpd_db.h b/src/mint/taler-mint-httpd_db.h
index bcec4521b..a5c195317 100644
--- a/src/mint/taler-mint-httpd_db.h
+++ b/src/mint/taler-mint-httpd_db.h
@@ -27,7 +27,7 @@
27#include "taler_util.h" 27#include "taler_util.h"
28#include "taler-mint-httpd_keys.h" 28#include "taler-mint-httpd_keys.h"
29#include "mint.h" 29#include "mint.h"
30 30#include "mint_db.h"
31 31
32 32
33/** 33/**
diff --git a/src/mint/taler-mint-httpd_responses.c b/src/mint/taler-mint-httpd_responses.c
index c8200b43a..8a0d7e797 100644
--- a/src/mint/taler-mint-httpd_responses.c
+++ b/src/mint/taler-mint-httpd_responses.c
@@ -250,15 +250,30 @@ TALER_MINT_reply_invalid_json (struct MHD_Connection *connection)
250 250
251 251
252/** 252/**
253 * Send confirmation of deposit success to client. 253 * Send confirmation of deposit success to client. This function
254 * will create a signed message affirming the given information
255 * and return it to the client. By this, the mint affirms that
256 * the coin had sufficient (residual) value for the specified
257 * transaction and that it will execute the requested deposit
258 * operation with the given wiring details.
254 * 259 *
255 * @param connection connection to the client 260 * @param connection connection to the client
256 * @param deposit deposit request to confirm 261 * @param coin_pub public key of the coin
262 * @param h_wire hash of wire details
263 * @param h_contract hash of contract details
264 * @param transaction_id transaction ID
265 * @param merchant merchant public key
266 * @param amount fraction of coin value to deposit
257 * @return MHD result code 267 * @return MHD result code
258 */ 268 */
259int 269int
260TALER_MINT_reply_deposit_success (struct MHD_Connection *connection, 270TALER_MINT_reply_deposit_success (struct MHD_Connection *connection,
261 const struct Deposit *deposit) 271 const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub,
272 const struct GNUNET_HashCode *h_wire,
273 const struct GNUNET_HashCode *h_contract,
274 uint64_t transaction_id,
275 const struct GNUNET_CRYPTO_EddsaPublicKey *merchant,
276 const struct TALER_Amount *amount)
262{ 277{
263 // FIXME: return more information here, 278 // FIXME: return more information here,
264 // including in particular a signature over 279 // including in particular a signature over
diff --git a/src/mint/taler-mint-httpd_responses.h b/src/mint/taler-mint-httpd_responses.h
index 2dc306110..30c9e1185 100644
--- a/src/mint/taler-mint-httpd_responses.h
+++ b/src/mint/taler-mint-httpd_responses.h
@@ -145,15 +145,30 @@ TALER_MINT_reply_invalid_json (struct MHD_Connection *connection);
145 145
146 146
147/** 147/**
148 * Send confirmation of deposit success to client. 148 * Send confirmation of deposit success to client. This function
149 * will create a signed message affirming the given information
150 * and return it to the client. By this, the mint affirms that
151 * the coin had sufficient (residual) value for the specified
152 * transaction and that it will execute the requested deposit
153 * operation with the given wiring details.
149 * 154 *
150 * @param connection connection to the client 155 * @param connection connection to the client
151 * @param deposit deposit request to confirm 156 * @param coin_pub public key of the coin
157 * @param h_wire hash of wire details
158 * @param h_contract hash of contract details
159 * @param transaction_id transaction ID
160 * @param merchant merchant public key
161 * @param amount fraction of coin value to deposit
152 * @return MHD result code 162 * @return MHD result code
153 */ 163 */
154int 164int
155TALER_MINT_reply_deposit_success (struct MHD_Connection *connection, 165TALER_MINT_reply_deposit_success (struct MHD_Connection *connection,
156 const struct Deposit *deposit); 166 const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub,
167 const struct GNUNET_HashCode *h_wire,
168 const struct GNUNET_HashCode *h_contract,
169 uint64_t transaction_id,
170 const struct GNUNET_CRYPTO_EddsaPublicKey *merchant,
171 const struct TALER_Amount *amount);
157 172
158 173
159/** 174/**