diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-05-21 18:36:12 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-05-21 18:36:12 +0200 |
commit | 9160245167ded9b2b7c11716dfa1a1e8887187f4 (patch) | |
tree | 64720ebc3b69f84055f25d8a7f309b19b0ebd52a /src/exchange | |
parent | 922175d3082b138f4973fe11d81327806e68021d (diff) | |
download | exchange-9160245167ded9b2b7c11716dfa1a1e8887187f4.tar.gz exchange-9160245167ded9b2b7c11716dfa1a1e8887187f4.tar.bz2 exchange-9160245167ded9b2b7c11716dfa1a1e8887187f4.zip |
make use of GNUNET_JSON_from_data_auto where possible
Diffstat (limited to 'src/exchange')
-rw-r--r-- | src/exchange/taler-exchange-httpd_keystate.c | 27 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_refund.c | 4 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_responses.c | 91 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_test.c | 19 |
4 files changed, 49 insertions, 92 deletions
diff --git a/src/exchange/taler-exchange-httpd_keystate.c b/src/exchange/taler-exchange-httpd_keystate.c index b293b94cb..a71d7676a 100644 --- a/src/exchange/taler-exchange-httpd_keystate.c +++ b/src/exchange/taler-exchange-httpd_keystate.c @@ -148,8 +148,7 @@ 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, s:o}", "master_sig", - GNUNET_JSON_from_data (&dki->signature, - sizeof (struct GNUNET_CRYPTO_EddsaSignature)), + GNUNET_JSON_from_data_auto (&dki->signature), "stamp_start", GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh (dki->properties.start)), "stamp_expire_withdraw", @@ -365,11 +364,9 @@ sign_key_issue_to_json (const struct TALER_ExchangeSigningKeyValidityPS *ski) "stamp_end", GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh (ski->end)), "master_sig", - GNUNET_JSON_from_data (&ski->signature, - sizeof (struct TALER_MasterSignatureP)), + GNUNET_JSON_from_data_auto (&ski->signature), "key", - GNUNET_JSON_from_data (&ski->signkey_pub, - sizeof (struct TALER_ExchangePublicKeyP))); + GNUNET_JSON_from_data_auto (&ski->signkey_pub)); } @@ -463,18 +460,15 @@ auditor_to_json (const struct TALER_AuditorPublicKeyP *apub, json_array_append_new (ja, json_pack ("{s:o, s:o}", "denom_pub_h", - GNUNET_JSON_from_data (&dki[i]->denom_hash, - sizeof (struct GNUNET_HashCode)), + GNUNET_JSON_from_data_auto (&dki[i]->denom_hash), "auditor_sig", - GNUNET_JSON_from_data (asigs[i], - sizeof (struct TALER_AuditorSignatureP)))); + GNUNET_JSON_from_data_auto (asigs[i]))); return json_pack ("{s:o, s:s, s:o}", "denomination_keys", ja, "auditor_url", auditor_url, "auditor_pub", - GNUNET_JSON_from_data (apub, - sizeof (struct TALER_AuditorPublicKeyP))); + GNUNET_JSON_from_data_auto (apub)); } @@ -704,16 +698,13 @@ 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", - GNUNET_JSON_from_data (&TMH_master_public_key, - sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)), + GNUNET_JSON_from_data_auto (&TMH_master_public_key), "signkeys", key_state->sign_keys_array, "denoms", key_state->denom_keys_array, "auditors", key_state->auditors_array, "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", GNUNET_JSON_from_data (&sig, - sizeof (struct TALER_ExchangeSignatureP))); + "eddsa_pub", GNUNET_JSON_from_data_auto (&key_state->current_sign_key_issue.issue.signkey_pub), + "eddsa_sig", GNUNET_JSON_from_data_auto (&sig)); GNUNET_assert (NULL != keys); key_state->auditors_array = NULL; key_state->sign_keys_array = NULL; diff --git a/src/exchange/taler-exchange-httpd_refund.c b/src/exchange/taler-exchange-httpd_refund.c index b6dc203c0..d8c9a6eed 100644 --- a/src/exchange/taler-exchange-httpd_refund.c +++ b/src/exchange/taler-exchange-httpd_refund.c @@ -56,13 +56,13 @@ verify_and_execute_refund (struct MHD_Connection *connection, dr.purpose.size = htonl (sizeof (struct TALER_RefundRequestPS)); dr.h_contract = refund->h_contract; dr.transaction_id = GNUNET_htonll (refund->transaction_id); + dr.coin_pub = refund->coin.coin_pub; + dr.merchant = refund->merchant_pub; dr.rtransaction_id = GNUNET_htonll (refund->rtransaction_id); TALER_amount_hton (&dr.refund_amount, &refund->refund_amount); TALER_amount_hton (&dr.refund_fee, &refund->refund_fee); - dr.merchant = refund->merchant_pub; - dr.coin_pub = refund->coin.coin_pub; if (GNUNET_YES != TALER_amount_cmp_currency (&refund->refund_amount, &refund->refund_fee) ) diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c index d3a73d38c..6873b2a8c 100644 --- a/src/exchange/taler-exchange-httpd_responses.c +++ b/src/exchange/taler-exchange-httpd_responses.c @@ -388,10 +388,8 @@ TMH_RESPONSE_reply_deposit_success (struct MHD_Connection *connection, MHD_HTTP_OK, "{s:s, s:o, s:o}", "status", "DEPOSIT_OK", - "sig", GNUNET_JSON_from_data (&sig, - sizeof (sig)), - "pub", GNUNET_JSON_from_data (&pub, - sizeof (pub))); + "sig", GNUNET_JSON_from_data_auto (&sig), + "pub", GNUNET_JSON_from_data_auto (&pub)); } @@ -449,8 +447,7 @@ compile_transaction_history (const struct TALER_EXCHANGEDB_TransactionList *tl) return NULL; } - details = GNUNET_JSON_from_data (&dr.purpose, - sizeof (struct TALER_DepositRequestPS)); + details = GNUNET_JSON_from_data_auto (&dr); break; } case TALER_EXCHANGEDB_TT_REFRESH_MELT: @@ -481,8 +478,7 @@ compile_transaction_history (const struct TALER_EXCHANGEDB_TransactionList *tl) return NULL; } - details = GNUNET_JSON_from_data (&ms.purpose, - sizeof (struct TALER_RefreshMeltCoinAffirmationPS)); + details = GNUNET_JSON_from_data_auto (&ms); } break; case TALER_EXCHANGEDB_TT_REFUND: @@ -523,8 +519,7 @@ compile_transaction_history (const struct TALER_EXCHANGEDB_TransactionList *tl) json_decref (history); return NULL; } - details = GNUNET_JSON_from_data (&rr.purpose, - sizeof (struct TALER_RefundRequestPS)); + details = GNUNET_JSON_from_data_auto (&rr); } break; default: @@ -534,8 +529,7 @@ compile_transaction_history (const struct TALER_EXCHANGEDB_TransactionList *tl) json_pack ("{s:s, s:o, s:o, s:o}", "type", type, "amount", TALER_JSON_from_amount (&value), - "signature", GNUNET_JSON_from_data (sig, - sizeof (struct GNUNET_CRYPTO_EddsaSignature)), + "signature", GNUNET_JSON_from_data_auto (sig), "details", details)); } return history; @@ -656,10 +650,8 @@ 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", GNUNET_JSON_from_data (&pos->details.withdraw->reserve_sig, - sizeof (struct TALER_ReserveSignatureP)), - "details", GNUNET_JSON_from_data (&wr, - sizeof (wr)), + "signature", GNUNET_JSON_from_data_auto (&pos->details.withdraw->reserve_sig), + "details", GNUNET_JSON_from_data_auto (&wr), "amount", TALER_JSON_from_amount (&value))); break; } @@ -757,10 +749,8 @@ TMH_RESPONSE_reply_refund_success (struct MHD_Connection *connection, MHD_HTTP_OK, "{s:s, s:o, s:o}", "status", "REFUND_OK", - "sig", GNUNET_JSON_from_data (&sig, - sizeof (sig)), - "pub", GNUNET_JSON_from_data (&pub, - sizeof (pub))); + "sig", GNUNET_JSON_from_data_auto (&sig), + "pub", GNUNET_JSON_from_data_auto (&pub)); } @@ -880,8 +870,7 @@ TMH_RESPONSE_reply_refresh_melt_insufficient_funds (struct MHD_Connection *conne "error", "insufficient funds", "coin_pub", - GNUNET_JSON_from_data (coin_pub, - sizeof (struct TALER_CoinSpendPublicKeyP)), + GNUNET_JSON_from_data_auto (coin_pub), "original_value", TALER_JSON_from_amount (&coin_value), "residual_value", @@ -919,16 +908,14 @@ TMH_RESPONSE_reply_refresh_melt_success (struct MHD_Connection *connection, TMH_KS_sign (&body.purpose, &pub, &sig); - sig_json = GNUNET_JSON_from_data (&sig, - sizeof (sig)); + sig_json = GNUNET_JSON_from_data_auto (&sig); GNUNET_assert (NULL != sig_json); return TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_OK, "{s:i, s:o, s:o}", "noreveal_index", (int) noreveal_index, "exchange_sig", sig_json, - "exchange_pub", GNUNET_JSON_from_data (&pub, - sizeof (pub))); + "exchange_pub", GNUNET_JSON_from_data_auto (&pub)); } @@ -1006,12 +993,10 @@ TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection, rm_json = json_object (); json_object_set_new (rm_json, "coin_sig", - GNUNET_JSON_from_data (&rm->coin_sig, - sizeof (struct TALER_CoinSpendSignatureP))); + GNUNET_JSON_from_data_auto (&rm->coin_sig)); json_object_set_new (rm_json, "coin_pub", - GNUNET_JSON_from_data (&rm->coin.coin_pub, - sizeof (struct TALER_CoinSpendPublicKeyP))); + GNUNET_JSON_from_data_auto (&rm->coin.coin_pub)); json_object_set_new (rm_json, "melt_amount_with_fee", TALER_JSON_from_amount (&rm->amount_with_fee)); @@ -1048,15 +1033,14 @@ TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection, json_object_set_new (cc_json, "coin_ev", GNUNET_JSON_from_data (cc->coin_ev, - cc->coin_ev_size)); + cc->coin_ev_size)); json_object_set_new (cc_json, "coin_priv_enc", - GNUNET_JSON_from_data (cc->refresh_link->coin_priv_enc, - sizeof (struct TALER_CoinSpendPrivateKeyP))); + GNUNET_JSON_from_data_auto (cc->refresh_link->coin_priv_enc)); json_object_set_new (cc_json, "blinding_key_enc", GNUNET_JSON_from_data (cc->refresh_link->blinding_key_enc, - cc->refresh_link->blinding_key_enc_size)); + cc->refresh_link->blinding_key_enc_size)); json_array_append_new (info_commit_k, cc_json); @@ -1068,12 +1052,10 @@ TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection, cl = &mc->commit_links[k]; json_object_set_new (info_link_k, "transfer_pub", - GNUNET_JSON_from_data (&cl->transfer_pub, - sizeof (struct TALER_TransferPublicKeyP))); + GNUNET_JSON_from_data_auto (&cl->transfer_pub)); json_object_set_new (info_link_k, "shared_secret_enc", - GNUNET_JSON_from_data (&cl->shared_secret_enc, - sizeof (struct TALER_EncryptedLinkSecretP))); + GNUNET_JSON_from_data_auto (&cl->shared_secret_enc)); json_array_append_new (info_links, info_link_k); } @@ -1141,12 +1123,10 @@ TMH_RESPONSE_reply_refresh_link_success (struct MHD_Connection *connection, list); json_object_set_new (root, "transfer_pub", - GNUNET_JSON_from_data (&sessions[i].transfer_pub, - sizeof (struct TALER_TransferPublicKeyP))); + GNUNET_JSON_from_data_auto (&sessions[i].transfer_pub)); json_object_set_new (root, "secret_enc", - GNUNET_JSON_from_data (&sessions[i].shared_secret_enc, - sizeof (struct TALER_EncryptedLinkSecretP))); + GNUNET_JSON_from_data_auto (&sessions[i].shared_secret_enc)); json_array_append_new (mlist, root); } @@ -1240,14 +1220,11 @@ 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}", - "wtid", GNUNET_JSON_from_data (wtid, - sizeof (*wtid)), + "wtid", GNUNET_JSON_from_data_auto (wtid), "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", GNUNET_JSON_from_data (&pub, - sizeof (pub))); + "exchange_sig", GNUNET_JSON_from_data_auto (&sig), + "exchange_pub", GNUNET_JSON_from_data_auto (&pub)); } @@ -1293,11 +1270,9 @@ TMH_RESPONSE_reply_wire_deposit_details (struct MHD_Connection *connection, sizeof (struct TALER_WireDepositDetailP)); json_array_append (deposits, json_pack ("{s:o, s:I, s:o, s:o, s:o}", - "H_contract", GNUNET_JSON_from_data (&wdd_pos->h_contract, - sizeof (struct GNUNET_HashCode)), + "H_contract", GNUNET_JSON_from_data_auto (&wdd_pos->h_contract), "transaction_id", (json_int_t) wdd_pos->transaction_id, - "coin_pub", GNUNET_JSON_from_data (&wdd_pos->coin_pub, - sizeof (struct TALER_CoinSpendPublicKeyP)), + "coin_pub", GNUNET_JSON_from_data_auto (&wdd_pos->coin_pub), "deposit_value", TALER_JSON_from_amount (&wdd_pos->deposit_value), "deposit_fee", TALER_JSON_from_amount (&wdd_pos->deposit_fee))); } @@ -1316,15 +1291,11 @@ TMH_RESPONSE_reply_wire_deposit_details (struct MHD_Connection *connection, MHD_HTTP_OK, "{s:o, s:o, s:o, s:o, s:o, s:o}", "total", TALER_JSON_from_amount (total), - "merchant_pub", GNUNET_JSON_from_data (merchant_pub, - sizeof (struct TALER_MerchantPublicKeyP)), - "H_wire", GNUNET_JSON_from_data (h_wire, - sizeof (struct GNUNET_HashCode)), + "merchant_pub", GNUNET_JSON_from_data_auto (merchant_pub), + "H_wire", GNUNET_JSON_from_data_auto (h_wire), "deposits", deposits, - "exchange_sig", GNUNET_JSON_from_data (&sig, - sizeof (sig)), - "exchange_pub", GNUNET_JSON_from_data (&pub, - sizeof (pub))); + "exchange_sig", GNUNET_JSON_from_data_auto (&sig), + "exchange_pub", GNUNET_JSON_from_data_auto (&pub)); } diff --git a/src/exchange/taler-exchange-httpd_test.c b/src/exchange/taler-exchange-httpd_test.c index 7c9e0820d..488701d65 100644 --- a/src/exchange/taler-exchange-httpd_test.c +++ b/src/exchange/taler-exchange-httpd_test.c @@ -91,7 +91,7 @@ TMH_TEST_handler_test_base32 (struct TMH_RequestHandler *rh, MHD_HTTP_OK, "{s:o}", "output", - GNUNET_JSON_from_data (&hc, sizeof (struct GNUNET_HashCode))); + GNUNET_JSON_from_data_auto (&hc)); } @@ -166,7 +166,7 @@ TMH_TEST_handler_test_encrypt (struct TMH_RequestHandler *rh, &iv, out)); json = GNUNET_JSON_from_data (out, - in_ptr_size); + in_ptr_size); GNUNET_free (out); GNUNET_JSON_parse_free (spec); return TMH_RESPONSE_reply_json_pack (connection, @@ -232,8 +232,7 @@ TMH_TEST_handler_test_hkdf (struct TMH_RequestHandler *rh, in_ptr_size, NULL, 0); GNUNET_JSON_parse_free (spec); - json = GNUNET_JSON_from_data (&hc, - sizeof (struct GNUNET_HashCode)); + json = GNUNET_JSON_from_data_auto (&hc); return TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_OK, "{s:o}", @@ -303,8 +302,7 @@ TMH_TEST_handler_test_ecdhe (struct TMH_RequestHandler *rh, MHD_HTTP_OK, "{s:o}", "ecdh_hash", - GNUNET_JSON_from_data (&hc, - sizeof (hc))); + GNUNET_JSON_from_data_auto (&hc)); } @@ -388,11 +386,9 @@ TMH_TEST_handler_test_eddsa (struct TMH_RequestHandler *rh, MHD_HTTP_OK, "{s:o, s:o}", "eddsa_pub", - GNUNET_JSON_from_data (&pub, - sizeof (pub)), + GNUNET_JSON_from_data_auto (&pub), "eddsa_sig", - GNUNET_JSON_from_data (&sig, - sizeof (sig))); + GNUNET_JSON_from_data_auto (&sig)); } @@ -579,8 +575,7 @@ TMH_TEST_handler_test_transfer (struct TMH_RequestHandler *rh, MHD_HTTP_OK, "{s:o}", "secret", - GNUNET_JSON_from_data (&secret, - sizeof (secret))); + GNUNET_JSON_from_data_auto (&secret)); } |