summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-05-21 18:36:12 +0200
committerChristian Grothoff <christian@grothoff.org>2016-05-21 18:36:12 +0200
commit9160245167ded9b2b7c11716dfa1a1e8887187f4 (patch)
tree64720ebc3b69f84055f25d8a7f309b19b0ebd52a /src
parent922175d3082b138f4973fe11d81327806e68021d (diff)
downloadexchange-9160245167ded9b2b7c11716dfa1a1e8887187f4.tar.gz
exchange-9160245167ded9b2b7c11716dfa1a1e8887187f4.tar.bz2
exchange-9160245167ded9b2b7c11716dfa1a1e8887187f4.zip
make use of GNUNET_JSON_from_data_auto where possible
Diffstat (limited to 'src')
-rw-r--r--src/bank-lib/bank_api_admin.c3
-rw-r--r--src/exchange-lib/exchange_api_admin.c3
-rw-r--r--src/exchange-lib/exchange_api_deposit.c15
-rw-r--r--src/exchange-lib/exchange_api_deposit_wtid.c15
-rw-r--r--src/exchange-lib/exchange_api_refresh.c22
-rw-r--r--src/exchange-lib/exchange_api_refund.c16
-rw-r--r--src/exchange-lib/exchange_api_reserve.c8
-rw-r--r--src/exchange-lib/test_exchange_api.c73
-rw-r--r--src/exchange/taler-exchange-httpd_keystate.c27
-rw-r--r--src/exchange/taler-exchange-httpd_refund.c4
-rw-r--r--src/exchange/taler-exchange-httpd_responses.c91
-rw-r--r--src/exchange/taler-exchange-httpd_test.c19
12 files changed, 145 insertions, 151 deletions
diff --git a/src/bank-lib/bank_api_admin.c b/src/bank-lib/bank_api_admin.c
index 5cd82b093..a4f7e8164 100644
--- a/src/bank-lib/bank_api_admin.c
+++ b/src/bank-lib/bank_api_admin.c
@@ -190,8 +190,7 @@ TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx,
admin_obj = json_pack ("{s:o, s:o,"
" s:I, s:I}",
- "wtid", GNUNET_JSON_from_data (wtid,
- sizeof (*wtid)), /* #4340 */
+ "wtid", GNUNET_JSON_from_data_auto (wtid), /* #4340 */
"amount", TALER_JSON_from_amount (amount),
"debit_account", (json_int_t) debit_account_no,
"credit_account", (json_int_t) credit_account_no);
diff --git a/src/exchange-lib/exchange_api_admin.c b/src/exchange-lib/exchange_api_admin.c
index 068a11e02..3c87be5a3 100644
--- a/src/exchange-lib/exchange_api_admin.c
+++ b/src/exchange-lib/exchange_api_admin.c
@@ -175,8 +175,7 @@ TALER_EXCHANGE_admin_add_incoming (struct TALER_EXCHANGE_Handle *exchange,
}
admin_obj = json_pack ("{s:o, s:o," /* reserve_pub/amount */
" s:o, s:O}", /* execution_Date/wire */
- "reserve_pub", GNUNET_JSON_from_data (reserve_pub,
- sizeof (*reserve_pub)),
+ "reserve_pub", GNUNET_JSON_from_data_auto (reserve_pub),
"amount", TALER_JSON_from_amount (amount),
"execution_date", GNUNET_JSON_from_time_abs (execution_date),
"wire", wire);
diff --git a/src/exchange-lib/exchange_api_deposit.c b/src/exchange-lib/exchange_api_deposit.c
index 0a5fc0eda..6ddfe6f65 100644
--- a/src/exchange-lib/exchange_api_deposit.c
+++ b/src/exchange-lib/exchange_api_deposit.c
@@ -469,22 +469,17 @@ TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle *exchange,
" s:o}", /* coin_sig */
"f", TALER_JSON_from_amount (amount),
"wire", wire_details,
- "H_wire", GNUNET_JSON_from_data (&h_wire,
- sizeof (h_wire)),
- "H_contract", GNUNET_JSON_from_data (h_contract,
- sizeof (struct GNUNET_HashCode)),
- "coin_pub", GNUNET_JSON_from_data (coin_pub,
- sizeof (*coin_pub)),
+ "H_wire", GNUNET_JSON_from_data_auto (&h_wire),
+ "H_contract", GNUNET_JSON_from_data_auto (h_contract),
+ "coin_pub", GNUNET_JSON_from_data_auto (coin_pub),
"denom_pub", GNUNET_JSON_from_rsa_public_key (denom_pub->rsa_public_key),
"ub_sig", GNUNET_JSON_from_rsa_signature (denom_sig->rsa_signature),
"timestamp", GNUNET_JSON_from_time_abs (timestamp),
"transaction_id", (json_int_t) transaction_id,
- "merchant_pub", GNUNET_JSON_from_data (merchant_pub,
- sizeof (*merchant_pub)),
+ "merchant_pub", GNUNET_JSON_from_data_auto (merchant_pub),
"refund_deadline", GNUNET_JSON_from_time_abs (refund_deadline),
"edate", GNUNET_JSON_from_time_abs (wire_deadline),
- "coin_sig", GNUNET_JSON_from_data (coin_sig,
- sizeof (*coin_sig))
+ "coin_sig", GNUNET_JSON_from_data_auto (coin_sig)
);
dh = GNUNET_new (struct TALER_EXCHANGE_DepositHandle);
diff --git a/src/exchange-lib/exchange_api_deposit_wtid.c b/src/exchange-lib/exchange_api_deposit_wtid.c
index b3c5b3282..073ce2b35 100644
--- a/src/exchange-lib/exchange_api_deposit_wtid.c
+++ b/src/exchange-lib/exchange_api_deposit_wtid.c
@@ -291,17 +291,12 @@ TALER_EXCHANGE_deposit_wtid (struct TALER_EXCHANGE_Handle *exchange,
deposit_wtid_obj = json_pack ("{s:o, s:o," /* H_wire, H_contract */
" s:o, s:I," /* coin_pub, transaction_id */
" s:o, s:o}", /* merchant_pub, merchant_sig */
- "H_wire", GNUNET_JSON_from_data (h_wire,
- sizeof (struct GNUNET_HashCode)),
- "H_contract", GNUNET_JSON_from_data (h_contract,
- sizeof (struct GNUNET_HashCode)),
- "coin_pub", GNUNET_JSON_from_data (coin_pub,
- sizeof (*coin_pub)),
+ "H_wire", GNUNET_JSON_from_data_auto (h_wire),
+ "H_contract", GNUNET_JSON_from_data_auto (h_contract),
+ "coin_pub", GNUNET_JSON_from_data_auto (coin_pub),
"transaction_id", (json_int_t) transaction_id,
- "merchant_pub", GNUNET_JSON_from_data (&dtp.merchant,
- sizeof (struct TALER_MerchantPublicKeyP)),
- "merchant_sig", GNUNET_JSON_from_data (&merchant_sig,
- sizeof (merchant_sig)));
+ "merchant_pub", GNUNET_JSON_from_data_auto (&dtp.merchant),
+ "merchant_sig", GNUNET_JSON_from_data_auto (&merchant_sig));
dwh = GNUNET_new (struct TALER_EXCHANGE_DepositWtidHandle);
dwh->exchange = exchange;
diff --git a/src/exchange-lib/exchange_api_refresh.c b/src/exchange-lib/exchange_api_refresh.c
index ad2195689..e98b3c782 100644
--- a/src/exchange-lib/exchange_api_refresh.c
+++ b/src/exchange-lib/exchange_api_refresh.c
@@ -1310,15 +1310,13 @@ melted_coin_to_json (const struct GNUNET_HashCode *melt_session_hash,
&confirm_sig.eddsa_signature);
return json_pack ("{s:o, s:o, s:o, s:o, s:o}",
"coin_pub",
- GNUNET_JSON_from_data (&melt.coin_pub,
- sizeof (melt.coin_pub)),
+ GNUNET_JSON_from_data_auto (&melt.coin_pub),
"denom_pub",
GNUNET_JSON_from_rsa_public_key (mc->pub_key.rsa_public_key),
"denom_sig",
GNUNET_JSON_from_rsa_signature (mc->sig.rsa_signature),
"confirm_sig",
- GNUNET_JSON_from_data (&confirm_sig,
- sizeof (confirm_sig)),
+ GNUNET_JSON_from_data_auto (&confirm_sig),
"value_with_fee",
TALER_JSON_from_amount (&mc->melt_amount_with_fee));
}
@@ -1398,8 +1396,7 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange,
GNUNET_CRYPTO_ecdhe_key_get_public (&mc->transfer_priv[j].ecdhe_priv,
&transfer_pub.ecdhe_pub);
json_array_append (transfer_pubs,
- GNUNET_JSON_from_data (&transfer_pub,
- sizeof (transfer_pub)));
+ GNUNET_JSON_from_data_auto (&transfer_pub));
}
/* now secret_encs */
@@ -1417,8 +1414,7 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange,
&trans_sec,
&els));
json_array_append (secret_encs,
- GNUNET_JSON_from_data (&els,
- sizeof (els)));
+ GNUNET_JSON_from_data_auto (&els));
}
/* now new_denoms */
@@ -1451,7 +1447,7 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange,
GNUNET_assert (NULL != buf);
json_array_append (tmp,
GNUNET_JSON_from_data (buf,
- buf_len));
+ buf_len));
GNUNET_free (buf);
GNUNET_free (rle);
}
@@ -1482,7 +1478,7 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange,
&coin_ev);
json_array_append (tmp,
GNUNET_JSON_from_data (coin_ev,
- coin_ev_size));
+ coin_ev_size));
GNUNET_free (coin_ev);
}
json_array_append (coin_evs,
@@ -1869,15 +1865,13 @@ TALER_EXCHANGE_refresh_reveal (struct TALER_EXCHANGE_Handle *exchange,
continue;
}
json_array_append (transfer_privs,
- GNUNET_JSON_from_data (&md->melted_coin.transfer_priv[j],
- sizeof (struct TALER_TransferPrivateKeyP)));
+ GNUNET_JSON_from_data_auto (&md->melted_coin.transfer_priv[j]));
}
/* build main JSON request */
reveal_obj = json_pack ("{s:o, s:o}",
"session_hash",
- GNUNET_JSON_from_data (&md->melt_session_hash,
- sizeof (struct GNUNET_HashCode)),
+ GNUNET_JSON_from_data_auto (&md->melt_session_hash),
"transfer_privs",
transfer_privs);
diff --git a/src/exchange-lib/exchange_api_refund.c b/src/exchange-lib/exchange_api_refund.c
index a6069f0b4..82ae5e8ab 100644
--- a/src/exchange-lib/exchange_api_refund.c
+++ b/src/exchange-lib/exchange_api_refund.c
@@ -265,18 +265,14 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange,
" s:o, s:o," /* H_contract, coin_pub */
" s:I, s:I," /* transaction id, rtransaction id */
" s:o, s:o}", /* merchant_pub, merchant_sig */
- "amount", TALER_JSON_from_amount (amount),
- "fee", TALER_JSON_from_amount (amount),
- "H_contract", GNUNET_JSON_from_data (h_contract,
- sizeof (struct GNUNET_HashCode)),
- "coin_pub", GNUNET_JSON_from_data (coin_pub,
- sizeof (*coin_pub)),
+ "refund_amount", TALER_JSON_from_amount (amount),
+ "refund_fee", TALER_JSON_from_amount (amount),
+ "H_contract", GNUNET_JSON_from_data_auto (h_contract),
+ "coin_pub", GNUNET_JSON_from_data_auto (coin_pub),
"transaction_id", (json_int_t) transaction_id,
"rtransaction_id", (json_int_t) rtransaction_id,
- "merchant_pub", GNUNET_JSON_from_data (&rr.merchant,
- sizeof (struct TALER_MerchantPublicKeyP)),
- "merchant_sig", GNUNET_JSON_from_data (&merchant_sig,
- sizeof (merchant_sig))
+ "merchant_pub", GNUNET_JSON_from_data_auto (&rr.merchant),
+ "merchant_sig", GNUNET_JSON_from_data_auto (&merchant_sig)
);
rh = GNUNET_new (struct TALER_EXCHANGE_RefundHandle);
diff --git a/src/exchange-lib/exchange_api_reserve.c b/src/exchange-lib/exchange_api_reserve.c
index 056d2f085..56cc3dc54 100644
--- a/src/exchange-lib/exchange_api_reserve.c
+++ b/src/exchange-lib/exchange_api_reserve.c
@@ -840,11 +840,9 @@ TALER_EXCHANGE_reserve_withdraw (struct TALER_EXCHANGE_Handle *exchange,
" s:o, s:o}",/* reserve_pub and reserve_sig */
"denom_pub", GNUNET_JSON_from_rsa_public_key (pk->key.rsa_public_key),
"coin_ev", GNUNET_JSON_from_data (coin_ev,
- coin_ev_size),
- "reserve_pub", GNUNET_JSON_from_data (&wsh->reserve_pub,
- sizeof (struct TALER_ReservePublicKeyP)),
- "reserve_sig", GNUNET_JSON_from_data (&reserve_sig,
- sizeof (reserve_sig)));
+ coin_ev_size),
+ "reserve_pub", GNUNET_JSON_from_data_auto (&wsh->reserve_pub),
+ "reserve_sig", GNUNET_JSON_from_data_auto (&reserve_sig));
GNUNET_free (coin_ev);
wsh->blinding_key = blinding_key;
diff --git a/src/exchange-lib/test_exchange_api.c b/src/exchange-lib/test_exchange_api.c
index 8e0d9d2aa..169d68f39 100644
--- a/src/exchange-lib/test_exchange_api.c
+++ b/src/exchange-lib/test_exchange_api.c
@@ -1906,17 +1906,20 @@ interpreter_run (void *cls)
if (0 != cmd->details.deposit.refund_deadline.rel_value_us)
{
refund_deadline = GNUNET_TIME_relative_to_absolute (cmd->details.deposit.refund_deadline);
+ wire_deadline = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (cmd->details.deposit.refund_deadline, 2));
}
else
{
refund_deadline = GNUNET_TIME_UNIT_ZERO_ABS;
+ wire_deadline = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_ZERO);
}
GNUNET_CRYPTO_eddsa_key_get_public (&cmd->details.deposit.merchant_priv.eddsa_priv,
&merchant_pub.eddsa_pub);
- wire_deadline = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_ZERO);
timestamp = GNUNET_TIME_absolute_get ();
GNUNET_TIME_round_abs (&timestamp);
+ GNUNET_TIME_round_abs (&refund_deadline);
+ GNUNET_TIME_round_abs (&wire_deadline);
{
struct TALER_DepositRequestPS dr;
@@ -2275,7 +2278,7 @@ interpreter_run (void *cls)
ref = find_command (is,
cmd->details.refund.deposit_ref);
GNUNET_assert (NULL != ref);
- contract = json_loads (cmd->details.deposit.contract,
+ contract = json_loads (ref->details.deposit.contract,
JSON_REJECT_DUPLICATES,
NULL);
GNUNET_assert (NULL != contract);
@@ -2670,7 +2673,7 @@ run (void *cls)
{ .oc = OC_ADMIN_ADD_INCOMING,
.label = "create-reserve-1",
.expected_response_code = MHD_HTTP_OK,
- .details.admin_add_incoming.wire = "{ \"type\":\"test\", \"bank_uri\":\"http://localhost:8082/\", \"account_number\":42 }",
+ .details.admin_add_incoming.wire = "{ \"type\":\"test\", \"bank_uri\":\"http://localhost:8082/\", \"account_number\":42, \"uuid\":1 }",
.details.admin_add_incoming.amount = "EUR:5.01" },
/* Withdraw a 5 EUR coin, at fee of 1 ct */
{ .oc = OC_WITHDRAW_SIGN,
@@ -2892,12 +2895,70 @@ run (void *cls)
.details.wire_deposits.wtid_ref = "deposit-wtid-ok",
.details.wire_deposits.total_amount_expected = "EUR:4.99" },
+ /* ************** End of tracking API testing************* */
- /* TODO: trigger aggregation logic and then check the
- cases where tracking succeeds! */
+ /* ************** Test /refund API ************* */
- /* ************** End of tracking API testing************* */
+ /* Fill reserve with EUR:5.01, as withdraw fee is 1 ct per config */
+ { .oc = OC_ADMIN_ADD_INCOMING,
+ .label = "create-reserve-r1",
+ .expected_response_code = MHD_HTTP_OK,
+ .details.admin_add_incoming.wire = "{ \"type\":\"test\", \"bank_uri\":\"http://localhost:8082/\", \"account_number\":42, \"uuid\":2 }",
+ .details.admin_add_incoming.amount = "EUR:5.01" },
+ /* Withdraw a 5 EUR coin, at fee of 1 ct */
+ { .oc = OC_WITHDRAW_SIGN,
+ .label = "withdraw-coin-r1",
+ .expected_response_code = MHD_HTTP_OK,
+ .details.reserve_withdraw.reserve_reference = "create-reserve-r1",
+ .details.reserve_withdraw.amount = "EUR:5" },
+ /* Spend 5 EUR of the 5 EUR coin (in full)
+ (merchant would receive EUR:4.99 due to 1 ct deposit fee) */
+ { .oc = OC_DEPOSIT,
+ .label = "deposit-refund-1",
+ .expected_response_code = MHD_HTTP_OK,
+ .details.deposit.amount = "EUR:5",
+ .details.deposit.coin_ref = "withdraw-coin-r1",
+ .details.deposit.wire_details = "{ \"type\":\"test\", \"bank_uri\":\"http://localhost:8082/\", \"account_number\":42 }",
+ .details.deposit.contract = "{ \"items\" : [ { \"name\":\"ice cream\", \"value\":\"EUR:5\" } ] }",
+ .details.deposit.transaction_id = 424210,
+ .details.deposit.refund_deadline = { 60LL * 1000 * 1000 } /* 60 s */,
+ },
+ /* Run transfers. Should do nothing as refund deadline blocks it */
+ { .oc = OC_RUN_AGGREGATOR,
+ .label = "run-aggregator" },
+ /* Trigger refund */
+ { .oc = OC_REFUND,
+ .label = "refund-ok",
+ .expected_response_code = MHD_HTTP_OK,
+ .details.refund.amount = "EUR:5",
+ .details.refund.fee = "EUR:0.01",
+ .details.refund.deposit_ref = "deposit-refund-1",
+ .details.refund.rtransaction_id = 1
+ },
+ /* Spend 4.99 EUR of the refunded 4.99 EUR coin (1ct gone due to refund)
+ (merchant would receive EUR:4.98 due to 1 ct deposit fee) */
+ { .oc = OC_DEPOSIT,
+ .label = "deposit-refund-2",
+ .expected_response_code = MHD_HTTP_OK,
+ .details.deposit.amount = "EUR:4.99",
+ .details.deposit.coin_ref = "withdraw-coin-r1",
+ .details.deposit.wire_details = "{ \"type\":\"test\", \"bank_uri\":\"http://localhost:8082/\", \"account_number\":42 }",
+ .details.deposit.contract = "{ \"items\" : [ { \"name\":\"more ice cream\", \"value\":\"EUR:5\" } ] }",
+ .details.deposit.transaction_id = 424211,
+ },
+ /* Run transfers. This will do the transfer as refund deadline was 0 */
+ { .oc = OC_RUN_AGGREGATOR,
+ .label = "run-aggregator" },
+ /* Run failing refund, as past deadline & aggregation */
+ { .oc = OC_REFUND,
+ .label = "refund-fail",
+ .expected_response_code = MHD_HTTP_OK,
+ .details.refund.amount = "EUR:4.99",
+ .details.refund.fee = "EUR:0.01",
+ .details.refund.deposit_ref = "deposit-refund-2",
+ .details.refund.rtransaction_id = 2
+ },
#endif
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));
}