summaryrefslogtreecommitdiff
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.tar.bz2
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
};
-/**
- * Specification for a /deposit operation.
- */
-struct Deposit
-{
- /**
- * Information about the coin that is being deposited.
- */
- struct TALER_CoinPublicInfo coin;
-
- /**
- * ECDSA signature affirming that the customer intends
- * this coin to be deposited at the merchant identified
- * by @e h_wire in relation to the contract identified
- * by @e h_contract.
- */
- struct GNUNET_CRYPTO_EcdsaSignature csig;
-
- /**
- * Public key of the merchant. Enables later identification
- * of the merchant in case of a need to rollback transactions.
- */
- struct GNUNET_CRYPTO_EddsaPublicKey merchant_pub;
-
- /**
- * Hash over the contract between merchant and customer
- * (remains unknown to the Mint).
- */
- struct GNUNET_HashCode h_contract;
-
- /**
- * Hash of the (canonical) representation of @e wire, used
- * to check the signature on the request. Generated by
- * the mint from the detailed wire data provided by the
- * merchant.
- */
- struct GNUNET_HashCode h_wire;
-
- /**
- * Detailed wire information for executing the transaction.
- */
- const json_t *wire;
-
- /**
- * Merchant-generated transaction ID to detect duplicate
- * transactions.
- */
- uint64_t transaction_id;
-
- /**
- * Fraction of the coin's remaining value to be deposited.
- * The coin is identified by @e coin_pub.
- */
- struct TALER_Amount amount;
-
- /**
- * Type of the deposit (also purpose of the signature). Either
- * #TALER_SIGNATURE_DEPOSIT or #TALER_SIGNATURE_INCREMENTAL_DEPOSIT.
- */
- uint32_t purpose; // FIXME: bad type, use ENUM!
-
-
-};
-
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 @@
#include <microhttpd.h>
#include <gnunet/gnunet_util_lib.h>
#include "taler_util.h"
-#include "taler-mint-httpd_db.h"
#include "mint.h"
@@ -329,11 +328,79 @@ int
TALER_MINT_DB_prepare_deposits (PGconn *db_conn);
+
+/**
+ * Specification for a /deposit operation.
+ */
+struct Deposit
+{
+ /**
+ * Information about the coin that is being deposited.
+ */
+ struct TALER_CoinPublicInfo coin;
+
+ /**
+ * ECDSA signature affirming that the customer intends
+ * this coin to be deposited at the merchant identified
+ * by @e h_wire in relation to the contract identified
+ * by @e h_contract.
+ */
+ struct GNUNET_CRYPTO_EcdsaSignature csig;
+
+ /**
+ * Public key of the merchant. Enables later identification
+ * of the merchant in case of a need to rollback transactions.
+ */
+ struct GNUNET_CRYPTO_EddsaPublicKey merchant_pub;
+
+ /**
+ * Hash over the contract between merchant and customer
+ * (remains unknown to the Mint).
+ */
+ struct GNUNET_HashCode h_contract;
+
+ /**
+ * Hash of the (canonical) representation of @e wire, used
+ * to check the signature on the request. Generated by
+ * the mint from the detailed wire data provided by the
+ * merchant.
+ */
+ struct GNUNET_HashCode h_wire;
+
+ /**
+ * Detailed wire information for executing the transaction.
+ */
+ const json_t *wire;
+
+ /**
+ * Merchant-generated transaction ID to detect duplicate
+ * transactions.
+ */
+ uint64_t transaction_id;
+
+ /**
+ * Fraction of the coin's remaining value to be deposited.
+ * The coin is identified by @e coin_pub.
+ */
+ struct TALER_Amount amount;
+
+ /**
+ * Type of the deposit (also purpose of the signature). Either
+ * #TALER_SIGNATURE_DEPOSIT or #TALER_SIGNATURE_INCREMENTAL_DEPOSIT.
+ */
+ uint32_t purpose; // FIXME: bad type, use ENUM!
+
+
+};
+
+
int
TALER_MINT_DB_insert_deposit (PGconn *db_conn,
const struct Deposit *deposit);
+// FIXME: with fractional deposits, we need more than
+// just the coin key to lookup deposits...
int
TALER_MINT_DB_get_deposit (PGconn *db_conn,
const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub,
@@ -341,6 +408,8 @@ TALER_MINT_DB_get_deposit (PGconn *db_conn,
+
+
/**
* Get the thread-local database-handle.
* 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,
if (0 == memcmp (&existing_deposit,
deposit,
sizeof (struct Deposit)))
- return TALER_MINT_reply_deposit_success (connection, deposit);
+ return TALER_MINT_reply_deposit_success (connection,
+ &deposit->coin.coin_pub,
+ &deposit->h_wire,
+ &deposit->h_contract,
+ deposit->transaction_id,
+ &deposit->merchant_pub,
+ &deposit->amount);
// FIXME: in the future, check if there's enough credits
// left on the coin. For now: refuse
// FIXME: return more information here
@@ -136,7 +142,13 @@ TALER_MINT_db_execute_deposit (struct MHD_Connection *connection,
}
// FIXME: check commit return value!
TALER_MINT_DB_commit (db_conn);
- return TALER_MINT_reply_deposit_success (connection, deposit);
+ return TALER_MINT_reply_deposit_success (connection,
+ &deposit->coin.coin_pub,
+ &deposit->h_wire,
+ &deposit->h_contract,
+ deposit->transaction_id,
+ &deposit->merchant_pub,
+ &deposit->amount);
}
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 @@
#include "taler_util.h"
#include "taler-mint-httpd_keys.h"
#include "mint.h"
-
+#include "mint_db.h"
/**
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)
/**
- * Send confirmation of deposit success to client.
+ * Send confirmation of deposit success to client. This function
+ * will create a signed message affirming the given information
+ * and return it to the client. By this, the mint affirms that
+ * the coin had sufficient (residual) value for the specified
+ * transaction and that it will execute the requested deposit
+ * operation with the given wiring details.
*
* @param connection connection to the client
- * @param deposit deposit request to confirm
+ * @param coin_pub public key of the coin
+ * @param h_wire hash of wire details
+ * @param h_contract hash of contract details
+ * @param transaction_id transaction ID
+ * @param merchant merchant public key
+ * @param amount fraction of coin value to deposit
* @return MHD result code
*/
int
TALER_MINT_reply_deposit_success (struct MHD_Connection *connection,
- const struct Deposit *deposit)
+ const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub,
+ const struct GNUNET_HashCode *h_wire,
+ const struct GNUNET_HashCode *h_contract,
+ uint64_t transaction_id,
+ const struct GNUNET_CRYPTO_EddsaPublicKey *merchant,
+ const struct TALER_Amount *amount)
{
// FIXME: return more information here,
// 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);
/**
- * Send confirmation of deposit success to client.
+ * Send confirmation of deposit success to client. This function
+ * will create a signed message affirming the given information
+ * and return it to the client. By this, the mint affirms that
+ * the coin had sufficient (residual) value for the specified
+ * transaction and that it will execute the requested deposit
+ * operation with the given wiring details.
*
* @param connection connection to the client
- * @param deposit deposit request to confirm
+ * @param coin_pub public key of the coin
+ * @param h_wire hash of wire details
+ * @param h_contract hash of contract details
+ * @param transaction_id transaction ID
+ * @param merchant merchant public key
+ * @param amount fraction of coin value to deposit
* @return MHD result code
*/
int
TALER_MINT_reply_deposit_success (struct MHD_Connection *connection,
- const struct Deposit *deposit);
+ const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub,
+ const struct GNUNET_HashCode *h_wire,
+ const struct GNUNET_HashCode *h_contract,
+ uint64_t transaction_id,
+ const struct GNUNET_CRYPTO_EddsaPublicKey *merchant,
+ const struct TALER_Amount *amount);
/**