Merge branch 'master' of git+ssh://taler.net/var/git/mint
This commit is contained in:
commit
1f3f4ed8dd
@ -1040,6 +1040,8 @@ TALER_MINT_DB_get_collectable_blindcoin (PGconn *db_conn,
|
|||||||
*
|
*
|
||||||
* @param db_conn database connection to use
|
* @param db_conn database connection to use
|
||||||
* @param h_blind hash of the blinded message
|
* @param h_blind hash of the blinded message
|
||||||
|
* @param withdraw amount by which the reserve will be withdrawn with this
|
||||||
|
* transaction
|
||||||
* @param collectable corresponding collectable coin (blind signature)
|
* @param collectable corresponding collectable coin (blind signature)
|
||||||
* if a coin is found
|
* if a coin is found
|
||||||
* @return #GNUNET_SYSERR on internal error
|
* @return #GNUNET_SYSERR on internal error
|
||||||
@ -1049,9 +1051,11 @@ TALER_MINT_DB_get_collectable_blindcoin (PGconn *db_conn,
|
|||||||
int
|
int
|
||||||
TALER_MINT_DB_insert_collectable_blindcoin (PGconn *db_conn,
|
TALER_MINT_DB_insert_collectable_blindcoin (PGconn *db_conn,
|
||||||
const struct GNUNET_HashCode *h_blind,
|
const struct GNUNET_HashCode *h_blind,
|
||||||
|
struct TALER_Amount withdraw,
|
||||||
const struct CollectableBlindcoin *collectable)
|
const struct CollectableBlindcoin *collectable)
|
||||||
{
|
{
|
||||||
PGresult *result;
|
PGresult *result;
|
||||||
|
struct Reserve reserve;
|
||||||
char *denom_pub_enc = NULL;
|
char *denom_pub_enc = NULL;
|
||||||
char *denom_sig_enc = NULL;
|
char *denom_sig_enc = NULL;
|
||||||
size_t denom_pub_enc_size;
|
size_t denom_pub_enc_size;
|
||||||
@ -1073,16 +1077,32 @@ TALER_MINT_DB_insert_collectable_blindcoin (PGconn *db_conn,
|
|||||||
TALER_DB_QUERY_PARAM_PTR (&collectable->reserve_sig),
|
TALER_DB_QUERY_PARAM_PTR (&collectable->reserve_sig),
|
||||||
TALER_DB_QUERY_PARAM_END
|
TALER_DB_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
|
if (GNUNET_OK != TALER_MINT_DB_transaction (db_conn))
|
||||||
|
goto cleanup;
|
||||||
result = TALER_DB_exec_prepared (db_conn,
|
result = TALER_DB_exec_prepared (db_conn,
|
||||||
"insert_collectable_blindcoin",
|
"insert_collectable_blindcoin",
|
||||||
params);
|
params);
|
||||||
if (PGRES_COMMAND_OK != PQresultStatus (result))
|
if (PGRES_COMMAND_OK != PQresultStatus (result))
|
||||||
{
|
{
|
||||||
QUERY_ERR (result);
|
QUERY_ERR (result);
|
||||||
|
goto rollback;
|
||||||
|
}
|
||||||
|
reserve.pub = (struct GNUNET_CRYPTO_EddsaPublicKey *)
|
||||||
|
&collectable->reserve_pub;
|
||||||
|
if (GNUNET_OK != TALER_MINT_DB_reserve_get (db_conn,
|
||||||
|
&reserve))
|
||||||
|
goto rollback;
|
||||||
|
reserve.balance = TALER_amount_subtract (reserve.balance, withdraw);
|
||||||
|
if (GNUNET_OK != reserves_update (db_conn, &reserve))
|
||||||
|
goto rollback;
|
||||||
|
if (GNUNET_OK == TALER_MINT_DB_commit (db_conn))
|
||||||
|
{
|
||||||
|
ret = GNUNET_OK;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
ret = GNUNET_OK;
|
|
||||||
|
|
||||||
|
rollback:
|
||||||
|
TALER_MINT_DB_rollback(db_conn);
|
||||||
cleanup:
|
cleanup:
|
||||||
PQclear (result);
|
PQclear (result);
|
||||||
GNUNET_free_non_null (denom_pub_enc);
|
GNUNET_free_non_null (denom_pub_enc);
|
||||||
|
@ -252,6 +252,8 @@ TALER_MINT_DB_get_collectable_blindcoin (PGconn *db_conn,
|
|||||||
*
|
*
|
||||||
* @param db_conn database connection to use
|
* @param db_conn database connection to use
|
||||||
* @param h_blind hash of the blinded message
|
* @param h_blind hash of the blinded message
|
||||||
|
* @param withdraw amount by which the reserve will be withdrawn with this
|
||||||
|
* transaction
|
||||||
* @param collectable corresponding collectable coin (blind signature)
|
* @param collectable corresponding collectable coin (blind signature)
|
||||||
* if a coin is found
|
* if a coin is found
|
||||||
* @return #GNUNET_SYSERR on internal error
|
* @return #GNUNET_SYSERR on internal error
|
||||||
@ -261,6 +263,7 @@ TALER_MINT_DB_get_collectable_blindcoin (PGconn *db_conn,
|
|||||||
int
|
int
|
||||||
TALER_MINT_DB_insert_collectable_blindcoin (PGconn *db_conn,
|
TALER_MINT_DB_insert_collectable_blindcoin (PGconn *db_conn,
|
||||||
const struct GNUNET_HashCode *h_blind,
|
const struct GNUNET_HashCode *h_blind,
|
||||||
|
struct TALER_Amount withdraw,
|
||||||
const struct CollectableBlindcoin *collectable);
|
const struct CollectableBlindcoin *collectable);
|
||||||
|
|
||||||
|
|
||||||
|
@ -422,6 +422,7 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_MINT_DB_insert_collectable_blindcoin (db_conn,
|
TALER_MINT_DB_insert_collectable_blindcoin (db_conn,
|
||||||
&h_blind,
|
&h_blind,
|
||||||
|
amount_required,
|
||||||
&collectable))
|
&collectable))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
|
@ -194,9 +194,18 @@ run (void *cls, char *const *args, const char *cfgfile,
|
|||||||
cbc.denom_pub = dkp->pub;
|
cbc.denom_pub = dkp->pub;
|
||||||
cbc.sig = GNUNET_CRYPTO_rsa_sign (dkp->priv, &h_blind, sizeof (h_blind));
|
cbc.sig = GNUNET_CRYPTO_rsa_sign (dkp->priv, &h_blind, sizeof (h_blind));
|
||||||
(void) memcpy (&cbc.reserve_pub, &reserve_pub, sizeof (reserve_pub));
|
(void) memcpy (&cbc.reserve_pub, &reserve_pub, sizeof (reserve_pub));
|
||||||
|
amount.value--;
|
||||||
|
amount.fraction--;
|
||||||
FAILIF (GNUNET_OK != TALER_MINT_DB_insert_collectable_blindcoin (db,
|
FAILIF (GNUNET_OK != TALER_MINT_DB_insert_collectable_blindcoin (db,
|
||||||
&h_blind,
|
&h_blind,
|
||||||
|
amount,
|
||||||
&cbc));
|
&cbc));
|
||||||
|
FAILIF (GNUNET_OK != check_reserve (db,
|
||||||
|
&reserve_pub,
|
||||||
|
amount.value,
|
||||||
|
amount.fraction,
|
||||||
|
amount.currency,
|
||||||
|
expiry.abs_value_us));
|
||||||
FAILIF (GNUNET_YES != TALER_MINT_DB_get_collectable_blindcoin (db,
|
FAILIF (GNUNET_YES != TALER_MINT_DB_get_collectable_blindcoin (db,
|
||||||
&h_blind,
|
&h_blind,
|
||||||
&cbc2));
|
&cbc2));
|
||||||
|
Loading…
Reference in New Issue
Block a user