fixing RC counting and a comma
This commit is contained in:
parent
ff6d4c081c
commit
9084ac4821
@ -36,7 +36,7 @@
|
||||
*/
|
||||
#define JSON_WARN(error) \
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, \
|
||||
"JSON parsing failed at %s:%u: %s (%s)", \
|
||||
"JSON parsing failed at %s:%u: %s (%s)\n", \
|
||||
__FILE__, __LINE__, error.text, error.source)
|
||||
|
||||
|
||||
@ -800,7 +800,20 @@ handle_withdraw_sign_finished (void *cls,
|
||||
|
||||
wsh->job = NULL;
|
||||
json = NULL;
|
||||
if (0 == wsh->eno)
|
||||
if (CURLE_OK !=
|
||||
curl_easy_getinfo (eh,
|
||||
CURLINFO_RESPONSE_CODE,
|
||||
&response_code))
|
||||
{
|
||||
/* unexpected error... */
|
||||
GNUNET_break (0);
|
||||
response_code = 0;
|
||||
}
|
||||
fprintf (stderr,
|
||||
"Response code: %u\n",
|
||||
(unsigned int) response_code);
|
||||
if ( (0 == wsh->eno) &&
|
||||
(0 != response_code) )
|
||||
{
|
||||
json = json_loadb (wsh->buf,
|
||||
wsh->buf_size,
|
||||
@ -812,18 +825,6 @@ handle_withdraw_sign_finished (void *cls,
|
||||
response_code = 0;
|
||||
}
|
||||
}
|
||||
if (NULL != json)
|
||||
{
|
||||
if (CURLE_OK !=
|
||||
curl_easy_getinfo (eh,
|
||||
CURLINFO_RESPONSE_CODE,
|
||||
&response_code))
|
||||
{
|
||||
/* unexpected error... */
|
||||
GNUNET_break (0);
|
||||
response_code = 0;
|
||||
}
|
||||
}
|
||||
switch (response_code)
|
||||
{
|
||||
case 0:
|
||||
@ -1032,6 +1033,10 @@ TALER_MINT_withdraw_sign (struct TALER_MINT_Handle *mint,
|
||||
curl_easy_setopt (eh,
|
||||
CURLOPT_URL,
|
||||
wsh->url));
|
||||
GNUNET_assert (CURLE_OK ==
|
||||
curl_easy_setopt (eh,
|
||||
CURLOPT_VERBOSE,
|
||||
1LL));
|
||||
GNUNET_assert (CURLE_OK ==
|
||||
curl_easy_setopt (eh,
|
||||
CURLOPT_POSTFIELDS,
|
||||
|
@ -358,6 +358,7 @@ add_incoming_cb (void *cls,
|
||||
cmd->details.admin_add_incoming.aih = NULL;
|
||||
if (MHD_HTTP_OK != http_status)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
fail (is);
|
||||
return;
|
||||
}
|
||||
@ -385,12 +386,10 @@ withdraw_sign_cb (void *cls,
|
||||
struct InterpreterState *is = cls;
|
||||
struct Command *cmd = &is->commands[is->ip];
|
||||
|
||||
fprintf (stderr,
|
||||
"Withdraw completed: %u\n",
|
||||
http_status);
|
||||
cmd->details.withdraw_sign.wsh = NULL;
|
||||
if (NULL == sig)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
fail (is);
|
||||
return;
|
||||
}
|
||||
|
@ -411,11 +411,23 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (0 == (res & 1))
|
||||
{
|
||||
/* did not encounter any deposit operations, how can we have a reserve? */
|
||||
GNUNET_break (0);
|
||||
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||
}
|
||||
if (0 == (res & 2))
|
||||
{
|
||||
/* did not encounter any withdraw operations, set to zero */
|
||||
TALER_amount_get_zero (deposit_total.currency,
|
||||
&withdraw_total);
|
||||
}
|
||||
/* All reserve balances should be non-negative */
|
||||
GNUNET_break (GNUNET_SYSERR !=
|
||||
TALER_amount_subtract (&balance,
|
||||
&deposit_total,
|
||||
&withdraw_total));
|
||||
GNUNET_assert (GNUNET_SYSERR !=
|
||||
TALER_amount_subtract (&balance,
|
||||
&deposit_total,
|
||||
&withdraw_total));
|
||||
if (0 < TALER_amount_cmp (&amount_required,
|
||||
&balance))
|
||||
{
|
||||
|
@ -139,8 +139,8 @@ parse_and_handle_deposit_request (struct MHD_Connection *connection,
|
||||
struct TALER_MINTDB_DenominationKeyIssueInformation *dki;
|
||||
struct TMH_KS_StateHandle *ks;
|
||||
struct TMH_PARSE_FieldSpecification spec[] = {
|
||||
TMH_PARSE_MEMBER_DENOMINATION_PUBLIC_KEY ("denom_pub", &deposit.coin.denom_pub),
|
||||
TMH_PARSE_MEMBER_DENOMINATION_SIGNATURE ("ub_sig", &deposit.coin.denom_sig),
|
||||
TMH_PARSE_member_denomination_public_key ("denom_pub", &deposit.coin.denom_pub),
|
||||
TMH_PARSE_member_denomination_signature ("ub_sig", &deposit.coin.denom_sig),
|
||||
TMH_PARSE_MEMBER_FIXED ("coin_pub", &deposit.coin.coin_pub),
|
||||
TMH_PARSE_MEMBER_FIXED ("merchant_pub", &deposit.merchant_pub),
|
||||
TMH_PARSE_MEMBER_FIXED ("H_contract", &deposit.h_contract),
|
||||
|
@ -768,24 +768,20 @@ TMH_PARSE_json_data (struct MHD_Connection *connection,
|
||||
*((void**)spec[i].destination) = ptr;
|
||||
break;
|
||||
case TMH_PARSE_JNC_RET_RSA_PUBLIC_KEY:
|
||||
ptr = NULL;
|
||||
ret = TMH_PARSE_navigate_json (connection,
|
||||
root,
|
||||
TMH_PARSE_JNC_FIELD,
|
||||
spec[i].field_name,
|
||||
TMH_PARSE_JNC_RET_RSA_PUBLIC_KEY,
|
||||
&ptr);
|
||||
spec[i].destination = ptr;
|
||||
spec[i].destination);
|
||||
break;
|
||||
case TMH_PARSE_JNC_RET_RSA_SIGNATURE:
|
||||
ptr = NULL;
|
||||
ret = TMH_PARSE_navigate_json (connection,
|
||||
root,
|
||||
TMH_PARSE_JNC_FIELD,
|
||||
spec[i].field_name,
|
||||
TMH_PARSE_JNC_RET_RSA_SIGNATURE,
|
||||
&ptr);
|
||||
spec[i].destination = ptr;
|
||||
spec[i].destination);
|
||||
break;
|
||||
case TMH_PARSE_JNC_RET_AMOUNT:
|
||||
GNUNET_assert (sizeof (struct TALER_Amount) ==
|
||||
@ -857,25 +853,25 @@ TMH_PARSE_release_data (struct TMH_PARSE_FieldSpecification *spec)
|
||||
break;
|
||||
case TMH_PARSE_JNC_RET_RSA_PUBLIC_KEY:
|
||||
{
|
||||
struct TALER_DenominationPublicKey pk;
|
||||
struct TALER_DenominationPublicKey *pk;
|
||||
|
||||
pk = *(struct TALER_DenominationPublicKey *) spec[i].destination;
|
||||
if (NULL != pk.rsa_public_key)
|
||||
pk = spec[i].destination;
|
||||
if (NULL != pk->rsa_public_key)
|
||||
{
|
||||
GNUNET_CRYPTO_rsa_public_key_free (pk.rsa_public_key);
|
||||
pk.rsa_public_key = NULL;
|
||||
GNUNET_CRYPTO_rsa_public_key_free (pk->rsa_public_key);
|
||||
pk->rsa_public_key = NULL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TMH_PARSE_JNC_RET_RSA_SIGNATURE:
|
||||
{
|
||||
struct TALER_DenominationSignature sig;
|
||||
struct TALER_DenominationSignature *sig;
|
||||
|
||||
sig = *(struct TALER_DenominationSignature *) spec[i].destination;
|
||||
if (NULL != sig.rsa_signature)
|
||||
sig = spec[i].destination;
|
||||
if (NULL != sig->rsa_signature)
|
||||
{
|
||||
GNUNET_CRYPTO_rsa_signature_free (sig.rsa_signature);
|
||||
sig.rsa_signature = NULL;
|
||||
GNUNET_CRYPTO_rsa_signature_free (sig->rsa_signature);
|
||||
sig->rsa_signature = NULL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1084,6 +1080,40 @@ TMH_PARSE_member_time_abs (const char *field,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate line in parser specification for RSA public key.
|
||||
*
|
||||
* @param field name of the field
|
||||
* @param[out] pk key to initialize
|
||||
* @return corresponding field spec
|
||||
*/
|
||||
struct TMH_PARSE_FieldSpecification
|
||||
TMH_PARSE_member_denomination_public_key (const char *field,
|
||||
struct TALER_DenominationPublicKey *pk)
|
||||
{
|
||||
struct TMH_PARSE_FieldSpecification ret =
|
||||
{ field, pk, 0, 0, TMH_PARSE_JNC_RET_RSA_PUBLIC_KEY, 0 };
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate line in parser specification for RSA public key.
|
||||
*
|
||||
* @param field name of the field
|
||||
* @param sig the signature to initialize
|
||||
* @return corresponding field spec
|
||||
*/
|
||||
struct TMH_PARSE_FieldSpecification
|
||||
TMH_PARSE_member_denomination_signature (const char *field,
|
||||
struct TALER_DenominationSignature *sig)
|
||||
{
|
||||
struct TMH_PARSE_FieldSpecification ret =
|
||||
{ field, sig, 0, 0, TMH_PARSE_JNC_RET_RSA_SIGNATURE, 0 };
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate line in parser specification for an amount.
|
||||
*
|
||||
|
@ -277,17 +277,24 @@ TMH_PARSE_member_object (const char *field,
|
||||
* Generate line in parser specification for RSA public key.
|
||||
*
|
||||
* @param field name of the field
|
||||
* @param ptrpk address of `struct TALER_DenominationPublicKey` initialize
|
||||
* @param[out] pk key to initialize
|
||||
* @return corresponding field spec
|
||||
*/
|
||||
#define TMH_PARSE_MEMBER_DENOMINATION_PUBLIC_KEY(field,ptrpk) { field, ptrpk, 0, 0, TMH_PARSE_JNC_RET_RSA_PUBLIC_KEY, 0 }
|
||||
struct TMH_PARSE_FieldSpecification
|
||||
TMH_PARSE_member_denomination_public_key (const char *field,
|
||||
struct TALER_DenominationPublicKey *pk);
|
||||
|
||||
|
||||
/**
|
||||
* Generate line in parser specification for RSA public key.
|
||||
*
|
||||
* @param field name of the field
|
||||
* @param ptrsig address of `struct TALER_DenominationSignature *` initialize
|
||||
* @param sig the signature to initialize
|
||||
* @return corresponding field spec
|
||||
*/
|
||||
#define TMH_PARSE_MEMBER_DENOMINATION_SIGNATURE(field,ptrsig) { field, ptrsig, 0, 0, TMH_PARSE_JNC_RET_RSA_SIGNATURE, 0 }
|
||||
struct TMH_PARSE_FieldSpecification
|
||||
TMH_PARSE_member_denomination_signature (const char *field,
|
||||
struct TALER_DenominationSignature *sig);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -174,8 +174,8 @@ get_coin_public_info (struct MHD_Connection *connection,
|
||||
struct TALER_Amount amount;
|
||||
struct TMH_PARSE_FieldSpecification spec[] = {
|
||||
TMH_PARSE_MEMBER_FIXED ("coin_pub", &r_melt_detail->coin_info.coin_pub),
|
||||
TMH_PARSE_MEMBER_DENOMINATION_SIGNATURE ("denom_sig", &sig.rsa_signature),
|
||||
TMH_PARSE_MEMBER_DENOMINATION_PUBLIC_KEY ("denom_pub", &pk.rsa_public_key),
|
||||
TMH_PARSE_member_denomination_signature ("denom_sig", &sig),
|
||||
TMH_PARSE_member_denomination_public_key ("denom_pub", &pk),
|
||||
TMH_PARSE_MEMBER_FIXED ("confirm_sig", &melt_sig),
|
||||
TMH_PARSE_member_amount ("value_with_fee", &amount),
|
||||
TMH_PARSE_MEMBER_END
|
||||
|
@ -47,10 +47,12 @@ TMH_RESPONSE_reply_json (struct MHD_Connection *connection,
|
||||
int ret;
|
||||
|
||||
json_str = json_dumps (json, JSON_INDENT(2));
|
||||
GNUNET_assert (NULL != json_str);
|
||||
resp = MHD_create_response_from_buffer (strlen (json_str), json_str,
|
||||
MHD_RESPMEM_MUST_FREE);
|
||||
if (NULL == resp)
|
||||
{
|
||||
free (json_str);
|
||||
GNUNET_break (0);
|
||||
return MHD_NO;
|
||||
}
|
||||
@ -84,12 +86,17 @@ TMH_RESPONSE_reply_json_pack (struct MHD_Connection *connection,
|
||||
json_t *json;
|
||||
va_list argp;
|
||||
int ret;
|
||||
json_error_t jerror;
|
||||
|
||||
va_start (argp, fmt);
|
||||
json = json_vpack_ex (NULL, 0, fmt, argp);
|
||||
json = json_vpack_ex (&jerror, 0, fmt, argp);
|
||||
va_end (argp);
|
||||
if (NULL == json)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Failed to pack JSON with format `%s': %s\n",
|
||||
fmt,
|
||||
jerror.text);
|
||||
GNUNET_break (0);
|
||||
return MHD_NO;
|
||||
}
|
||||
@ -229,10 +236,10 @@ TMH_RESPONSE_reply_external_error (struct MHD_Connection *connection,
|
||||
const char *hint)
|
||||
{
|
||||
return TMH_RESPONSE_reply_json_pack (connection,
|
||||
MHD_HTTP_BAD_REQUEST,
|
||||
"{s:s, s:s}",
|
||||
"error", "client error",
|
||||
"hint", hint);
|
||||
MHD_HTTP_BAD_REQUEST,
|
||||
"{s:s, s:s}",
|
||||
"error", "client error",
|
||||
"hint", hint);
|
||||
}
|
||||
|
||||
|
||||
@ -247,9 +254,9 @@ int
|
||||
TMH_RESPONSE_reply_commit_error (struct MHD_Connection *connection)
|
||||
{
|
||||
return TMH_RESPONSE_reply_json_pack (connection,
|
||||
MHD_HTTP_BAD_REQUEST,
|
||||
"{s:s}",
|
||||
"error", "commit failure");
|
||||
MHD_HTTP_BAD_REQUEST,
|
||||
"{s:s}",
|
||||
"error", "commit failure");
|
||||
}
|
||||
|
||||
|
||||
@ -571,16 +578,14 @@ compile_reserve_history (const struct TALER_MINTDB_ReserveHistory *rh,
|
||||
"type", "WITHDRAW",
|
||||
"signature", transaction,
|
||||
"amount", TALER_json_from_amount (&value)));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (0 == ret)
|
||||
{
|
||||
/* history is empty!? */
|
||||
GNUNET_break (0);
|
||||
json_decref (json_history);
|
||||
return NULL;
|
||||
/* did not encounter any withdraw operations, set to zero */
|
||||
TALER_amount_get_zero (deposit_total.currency,
|
||||
&withdraw_total);
|
||||
}
|
||||
if (GNUNET_SYSERR ==
|
||||
TALER_amount_subtract (balance,
|
||||
@ -591,6 +596,7 @@ compile_reserve_history (const struct TALER_MINTDB_ReserveHistory *rh,
|
||||
json_decref (json_history);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return json_history;
|
||||
}
|
||||
|
||||
@ -609,7 +615,6 @@ TMH_RESPONSE_reply_withdraw_status_success (struct MHD_Connection *connection,
|
||||
json_t *json_balance;
|
||||
json_t *json_history;
|
||||
struct TALER_Amount balance;
|
||||
int ret;
|
||||
|
||||
json_history = compile_reserve_history (rh,
|
||||
&balance);
|
||||
@ -617,14 +622,11 @@ TMH_RESPONSE_reply_withdraw_status_success (struct MHD_Connection *connection,
|
||||
return TMH_RESPONSE_reply_internal_error (connection,
|
||||
"balance calculation failure");
|
||||
json_balance = TALER_json_from_amount (&balance);
|
||||
ret = TMH_RESPONSE_reply_json_pack (connection,
|
||||
MHD_HTTP_OK,
|
||||
"{s:o, s:o}",
|
||||
"balance", json_balance,
|
||||
"history", json_history);
|
||||
json_decref (json_history);
|
||||
json_decref (json_balance);
|
||||
return ret;
|
||||
return TMH_RESPONSE_reply_json_pack (connection,
|
||||
MHD_HTTP_OK,
|
||||
"{s:o, s:o}",
|
||||
"balance", json_balance,
|
||||
"history", json_history);
|
||||
}
|
||||
|
||||
|
||||
@ -644,7 +646,6 @@ TMH_RESPONSE_reply_withdraw_sign_insufficient_funds (struct MHD_Connection *conn
|
||||
json_t *json_balance;
|
||||
json_t *json_history;
|
||||
struct TALER_Amount balance;
|
||||
int ret;
|
||||
|
||||
json_history = compile_reserve_history (rh,
|
||||
&balance);
|
||||
@ -652,15 +653,12 @@ TMH_RESPONSE_reply_withdraw_sign_insufficient_funds (struct MHD_Connection *conn
|
||||
return TMH_RESPONSE_reply_internal_error (connection,
|
||||
"balance calculation failure");
|
||||
json_balance = TALER_json_from_amount (&balance);
|
||||
ret = TMH_RESPONSE_reply_json_pack (connection,
|
||||
MHD_HTTP_FORBIDDEN,
|
||||
"{s:s, s:o, s:o}",
|
||||
"error", "Insufficient funds"
|
||||
"balance", json_balance,
|
||||
"history", json_history);
|
||||
json_decref (json_history);
|
||||
json_decref (json_balance);
|
||||
return ret;
|
||||
return TMH_RESPONSE_reply_json_pack (connection,
|
||||
MHD_HTTP_FORBIDDEN,
|
||||
"{s:s, s:o, s:o}",
|
||||
"error", "Insufficient funds",
|
||||
"balance", json_balance,
|
||||
"history", json_history);
|
||||
}
|
||||
|
||||
|
||||
@ -676,15 +674,12 @@ TMH_RESPONSE_reply_withdraw_sign_success (struct MHD_Connection *connection,
|
||||
const struct TALER_MINTDB_CollectableBlindcoin *collectable)
|
||||
{
|
||||
json_t *sig_json;
|
||||
int ret;
|
||||
|
||||
sig_json = TALER_json_from_rsa_signature (collectable->sig.rsa_signature);
|
||||
ret = TMH_RESPONSE_reply_json_pack (connection,
|
||||
MHD_HTTP_OK,
|
||||
"{s:o}",
|
||||
"ev_sig", sig_json);
|
||||
json_decref (sig_json);
|
||||
return ret;
|
||||
return TMH_RESPONSE_reply_json_pack (connection,
|
||||
MHD_HTTP_OK,
|
||||
"{s:o}",
|
||||
"ev_sig", sig_json);
|
||||
}
|
||||
|
||||
|
||||
@ -743,7 +738,6 @@ TMH_RESPONSE_reply_refresh_melt_success (struct MHD_Connection *connection,
|
||||
struct TALER_RefreshMeltConfirmationPS body;
|
||||
struct TALER_MintSignatureP sig;
|
||||
json_t *sig_json;
|
||||
int ret;
|
||||
|
||||
body.purpose.size = htonl (sizeof (struct TALER_RefreshMeltConfirmationPS));
|
||||
body.purpose.purpose = htonl (TALER_SIGNATURE_MINT_CONFIRM_MELT);
|
||||
@ -754,13 +748,11 @@ TMH_RESPONSE_reply_refresh_melt_success (struct MHD_Connection *connection,
|
||||
sig_json = TALER_json_from_eddsa_sig (&body.purpose,
|
||||
&sig.eddsa_signature);
|
||||
GNUNET_assert (NULL != sig_json);
|
||||
ret = TMH_RESPONSE_reply_json_pack (connection,
|
||||
MHD_HTTP_OK,
|
||||
"{s:i, s:o}",
|
||||
"noreveal_index", (int) noreveal_index,
|
||||
"signature", sig_json);
|
||||
json_decref (sig_json);
|
||||
return ret;
|
||||
return TMH_RESPONSE_reply_json_pack (connection,
|
||||
MHD_HTTP_OK,
|
||||
"{s:i, s:o}",
|
||||
"noreveal_index", (int) noreveal_index,
|
||||
"signature", sig_json);
|
||||
}
|
||||
|
||||
|
||||
@ -916,7 +908,6 @@ TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection,
|
||||
json_array_append_new (info_links,
|
||||
info_link_k);
|
||||
}
|
||||
|
||||
return TMH_RESPONSE_reply_json_pack (connection,
|
||||
MHD_HTTP_CONFLICT,
|
||||
"{s:s, s:i, s:i, s:o, s:o, s:o, s:o, s:s}",
|
||||
|
@ -105,7 +105,7 @@ TMH_WITHDRAW_handler_withdraw_sign (struct TMH_RequestHandler *rh,
|
||||
TMH_PARSE_MEMBER_VARIABLE ("coin_ev"),
|
||||
TMH_PARSE_MEMBER_FIXED ("reserve_pub", &wsrd.reserve_pub),
|
||||
TMH_PARSE_MEMBER_FIXED ("reserve_sig", &signature),
|
||||
TMH_PARSE_MEMBER_DENOMINATION_PUBLIC_KEY ("denom_pub", &denomination_pub),
|
||||
TMH_PARSE_member_denomination_public_key ("denom_pub", &denomination_pub),
|
||||
TMH_PARSE_MEMBER_END
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user