simplify json construction code
This commit is contained in:
parent
53b189868e
commit
37a194c0ba
@ -1049,7 +1049,8 @@ TALER_MINT_DB_insert_collectable_blindcoin (PGconn *db_conn,
|
|||||||
GNUNET_CRYPTO_rsa_public_key_encode (collectable->denom_pub,
|
GNUNET_CRYPTO_rsa_public_key_encode (collectable->denom_pub,
|
||||||
&denom_pub_enc);
|
&denom_pub_enc);
|
||||||
denom_sig_enc_size =
|
denom_sig_enc_size =
|
||||||
GNUNET_CRYPTO_rsa_signature_encode (collectable->sig, &denom_sig_enc);
|
GNUNET_CRYPTO_rsa_signature_encode (collectable->sig,
|
||||||
|
&denom_sig_enc);
|
||||||
struct TALER_DB_QueryParam params[] = {
|
struct TALER_DB_QueryParam params[] = {
|
||||||
TALER_DB_QUERY_PARAM_PTR (h_blind),
|
TALER_DB_QUERY_PARAM_PTR (h_blind),
|
||||||
TALER_DB_QUERY_PARAM_PTR_SIZED (denom_pub_enc, denom_pub_enc_size - 1),
|
TALER_DB_QUERY_PARAM_PTR_SIZED (denom_pub_enc, denom_pub_enc_size - 1),
|
||||||
|
@ -116,38 +116,27 @@ static int reload_pipe[2];
|
|||||||
static json_t *
|
static json_t *
|
||||||
denom_key_issue_to_json (const struct TALER_MINT_DenomKeyIssue *dki)
|
denom_key_issue_to_json (const struct TALER_MINT_DenomKeyIssue *dki)
|
||||||
{
|
{
|
||||||
json_t *dk_json = json_object ();
|
return
|
||||||
|
json_pack ("{s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}",
|
||||||
json_object_set_new (dk_json,
|
"master_sig",
|
||||||
"master_sig",
|
TALER_JSON_from_data (&dki->signature,
|
||||||
TALER_JSON_from_data (&dki->signature,
|
sizeof (struct GNUNET_CRYPTO_EddsaSignature)),
|
||||||
sizeof (struct GNUNET_CRYPTO_EddsaSignature)));
|
"stamp_start",
|
||||||
json_object_set_new (dk_json,
|
TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (dki->start)),
|
||||||
"stamp_start",
|
"stamp_expire_withdraw",
|
||||||
TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (dki->start)));
|
TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (dki->expire_withdraw)),
|
||||||
json_object_set_new (dk_json,
|
"stamp_expire_deposit",
|
||||||
"stamp_expire_withdraw",
|
TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (dki->expire_spend)),
|
||||||
TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (dki->expire_withdraw)));
|
"denom_pub",
|
||||||
json_object_set_new (dk_json,
|
TALER_JSON_from_rsa_public_key (dki->denom_pub),
|
||||||
"stamp_expire_deposit",
|
"value",
|
||||||
TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (dki->expire_spend)));
|
TALER_JSON_from_amount (TALER_amount_ntoh (dki->value)),
|
||||||
|
"fee_withdraw",
|
||||||
json_object_set_new (dk_json,
|
TALER_JSON_from_amount (TALER_amount_ntoh (dki->fee_withdraw)),
|
||||||
"denom_pub",
|
"fee_deposit",
|
||||||
TALER_JSON_from_rsa_public_key (dki->denom_pub));
|
TALER_JSON_from_amount (TALER_amount_ntoh (dki->fee_deposit)),
|
||||||
json_object_set_new (dk_json,
|
"fee_refresh",
|
||||||
"value",
|
TALER_JSON_from_amount (TALER_amount_ntoh (dki->fee_refresh)));
|
||||||
TALER_JSON_from_amount (TALER_amount_ntoh (dki->value)));
|
|
||||||
json_object_set_new (dk_json,
|
|
||||||
"fee_withdraw",
|
|
||||||
TALER_JSON_from_amount (TALER_amount_ntoh (dki->fee_withdraw)));
|
|
||||||
json_object_set_new (dk_json,
|
|
||||||
"fee_deposit",
|
|
||||||
TALER_JSON_from_amount (TALER_amount_ntoh (dki->fee_deposit)));
|
|
||||||
json_object_set_new (dk_json,
|
|
||||||
"fee_refresh",
|
|
||||||
TALER_JSON_from_amount (TALER_amount_ntoh (dki->fee_refresh)));
|
|
||||||
return dk_json;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -160,23 +149,18 @@ denom_key_issue_to_json (const struct TALER_MINT_DenomKeyIssue *dki)
|
|||||||
static json_t *
|
static json_t *
|
||||||
sign_key_issue_to_json (const struct TALER_MINT_SignKeyIssue *ski)
|
sign_key_issue_to_json (const struct TALER_MINT_SignKeyIssue *ski)
|
||||||
{
|
{
|
||||||
json_t *sk_json = json_object ();
|
return
|
||||||
|
json_pack ("{s:o, s:o, s:o, s:o}",
|
||||||
json_object_set_new (sk_json,
|
"stamp_start",
|
||||||
"stamp_start",
|
TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (ski->start)),
|
||||||
TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (ski->start)));
|
"stamp_expire",
|
||||||
json_object_set_new (sk_json,
|
TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (ski->expire)),
|
||||||
"stamp_expire",
|
"master_sig",
|
||||||
TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (ski->expire)));
|
TALER_JSON_from_data (&ski->signature,
|
||||||
json_object_set_new (sk_json,
|
sizeof (struct GNUNET_CRYPTO_EddsaSignature)),
|
||||||
"master_sig",
|
"key",
|
||||||
TALER_JSON_from_data (&ski->signature,
|
TALER_JSON_from_data (&ski->signkey_pub,
|
||||||
sizeof (struct GNUNET_CRYPTO_EddsaSignature)));
|
sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)));
|
||||||
json_object_set_new (sk_json,
|
|
||||||
"key",
|
|
||||||
TALER_JSON_from_data (&ski->signkey_pub,
|
|
||||||
sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)));
|
|
||||||
return sk_json;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -689,7 +689,9 @@ TALER_MINT_reply_refresh_reveal_success (struct MHD_Connection *connection,
|
|||||||
|
|
||||||
root = json_object ();
|
root = json_object ();
|
||||||
list = json_array ();
|
list = json_array ();
|
||||||
json_object_set_new (root, "ev_sigs", list);
|
json_object_set_new (root,
|
||||||
|
"ev_sigs",
|
||||||
|
list);
|
||||||
for (newcoin_index = 0; newcoin_index < num_newcoins; newcoin_index++)
|
for (newcoin_index = 0; newcoin_index < num_newcoins; newcoin_index++)
|
||||||
json_array_append_new (list,
|
json_array_append_new (list,
|
||||||
TALER_JSON_from_rsa_signature (sigs[newcoin_index]));
|
TALER_JSON_from_rsa_signature (sigs[newcoin_index]));
|
||||||
|
Loading…
Reference in New Issue
Block a user