2015-01-19 21:04:58 +01:00
|
|
|
/*
|
|
|
|
This file is part of TALER
|
2015-02-08 00:16:22 +01:00
|
|
|
Copyright (C) 2014, 2015 Christian Grothoff (and other contributing authors)
|
2015-01-19 21:04:58 +01:00
|
|
|
|
|
|
|
TALER is free software; you can redistribute it and/or modify it under the
|
|
|
|
terms of the GNU General Public License as published by the Free Software
|
|
|
|
Foundation; either version 3, or (at your option) any later version.
|
|
|
|
|
|
|
|
TALER is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
|
|
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* @file mint/taler-mint_httpd_db.h
|
2015-01-28 22:35:57 +01:00
|
|
|
* @brief High-level (transactional-layer) database operations for the mint
|
2015-01-19 21:04:58 +01:00
|
|
|
* @author Chrisitan Grothoff
|
|
|
|
*/
|
|
|
|
#ifndef TALER_MINT_HTTPD_DB_H
|
|
|
|
#define TALER_MINT_HTTPD_DB_H
|
|
|
|
|
|
|
|
#include <microhttpd.h>
|
|
|
|
#include <gnunet/gnunet_util_lib.h>
|
|
|
|
#include "taler_util.h"
|
2015-03-20 23:51:28 +01:00
|
|
|
#include "taler_mintdb_plugin.h"
|
2015-01-19 21:04:58 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2015-01-29 18:46:34 +01:00
|
|
|
* Execute a "/deposit". The validity of the coin and signature
|
2015-01-19 21:04:58 +01:00
|
|
|
* have already been checked. The database must now check that
|
|
|
|
* the coin is not (double or over) spent, and execute the
|
|
|
|
* transaction (record details, generate success or failure response).
|
|
|
|
*
|
|
|
|
* @param connection the MHD connection to handle
|
|
|
|
* @param deposit information about the deposit
|
|
|
|
* @return MHD result code
|
|
|
|
*/
|
|
|
|
int
|
2015-03-27 19:58:40 +01:00
|
|
|
TMH_DB_execute_deposit (struct MHD_Connection *connection,
|
|
|
|
const struct Deposit *deposit);
|
2015-01-19 21:04:58 +01:00
|
|
|
|
|
|
|
|
2015-01-19 21:53:23 +01:00
|
|
|
/**
|
2015-01-29 18:46:34 +01:00
|
|
|
* Execute a "/withdraw/status". Given the public key of a reserve,
|
|
|
|
* return the associated transaction history.
|
2015-01-19 21:53:23 +01:00
|
|
|
*
|
|
|
|
* @param connection the MHD connection to handle
|
|
|
|
* @param reserve_pub public key of the reserve to check
|
|
|
|
* @return MHD result code
|
|
|
|
*/
|
|
|
|
int
|
2015-03-27 19:58:40 +01:00
|
|
|
TMH_DB_execute_withdraw_status (struct MHD_Connection *connection,
|
|
|
|
const struct TALER_ReservePublicKeyP *reserve_pub);
|
2015-01-19 21:53:23 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2015-01-29 18:46:34 +01:00
|
|
|
* Execute a "/withdraw/sign". Given a reserve and a properly signed
|
|
|
|
* request to withdraw a coin, check the balance of the reserve and
|
|
|
|
* if it is sufficient, store the request and return the signed
|
|
|
|
* blinded envelope.
|
2015-01-19 21:53:23 +01:00
|
|
|
*
|
|
|
|
* @param connection the MHD connection to handle
|
2015-01-26 12:22:26 +01:00
|
|
|
* @param reserve public key of the reserve
|
|
|
|
* @param denomination_pub public key of the denomination requested
|
|
|
|
* @param blinded_msg blinded message to be signed
|
|
|
|
* @param blinded_msg_len number of bytes in @a blinded_msg
|
|
|
|
* @param signature signature over the withdraw request, to be stored in DB
|
2015-01-19 21:53:23 +01:00
|
|
|
* @return MHD result code
|
|
|
|
*/
|
|
|
|
int
|
2015-03-27 19:58:40 +01:00
|
|
|
TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
|
|
|
|
const struct TALER_ReservePublicKeyP *reserve,
|
|
|
|
const struct TALER_DenominationPublicKey *denomination_pub,
|
|
|
|
const char *blinded_msg,
|
|
|
|
size_t blinded_msg_len,
|
|
|
|
const struct TALER_ReserveSignatureP *signature);
|
2015-01-19 21:53:23 +01:00
|
|
|
|
|
|
|
|
2015-01-30 15:34:01 +01:00
|
|
|
/**
|
|
|
|
* Details about a melt operation of an individual coin.
|
|
|
|
*/
|
2015-03-27 19:58:40 +01:00
|
|
|
struct TMH_DB_MeltDetails
|
2015-01-30 15:34:01 +01:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Signature allowing the melt (using
|
|
|
|
* a `struct RefreshMeltConfirmSignRequestBody`) to sign over.
|
|
|
|
*/
|
2015-03-27 19:58:40 +01:00
|
|
|
union TALER_CoinSpendSignatureP melt_sig;
|
2015-01-30 15:34:01 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* How much of the coin's value did the client allow to be melted?
|
2015-03-09 12:29:41 +01:00
|
|
|
* This amount includes the fees, so the final amount contributed
|
|
|
|
* to the melt is this value minus the fee for melting the coin.
|
2015-01-30 15:34:01 +01:00
|
|
|
*/
|
2015-03-22 16:09:01 +01:00
|
|
|
struct TALER_Amount melt_amount_with_fee;
|
2015-01-30 15:34:01 +01:00
|
|
|
};
|
|
|
|
|
2015-01-21 12:46:14 +01:00
|
|
|
|
|
|
|
/**
|
2015-01-29 18:46:34 +01:00
|
|
|
* Execute a "/refresh/melt". We have been given a list of valid
|
|
|
|
* coins and a request to melt them into the given
|
|
|
|
* @a refresh_session_pub. Check that the coins all have the
|
|
|
|
* required value left and if so, store that they have been
|
|
|
|
* melted and confirm the melting operation to the client.
|
2015-01-21 12:46:14 +01:00
|
|
|
*
|
|
|
|
* @param connection the MHD connection to handle
|
2015-03-24 16:56:06 +01:00
|
|
|
* @param session_hash hash code of the session the coins are melted into
|
2015-03-10 16:25:23 +01:00
|
|
|
* @param num_new_denoms number of entries in @a denom_pubs, size of y-dimension of @commit_coin array
|
2015-01-27 15:22:34 +01:00
|
|
|
* @param denum_pubs array of public denomination keys for the refresh (?)
|
2015-03-10 16:25:23 +01:00
|
|
|
* @param coin_count number of entries in @a coin_public_infos and @ a coin_melt_details, size of y-dimension of @commit_link array
|
2015-01-21 12:46:14 +01:00
|
|
|
* @param coin_public_infos information about the coins to melt
|
2015-01-30 15:34:01 +01:00
|
|
|
* @param coin_melt_details signatures and (residual) value of the respective coin should be melted
|
2015-01-29 18:46:34 +01:00
|
|
|
* @param commit_coin 2d array of coin commitments (what the mint is to sign
|
|
|
|
* once the "/refres/reveal" of cut and choose is done)
|
|
|
|
* @param commit_link 2d array of coin link commitments (what the mint is
|
|
|
|
* to return via "/refresh/link" to enable linkage in the
|
|
|
|
* future)
|
2015-01-21 13:31:05 +01:00
|
|
|
* @return MHD result code
|
|
|
|
*/
|
|
|
|
int
|
2015-03-27 19:58:40 +01:00
|
|
|
TMH_DB_execute_refresh_melt (struct MHD_Connection *connection,
|
|
|
|
const struct GNUNET_HashCode *session_hash,
|
|
|
|
unsigned int num_new_denoms,
|
|
|
|
const struct TALER_DenominationPublicKey *denom_pubs,
|
|
|
|
unsigned int coin_count,
|
|
|
|
const struct TALER_CoinPublicInfo *coin_public_infos,
|
|
|
|
const struct TMH_DB_MeltDetails *coin_melt_details,
|
|
|
|
struct RefreshCommitCoin *const* commit_coin,
|
|
|
|
struct RefreshCommitLink *const* commit_link);
|
2015-01-21 13:31:05 +01:00
|
|
|
|
|
|
|
|
2015-01-21 14:46:33 +01:00
|
|
|
/**
|
2015-01-29 18:46:34 +01:00
|
|
|
* Execute a "/refresh/reveal". The client is revealing to us the
|
2015-03-27 19:58:40 +01:00
|
|
|
* transfer keys for #TALER_CNC_KAPPA-1 sets of coins. Verify that the
|
2015-01-29 18:46:34 +01:00
|
|
|
* revealed transfer keys would allow linkage to the blinded coins,
|
|
|
|
* and if so, return the signed coins for corresponding to the set of
|
|
|
|
* coins that was not chosen.
|
2015-01-21 14:46:33 +01:00
|
|
|
*
|
|
|
|
* @param connection the MHD connection to handle
|
2015-03-24 16:56:06 +01:00
|
|
|
* @param session_hash hash over the refresh session
|
2015-01-21 14:46:33 +01:00
|
|
|
* @param num_oldcoins size of y-dimension of @transfer_privs array
|
2015-03-27 19:58:40 +01:00
|
|
|
* @param transfer_pubs array with the revealed transfer keys, #TALER_CNC_KAPPA is 1st-dimension
|
2015-01-21 14:46:33 +01:00
|
|
|
* @return MHD result code
|
|
|
|
*/
|
|
|
|
int
|
2015-03-27 19:58:40 +01:00
|
|
|
TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection,
|
|
|
|
const struct GNUNET_HashCode *session_hash,
|
|
|
|
unsigned int num_oldcoins,
|
|
|
|
struct TALER_TransferPrivateKeyP **transfer_privs);
|
2015-01-21 14:46:33 +01:00
|
|
|
|
2015-01-21 13:46:05 +01:00
|
|
|
|
|
|
|
/**
|
2015-01-29 18:46:34 +01:00
|
|
|
* Execute a "/refresh/link". Returns the linkage information that
|
|
|
|
* will allow the owner of a coin to follow the refresh trail to the
|
|
|
|
* refreshed coin.
|
2015-01-21 13:46:05 +01:00
|
|
|
*
|
|
|
|
* @param connection the MHD connection to handle
|
|
|
|
* @param coin_pub public key of the coin to link
|
|
|
|
* @return MHD result code
|
|
|
|
*/
|
|
|
|
int
|
2015-03-27 19:58:40 +01:00
|
|
|
TMH_DB_execute_refresh_link (struct MHD_Connection *connection,
|
|
|
|
const union TALER_CoinSpendPublicKeyP *coin_pub);
|
2015-01-21 13:46:05 +01:00
|
|
|
|
|
|
|
|
2015-01-29 18:46:34 +01:00
|
|
|
#endif
|
|
|
|
/* TALER_MINT_HTTPD_DB_H */
|