diff --git a/src/mint/mint.h b/src/mint/mint.h index 202de94d3..a0309e9ea 100644 --- a/src/mint/mint.h +++ b/src/mint/mint.h @@ -15,7 +15,7 @@ */ /** * @file mint.h - * @brief Common functionality for the mint + * @brief Common structs passed all over the mint logic * @author Florian Dold * @author Benedikt Mueller */ @@ -23,10 +23,8 @@ #define _MINT_H #include -#include #include #include "taler_util.h" -#include "taler_signatures.h" /** @@ -62,7 +60,6 @@ struct TALER_CoinPublicInfo }; - /** * Information we keep for a withdrawn coin to reproduce * the /withdraw operation if needed, and to have proof @@ -160,25 +157,6 @@ struct Deposit -/** - * FIXME - */ -struct KnownCoin -{ - struct TALER_CoinPublicInfo public_info; - - /** - * Refreshing session, only valid if - * is_refreshed==1. - */ - struct GNUNET_CRYPTO_EddsaPublicKey refresh_session_pub; - - struct TALER_Amount expended_balance; - - int is_refreshed; - -}; - /** * Global information for a refreshing session. @@ -280,50 +258,4 @@ struct RefreshCommitCoin - - - -/** - * Reserve row. Corresponds to table 'reserves' in the mint's - * database. FIXME: not sure this is how we want to store this - * information. Also, may currently used in different ways in the - * code, so we might need to separate the struct into different ones - * depending on the context it is used in. - */ -struct Reserve -{ - /** - * Signature over the purse. - * Only valid if (blind_session_missing==GNUNET_YES). - */ - struct GNUNET_CRYPTO_EddsaSignature status_sig; - /** - * Signature with purpose TALER_SIGNATURE_PURSE. - * Only valid if (blind_session_missing==GNUNET_YES). - */ - struct GNUNET_CRYPTO_EccSignaturePurpose status_sig_purpose; - /** - * Signing key used to sign the purse. - * Only valid if (blind_session_missing==GNUNET_YES). - */ - struct GNUNET_CRYPTO_EddsaPublicKey status_sign_pub; - /** - * Withdraw public key, identifies the purse. - * Only the customer knows the corresponding private key. - */ - struct GNUNET_CRYPTO_EddsaPublicKey reserve_pub; - /** - * Remaining balance in the purse. - */ - struct TALER_AmountNBO balance; - - /** - * Expiration date for the purse. - */ - struct GNUNET_TIME_AbsoluteNBO expiration; -}; - - - - #endif /* _MINT_H */ diff --git a/src/mint/mint_db.h b/src/mint/mint_db.h index 64d72a350..5ed5db96c 100644 --- a/src/mint/mint_db.h +++ b/src/mint/mint_db.h @@ -83,6 +83,52 @@ int TALER_MINT_DB_commit (PGconn *db_conn); + +/** + * Reserve row. Corresponds to table 'reserves' in the mint's + * database. FIXME: not sure this is how we want to store this + * information. Also, may currently used in different ways in the + * code, so we might need to separate the struct into different ones + * depending on the context it is used in. + */ +struct Reserve +{ + /** + * Signature over the purse. + * Only valid if (blind_session_missing==GNUNET_YES). + */ + struct GNUNET_CRYPTO_EddsaSignature status_sig; + + /** + * Signature with purpose TALER_SIGNATURE_PURSE. + * Only valid if (blind_session_missing==GNUNET_YES). + */ + struct GNUNET_CRYPTO_EccSignaturePurpose status_sig_purpose; + + /** + * Signing key used to sign the purse. + * Only valid if (blind_session_missing==GNUNET_YES). + */ + struct GNUNET_CRYPTO_EddsaPublicKey status_sign_pub; + + /** + * Withdraw public key, identifies the purse. + * Only the customer knows the corresponding private key. + */ + struct GNUNET_CRYPTO_EddsaPublicKey reserve_pub; + + /** + * Remaining balance in the purse. // FIXME: do not use NBO here! + */ + struct TALER_AmountNBO balance; + + /** + * Expiration date for the purse. + */ + struct GNUNET_TIME_AbsoluteNBO expiration; +}; + + int TALER_MINT_DB_get_reserve (PGconn *db_conn, const struct GNUNET_CRYPTO_EddsaPublicKey *reserve_pub, @@ -103,6 +149,9 @@ TALER_MINT_DB_update_reserve (PGconn *db_conn, int fresh); + + + int TALER_MINT_DB_insert_refresh_order (PGconn *db_conn, uint16_t newcoin_index, @@ -115,17 +164,46 @@ TALER_MINT_DB_get_refresh_session (PGconn *db_conn, struct RefreshSession *r_session); + + +/** + * FIXME + */ +struct KnownCoin +{ + struct TALER_CoinPublicInfo public_info; + + /** + * Refreshing session, only valid if + * is_refreshed==1. + */ + struct GNUNET_CRYPTO_EddsaPublicKey refresh_session_pub; + + struct TALER_Amount expended_balance; + + int is_refreshed; + +}; + + int TALER_MINT_DB_get_known_coin (PGconn *db_conn, const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub, struct KnownCoin *known_coin); - +// FIXME: what does 'upsert' even mean!? int TALER_MINT_DB_upsert_known_coin (PGconn *db_conn, struct KnownCoin *known_coin); +int +TALER_MINT_DB_insert_known_coin (PGconn *db_conn, + const struct KnownCoin *known_coin); + + + + int @@ -262,10 +340,6 @@ TALER_MINT_DB_get_deposit (PGconn *db_conn, struct Deposit *r_deposit); -int -TALER_MINT_DB_insert_known_coin (PGconn *db_conn, - const struct KnownCoin *known_coin); - /** * Get the thread-local database-handle. diff --git a/src/mint/taler-mint-httpd_db.c b/src/mint/taler-mint-httpd_db.c index 49c359a89..1fa42f8de 100644 --- a/src/mint/taler-mint-httpd_db.c +++ b/src/mint/taler-mint-httpd_db.c @@ -217,7 +217,8 @@ TALER_MINT_db_execute_withdraw_status (struct MHD_Connection *connection, return MHD_YES; } return TALER_MINT_reply_withdraw_status_success (connection, - &reserve); + TALER_amount_ntoh (reserve.balance), + GNUNET_TIME_absolute_ntoh (reserve.expiration)); } diff --git a/src/mint/taler-mint-httpd_responses.c b/src/mint/taler-mint-httpd_responses.c index 432772d79..c8200b43a 100644 --- a/src/mint/taler-mint-httpd_responses.c +++ b/src/mint/taler-mint-httpd_responses.c @@ -275,12 +275,14 @@ TALER_MINT_reply_deposit_success (struct MHD_Connection *connection, * Send reserve status information to client. * * @param connection connection to the client - * @param reserve reserve status information to return + * @param balance current reserve balance + * @param expiration when will the reserve expire * @return MHD result code */ int TALER_MINT_reply_withdraw_status_success (struct MHD_Connection *connection, - const struct Reserve *reserve) + const struct TALER_Amount balance, + struct GNUNET_TIME_Absolute expiration) { json_t *json; @@ -289,15 +291,10 @@ TALER_MINT_reply_withdraw_status_success (struct MHD_Connection *connection, json = json_object (); json_object_set_new (json, "balance", - TALER_JSON_from_amount (TALER_amount_ntoh (reserve->balance))); + TALER_JSON_from_amount (balance)); json_object_set_new (json, "expiration", - TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (reserve->expiration))); - json_object_set_new (json, - "signature", - TALER_JSON_from_sig (&reserve->status_sig_purpose, - &reserve->status_sig)); - + TALER_JSON_from_abs (expiration)); return TALER_MINT_reply_json (connection, json, MHD_HTTP_OK); diff --git a/src/mint/taler-mint-httpd_responses.h b/src/mint/taler-mint-httpd_responses.h index 471d73bd1..2dc306110 100644 --- a/src/mint/taler-mint-httpd_responses.h +++ b/src/mint/taler-mint-httpd_responses.h @@ -160,12 +160,14 @@ TALER_MINT_reply_deposit_success (struct MHD_Connection *connection, * Send reserve status information to client. * * @param connection connection to the client - * @param reserve reserve status information to return + * @param balance current reserve balance + * @param expiration when will the reserve expire * @return MHD result code */ int TALER_MINT_reply_withdraw_status_success (struct MHD_Connection *connection, - const struct Reserve *reserve); + struct TALER_Amount balance, + struct GNUNET_TIME_Absolute expiration); /**