fix type of transfer keys
This commit is contained in:
commit
5f879c0b4b
@ -143,7 +143,7 @@ TMH_DB_execute_deposit (struct MHD_Connection *connection,
|
|||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TMH_plugin->start (TMH_plugin->cls,
|
TMH_plugin->start (TMH_plugin->cls,
|
||||||
session))
|
session))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return TMH_RESPONSE_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
@ -169,7 +169,7 @@ TMH_DB_execute_deposit (struct MHD_Connection *connection,
|
|||||||
&value))
|
&value))
|
||||||
{
|
{
|
||||||
TMH_plugin->rollback (TMH_plugin->cls,
|
TMH_plugin->rollback (TMH_plugin->cls,
|
||||||
session);
|
session);
|
||||||
ret = TMH_RESPONSE_reply_deposit_insufficient_funds (connection,
|
ret = TMH_RESPONSE_reply_deposit_insufficient_funds (connection,
|
||||||
tl);
|
tl);
|
||||||
TMH_plugin->free_coin_transaction_list (TMH_plugin->cls,
|
TMH_plugin->free_coin_transaction_list (TMH_plugin->cls,
|
||||||
@ -192,7 +192,7 @@ TMH_DB_execute_deposit (struct MHD_Connection *connection,
|
|||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TMH_plugin->commit (TMH_plugin->cls,
|
TMH_plugin->commit (TMH_plugin->cls,
|
||||||
session))
|
session))
|
||||||
{
|
{
|
||||||
TALER_LOG_WARNING ("/deposit transaction commit failed\n");
|
TALER_LOG_WARNING ("/deposit transaction commit failed\n");
|
||||||
return TMH_RESPONSE_reply_commit_error (connection);
|
return TMH_RESPONSE_reply_commit_error (connection);
|
||||||
@ -310,7 +310,7 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
if (GNUNET_YES == res)
|
if (GNUNET_YES == res)
|
||||||
{
|
{
|
||||||
res = TMH_RESPONSE_reply_withdraw_sign_success (connection,
|
res = TMH_RESPONSE_reply_withdraw_sign_success (connection,
|
||||||
&collectable);
|
&collectable);
|
||||||
GNUNET_CRYPTO_rsa_signature_free (collectable.sig.rsa_signature);
|
GNUNET_CRYPTO_rsa_signature_free (collectable.sig.rsa_signature);
|
||||||
GNUNET_CRYPTO_rsa_public_key_free (collectable.denom_pub.rsa_public_key);
|
GNUNET_CRYPTO_rsa_public_key_free (collectable.denom_pub.rsa_public_key);
|
||||||
return res;
|
return res;
|
||||||
@ -332,7 +332,7 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TMH_plugin->start (TMH_plugin->cls,
|
TMH_plugin->start (TMH_plugin->cls,
|
||||||
session))
|
session))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
TMH_KS_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
@ -345,7 +345,7 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
if (NULL == rh)
|
if (NULL == rh)
|
||||||
{
|
{
|
||||||
TMH_plugin->rollback (TMH_plugin->cls,
|
TMH_plugin->rollback (TMH_plugin->cls,
|
||||||
session);
|
session);
|
||||||
TMH_KS_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
return TMH_RESPONSE_reply_arg_unknown (connection,
|
return TMH_RESPONSE_reply_arg_unknown (connection,
|
||||||
"reserve_pub");
|
"reserve_pub");
|
||||||
@ -363,7 +363,7 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
&fee_withdraw))
|
&fee_withdraw))
|
||||||
{
|
{
|
||||||
TMH_plugin->rollback (TMH_plugin->cls,
|
TMH_plugin->rollback (TMH_plugin->cls,
|
||||||
session);
|
session);
|
||||||
TMH_KS_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
return TMH_RESPONSE_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
@ -422,7 +422,7 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
TMH_KS_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
TMH_plugin->rollback (TMH_plugin->cls,
|
TMH_plugin->rollback (TMH_plugin->cls,
|
||||||
session);
|
session);
|
||||||
res = TMH_RESPONSE_reply_withdraw_sign_insufficient_funds (connection,
|
res = TMH_RESPONSE_reply_withdraw_sign_insufficient_funds (connection,
|
||||||
rh);
|
rh);
|
||||||
TMH_plugin->free_reserve_history (TMH_plugin->cls,
|
TMH_plugin->free_reserve_history (TMH_plugin->cls,
|
||||||
@ -441,9 +441,9 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
TMH_plugin->rollback (TMH_plugin->cls,
|
TMH_plugin->rollback (TMH_plugin->cls,
|
||||||
session);
|
session);
|
||||||
return TMH_RESPONSE_reply_internal_error (connection,
|
return TMH_RESPONSE_reply_internal_error (connection,
|
||||||
"Internal error");
|
"Internal error");
|
||||||
}
|
}
|
||||||
collectable.sig.rsa_signature = sig;
|
collectable.sig.rsa_signature = sig;
|
||||||
collectable.denom_pub = *denomination_pub;
|
collectable.denom_pub = *denomination_pub;
|
||||||
@ -454,26 +454,26 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
collectable.reserve_sig = *signature;
|
collectable.reserve_sig = *signature;
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TMH_plugin->insert_collectable_blindcoin (TMH_plugin->cls,
|
TMH_plugin->insert_collectable_blindcoin (TMH_plugin->cls,
|
||||||
session,
|
session,
|
||||||
&h_blind,
|
&h_blind,
|
||||||
amount_required,
|
amount_required,
|
||||||
&collectable))
|
&collectable))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
GNUNET_CRYPTO_rsa_signature_free (sig);
|
GNUNET_CRYPTO_rsa_signature_free (sig);
|
||||||
TMH_plugin->rollback (TMH_plugin->cls,
|
TMH_plugin->rollback (TMH_plugin->cls,
|
||||||
session);
|
session);
|
||||||
return TMH_RESPONSE_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TMH_plugin->commit (TMH_plugin->cls,
|
TMH_plugin->commit (TMH_plugin->cls,
|
||||||
session))
|
session))
|
||||||
{
|
{
|
||||||
TALER_LOG_WARNING ("/withdraw/sign transaction commit failed\n");
|
TALER_LOG_WARNING ("/withdraw/sign transaction commit failed\n");
|
||||||
return TMH_RESPONSE_reply_commit_error (connection);
|
return TMH_RESPONSE_reply_commit_error (connection);
|
||||||
}
|
}
|
||||||
res = TMH_RESPONSE_reply_withdraw_sign_success (connection,
|
res = TMH_RESPONSE_reply_withdraw_sign_success (connection,
|
||||||
&collectable);
|
&collectable);
|
||||||
GNUNET_CRYPTO_rsa_signature_free (sig);
|
GNUNET_CRYPTO_rsa_signature_free (sig);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -514,12 +514,9 @@ refresh_accept_melts (struct MHD_Connection *connection,
|
|||||||
|
|
||||||
if (NULL == dki)
|
if (NULL == dki)
|
||||||
return (MHD_YES ==
|
return (MHD_YES ==
|
||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_arg_unknown (connection,
|
||||||
MHD_HTTP_NOT_FOUND,
|
"denom_pub"))
|
||||||
"{s:s}",
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
"error",
|
|
||||||
"denom not found"))
|
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
|
||||||
|
|
||||||
TALER_amount_ntoh (&coin_value,
|
TALER_amount_ntoh (&coin_value,
|
||||||
&dki->value);
|
&dki->value);
|
||||||
@ -555,7 +552,7 @@ refresh_accept_melts (struct MHD_Connection *connection,
|
|||||||
tl,
|
tl,
|
||||||
coin_details->melt_amount_with_fee,
|
coin_details->melt_amount_with_fee,
|
||||||
coin_residual))
|
coin_residual))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
TMH_plugin->free_coin_transaction_list (TMH_plugin->cls,
|
TMH_plugin->free_coin_transaction_list (TMH_plugin->cls,
|
||||||
tl);
|
tl);
|
||||||
return res;
|
return res;
|
||||||
@ -621,13 +618,13 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection,
|
|||||||
if (NULL ==
|
if (NULL ==
|
||||||
(session = TMH_plugin->get_session (TMH_plugin->cls,
|
(session = TMH_plugin->get_session (TMH_plugin->cls,
|
||||||
GNUNET_NO)))
|
GNUNET_NO)))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return TMH_RESPONSE_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TMH_plugin->start (TMH_plugin->cls,
|
TMH_plugin->start (TMH_plugin->cls,
|
||||||
session))
|
session))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return TMH_RESPONSE_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
@ -639,7 +636,7 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection,
|
|||||||
if (GNUNET_YES == res)
|
if (GNUNET_YES == res)
|
||||||
{
|
{
|
||||||
TMH_plugin->rollback (TMH_plugin->cls,
|
TMH_plugin->rollback (TMH_plugin->cls,
|
||||||
session);
|
session);
|
||||||
res = TMH_RESPONSE_reply_refresh_melt_success (connection,
|
res = TMH_RESPONSE_reply_refresh_melt_success (connection,
|
||||||
session_hash,
|
session_hash,
|
||||||
refresh_session.noreveal_index);
|
refresh_session.noreveal_index);
|
||||||
@ -648,7 +645,24 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection,
|
|||||||
if (GNUNET_SYSERR == res)
|
if (GNUNET_SYSERR == res)
|
||||||
{
|
{
|
||||||
TMH_plugin->rollback (TMH_plugin->cls,
|
TMH_plugin->rollback (TMH_plugin->cls,
|
||||||
session);
|
session);
|
||||||
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* store 'global' session data */
|
||||||
|
refresh_session.num_oldcoins = coin_count;
|
||||||
|
refresh_session.num_newcoins = num_new_denoms;
|
||||||
|
refresh_session.noreveal_index
|
||||||
|
= GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG,
|
||||||
|
TALER_CNC_KAPPA);
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
(res = TMH_plugin->create_refresh_session (TMH_plugin->cls,
|
||||||
|
session,
|
||||||
|
session_hash,
|
||||||
|
&refresh_session)))
|
||||||
|
{
|
||||||
|
TMH_plugin->rollback (TMH_plugin->cls,
|
||||||
|
session);
|
||||||
return TMH_RESPONSE_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -666,7 +680,7 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
TMH_KS_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
TMH_plugin->rollback (TMH_plugin->cls,
|
TMH_plugin->rollback (TMH_plugin->cls,
|
||||||
session);
|
session);
|
||||||
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -675,13 +689,13 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection,
|
|||||||
/* store requested new denominations */
|
/* store requested new denominations */
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TMH_plugin->insert_refresh_order (TMH_plugin->cls,
|
TMH_plugin->insert_refresh_order (TMH_plugin->cls,
|
||||||
session,
|
session,
|
||||||
session_hash,
|
session_hash,
|
||||||
num_new_denoms,
|
num_new_denoms,
|
||||||
denom_pubs))
|
denom_pubs))
|
||||||
{
|
{
|
||||||
TMH_plugin->rollback (TMH_plugin->cls,
|
TMH_plugin->rollback (TMH_plugin->cls,
|
||||||
session);
|
session);
|
||||||
return TMH_RESPONSE_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -689,14 +703,14 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TMH_plugin->insert_refresh_commit_coins (TMH_plugin->cls,
|
TMH_plugin->insert_refresh_commit_coins (TMH_plugin->cls,
|
||||||
session,
|
session,
|
||||||
session_hash,
|
session_hash,
|
||||||
i,
|
i,
|
||||||
num_new_denoms,
|
num_new_denoms,
|
||||||
commit_coin[i]))
|
commit_coin[i]))
|
||||||
{
|
{
|
||||||
TMH_plugin->rollback (TMH_plugin->cls,
|
TMH_plugin->rollback (TMH_plugin->cls,
|
||||||
session);
|
session);
|
||||||
return TMH_RESPONSE_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -704,48 +718,28 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TMH_plugin->insert_refresh_commit_links (TMH_plugin->cls,
|
TMH_plugin->insert_refresh_commit_links (TMH_plugin->cls,
|
||||||
session,
|
session,
|
||||||
session_hash,
|
session_hash,
|
||||||
i,
|
i,
|
||||||
coin_count,
|
coin_count,
|
||||||
commit_link[i]))
|
commit_link[i]))
|
||||||
{
|
{
|
||||||
TMH_plugin->rollback (TMH_plugin->cls,
|
TMH_plugin->rollback (TMH_plugin->cls,
|
||||||
session);
|
session);
|
||||||
return TMH_RESPONSE_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* store 'global' session data */
|
|
||||||
refresh_session.num_oldcoins = coin_count;
|
|
||||||
refresh_session.num_newcoins = num_new_denoms;
|
|
||||||
refresh_session.noreveal_index
|
|
||||||
= GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG,
|
|
||||||
TALER_CNC_KAPPA);
|
|
||||||
if (GNUNET_OK !=
|
|
||||||
(res = TMH_plugin->create_refresh_session (TMH_plugin->cls,
|
|
||||||
session,
|
|
||||||
session_hash,
|
|
||||||
&refresh_session)))
|
|
||||||
{
|
|
||||||
TMH_plugin->rollback (TMH_plugin->cls,
|
|
||||||
session);
|
|
||||||
return TMH_RESPONSE_reply_internal_db_error (connection);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TMH_plugin->commit (TMH_plugin->cls,
|
TMH_plugin->commit (TMH_plugin->cls,
|
||||||
session))
|
session))
|
||||||
{
|
{
|
||||||
TALER_LOG_WARNING ("/refresh/melt transaction commit failed\n");
|
TALER_LOG_WARNING ("/refresh/melt transaction commit failed\n");
|
||||||
return TMH_RESPONSE_reply_commit_error (connection);
|
return TMH_RESPONSE_reply_commit_error (connection);
|
||||||
}
|
}
|
||||||
return TMH_RESPONSE_reply_refresh_melt_success (connection,
|
return TMH_RESPONSE_reply_refresh_melt_success (connection,
|
||||||
session_hash,
|
session_hash,
|
||||||
refresh_session.noreveal_index);
|
refresh_session.noreveal_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -789,16 +783,16 @@ check_commitment (struct MHD_Connection *connection,
|
|||||||
sizeof (struct TALER_MINTDB_RefreshCommitLinkP));
|
sizeof (struct TALER_MINTDB_RefreshCommitLinkP));
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TMH_plugin->get_refresh_commit_links (TMH_plugin->cls,
|
TMH_plugin->get_refresh_commit_links (TMH_plugin->cls,
|
||||||
session,
|
session,
|
||||||
session_hash,
|
session_hash,
|
||||||
off,
|
off,
|
||||||
num_oldcoins,
|
num_oldcoins,
|
||||||
commit_links))
|
commit_links))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
GNUNET_free (commit_links);
|
GNUNET_free (commit_links);
|
||||||
return (MHD_YES == TMH_RESPONSE_reply_internal_db_error (connection))
|
return (MHD_YES == TMH_RESPONSE_reply_internal_db_error (connection))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < num_oldcoins; j++)
|
for (j = 0; j < num_oldcoins; j++)
|
||||||
@ -836,8 +830,8 @@ check_commitment (struct MHD_Connection *connection,
|
|||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
GNUNET_free (commit_links);
|
GNUNET_free (commit_links);
|
||||||
return (MHD_YES == TMH_RESPONSE_reply_internal_error (connection,
|
return (MHD_YES == TMH_RESPONSE_reply_internal_error (connection,
|
||||||
"ECDH error"))
|
"ECDH error"))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_transfer_decrypt (&commit_links[j].shared_secret_enc,
|
TALER_transfer_decrypt (&commit_links[j].shared_secret_enc,
|
||||||
@ -847,9 +841,9 @@ check_commitment (struct MHD_Connection *connection,
|
|||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
GNUNET_free (commit_links);
|
GNUNET_free (commit_links);
|
||||||
return (MHD_YES ==
|
return (MHD_YES ==
|
||||||
TMH_RESPONSE_reply_internal_error (connection,
|
TMH_RESPONSE_reply_internal_error (connection,
|
||||||
"Decryption error"))
|
"Decryption error"))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GNUNET_NO == secret_initialized)
|
if (GNUNET_NO == secret_initialized)
|
||||||
@ -866,11 +860,11 @@ check_commitment (struct MHD_Connection *connection,
|
|||||||
GNUNET_free (commit_links);
|
GNUNET_free (commit_links);
|
||||||
/* FIXME: return more specific error with original signature (#3712) */
|
/* FIXME: return more specific error with original signature (#3712) */
|
||||||
return (MHD_YES ==
|
return (MHD_YES ==
|
||||||
TMH_RESPONSE_reply_refresh_reveal_missmatch (connection,
|
TMH_RESPONSE_reply_refresh_reveal_missmatch (connection,
|
||||||
off,
|
off,
|
||||||
j,
|
j,
|
||||||
"transfer secret"))
|
"transfer secret"))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GNUNET_break (GNUNET_YES == secret_initialized);
|
GNUNET_break (GNUNET_YES == secret_initialized);
|
||||||
@ -882,16 +876,16 @@ check_commitment (struct MHD_Connection *connection,
|
|||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TMH_plugin->get_refresh_commit_coins (TMH_plugin->cls,
|
TMH_plugin->get_refresh_commit_coins (TMH_plugin->cls,
|
||||||
session,
|
session,
|
||||||
session_hash,
|
session_hash,
|
||||||
off,
|
off,
|
||||||
num_newcoins,
|
num_newcoins,
|
||||||
commit_coins))
|
commit_coins))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
GNUNET_free (commit_coins);
|
GNUNET_free (commit_coins);
|
||||||
return (MHD_YES == TMH_RESPONSE_reply_internal_db_error (connection))
|
return (MHD_YES == TMH_RESPONSE_reply_internal_db_error (connection))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < num_newcoins; j++)
|
for (j = 0; j < num_newcoins; j++)
|
||||||
@ -909,8 +903,8 @@ check_commitment (struct MHD_Connection *connection,
|
|||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
GNUNET_free (commit_coins);
|
GNUNET_free (commit_coins);
|
||||||
return (MHD_YES == TMH_RESPONSE_reply_internal_error (connection,
|
return (MHD_YES == TMH_RESPONSE_reply_internal_error (connection,
|
||||||
"Decryption error"))
|
"Decryption error"))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
GNUNET_CRYPTO_ecdsa_key_get_public (&link_data->coin_priv.ecdsa_priv,
|
GNUNET_CRYPTO_ecdsa_key_get_public (&link_data->coin_priv.ecdsa_priv,
|
||||||
@ -928,8 +922,8 @@ check_commitment (struct MHD_Connection *connection,
|
|||||||
"blind failed\n");
|
"blind failed\n");
|
||||||
GNUNET_free (commit_coins);
|
GNUNET_free (commit_coins);
|
||||||
return (MHD_YES == TMH_RESPONSE_reply_internal_error (connection,
|
return (MHD_YES == TMH_RESPONSE_reply_internal_error (connection,
|
||||||
"Blinding error"))
|
"Blinding error"))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (buf_len != commit_coins[j].coin_ev_size) ||
|
if ( (buf_len != commit_coins[j].coin_ev_size) ||
|
||||||
@ -944,11 +938,11 @@ check_commitment (struct MHD_Connection *connection,
|
|||||||
/* FIXME: return more specific error with original signature (#3712) */
|
/* FIXME: return more specific error with original signature (#3712) */
|
||||||
GNUNET_free (commit_coins);
|
GNUNET_free (commit_coins);
|
||||||
return (MHD_YES ==
|
return (MHD_YES ==
|
||||||
TMH_RESPONSE_reply_refresh_reveal_missmatch (connection,
|
TMH_RESPONSE_reply_refresh_reveal_missmatch (connection,
|
||||||
off,
|
off,
|
||||||
j,
|
j,
|
||||||
"envelope"))
|
"envelope"))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
GNUNET_free (buf);
|
GNUNET_free (buf);
|
||||||
}
|
}
|
||||||
@ -984,7 +978,7 @@ refresh_mint_coin (struct MHD_Connection *connection,
|
|||||||
struct TALER_DenominationSignature ev_sig;
|
struct TALER_DenominationSignature ev_sig;
|
||||||
|
|
||||||
dki = TMH_KS_denomination_key_lookup (key_state,
|
dki = TMH_KS_denomination_key_lookup (key_state,
|
||||||
denom_pub);
|
denom_pub);
|
||||||
if (NULL == dki)
|
if (NULL == dki)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
@ -992,9 +986,9 @@ refresh_mint_coin (struct MHD_Connection *connection,
|
|||||||
return ev_sig;
|
return ev_sig;
|
||||||
}
|
}
|
||||||
ev_sig.rsa_signature
|
ev_sig.rsa_signature
|
||||||
= GNUNET_CRYPTO_rsa_sign (dki->denom_priv.rsa_private_key,
|
= GNUNET_CRYPTO_rsa_sign (dki->denom_priv.rsa_private_key,
|
||||||
commit_coin->coin_ev,
|
commit_coin->coin_ev,
|
||||||
commit_coin->coin_ev_size);
|
commit_coin->coin_ev_size);
|
||||||
if (NULL == ev_sig.rsa_signature)
|
if (NULL == ev_sig.rsa_signature)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
@ -1002,10 +996,10 @@ refresh_mint_coin (struct MHD_Connection *connection,
|
|||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TMH_plugin->insert_refresh_collectable (TMH_plugin->cls,
|
TMH_plugin->insert_refresh_collectable (TMH_plugin->cls,
|
||||||
session,
|
session,
|
||||||
session_hash,
|
session_hash,
|
||||||
coin_off,
|
coin_off,
|
||||||
&ev_sig))
|
&ev_sig))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
GNUNET_CRYPTO_rsa_signature_free (ev_sig.rsa_signature);
|
GNUNET_CRYPTO_rsa_signature_free (ev_sig.rsa_signature);
|
||||||
@ -1031,9 +1025,9 @@ refresh_mint_coin (struct MHD_Connection *connection,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection,
|
TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection,
|
||||||
const struct GNUNET_HashCode *session_hash,
|
const struct GNUNET_HashCode *session_hash,
|
||||||
unsigned int num_oldcoins,
|
unsigned int num_oldcoins,
|
||||||
struct TALER_TransferPrivateKeyP **transfer_privs)
|
struct TALER_TransferPrivateKeyP **transfer_privs)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
struct TALER_MINTDB_Session *session;
|
struct TALER_MINTDB_Session *session;
|
||||||
@ -1048,19 +1042,19 @@ TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection,
|
|||||||
unsigned int off;
|
unsigned int off;
|
||||||
|
|
||||||
if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls,
|
if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls,
|
||||||
GNUNET_NO)))
|
GNUNET_NO)))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return TMH_RESPONSE_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
res = TMH_plugin->get_refresh_session (TMH_plugin->cls,
|
res = TMH_plugin->get_refresh_session (TMH_plugin->cls,
|
||||||
session,
|
session,
|
||||||
session_hash,
|
session_hash,
|
||||||
&refresh_session);
|
&refresh_session);
|
||||||
if (GNUNET_NO == res)
|
if (GNUNET_NO == res)
|
||||||
return TMH_RESPONSE_reply_arg_invalid (connection,
|
return TMH_RESPONSE_reply_arg_invalid (connection,
|
||||||
"session_hash");
|
"session_hash");
|
||||||
if (GNUNET_SYSERR == res)
|
if (GNUNET_SYSERR == res)
|
||||||
return TMH_RESPONSE_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
if (0 == refresh_session.num_oldcoins)
|
if (0 == refresh_session.num_oldcoins)
|
||||||
@ -1075,10 +1069,10 @@ TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TMH_plugin->get_refresh_melt (TMH_plugin->cls,
|
TMH_plugin->get_refresh_melt (TMH_plugin->cls,
|
||||||
session,
|
session,
|
||||||
session_hash,
|
session_hash,
|
||||||
j,
|
j,
|
||||||
&melts[j]))
|
&melts[j]))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
GNUNET_free (melts);
|
GNUNET_free (melts);
|
||||||
@ -1089,16 +1083,16 @@ TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection,
|
|||||||
sizeof (struct TALER_DenominationPublicKey));
|
sizeof (struct TALER_DenominationPublicKey));
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TMH_plugin->get_refresh_order (TMH_plugin->cls,
|
TMH_plugin->get_refresh_order (TMH_plugin->cls,
|
||||||
session,
|
session,
|
||||||
session_hash,
|
session_hash,
|
||||||
refresh_session.num_newcoins,
|
refresh_session.num_newcoins,
|
||||||
denom_pubs))
|
denom_pubs))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
GNUNET_free (denom_pubs);
|
GNUNET_free (denom_pubs);
|
||||||
GNUNET_free (melts);
|
GNUNET_free (melts);
|
||||||
return (MHD_YES == TMH_RESPONSE_reply_internal_db_error (connection))
|
return (MHD_YES == TMH_RESPONSE_reply_internal_db_error (connection))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1130,7 +1124,7 @@ TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection,
|
|||||||
/* Client request OK, start transaction */
|
/* Client request OK, start transaction */
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TMH_plugin->start (TMH_plugin->cls,
|
TMH_plugin->start (TMH_plugin->cls,
|
||||||
session))
|
session))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
for (j=0;j<refresh_session.num_newcoins;j++)
|
for (j=0;j<refresh_session.num_newcoins;j++)
|
||||||
@ -1143,11 +1137,11 @@ TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection,
|
|||||||
sizeof (struct TALER_MINTDB_RefreshCommitCoin));
|
sizeof (struct TALER_MINTDB_RefreshCommitCoin));
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TMH_plugin->get_refresh_commit_coins (TMH_plugin->cls,
|
TMH_plugin->get_refresh_commit_coins (TMH_plugin->cls,
|
||||||
session,
|
session,
|
||||||
session_hash,
|
session_hash,
|
||||||
refresh_session.noreveal_index,
|
refresh_session.noreveal_index,
|
||||||
refresh_session.num_newcoins,
|
refresh_session.num_newcoins,
|
||||||
commit_coins))
|
commit_coins))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
GNUNET_free (commit_coins);
|
GNUNET_free (commit_coins);
|
||||||
@ -1189,7 +1183,7 @@ TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection,
|
|||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TMH_plugin->commit (TMH_plugin->cls,
|
TMH_plugin->commit (TMH_plugin->cls,
|
||||||
session))
|
session))
|
||||||
{
|
{
|
||||||
TALER_LOG_WARNING ("/refresh/reveal transaction commit failed\n");
|
TALER_LOG_WARNING ("/refresh/reveal transaction commit failed\n");
|
||||||
for (i=0;i<refresh_session.num_newcoins;i++)
|
for (i=0;i<refresh_session.num_newcoins;i++)
|
||||||
@ -1199,8 +1193,8 @@ TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection,
|
|||||||
}
|
}
|
||||||
|
|
||||||
res = TMH_RESPONSE_reply_refresh_reveal_success (connection,
|
res = TMH_RESPONSE_reply_refresh_reveal_success (connection,
|
||||||
refresh_session.num_newcoins,
|
refresh_session.num_newcoins,
|
||||||
ev_sigs);
|
ev_sigs);
|
||||||
for (i=0;i<refresh_session.num_newcoins;i++)
|
for (i=0;i<refresh_session.num_newcoins;i++)
|
||||||
GNUNET_CRYPTO_rsa_signature_free (ev_sigs[i].rsa_signature);
|
GNUNET_CRYPTO_rsa_signature_free (ev_sigs[i].rsa_signature);
|
||||||
GNUNET_free (ev_sigs);
|
GNUNET_free (ev_sigs);
|
||||||
@ -1219,7 +1213,7 @@ TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TMH_DB_execute_refresh_link (struct MHD_Connection *connection,
|
TMH_DB_execute_refresh_link (struct MHD_Connection *connection,
|
||||||
const union TALER_CoinSpendPublicKeyP *coin_pub)
|
const union TALER_CoinSpendPublicKeyP *coin_pub)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
struct TALER_MINTDB_Session *session;
|
struct TALER_MINTDB_Session *session;
|
||||||
@ -1228,16 +1222,16 @@ TMH_DB_execute_refresh_link (struct MHD_Connection *connection,
|
|||||||
struct TALER_MINTDB_LinkDataList *ldl;
|
struct TALER_MINTDB_LinkDataList *ldl;
|
||||||
|
|
||||||
if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls,
|
if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls,
|
||||||
GNUNET_NO)))
|
GNUNET_NO)))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return TMH_RESPONSE_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
res = TMH_plugin->get_transfer (TMH_plugin->cls,
|
res = TMH_plugin->get_transfer (TMH_plugin->cls,
|
||||||
session,
|
session,
|
||||||
coin_pub,
|
coin_pub,
|
||||||
&transfer_pub,
|
&transfer_pub,
|
||||||
&shared_secret_enc);
|
&shared_secret_enc);
|
||||||
if (GNUNET_SYSERR == res)
|
if (GNUNET_SYSERR == res)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
@ -1245,31 +1239,28 @@ TMH_DB_execute_refresh_link (struct MHD_Connection *connection,
|
|||||||
}
|
}
|
||||||
if (GNUNET_NO == res)
|
if (GNUNET_NO == res)
|
||||||
{
|
{
|
||||||
return TMH_RESPONSE_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_arg_unknown (connection,
|
||||||
MHD_HTTP_NOT_FOUND,
|
"coin_pub");
|
||||||
"{s:s}",
|
|
||||||
"error",
|
|
||||||
"link data not found (transfer)");
|
|
||||||
}
|
}
|
||||||
GNUNET_assert (GNUNET_OK == res);
|
GNUNET_assert (GNUNET_OK == res);
|
||||||
|
|
||||||
ldl = TMH_plugin->get_link_data_list (TMH_plugin->cls,
|
ldl = TMH_plugin->get_link_data_list (TMH_plugin->cls,
|
||||||
session,
|
session,
|
||||||
coin_pub);
|
coin_pub);
|
||||||
if (NULL == ldl)
|
if (NULL == ldl)
|
||||||
{
|
{
|
||||||
return TMH_RESPONSE_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_NOT_FOUND,
|
MHD_HTTP_NOT_FOUND,
|
||||||
"{s:s}",
|
"{s:s}",
|
||||||
"error",
|
"error",
|
||||||
"link data not found (link)");
|
"link data not found (link)");
|
||||||
}
|
}
|
||||||
res = TMH_RESPONSE_reply_refresh_link_success (connection,
|
res = TMH_RESPONSE_reply_refresh_link_success (connection,
|
||||||
&transfer_pub,
|
&transfer_pub,
|
||||||
&shared_secret_enc,
|
&shared_secret_enc,
|
||||||
ldl);
|
ldl);
|
||||||
TMH_plugin->free_link_data_list (TMH_plugin->cls,
|
TMH_plugin->free_link_data_list (TMH_plugin->cls,
|
||||||
ldl);
|
ldl);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ handle_refresh_melt_binary (struct MHD_Connection *connection,
|
|||||||
for (i=0;i<num_new_denoms;i++)
|
for (i=0;i<num_new_denoms;i++)
|
||||||
{
|
{
|
||||||
dki = &TMH_KS_denomination_key_lookup (key_state,
|
dki = &TMH_KS_denomination_key_lookup (key_state,
|
||||||
&denom_pubs[i])->issue;
|
&denom_pubs[i])->issue;
|
||||||
TALER_amount_ntoh (&value,
|
TALER_amount_ntoh (&value,
|
||||||
&dki->value);
|
&dki->value);
|
||||||
TALER_amount_ntoh (&fee_withdraw,
|
TALER_amount_ntoh (&fee_withdraw,
|
||||||
@ -97,7 +97,7 @@ handle_refresh_melt_binary (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
TMH_KS_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
return TMH_RESPONSE_reply_internal_error (connection,
|
return TMH_RESPONSE_reply_internal_error (connection,
|
||||||
"cost calculation failure");
|
"cost calculation failure");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ handle_refresh_melt_binary (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
TMH_KS_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
return TMH_RESPONSE_reply_external_error (connection,
|
return TMH_RESPONSE_reply_external_error (connection,
|
||||||
"Melt contribution below melting fee");
|
"Melt contribution below melting fee");
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_amount_add (&total_melt,
|
TALER_amount_add (&total_melt,
|
||||||
@ -128,7 +128,7 @@ handle_refresh_melt_binary (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
TMH_KS_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
return TMH_RESPONSE_reply_internal_error (connection,
|
return TMH_RESPONSE_reply_internal_error (connection,
|
||||||
"balance calculation failure");
|
"balance calculation failure");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TMH_KS_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
@ -198,10 +198,8 @@ get_coin_public_info (struct MHD_Connection *connection,
|
|||||||
r_melt_detail->coin_info.denom_sig.rsa_signature = NULL;
|
r_melt_detail->coin_info.denom_sig.rsa_signature = NULL;
|
||||||
r_melt_detail->coin_info.denom_pub.rsa_public_key = NULL;
|
r_melt_detail->coin_info.denom_pub.rsa_public_key = NULL;
|
||||||
return (MHD_YES ==
|
return (MHD_YES ==
|
||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_signature_invalid (connection,
|
||||||
MHD_HTTP_NOT_FOUND,
|
"denom_sig"))
|
||||||
"{s:s}",
|
|
||||||
"error", "coin invalid"))
|
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
r_melt_detail->melt_sig = melt_sig;
|
r_melt_detail->melt_sig = melt_sig;
|
||||||
@ -242,7 +240,7 @@ verify_coin_public_info (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
TMH_KS_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
TALER_LOG_WARNING ("Unknown denomination key in /refresh/melt request\n");
|
TALER_LOG_WARNING ("Unknown denomination key in /refresh/melt request\n");
|
||||||
return TMH_RESPONSE_reply_arg_invalid (connection,
|
return TMH_RESPONSE_reply_arg_unknown (connection,
|
||||||
"denom_pub");
|
"denom_pub");
|
||||||
}
|
}
|
||||||
/* FIXME: need to check if denomination key is still
|
/* FIXME: need to check if denomination key is still
|
||||||
@ -275,10 +273,8 @@ verify_coin_public_info (struct MHD_Connection *connection,
|
|||||||
&melt_detail->coin_info.coin_pub.ecdsa_pub))
|
&melt_detail->coin_info.coin_pub.ecdsa_pub))
|
||||||
{
|
{
|
||||||
if (MHD_YES !=
|
if (MHD_YES !=
|
||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_signature_invalid (connection,
|
||||||
MHD_HTTP_UNAUTHORIZED,
|
"confirm_sig"))
|
||||||
"{s:s}",
|
|
||||||
"error", "signature invalid"))
|
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
return GNUNET_NO;
|
return GNUNET_NO;
|
||||||
}
|
}
|
||||||
@ -453,7 +449,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
|
|||||||
GNUNET_free (coin_melt_details);
|
GNUNET_free (coin_melt_details);
|
||||||
GNUNET_free (denom_pubs);
|
GNUNET_free (denom_pubs);
|
||||||
return TMH_RESPONSE_reply_external_error (connection,
|
return TMH_RESPONSE_reply_external_error (connection,
|
||||||
"melting same coin twice in same session is not allowed");
|
"melting same coin twice in same session is not allowed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TALER_amount_hton (&melt_amount,
|
TALER_amount_hton (&melt_amount,
|
||||||
@ -558,7 +554,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
|
|||||||
TMH_PARSE_JNC_INDEX, (int) j,
|
TMH_PARSE_JNC_INDEX, (int) j,
|
||||||
TMH_PARSE_JNC_RET_DATA,
|
TMH_PARSE_JNC_RET_DATA,
|
||||||
&rcl->shared_secret_enc,
|
&rcl->shared_secret_enc,
|
||||||
sizeof (struct GNUNET_HashCode));
|
sizeof (struct TALER_EncryptedLinkSecretP));
|
||||||
|
|
||||||
if (GNUNET_OK != res)
|
if (GNUNET_OK != res)
|
||||||
{
|
{
|
||||||
@ -676,8 +672,8 @@ TMH_REFRESH_handler_refresh_melt (struct TMH_RequestHandler *rh,
|
|||||||
return MHD_YES;
|
return MHD_YES;
|
||||||
|
|
||||||
res = TMH_PARSE_json_data (connection,
|
res = TMH_PARSE_json_data (connection,
|
||||||
root,
|
root,
|
||||||
spec);
|
spec);
|
||||||
json_decref (root);
|
json_decref (root);
|
||||||
if (GNUNET_OK != res)
|
if (GNUNET_OK != res)
|
||||||
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
||||||
@ -688,19 +684,19 @@ TMH_REFRESH_handler_refresh_melt (struct TMH_RequestHandler *rh,
|
|||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
TMH_PARSE_release_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
return TMH_RESPONSE_reply_arg_invalid (connection,
|
return TMH_RESPONSE_reply_arg_invalid (connection,
|
||||||
"coin_evs");
|
"coin_evs");
|
||||||
}
|
}
|
||||||
if (TALER_CNC_KAPPA != json_array_size (transfer_pubs))
|
if (TALER_CNC_KAPPA != json_array_size (transfer_pubs))
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
TMH_PARSE_release_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
return TMH_RESPONSE_reply_arg_invalid (connection,
|
return TMH_RESPONSE_reply_arg_invalid (connection,
|
||||||
"transfer_pubs");
|
"transfer_pubs");
|
||||||
}
|
}
|
||||||
res = TMH_PARSE_navigate_json (connection, coin_evs,
|
res = TMH_PARSE_navigate_json (connection, coin_evs,
|
||||||
TMH_PARSE_JNC_INDEX, (int) 0,
|
TMH_PARSE_JNC_INDEX, (int) 0,
|
||||||
TMH_PARSE_JNC_RET_DATA,
|
TMH_PARSE_JNC_RET_DATA,
|
||||||
JSON_ARRAY, &coin_detail);
|
JSON_ARRAY, &coin_detail);
|
||||||
if (GNUNET_OK != res)
|
if (GNUNET_OK != res)
|
||||||
{
|
{
|
||||||
TMH_PARSE_release_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
@ -708,10 +704,10 @@ TMH_REFRESH_handler_refresh_melt (struct TMH_RequestHandler *rh,
|
|||||||
}
|
}
|
||||||
num_newcoins = json_array_size (coin_detail);
|
num_newcoins = json_array_size (coin_detail);
|
||||||
res = TMH_PARSE_navigate_json (connection,
|
res = TMH_PARSE_navigate_json (connection,
|
||||||
transfer_pubs,
|
transfer_pubs,
|
||||||
TMH_PARSE_JNC_INDEX, (int) 0,
|
TMH_PARSE_JNC_INDEX, (int) 0,
|
||||||
TMH_PARSE_JNC_RET_DATA,
|
TMH_PARSE_JNC_RET_DATA,
|
||||||
JSON_ARRAY, &coin_detail);
|
JSON_ARRAY, &coin_detail);
|
||||||
if (GNUNET_OK != res)
|
if (GNUNET_OK != res)
|
||||||
{
|
{
|
||||||
TMH_PARSE_release_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
@ -771,12 +767,12 @@ handle_refresh_reveal_json (struct MHD_Connection *connection,
|
|||||||
if (GNUNET_OK != res)
|
if (GNUNET_OK != res)
|
||||||
break;
|
break;
|
||||||
res = TMH_PARSE_navigate_json (connection,
|
res = TMH_PARSE_navigate_json (connection,
|
||||||
tp_json,
|
tp_json,
|
||||||
TMH_PARSE_JNC_INDEX, (int) i,
|
TMH_PARSE_JNC_INDEX, (int) i,
|
||||||
TMH_PARSE_JNC_INDEX, (int) j,
|
TMH_PARSE_JNC_INDEX, (int) j,
|
||||||
TMH_PARSE_JNC_RET_DATA,
|
TMH_PARSE_JNC_RET_DATA,
|
||||||
&transfer_privs[i][j],
|
&transfer_privs[i][j],
|
||||||
sizeof (struct TALER_TransferPrivateKeyP));
|
sizeof (struct TALER_TransferPrivateKeyP));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (GNUNET_OK != res)
|
if (GNUNET_OK != res)
|
||||||
@ -838,8 +834,8 @@ TMH_REFRESH_handler_refresh_reveal (struct TMH_RequestHandler *rh,
|
|||||||
return MHD_YES;
|
return MHD_YES;
|
||||||
|
|
||||||
res = TMH_PARSE_json_data (connection,
|
res = TMH_PARSE_json_data (connection,
|
||||||
root,
|
root,
|
||||||
spec);
|
spec);
|
||||||
json_decref (root);
|
json_decref (root);
|
||||||
if (GNUNET_OK != res)
|
if (GNUNET_OK != res)
|
||||||
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
||||||
@ -849,15 +845,15 @@ TMH_REFRESH_handler_refresh_reveal (struct TMH_RequestHandler *rh,
|
|||||||
{
|
{
|
||||||
TMH_PARSE_release_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
return TMH_RESPONSE_reply_arg_invalid (connection,
|
return TMH_RESPONSE_reply_arg_invalid (connection,
|
||||||
"transfer_privs");
|
"transfer_privs");
|
||||||
}
|
}
|
||||||
/* Note we do +1 as 1 row (cut-and-choose!) is missing! */
|
/* Note we do +1 as 1 row (cut-and-choose!) is missing! */
|
||||||
res = TMH_PARSE_navigate_json (connection,
|
res = TMH_PARSE_navigate_json (connection,
|
||||||
transfer_privs,
|
transfer_privs,
|
||||||
TMH_PARSE_JNC_INDEX, 0,
|
TMH_PARSE_JNC_INDEX, 0,
|
||||||
TMH_PARSE_JNC_RET_TYPED_JSON,
|
TMH_PARSE_JNC_RET_TYPED_JSON,
|
||||||
JSON_ARRAY,
|
JSON_ARRAY,
|
||||||
&reveal_detail);
|
&reveal_detail);
|
||||||
if (GNUNET_OK != res)
|
if (GNUNET_OK != res)
|
||||||
{
|
{
|
||||||
TMH_PARSE_release_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
|
@ -199,7 +199,7 @@ TMH_RESPONSE_reply_internal_error (struct MHD_Connection *connection,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TMH_RESPONSE_reply_external_error (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_external_error (struct MHD_Connection *connection,
|
||||||
const char *hint)
|
const char *hint)
|
||||||
{
|
{
|
||||||
return TMH_RESPONSE_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
@ -442,7 +442,7 @@ TMH_RESPONSE_reply_deposit_insufficient_funds (struct MHD_Connection *connection
|
|||||||
|
|
||||||
history = compile_transaction_history (tl);
|
history = compile_transaction_history (tl);
|
||||||
return TMH_RESPONSE_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_FORBIDDEN,
|
MHD_HTTP_PRECONDITION_FAILED,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:o}",
|
||||||
"error", "insufficient funds",
|
"error", "insufficient funds",
|
||||||
"history", history);
|
"history", history);
|
||||||
@ -625,7 +625,7 @@ TMH_RESPONSE_reply_withdraw_sign_insufficient_funds (struct MHD_Connection *conn
|
|||||||
"balance calculation failure");
|
"balance calculation failure");
|
||||||
json_balance = TALER_json_from_amount (&balance);
|
json_balance = TALER_json_from_amount (&balance);
|
||||||
ret = TMH_RESPONSE_reply_json_pack (connection,
|
ret = TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_PAYMENT_REQUIRED,
|
MHD_HTTP_FORBIDDEN,
|
||||||
"{s:s, s:o, s:o}",
|
"{s:s, s:o, s:o}",
|
||||||
"error", "Insufficient funds"
|
"error", "Insufficient funds"
|
||||||
"balance", json_balance,
|
"balance", json_balance,
|
||||||
@ -677,25 +677,25 @@ TMH_RESPONSE_reply_withdraw_sign_success (struct MHD_Connection *connection,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TMH_RESPONSE_reply_refresh_melt_insufficient_funds (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_refresh_melt_insufficient_funds (struct MHD_Connection *connection,
|
||||||
const union TALER_CoinSpendPublicKeyP *coin_pub,
|
const union TALER_CoinSpendPublicKeyP *coin_pub,
|
||||||
struct TALER_Amount coin_value,
|
struct TALER_Amount coin_value,
|
||||||
struct TALER_MINTDB_TransactionList *tl,
|
struct TALER_MINTDB_TransactionList *tl,
|
||||||
struct TALER_Amount requested,
|
struct TALER_Amount requested,
|
||||||
struct TALER_Amount residual)
|
struct TALER_Amount residual)
|
||||||
{
|
{
|
||||||
json_t *history;
|
json_t *history;
|
||||||
|
|
||||||
history = compile_transaction_history (tl);
|
history = compile_transaction_history (tl);
|
||||||
return TMH_RESPONSE_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_NOT_FOUND,
|
MHD_HTTP_NOT_FOUND,
|
||||||
"{s:s, s:o, s:o, s:o, s:o, s:o}",
|
"{s:s, s:o, s:o, s:o, s:o, s:o}",
|
||||||
"error", "insufficient funds",
|
"error", "insufficient funds",
|
||||||
"coin-pub", TALER_json_from_data (coin_pub,
|
"coin-pub", TALER_json_from_data (coin_pub,
|
||||||
sizeof (union TALER_CoinSpendPublicKeyP)),
|
sizeof (union TALER_CoinSpendPublicKeyP)),
|
||||||
"original-value", TALER_json_from_amount (&coin_value),
|
"original-value", TALER_json_from_amount (&coin_value),
|
||||||
"residual-value", TALER_json_from_amount (&residual),
|
"residual-value", TALER_json_from_amount (&residual),
|
||||||
"requested-value", TALER_json_from_amount (&requested),
|
"requested-value", TALER_json_from_amount (&requested),
|
||||||
"history", history);
|
"history", history);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -709,8 +709,8 @@ TMH_RESPONSE_reply_refresh_melt_insufficient_funds (struct MHD_Connection *conne
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TMH_RESPONSE_reply_refresh_melt_success (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_refresh_melt_success (struct MHD_Connection *connection,
|
||||||
const struct GNUNET_HashCode *session_hash,
|
const struct GNUNET_HashCode *session_hash,
|
||||||
uint16_t noreveal_index)
|
uint16_t noreveal_index)
|
||||||
{
|
{
|
||||||
struct TALER_RefreshMeltConfirmationPS body;
|
struct TALER_RefreshMeltConfirmationPS body;
|
||||||
struct TALER_MintSignatureP sig;
|
struct TALER_MintSignatureP sig;
|
||||||
@ -727,10 +727,10 @@ TMH_RESPONSE_reply_refresh_melt_success (struct MHD_Connection *connection,
|
|||||||
&sig.eddsa_signature);
|
&sig.eddsa_signature);
|
||||||
GNUNET_assert (NULL != sig_json);
|
GNUNET_assert (NULL != sig_json);
|
||||||
ret = TMH_RESPONSE_reply_json_pack (connection,
|
ret = TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"{s:i, s:o}",
|
"{s:i, s:o}",
|
||||||
"noreveal_index", (int) noreveal_index,
|
"noreveal_index", (int) noreveal_index,
|
||||||
"signature", sig_json);
|
"signature", sig_json);
|
||||||
json_decref (sig_json);
|
json_decref (sig_json);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -746,8 +746,8 @@ TMH_RESPONSE_reply_refresh_melt_success (struct MHD_Connection *connection,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TMH_RESPONSE_reply_refresh_reveal_success (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_refresh_reveal_success (struct MHD_Connection *connection,
|
||||||
unsigned int num_newcoins,
|
unsigned int num_newcoins,
|
||||||
const struct TALER_DenominationSignature *sigs)
|
const struct TALER_DenominationSignature *sigs)
|
||||||
{
|
{
|
||||||
int newcoin_index;
|
int newcoin_index;
|
||||||
json_t *root;
|
json_t *root;
|
||||||
@ -763,8 +763,8 @@ TMH_RESPONSE_reply_refresh_reveal_success (struct MHD_Connection *connection,
|
|||||||
json_array_append_new (list,
|
json_array_append_new (list,
|
||||||
TALER_json_from_rsa_signature (sigs[newcoin_index].rsa_signature));
|
TALER_json_from_rsa_signature (sigs[newcoin_index].rsa_signature));
|
||||||
ret = TMH_RESPONSE_reply_json (connection,
|
ret = TMH_RESPONSE_reply_json (connection,
|
||||||
root,
|
root,
|
||||||
MHD_HTTP_OK);
|
MHD_HTTP_OK);
|
||||||
json_decref (root);
|
json_decref (root);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -789,12 +789,12 @@ TMH_RESPONSE_reply_refresh_reveal_success (struct MHD_Connection *connection,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection,
|
||||||
unsigned int off,
|
unsigned int off,
|
||||||
unsigned int j,
|
unsigned int j,
|
||||||
const char *missmatch_object)
|
const char *missmatch_object)
|
||||||
{
|
{
|
||||||
return TMH_RESPONSE_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_CONFLICT,
|
||||||
"{s:s, s:i, s:i, s:s}",
|
"{s:s, s:i, s:i, s:s}",
|
||||||
"error", "commitment violation",
|
"error", "commitment violation",
|
||||||
"offset", (int) off,
|
"offset", (int) off,
|
||||||
@ -814,9 +814,9 @@ TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TMH_RESPONSE_reply_refresh_link_success (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_refresh_link_success (struct MHD_Connection *connection,
|
||||||
const struct TALER_TransferPublicKeyP *transfer_pub,
|
const struct TALER_TransferPublicKeyP *transfer_pub,
|
||||||
const struct TALER_EncryptedLinkSecretP *shared_secret_enc,
|
const struct TALER_EncryptedLinkSecretP *shared_secret_enc,
|
||||||
const struct TALER_MINTDB_LinkDataList *ldl)
|
const struct TALER_MINTDB_LinkDataList *ldl)
|
||||||
{
|
{
|
||||||
const struct TALER_MINTDB_LinkDataList *pos;
|
const struct TALER_MINTDB_LinkDataList *pos;
|
||||||
json_t *root;
|
json_t *root;
|
||||||
@ -829,7 +829,8 @@ TMH_RESPONSE_reply_refresh_link_success (struct MHD_Connection *connection,
|
|||||||
json_t *obj;
|
json_t *obj;
|
||||||
|
|
||||||
obj = json_object ();
|
obj = json_object ();
|
||||||
json_object_set_new (obj, "link_enc",
|
json_object_set_new (obj,
|
||||||
|
"link_enc",
|
||||||
TALER_json_from_data (ldl->link_data_enc->coin_priv_enc,
|
TALER_json_from_data (ldl->link_data_enc->coin_priv_enc,
|
||||||
sizeof (union TALER_CoinSpendPrivateKeyP) +
|
sizeof (union TALER_CoinSpendPrivateKeyP) +
|
||||||
ldl->link_data_enc->blinding_key_enc_size));
|
ldl->link_data_enc->blinding_key_enc_size));
|
||||||
|
@ -223,11 +223,18 @@ postgres_create_tables (void *cls,
|
|||||||
",expended_currency VARCHAR(4) NOT NULL"
|
",expended_currency VARCHAR(4) NOT NULL"
|
||||||
",refresh_session_hash BYTEA"
|
",refresh_session_hash BYTEA"
|
||||||
")");
|
")");
|
||||||
|
/**
|
||||||
|
* The DB will show negative values for some values of the following fields as
|
||||||
|
* we use them as 16 bit unsigned integers
|
||||||
|
* @a num_oldcoins
|
||||||
|
* @a num_newcoins
|
||||||
|
* Do not do arithmetic in SQL on these fields
|
||||||
|
*/
|
||||||
SQLEXEC("CREATE TABLE IF NOT EXISTS refresh_sessions "
|
SQLEXEC("CREATE TABLE IF NOT EXISTS refresh_sessions "
|
||||||
"("
|
"("
|
||||||
" session_hash BYTEA PRIMARY KEY CHECK (length(session_hash) = 32)"
|
" session_hash BYTEA PRIMARY KEY CHECK (length(session_hash) = 32)"
|
||||||
",session_melt_sig BYTEA"
|
",num_oldcoins INT2 NOT NULL"
|
||||||
",session_commit_sig BYTEA"
|
",num_newcoins INT2 NOT NULL"
|
||||||
",noreveal_index INT2 NOT NULL"
|
",noreveal_index INT2 NOT NULL"
|
||||||
// non-zero if all reveals were ok
|
// non-zero if all reveals were ok
|
||||||
// and the new coin signatures are ready
|
// and the new coin signatures are ready
|
||||||
@ -389,23 +396,24 @@ postgres_prepare (PGconn *db_conn)
|
|||||||
" FROM collectable_blindcoins"
|
" FROM collectable_blindcoins"
|
||||||
" WHERE reserve_pub=$1;",
|
" WHERE reserve_pub=$1;",
|
||||||
1, NULL);
|
1, NULL);
|
||||||
|
/* refreshing */
|
||||||
/* FIXME: does it make sense to store these computed values in the DB? */
|
|
||||||
#if 0
|
|
||||||
PREPARE ("get_refresh_session",
|
PREPARE ("get_refresh_session",
|
||||||
"SELECT "
|
"SELECT "
|
||||||
" (SELECT count(*) FROM refresh_melt WHERE session_hash = $1)::INT2 as num_oldcoins "
|
" num_oldcoins"
|
||||||
",(SELECT count(*) FROM refresh_blind_session_keys "
|
",num_newcoins"
|
||||||
" WHERE session_hash = $1 and cnc_index = 0)::INT2 as num_newcoins "
|
|
||||||
",(SELECT count(*) FROM refresh_blind_session_keys "
|
|
||||||
" WHERE session_hash = $1 and newcoin_index = 0)::INT2 as kappa "
|
|
||||||
",noreveal_index"
|
",noreveal_index"
|
||||||
",session_commit_sig "
|
" FROM refresh_sessions "
|
||||||
",reveal_ok "
|
" WHERE session_hash = $1 ",
|
||||||
"FROM refresh_sessions "
|
|
||||||
"WHERE session_hash = $1",
|
|
||||||
1, NULL);
|
1, NULL);
|
||||||
#endif
|
PREPARE ("insert_refresh_session",
|
||||||
|
"INSERT INTO refresh_sessions ( "
|
||||||
|
" session_hash "
|
||||||
|
",num_oldcoins "
|
||||||
|
",num_newcoins "
|
||||||
|
",noreveal_index "
|
||||||
|
") "
|
||||||
|
"VALUES ($1, $2, $3, $4) ",
|
||||||
|
4, NULL);
|
||||||
|
|
||||||
PREPARE ("get_known_coin",
|
PREPARE ("get_known_coin",
|
||||||
"SELECT "
|
"SELECT "
|
||||||
@ -485,13 +493,6 @@ postgres_prepare (PGconn *db_conn)
|
|||||||
"FROM refresh_melt "
|
"FROM refresh_melt "
|
||||||
"WHERE session_hash = $1 AND oldcoin_index = $2",
|
"WHERE session_hash = $1 AND oldcoin_index = $2",
|
||||||
2, NULL);
|
2, NULL);
|
||||||
PREPARE ("insert_refresh_session",
|
|
||||||
"INSERT INTO refresh_sessions ( "
|
|
||||||
" session_hash "
|
|
||||||
",noreveal_index "
|
|
||||||
") "
|
|
||||||
"VALUES ($1, $2) ",
|
|
||||||
2, NULL);
|
|
||||||
PREPARE ("insert_refresh_commit_link",
|
PREPARE ("insert_refresh_commit_link",
|
||||||
"INSERT INTO refresh_commit_link ( "
|
"INSERT INTO refresh_commit_link ( "
|
||||||
" session_hash "
|
" session_hash "
|
||||||
@ -1451,61 +1452,59 @@ postgres_get_refresh_session (void *cls,
|
|||||||
const struct GNUNET_HashCode *session_hash,
|
const struct GNUNET_HashCode *session_hash,
|
||||||
struct TALER_MINTDB_RefreshSession *refresh_session)
|
struct TALER_MINTDB_RefreshSession *refresh_session)
|
||||||
{
|
{
|
||||||
// FIXME: check logic!
|
PGresult *result;
|
||||||
int res;
|
|
||||||
struct TALER_PQ_QueryParam params[] = {
|
struct TALER_PQ_QueryParam params[] = {
|
||||||
TALER_PQ_QUERY_PARAM_PTR(session_hash),
|
TALER_PQ_QUERY_PARAM_PTR(session_hash),
|
||||||
TALER_PQ_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
|
int ret;
|
||||||
|
uint16_t num_oldcoins;
|
||||||
|
uint16_t num_newcoins;
|
||||||
|
uint16_t noreveal_index;
|
||||||
|
|
||||||
PGresult *result = TALER_PQ_exec_prepared (session->conn,
|
ret = GNUNET_SYSERR;
|
||||||
"get_refresh_session",
|
result = TALER_PQ_exec_prepared (session->conn,
|
||||||
params);
|
"get_refresh_session",
|
||||||
|
params);
|
||||||
if (PGRES_TUPLES_OK != PQresultStatus (result))
|
if (PGRES_TUPLES_OK != PQresultStatus (result))
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
BREAK_DB_ERR (result);
|
||||||
"Query failed: %s\n",
|
goto cleanup;
|
||||||
PQresultErrorMessage (result));
|
|
||||||
PQclear (result);
|
|
||||||
return GNUNET_SYSERR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == PQntuples (result))
|
if (0 == PQntuples (result))
|
||||||
return GNUNET_NO;
|
{
|
||||||
|
ret = GNUNET_NO;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
GNUNET_assert (1 == PQntuples (result));
|
GNUNET_assert (1 == PQntuples (result));
|
||||||
|
/* We're done if the caller is only interested in whether the session exists
|
||||||
/* We're done if the caller is only interested in
|
* or not */
|
||||||
* whether the session exists or not */
|
|
||||||
|
|
||||||
if (NULL == refresh_session)
|
if (NULL == refresh_session)
|
||||||
return GNUNET_YES;
|
{
|
||||||
|
ret = GNUNET_YES;
|
||||||
memset (session, 0, sizeof (struct TALER_MINTDB_RefreshSession));
|
goto cleanup;
|
||||||
|
}
|
||||||
|
memset (refresh_session, 0, sizeof (struct TALER_MINTDB_RefreshSession));
|
||||||
struct TALER_PQ_ResultSpec rs[] = {
|
struct TALER_PQ_ResultSpec rs[] = {
|
||||||
TALER_PQ_RESULT_SPEC("num_oldcoins", &refresh_session->num_oldcoins),
|
TALER_PQ_RESULT_SPEC("num_oldcoins", &num_oldcoins),
|
||||||
TALER_PQ_RESULT_SPEC("num_newcoins", &refresh_session->num_newcoins),
|
TALER_PQ_RESULT_SPEC("num_newcoins", &num_newcoins),
|
||||||
TALER_PQ_RESULT_SPEC("noreveal_index", &refresh_session->noreveal_index),
|
TALER_PQ_RESULT_SPEC("noreveal_index", &noreveal_index),
|
||||||
TALER_PQ_RESULT_SPEC_END
|
TALER_PQ_RESULT_SPEC_END
|
||||||
};
|
};
|
||||||
|
if (GNUNET_OK != TALER_PQ_extract_result (result, rs, 0))
|
||||||
res = TALER_PQ_extract_result (result, rs, 0);
|
|
||||||
|
|
||||||
if (GNUNET_OK != res)
|
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
PQclear (result);
|
goto cleanup;
|
||||||
return GNUNET_SYSERR;
|
|
||||||
}
|
}
|
||||||
|
refresh_session->num_oldcoins = ntohs (num_oldcoins);
|
||||||
|
refresh_session->num_newcoins = ntohs (num_newcoins);
|
||||||
|
refresh_session->noreveal_index = ntohs (noreveal_index);
|
||||||
|
ret = GNUNET_YES;
|
||||||
|
|
||||||
refresh_session->num_oldcoins = ntohs (refresh_session->num_oldcoins);
|
cleanup:
|
||||||
refresh_session->num_newcoins = ntohs (refresh_session->num_newcoins);
|
if (NULL != result)
|
||||||
refresh_session->noreveal_index = ntohs (refresh_session->noreveal_index);
|
PQclear (result);
|
||||||
|
return ret;
|
||||||
PQclear (result);
|
|
||||||
return GNUNET_YES;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1525,28 +1524,29 @@ postgres_create_refresh_session (void *cls,
|
|||||||
const struct GNUNET_HashCode *session_hash,
|
const struct GNUNET_HashCode *session_hash,
|
||||||
const struct TALER_MINTDB_RefreshSession *refresh_session)
|
const struct TALER_MINTDB_RefreshSession *refresh_session)
|
||||||
{
|
{
|
||||||
// FIXME: actually store session data!
|
PGresult *result;
|
||||||
|
uint16_t num_oldcoins;
|
||||||
|
uint16_t num_newcoins;
|
||||||
uint16_t noreveal_index;
|
uint16_t noreveal_index;
|
||||||
struct TALER_PQ_QueryParam params[] = {
|
struct TALER_PQ_QueryParam params[] = {
|
||||||
TALER_PQ_QUERY_PARAM_PTR(session_hash),
|
TALER_PQ_QUERY_PARAM_PTR(session_hash),
|
||||||
|
TALER_PQ_QUERY_PARAM_PTR(&num_oldcoins),
|
||||||
|
TALER_PQ_QUERY_PARAM_PTR(&num_newcoins),
|
||||||
TALER_PQ_QUERY_PARAM_PTR(&noreveal_index),
|
TALER_PQ_QUERY_PARAM_PTR(&noreveal_index),
|
||||||
TALER_PQ_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
|
num_oldcoins = htons (refresh_session->num_oldcoins);
|
||||||
noreveal_index = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1<<15);
|
num_newcoins = htons (refresh_session->num_newcoins);
|
||||||
noreveal_index = htonl (noreveal_index);
|
noreveal_index = htons (refresh_session->noreveal_index);
|
||||||
|
result = TALER_PQ_exec_prepared (session->conn,
|
||||||
PGresult *result = TALER_PQ_exec_prepared (session->conn,
|
"insert_refresh_session",
|
||||||
"insert_refresh_session",
|
params);
|
||||||
params);
|
|
||||||
|
|
||||||
if (PGRES_COMMAND_OK != PQresultStatus (result))
|
if (PGRES_COMMAND_OK != PQresultStatus (result))
|
||||||
{
|
{
|
||||||
BREAK_DB_ERR (result);
|
BREAK_DB_ERR (result);
|
||||||
PQclear (result);
|
PQclear (result);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
PQclear (result);
|
PQclear (result);
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
}
|
}
|
||||||
|
@ -325,6 +325,28 @@ run (void *cls,
|
|||||||
plugin->have_deposit (plugin->cls,
|
plugin->have_deposit (plugin->cls,
|
||||||
session,
|
session,
|
||||||
&deposit2));
|
&deposit2));
|
||||||
|
/* Tests for refreshing */
|
||||||
|
{
|
||||||
|
struct TALER_MINTDB_RefreshSession refresh_session;
|
||||||
|
struct TALER_MINTDB_RefreshSession ret_refresh_session;
|
||||||
|
struct GNUNET_HashCode session_hash;
|
||||||
|
RND_BLK (&refresh_session);
|
||||||
|
RND_BLK (&session_hash);
|
||||||
|
refresh_session.num_oldcoins = UINT16_MAX;
|
||||||
|
refresh_session.num_newcoins = 1;
|
||||||
|
refresh_session.noreveal_index = 1;
|
||||||
|
FAILIF (GNUNET_OK != plugin->create_refresh_session (plugin->cls,
|
||||||
|
session,
|
||||||
|
&session_hash,
|
||||||
|
&refresh_session));
|
||||||
|
FAILIF (GNUNET_OK != plugin->get_refresh_session (plugin->cls,
|
||||||
|
session,
|
||||||
|
&session_hash,
|
||||||
|
&ret_refresh_session));
|
||||||
|
FAILIF (0 != memcmp (&ret_refresh_session,
|
||||||
|
&refresh_session,
|
||||||
|
sizeof (refresh_session)));
|
||||||
|
}
|
||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
drop:
|
drop:
|
||||||
|
Loading…
Reference in New Issue
Block a user