more cleanup of mint.h
This commit is contained in:
parent
c119d914b3
commit
7f171e69b2
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @file mint.h
|
* @file mint.h
|
||||||
* @brief Common functionality for the mint
|
* @brief Common structs passed all over the mint logic
|
||||||
* @author Florian Dold
|
* @author Florian Dold
|
||||||
* @author Benedikt Mueller
|
* @author Benedikt Mueller
|
||||||
*/
|
*/
|
||||||
@ -23,10 +23,8 @@
|
|||||||
#define _MINT_H
|
#define _MINT_H
|
||||||
|
|
||||||
#include <gnunet/gnunet_util_lib.h>
|
#include <gnunet/gnunet_util_lib.h>
|
||||||
#include <gnunet/gnunet_common.h>
|
|
||||||
#include <jansson.h>
|
#include <jansson.h>
|
||||||
#include "taler_util.h"
|
#include "taler_util.h"
|
||||||
#include "taler_signatures.h"
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,7 +60,6 @@ struct TALER_CoinPublicInfo
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information we keep for a withdrawn coin to reproduce
|
* Information we keep for a withdrawn coin to reproduce
|
||||||
* the /withdraw operation if needed, and to have proof
|
* 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.
|
* 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 */
|
#endif /* _MINT_H */
|
||||||
|
@ -83,6 +83,52 @@ int
|
|||||||
TALER_MINT_DB_commit (PGconn *db_conn);
|
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
|
int
|
||||||
TALER_MINT_DB_get_reserve (PGconn *db_conn,
|
TALER_MINT_DB_get_reserve (PGconn *db_conn,
|
||||||
const struct GNUNET_CRYPTO_EddsaPublicKey *reserve_pub,
|
const struct GNUNET_CRYPTO_EddsaPublicKey *reserve_pub,
|
||||||
@ -103,6 +149,9 @@ TALER_MINT_DB_update_reserve (PGconn *db_conn,
|
|||||||
int fresh);
|
int fresh);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
TALER_MINT_DB_insert_refresh_order (PGconn *db_conn,
|
TALER_MINT_DB_insert_refresh_order (PGconn *db_conn,
|
||||||
uint16_t newcoin_index,
|
uint16_t newcoin_index,
|
||||||
@ -115,17 +164,46 @@ TALER_MINT_DB_get_refresh_session (PGconn *db_conn,
|
|||||||
struct RefreshSession *r_session);
|
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
|
int
|
||||||
TALER_MINT_DB_get_known_coin (PGconn *db_conn,
|
TALER_MINT_DB_get_known_coin (PGconn *db_conn,
|
||||||
const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub,
|
const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub,
|
||||||
struct KnownCoin *known_coin);
|
struct KnownCoin *known_coin);
|
||||||
|
|
||||||
|
// FIXME: what does 'upsert' even mean!?
|
||||||
int
|
int
|
||||||
TALER_MINT_DB_upsert_known_coin (PGconn *db_conn,
|
TALER_MINT_DB_upsert_known_coin (PGconn *db_conn,
|
||||||
struct KnownCoin *known_coin);
|
struct KnownCoin *known_coin);
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
TALER_MINT_DB_insert_known_coin (PGconn *db_conn,
|
||||||
|
const struct KnownCoin *known_coin);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -262,10 +340,6 @@ TALER_MINT_DB_get_deposit (PGconn *db_conn,
|
|||||||
struct Deposit *r_deposit);
|
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.
|
* Get the thread-local database-handle.
|
||||||
|
@ -217,7 +217,8 @@ TALER_MINT_db_execute_withdraw_status (struct MHD_Connection *connection,
|
|||||||
return MHD_YES;
|
return MHD_YES;
|
||||||
}
|
}
|
||||||
return TALER_MINT_reply_withdraw_status_success (connection,
|
return TALER_MINT_reply_withdraw_status_success (connection,
|
||||||
&reserve);
|
TALER_amount_ntoh (reserve.balance),
|
||||||
|
GNUNET_TIME_absolute_ntoh (reserve.expiration));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -275,12 +275,14 @@ TALER_MINT_reply_deposit_success (struct MHD_Connection *connection,
|
|||||||
* Send reserve status information to client.
|
* Send reserve status information to client.
|
||||||
*
|
*
|
||||||
* @param connection connection to the 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
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_withdraw_status_success (struct MHD_Connection *connection,
|
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;
|
json_t *json;
|
||||||
|
|
||||||
@ -289,15 +291,10 @@ TALER_MINT_reply_withdraw_status_success (struct MHD_Connection *connection,
|
|||||||
json = json_object ();
|
json = json_object ();
|
||||||
json_object_set_new (json,
|
json_object_set_new (json,
|
||||||
"balance",
|
"balance",
|
||||||
TALER_JSON_from_amount (TALER_amount_ntoh (reserve->balance)));
|
TALER_JSON_from_amount (balance));
|
||||||
json_object_set_new (json,
|
json_object_set_new (json,
|
||||||
"expiration",
|
"expiration",
|
||||||
TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (reserve->expiration)));
|
TALER_JSON_from_abs (expiration));
|
||||||
json_object_set_new (json,
|
|
||||||
"signature",
|
|
||||||
TALER_JSON_from_sig (&reserve->status_sig_purpose,
|
|
||||||
&reserve->status_sig));
|
|
||||||
|
|
||||||
return TALER_MINT_reply_json (connection,
|
return TALER_MINT_reply_json (connection,
|
||||||
json,
|
json,
|
||||||
MHD_HTTP_OK);
|
MHD_HTTP_OK);
|
||||||
|
@ -160,12 +160,14 @@ TALER_MINT_reply_deposit_success (struct MHD_Connection *connection,
|
|||||||
* Send reserve status information to client.
|
* Send reserve status information to client.
|
||||||
*
|
*
|
||||||
* @param connection connection to the 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
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_withdraw_status_success (struct MHD_Connection *connection,
|
TALER_MINT_reply_withdraw_status_success (struct MHD_Connection *connection,
|
||||||
const struct Reserve *reserve);
|
struct TALER_Amount balance,
|
||||||
|
struct GNUNET_TIME_Absolute expiration);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user