avoid using struct Deposit in response

This commit is contained in:
Christian Grothoff 2015-01-28 15:35:41 +01:00
parent 7f171e69b2
commit e19f1906a3
6 changed files with 121 additions and 74 deletions

View File

@ -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!
};

View File

@ -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.

View File

@ -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);
}

View File

@ -27,7 +27,7 @@
#include "taler_util.h"
#include "taler-mint-httpd_keys.h"
#include "mint.h"
#include "mint_db.h"
/**

View File

@ -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

View File

@ -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);
/**