summaryrefslogtreecommitdiff
path: root/src/exchange
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-03-19 15:23:11 +0100
committerChristian Grothoff <christian@grothoff.org>2016-03-19 15:23:11 +0100
commit0d1eced630f4ed05ad95fdbb4354fd428c9cdbf6 (patch)
tree0ed4d6f189ed72287a0e003446c87a2b6db70c1a /src/exchange
parentd229f78da3b0b7f851d3541f59651b4f600c879d (diff)
downloadexchange-0d1eced630f4ed05ad95fdbb4354fd428c9cdbf6.tar.gz
exchange-0d1eced630f4ed05ad95fdbb4354fd428c9cdbf6.tar.bz2
exchange-0d1eced630f4ed05ad95fdbb4354fd428c9cdbf6.zip
first refactoring of JSON logic to address #4150 and #4237
Diffstat (limited to 'src/exchange')
-rw-r--r--src/exchange/Makefile.am5
-rw-r--r--src/exchange/taler-exchange-aggregator.c3
-rw-r--r--src/exchange/taler-exchange-httpd.c4
-rw-r--r--src/exchange/taler-exchange-httpd.h2
-rw-r--r--src/exchange/taler-exchange-httpd_db.c10
-rw-r--r--src/exchange/taler-exchange-httpd_deposit.c4
-rw-r--r--src/exchange/taler-exchange-httpd_keystate.c49
-rw-r--r--src/exchange/taler-exchange-httpd_parsing.c19
-rw-r--r--src/exchange/taler-exchange-httpd_responses.c90
-rw-r--r--src/exchange/taler-exchange-httpd_test.c19
-rw-r--r--src/exchange/taler-exchange-httpd_validation.c5
-rw-r--r--src/exchange/taler-exchange-httpd_wire.c5
12 files changed, 120 insertions, 95 deletions
diff --git a/src/exchange/Makefile.am b/src/exchange/Makefile.am
index 443ac511a..e29a51bbb 100644
--- a/src/exchange/Makefile.am
+++ b/src/exchange/Makefile.am
@@ -14,6 +14,7 @@ taler_exchange_aggregator_SOURCES = \
taler-exchange-aggregator.c
taler_exchange_aggregator_LDADD = \
$(LIBGCRYPT_LIBS) \
+ $(top_builddir)/src/json/libtalerjson.la \
$(top_builddir)/src/util/libtalerutil.la \
$(top_builddir)/src/wire/libtalerwire.la \
$(top_builddir)/src/exchangedb/libtalerexchangedb.la \
@@ -36,11 +37,13 @@ taler_exchange_httpd_SOURCES = \
taler-exchange-httpd_validation.c taler-exchange-httpd_validation.h
taler_exchange_httpd_LDADD = \
$(LIBGCRYPT_LIBS) \
+ $(top_builddir)/src/json/libtalerjson.la \
$(top_builddir)/src/util/libtalerutil.la \
$(top_builddir)/src/exchangedb/libtalerexchangedb.la \
-lmicrohttpd \
- -ljansson \
-lgnunetutil \
+ -lgnunetjson \
+ -ljansson \
-lpthread
if HAVE_DEVELOPER
diff --git a/src/exchange/taler-exchange-aggregator.c b/src/exchange/taler-exchange-aggregator.c
index 3ffce1d3f..e399a422e 100644
--- a/src/exchange/taler-exchange-aggregator.c
+++ b/src/exchange/taler-exchange-aggregator.c
@@ -29,6 +29,7 @@
#include <pthread.h>
#include "taler_exchangedb_lib.h"
#include "taler_exchangedb_plugin.h"
+#include "taler_json_lib.h"
#include "taler_wire_lib.h"
/**
@@ -277,7 +278,7 @@ deposit_cb (void *cls,
au->row_id = row_id;
au->wire = (json_t *) wire;
au->execution_time = GNUNET_TIME_absolute_get ();
- TALER_hash_json (au->wire,
+ TALER_JSON_hash (au->wire,
&au->h_wire);
json_incref (au->wire);
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c
index c16e26409..877876dbb 100644
--- a/src/exchange/taler-exchange-httpd.c
+++ b/src/exchange/taler-exchange-httpd.c
@@ -65,7 +65,7 @@ struct GNUNET_CONFIGURATION_Handle *cfg;
* Master public key (according to the
* configuration in the exchange directory).
*/
-struct GNUNET_CRYPTO_EddsaPublicKey TMH_master_public_key;
+struct TALER_MasterPublicKeyP TMH_master_public_key;
/**
* Our DB plugin.
@@ -424,7 +424,7 @@ exchange_serve_process_config (const char *exchange_directory)
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_public_key_from_string (TMH_master_public_key_str,
strlen (TMH_master_public_key_str),
- &TMH_master_public_key))
+ &TMH_master_public_key.eddsa_pub))
{
fprintf (stderr,
"Invalid master public key given in exchange configuration.");
diff --git a/src/exchange/taler-exchange-httpd.h b/src/exchange/taler-exchange-httpd.h
index 5f17eac5b..236df9e19 100644
--- a/src/exchange/taler-exchange-httpd.h
+++ b/src/exchange/taler-exchange-httpd.h
@@ -57,7 +57,7 @@ extern char *TMH_exchange_directory;
* Master public key (according to the
* configuration in the exchange directory).
*/
-extern struct GNUNET_CRYPTO_EddsaPublicKey TMH_master_public_key;
+extern struct TALER_MasterPublicKeyP TMH_master_public_key;
/**
* Private key of the exchange we use to sign messages.
diff --git a/src/exchange/taler-exchange-httpd_db.c b/src/exchange/taler-exchange-httpd_db.c
index 9d04efa9b..e96653a63 100644
--- a/src/exchange/taler-exchange-httpd_db.c
+++ b/src/exchange/taler-exchange-httpd_db.c
@@ -21,6 +21,8 @@
#include "platform.h"
#include <pthread.h>
#include <jansson.h>
+#include <gnunet/gnunet_json_lib.h>
+#include "taler_json_lib.h"
#include "taler-exchange-httpd_responses.h"
#include "taler-exchange-httpd_keystate.h"
@@ -1673,12 +1675,12 @@ handle_transaction_data (void *cls,
is also ugly if we ever add signatures over this data. (#4135) */
json_array_append (ctx->deposits,
json_pack ("{s:o, s:o, s:o, s:I, s:o}",
- "deposit_value", TALER_json_from_amount (deposit_value),
- "deposit_fee", TALER_json_from_amount (deposit_fee),
- "H_contract", TALER_json_from_data (h_contract,
+ "deposit_value", TALER_JSON_from_amount (deposit_value),
+ "deposit_fee", TALER_JSON_from_amount (deposit_fee),
+ "H_contract", GNUNET_JSON_from_data (h_contract,
sizeof (struct GNUNET_HashCode)),
"transaction_id", (json_int_t) transaction_id,
- "coin_pub", TALER_json_from_data (coin_pub,
+ "coin_pub", GNUNET_JSON_from_data (coin_pub,
sizeof (struct TALER_CoinSpendPublicKeyP))));
}
diff --git a/src/exchange/taler-exchange-httpd_deposit.c b/src/exchange/taler-exchange-httpd_deposit.c
index 629d6f8b5..82dcf1a55 100644
--- a/src/exchange/taler-exchange-httpd_deposit.c
+++ b/src/exchange/taler-exchange-httpd_deposit.c
@@ -27,9 +27,11 @@
*/
#include "platform.h"
#include <gnunet/gnunet_util_lib.h>
+#include <gnunet/gnunet_json_lib.h>
#include <jansson.h>
#include <microhttpd.h>
#include <pthread.h>
+#include "taler_json_lib.h"
#include "taler-exchange-httpd_parsing.h"
#include "taler-exchange-httpd_deposit.h"
#include "taler-exchange-httpd_responses.h"
@@ -170,7 +172,7 @@ parse_and_handle_deposit_request (struct MHD_Connection *connection,
"wire");
}
if (GNUNET_OK !=
- TALER_hash_json (wire,
+ TALER_JSON_hash (wire,
&my_h_wire))
{
TALER_LOG_WARNING ("Failed to parse JSON wire format specification for /deposit request\n");
diff --git a/src/exchange/taler-exchange-httpd_keystate.c b/src/exchange/taler-exchange-httpd_keystate.c
index e278882fe..bf91b8183 100644
--- a/src/exchange/taler-exchange-httpd_keystate.c
+++ b/src/exchange/taler-exchange-httpd_keystate.c
@@ -22,6 +22,7 @@
*/
#include "platform.h"
#include <pthread.h>
+#include "taler_json_lib.h"
#include "taler-exchange-httpd_keystate.h"
#include "taler-exchange-httpd_responses.h"
#include "taler_exchangedb_plugin.h"
@@ -144,26 +145,26 @@ denom_key_issue_to_json (const struct TALER_DenominationPublicKey *pk,
return
json_pack ("{s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}",
"master_sig",
- TALER_json_from_data (&dki->signature,
+ GNUNET_JSON_from_data (&dki->signature,
sizeof (struct GNUNET_CRYPTO_EddsaSignature)),
"stamp_start",
- TALER_json_from_abs (GNUNET_TIME_absolute_ntoh (dki->properties.start)),
+ GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh (dki->properties.start)),
"stamp_expire_withdraw",
- TALER_json_from_abs (GNUNET_TIME_absolute_ntoh (dki->properties.expire_withdraw)),
+ GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh (dki->properties.expire_withdraw)),
"stamp_expire_deposit",
- TALER_json_from_abs (GNUNET_TIME_absolute_ntoh (dki->properties.expire_spend)),
+ GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh (dki->properties.expire_spend)),
"stamp_expire_legal",
- TALER_json_from_abs (GNUNET_TIME_absolute_ntoh (dki->properties.expire_legal)),
+ GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh (dki->properties.expire_legal)),
"denom_pub",
- TALER_json_from_rsa_public_key (pk->rsa_public_key),
+ GNUNET_JSON_from_rsa_public_key (pk->rsa_public_key),
"value",
- TALER_json_from_amount (&value),
+ TALER_JSON_from_amount (&value),
"fee_withdraw",
- TALER_json_from_amount (&fee_withdraw),
+ TALER_JSON_from_amount (&fee_withdraw),
"fee_deposit",
- TALER_json_from_amount (&fee_deposit),
+ TALER_JSON_from_amount (&fee_deposit),
"fee_refresh",
- TALER_json_from_amount (&fee_refresh));
+ TALER_JSON_from_amount (&fee_refresh));
}
@@ -342,19 +343,19 @@ sign_key_issue_to_json (const struct TALER_ExchangeSigningKeyValidityPS *ski)
return
json_pack ("{s:o, s:o, s:o, s:o, s:o, s:o}",
"stamp_start",
- TALER_json_from_abs (GNUNET_TIME_absolute_ntoh (ski->start)),
+ GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh (ski->start)),
"stamp_expire",
- TALER_json_from_abs (GNUNET_TIME_absolute_ntoh (ski->expire)),
+ GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh (ski->expire)),
"stamp_end",
- TALER_json_from_abs (GNUNET_TIME_absolute_ntoh (ski->end)),
+ GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh (ski->end)),
"master_pub",
- TALER_json_from_data (&ski->master_public_key,
+ GNUNET_JSON_from_data (&ski->master_public_key,
sizeof (struct TALER_MasterPublicKeyP)),
"master_sig",
- TALER_json_from_data (&ski->signature,
+ GNUNET_JSON_from_data (&ski->signature,
sizeof (struct TALER_MasterSignatureP)),
"key",
- TALER_json_from_data (&ski->signkey_pub,
+ GNUNET_JSON_from_data (&ski->signkey_pub,
sizeof (struct TALER_ExchangePublicKeyP)));
}
@@ -437,16 +438,16 @@ auditor_to_json (const struct TALER_AuditorPublicKeyP *apub,
json_array_append_new (ja,
json_pack ("{s:o, s:o}",
"denom_pub_h",
- TALER_json_from_data (&dki[i]->denom_hash,
+ GNUNET_JSON_from_data (&dki[i]->denom_hash,
sizeof (struct GNUNET_HashCode)),
"auditor_sig",
- TALER_json_from_data (asigs[i],
+ GNUNET_JSON_from_data (asigs[i],
sizeof (struct TALER_AuditorSignatureP))));
return
json_pack ("{s:o, s:o}",
"denomination_keys", ja,
"auditor_pub",
- TALER_json_from_data (apub,
+ GNUNET_JSON_from_data (apub,
sizeof (struct TALER_AuditorPublicKeyP)));
}
@@ -633,7 +634,7 @@ TMH_KS_acquire_ (const char *location)
key_state->denomkey_map = GNUNET_CONTAINER_multihashmap_create (32,
GNUNET_NO);
key_state->reload_time = GNUNET_TIME_absolute_get ();
- TALER_round_abs_time (&key_state->reload_time);
+ GNUNET_TIME_round_abs (&key_state->reload_time);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Loading keys from `%s'\n",
TMH_exchange_directory);
@@ -663,15 +664,15 @@ TMH_KS_acquire_ (const char *location)
keys = json_pack ("{s:o, s:o, s:o, s:o, s:o, s:o, s:o}",
"master_public_key",
- TALER_json_from_data (&TMH_master_public_key,
+ GNUNET_JSON_from_data (&TMH_master_public_key,
sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)),
"signkeys", key_state->sign_keys_array,
"denoms", key_state->denom_keys_array,
"auditors", key_state->auditors_array,
- "list_issue_date", TALER_json_from_abs (key_state->reload_time),
- "eddsa_pub", TALER_json_from_data (&key_state->current_sign_key_issue.issue.signkey_pub,
+ "list_issue_date", GNUNET_JSON_from_time_abs (key_state->reload_time),
+ "eddsa_pub", GNUNET_JSON_from_data (&key_state->current_sign_key_issue.issue.signkey_pub,
sizeof (struct TALER_ExchangePublicKeyP)),
- "eddsa_sig", TALER_json_from_data (&sig,
+ "eddsa_sig", GNUNET_JSON_from_data (&sig,
sizeof (struct TALER_ExchangeSignatureP)));
key_state->auditors_array = NULL;
key_state->sign_keys_array = NULL;
diff --git a/src/exchange/taler-exchange-httpd_parsing.c b/src/exchange/taler-exchange-httpd_parsing.c
index 25539aeb7..3fd69ae50 100644
--- a/src/exchange/taler-exchange-httpd_parsing.c
+++ b/src/exchange/taler-exchange-httpd_parsing.c
@@ -24,6 +24,7 @@
#include "platform.h"
#include <gnunet/gnunet_util_lib.h>
+#include "taler_json_lib.h"
#include "taler-exchange-httpd_parsing.h"
#include "taler-exchange-httpd_responses.h"
@@ -786,10 +787,15 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
case TMH_PARSE_JNC_RET_AMOUNT:
{
struct TALER_Amount *where = va_arg (argp, void *);
+ struct GNUNET_JSON_Specification spec[] = {
+ TALER_JSON_spec_amount (NULL, where),
+ GNUNET_JSON_spec_end ()
+ };
if (GNUNET_OK !=
- TALER_json_to_amount ((json_t *) root,
- where))
+ GNUNET_JSON_parse ((json_t *) root,
+ spec,
+ NULL, NULL))
{
GNUNET_break_op (0);
ret = (MHD_YES !=
@@ -823,10 +829,15 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
case TMH_PARSE_JNC_RET_TIME_ABSOLUTE:
{
struct GNUNET_TIME_Absolute *where = va_arg (argp, void *);
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_absolute_time (NULL, where),
+ GNUNET_JSON_spec_end ()
+ };
if (GNUNET_OK !=
- TALER_json_to_abs ((json_t *) root,
- where))
+ GNUNET_JSON_parse ((json_t *) root,
+ spec,
+ NULL, NULL))
{
GNUNET_break_op (0);
ret = (MHD_YES !=
diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c
index d6cf81bb7..a47b29cae 100644
--- a/src/exchange/taler-exchange-httpd_responses.c
+++ b/src/exchange/taler-exchange-httpd_responses.c
@@ -25,7 +25,7 @@
#include "platform.h"
#include "taler-exchange-httpd_responses.h"
#include "taler_util.h"
-#include <gnunet/gnunet_util_lib.h>
+#include "taler_json_lib.h"
#include "taler-exchange-httpd_keystate.h"
@@ -388,9 +388,9 @@ TMH_RESPONSE_reply_deposit_success (struct MHD_Connection *connection,
MHD_HTTP_OK,
"{s:s, s:o, s:o}",
"status", "DEPOSIT_OK",
- "sig", TALER_json_from_data (&sig,
+ "sig", GNUNET_JSON_from_data (&sig,
sizeof (sig)),
- "pub", TALER_json_from_data (&pub,
+ "pub", GNUNET_JSON_from_data (&pub,
sizeof (pub)));
}
@@ -449,7 +449,7 @@ compile_transaction_history (const struct TALER_EXCHANGEDB_TransactionList *tl)
return NULL;
}
- details = TALER_json_from_data (&dr.purpose,
+ details = GNUNET_JSON_from_data (&dr.purpose,
sizeof (struct TALER_DepositRequestPS));
break;
}
@@ -481,7 +481,7 @@ compile_transaction_history (const struct TALER_EXCHANGEDB_TransactionList *tl)
return NULL;
}
- details = TALER_json_from_data (&ms.purpose,
+ details = GNUNET_JSON_from_data (&ms.purpose,
sizeof (struct TALER_RefreshMeltCoinAffirmationPS));
}
break;
@@ -491,8 +491,8 @@ compile_transaction_history (const struct TALER_EXCHANGEDB_TransactionList *tl)
json_array_append_new (history,
json_pack ("{s:s, s:o, s:o, s:o}",
"type", type,
- "amount", TALER_json_from_amount (&value),
- "signature", TALER_json_from_data (sig,
+ "amount", TALER_JSON_from_amount (&value),
+ "signature", GNUNET_JSON_from_data (sig,
sizeof (struct TALER_CoinSpendSignatureP)),
"details", details));
}
@@ -569,7 +569,7 @@ compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHistory *rh,
json_pack ("{s:s, s:O, s:o}",
"type", "DEPOSIT",
"wire", pos->details.bank->wire,
- "amount", TALER_json_from_amount (&pos->details.bank->amount)));
+ "amount", TALER_JSON_from_amount (&pos->details.bank->amount)));
break;
case TALER_EXCHANGEDB_RO_WITHDRAW_COIN:
break;
@@ -614,11 +614,11 @@ compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHistory *rh,
json_array_append_new (json_history,
json_pack ("{s:s, s:o, s:o, s:o}",
"type", "WITHDRAW",
- "signature", TALER_json_from_data (&pos->details.withdraw->reserve_sig,
+ "signature", GNUNET_JSON_from_data (&pos->details.withdraw->reserve_sig,
sizeof (struct TALER_ReserveSignatureP)),
- "details", TALER_json_from_data (&wr,
+ "details", GNUNET_JSON_from_data (&wr,
sizeof (wr)),
- "amount", TALER_json_from_amount (&value)));
+ "amount", TALER_JSON_from_amount (&value)));
break;
}
}
@@ -662,7 +662,7 @@ TMH_RESPONSE_reply_reserve_status_success (struct MHD_Connection *connection,
if (NULL == json_history)
return TMH_RESPONSE_reply_internal_error (connection,
"balance calculation failure");
- json_balance = TALER_json_from_amount (&balance);
+ json_balance = TALER_JSON_from_amount (&balance);
return TMH_RESPONSE_reply_json_pack (connection,
MHD_HTTP_OK,
"{s:o, s:o}",
@@ -693,7 +693,7 @@ TMH_RESPONSE_reply_reserve_withdraw_insufficient_funds (struct MHD_Connection *c
if (NULL == json_history)
return TMH_RESPONSE_reply_internal_error (connection,
"balance calculation failure");
- json_balance = TALER_json_from_amount (&balance);
+ json_balance = TALER_JSON_from_amount (&balance);
return TMH_RESPONSE_reply_json_pack (connection,
MHD_HTTP_PAYMENT_REQUIRED,
"{s:s, s:o, s:o}",
@@ -716,7 +716,7 @@ TMH_RESPONSE_reply_reserve_withdraw_success (struct MHD_Connection *connection,
{
json_t *sig_json;
- sig_json = TALER_json_from_rsa_signature (collectable->sig.rsa_signature);
+ sig_json = GNUNET_JSON_from_rsa_signature (collectable->sig.rsa_signature);
return TMH_RESPONSE_reply_json_pack (connection,
MHD_HTTP_OK,
"{s:o}",
@@ -758,14 +758,14 @@ TMH_RESPONSE_reply_refresh_melt_insufficient_funds (struct MHD_Connection *conne
"error",
"insufficient funds",
"coin_pub",
- TALER_json_from_data (coin_pub,
+ GNUNET_JSON_from_data (coin_pub,
sizeof (struct TALER_CoinSpendPublicKeyP)),
"original_value",
- TALER_json_from_amount (&coin_value),
+ TALER_JSON_from_amount (&coin_value),
"residual_value",
- TALER_json_from_amount (&residual),
+ TALER_JSON_from_amount (&residual),
"requested_value",
- TALER_json_from_amount (&requested),
+ TALER_JSON_from_amount (&requested),
"history",
history);
}
@@ -797,7 +797,7 @@ TMH_RESPONSE_reply_refresh_melt_success (struct MHD_Connection *connection,
TMH_KS_sign (&body.purpose,
&pub,
&sig);
- sig_json = TALER_json_from_data (&sig,
+ sig_json = GNUNET_JSON_from_data (&sig,
sizeof (sig));
GNUNET_assert (NULL != sig_json);
return TMH_RESPONSE_reply_json_pack (connection,
@@ -805,7 +805,7 @@ TMH_RESPONSE_reply_refresh_melt_success (struct MHD_Connection *connection,
"{s:i, s:o, s:o}",
"noreveal_index", (int) noreveal_index,
"exchange_sig", sig_json,
- "exchange_pub", TALER_json_from_data (&pub,
+ "exchange_pub", GNUNET_JSON_from_data (&pub,
sizeof (pub)));
}
@@ -835,7 +835,7 @@ TMH_RESPONSE_reply_refresh_reveal_success (struct MHD_Connection *connection,
obj = json_object ();
json_object_set_new (obj,
"ev_sig",
- TALER_json_from_rsa_signature (sigs[newcoin_index].rsa_signature));
+ GNUNET_JSON_from_rsa_signature (sigs[newcoin_index].rsa_signature));
json_array_append_new (list,
obj);
}
@@ -889,18 +889,18 @@ TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection,
rm_json = json_object ();
json_object_set_new (rm_json,
"coin_sig",
- TALER_json_from_data (&rm->coin_sig,
+ GNUNET_JSON_from_data (&rm->coin_sig,
sizeof (struct TALER_CoinSpendSignatureP)));
json_object_set_new (rm_json,
"coin_pub",
- TALER_json_from_data (&rm->coin.coin_pub,
+ GNUNET_JSON_from_data (&rm->coin.coin_pub,
sizeof (struct TALER_CoinSpendPublicKeyP)));
json_object_set_new (rm_json,
"melt_amount_with_fee",
- TALER_json_from_amount (&rm->amount_with_fee));
+ TALER_JSON_from_amount (&rm->amount_with_fee));
json_object_set_new (rm_json,
"melt_fee",
- TALER_json_from_amount (&rm->melt_fee));
+ TALER_JSON_from_amount (&rm->melt_fee));
json_array_append_new (info_old,
rm_json);
}
@@ -911,7 +911,7 @@ TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection,
pk = &mc->denom_pubs[i];
json_array_append_new (info_new,
- TALER_json_from_rsa_public_key (pk->rsa_public_key));
+ GNUNET_JSON_from_rsa_public_key (pk->rsa_public_key));
}
info_commit = json_array ();
@@ -931,15 +931,15 @@ TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection,
cc_json = json_object ();
json_object_set_new (cc_json,
"coin_ev",
- TALER_json_from_data (cc->coin_ev,
+ GNUNET_JSON_from_data (cc->coin_ev,
cc->coin_ev_size));
json_object_set_new (cc_json,
"coin_priv_enc",
- TALER_json_from_data (cc->refresh_link->coin_priv_enc,
+ GNUNET_JSON_from_data (cc->refresh_link->coin_priv_enc,
sizeof (struct TALER_CoinSpendPrivateKeyP)));
json_object_set_new (cc_json,
"blinding_key_enc",
- TALER_json_from_data (cc->refresh_link->blinding_key_enc,
+ GNUNET_JSON_from_data (cc->refresh_link->blinding_key_enc,
cc->refresh_link->blinding_key_enc_size));
json_array_append_new (info_commit_k,
@@ -957,11 +957,11 @@ TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection,
cl_json = json_object ();
json_object_set_new (cl_json,
"transfer_pub",
- TALER_json_from_data (&cl->transfer_pub,
+ GNUNET_JSON_from_data (&cl->transfer_pub,
sizeof (struct TALER_TransferPublicKeyP)));
json_object_set_new (cl_json,
"shared_secret_enc",
- TALER_json_from_data (&cl->shared_secret_enc,
+ GNUNET_JSON_from_data (&cl->shared_secret_enc,
sizeof (struct TALER_EncryptedLinkSecretP)));
json_array_append_new (info_link_k,
cl_json);
@@ -1015,15 +1015,15 @@ TMH_RESPONSE_reply_refresh_link_success (struct MHD_Connection *connection,
obj = json_object ();
json_object_set_new (obj,
"link_enc",
- TALER_json_from_data (pos->link_data_enc->coin_priv_enc,
+ GNUNET_JSON_from_data (pos->link_data_enc->coin_priv_enc,
sizeof (struct TALER_CoinSpendPrivateKeyP) +
pos->link_data_enc->blinding_key_enc_size));
json_object_set_new (obj,
"denom_pub",
- TALER_json_from_rsa_public_key (pos->denom_pub.rsa_public_key));
+ GNUNET_JSON_from_rsa_public_key (pos->denom_pub.rsa_public_key));
json_object_set_new (obj,
"ev_sig",
- TALER_json_from_rsa_signature (pos->ev_sig.rsa_signature));
+ GNUNET_JSON_from_rsa_signature (pos->ev_sig.rsa_signature));
json_array_append_new (list,
obj);
}
@@ -1033,11 +1033,11 @@ TMH_RESPONSE_reply_refresh_link_success (struct MHD_Connection *connection,
list);
json_object_set_new (root,
"transfer_pub",
- TALER_json_from_data (&sessions[i].transfer_pub,
+ GNUNET_JSON_from_data (&sessions[i].transfer_pub,
sizeof (struct TALER_TransferPublicKeyP)));
json_object_set_new (root,
"secret_enc",
- TALER_json_from_data (&sessions[i].shared_secret_enc,
+ GNUNET_JSON_from_data (&sessions[i].shared_secret_enc,
sizeof (struct TALER_EncryptedLinkSecretP)));
json_array_append_new (mlist,
root);
@@ -1083,7 +1083,7 @@ TMH_RESPONSE_reply_deposit_pending (struct MHD_Connection *connection,
return TMH_RESPONSE_reply_json_pack (connection,
MHD_HTTP_ACCEPTED,
"{s:o}",
- "execution_time", TALER_json_from_abs (planned_exec_time));
+ "execution_time", GNUNET_JSON_from_time_abs (planned_exec_time));
}
@@ -1132,13 +1132,13 @@ TMH_RESPONSE_reply_deposit_wtid (struct MHD_Connection *connection,
return TMH_RESPONSE_reply_json_pack (connection,
MHD_HTTP_OK,
"{s:o, s:o, s:o, s:o, s:o, s:o}",
- "wtid", TALER_json_from_data (wtid,
+ "wtid", GNUNET_JSON_from_data (wtid,
sizeof (*wtid)),
- "execution_time", TALER_json_from_abs (exec_time),
- "coin_contribution", TALER_json_from_amount (coin_contribution),
- "exchange_sig", TALER_json_from_data (&sig,
+ "execution_time", GNUNET_JSON_from_time_abs (exec_time),
+ "coin_contribution", TALER_JSON_from_amount (coin_contribution),
+ "exchange_sig", GNUNET_JSON_from_data (&sig,
sizeof (sig)),
- "exchange_pub", TALER_json_from_data (&pub,
+ "exchange_pub", GNUNET_JSON_from_data (&pub,
sizeof (pub)));
}
@@ -1165,10 +1165,10 @@ TMH_RESPONSE_reply_wire_deposit_details (struct MHD_Connection *connection,
return TMH_RESPONSE_reply_json_pack (connection,
MHD_HTTP_OK,
"{s:o, s:o, s:o, s:o}",
- "total", TALER_json_from_amount (total),
- "merchant_pub", TALER_json_from_data (merchant_pub,
+ "total", TALER_JSON_from_amount (total),
+ "merchant_pub", GNUNET_JSON_from_data (merchant_pub,
sizeof (struct TALER_MerchantPublicKeyP)),
- "h_wire", TALER_json_from_data (h_wire,
+ "h_wire", GNUNET_JSON_from_data (h_wire,
sizeof (struct GNUNET_HashCode)),
"deposits", deposits);
}
diff --git a/src/exchange/taler-exchange-httpd_test.c b/src/exchange/taler-exchange-httpd_test.c
index 876869d86..7b6438cae 100644
--- a/src/exchange/taler-exchange-httpd_test.c
+++ b/src/exchange/taler-exchange-httpd_test.c
@@ -21,6 +21,7 @@
*/
#include "platform.h"
#include <gnunet/gnunet_util_lib.h>
+#include <gnunet/gnunet_json_lib.h>
#include <jansson.h>
#include <microhttpd.h>
#include "taler_signatures.h"
@@ -90,7 +91,7 @@ TMH_TEST_handler_test_base32 (struct TMH_RequestHandler *rh,
MHD_HTTP_OK,
"{s:o}",
"output",
- TALER_json_from_data (&hc, sizeof (struct GNUNET_HashCode)));
+ GNUNET_JSON_from_data (&hc, sizeof (struct GNUNET_HashCode)));
}
@@ -164,7 +165,7 @@ TMH_TEST_handler_test_encrypt (struct TMH_RequestHandler *rh,
&skey,
&iv,
out));
- json = TALER_json_from_data (out,
+ json = GNUNET_JSON_from_data (out,
in_ptr_size);
GNUNET_free (out);
TMH_PARSE_release_data (spec);
@@ -231,7 +232,7 @@ TMH_TEST_handler_test_hkdf (struct TMH_RequestHandler *rh,
in_ptr_size,
NULL, 0);
TMH_PARSE_release_data (spec);
- json = TALER_json_from_data (&hc,
+ json = GNUNET_JSON_from_data (&hc,
sizeof (struct GNUNET_HashCode));
return TMH_RESPONSE_reply_json_pack (connection,
MHD_HTTP_OK,
@@ -302,7 +303,7 @@ TMH_TEST_handler_test_ecdhe (struct TMH_RequestHandler *rh,
MHD_HTTP_OK,
"{s:o}",
"ecdh_hash",
- TALER_json_from_data (&hc,
+ GNUNET_JSON_from_data (&hc,
sizeof (hc)));
}
@@ -387,10 +388,10 @@ TMH_TEST_handler_test_eddsa (struct TMH_RequestHandler *rh,
MHD_HTTP_OK,
"{s:o, s:o}",
"eddsa_pub",
- TALER_json_from_data (&pub,
+ GNUNET_JSON_from_data (&pub,
sizeof (pub)),
"eddsa_sig",
- TALER_json_from_data (&sig,
+ GNUNET_JSON_from_data (&sig,
sizeof (sig)));
}
@@ -435,7 +436,7 @@ TMH_TEST_handler_test_rsa_get (struct TMH_RequestHandler *rh,
MHD_HTTP_OK,
"{s:o}",
"rsa_pub",
- TALER_json_from_rsa_public_key (pub));
+ GNUNET_JSON_from_rsa_public_key (pub));
GNUNET_CRYPTO_rsa_public_key_free (pub);
return res;
}
@@ -509,7 +510,7 @@ TMH_TEST_handler_test_rsa_sign (struct TMH_RequestHandler *rh,
MHD_HTTP_OK,
"{s:o}",
"rsa_blind_sig",
- TALER_json_from_rsa_signature (sig));
+ GNUNET_JSON_from_rsa_signature (sig));
GNUNET_CRYPTO_rsa_signature_free (sig);
return res;
}
@@ -578,7 +579,7 @@ TMH_TEST_handler_test_transfer (struct TMH_RequestHandler *rh,
MHD_HTTP_OK,
"{s:o}",
"secret",
- TALER_json_from_data (&secret,
+ GNUNET_JSON_from_data (&secret,
sizeof (secret)));
}
diff --git a/src/exchange/taler-exchange-httpd_validation.c b/src/exchange/taler-exchange-httpd_validation.c
index 9132e3e02..b7e8a7f80 100644
--- a/src/exchange/taler-exchange-httpd_validation.c
+++ b/src/exchange/taler-exchange-httpd_validation.c
@@ -21,6 +21,7 @@
*/
#include "platform.h"
#include <gnunet/gnunet_util_lib.h>
+#include "taler-exchange-httpd.h"
#include "taler-exchange-httpd_validation.h"
#include "taler_wire_plugin.h"
@@ -172,7 +173,9 @@ TMH_json_validate_wireformat (const json_t *wire)
for (p=wire_head; NULL != p; p = p->next)
if (0 == strcasecmp (p->type,
stype))
- return p->plugin->wire_validate (wire);
+ return p->plugin->wire_validate (p->plugin->cls,
+ wire,
+ &TMH_master_public_key);
return GNUNET_NO;
}
diff --git a/src/exchange/taler-exchange-httpd_wire.c b/src/exchange/taler-exchange-httpd_wire.c
index cec041762..1b3d3b541 100644
--- a/src/exchange/taler-exchange-httpd_wire.c
+++ b/src/exchange/taler-exchange-httpd_wire.c
@@ -19,6 +19,7 @@
* @author Christian Grothoff
*/
#include "platform.h"
+#include <gnunet/gnunet_json_lib.h>
#include "taler-exchange-httpd_keystate.h"
#include "taler-exchange-httpd_responses.h"
#include "taler-exchange-httpd_validation.h"
@@ -57,9 +58,9 @@ TMH_WIRE_handler_wire (struct TMH_RequestHandler *rh,
MHD_HTTP_OK,
"{s:o, s:o, s:o}",
"methods", methods,
- "sig", TALER_json_from_data (&sig,
+ "sig", GNUNET_JSON_from_data (&sig,
sizeof (sig)),
- "pub", TALER_json_from_data (&pub,
+ "pub", GNUNET_JSON_from_data (&pub,
sizeof (pub)));
}