second pass on responses: indentation cleanup and CSE

This commit is contained in:
Christian Grothoff 2020-03-27 13:21:02 +01:00
parent a2bfd9f6b5
commit b5f62c8060
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC

View File

@ -91,33 +91,28 @@ TEH_RESPONSE_compile_transaction_history (
}
#endif
if (0 !=
json_array_append_new (history,
json_array_append_new (
history,
json_pack (
"{s:s, s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}",
"type", "DEPOSIT",
"amount", TALER_JSON_from_amount (
&deposit->amount_with_fee),
"type",
"DEPOSIT",
"amount",
TALER_JSON_from_amount (&deposit->amount_with_fee),
"deposit_fee",
TALER_JSON_from_amount (
&deposit->deposit_fee),
TALER_JSON_from_amount (&deposit->deposit_fee),
"timestamp",
GNUNET_JSON_from_time_abs (
deposit->timestamp),
GNUNET_JSON_from_time_abs (deposit->timestamp),
"refund_deadline",
GNUNET_JSON_from_time_abs (
deposit->refund_deadline),
GNUNET_JSON_from_time_abs (deposit->refund_deadline),
"merchant_pub",
GNUNET_JSON_from_data_auto (
&deposit->merchant_pub),
GNUNET_JSON_from_data_auto (&deposit->merchant_pub),
"h_contract_terms",
GNUNET_JSON_from_data_auto (
&deposit->h_contract_terms),
GNUNET_JSON_from_data_auto (&deposit->h_contract_terms),
"h_wire",
GNUNET_JSON_from_data_auto (
&deposit->h_wire),
GNUNET_JSON_from_data_auto (&deposit->h_wire),
"coin_sig",
GNUNET_JSON_from_data_auto (
&deposit->csig))))
GNUNET_JSON_from_data_auto (&deposit->csig))))
{
GNUNET_break (0);
json_decref (history);
@ -154,19 +149,19 @@ TEH_RESPONSE_compile_transaction_history (
}
#endif
if (0 !=
json_array_append_new (history,
json_array_append_new (
history,
json_pack ("{s:s, s:o, s:o, s:o, s:o}",
"type", "MELT",
"amount", TALER_JSON_from_amount (
&melt->amount_with_fee),
"type",
"MELT",
"amount",
TALER_JSON_from_amount (&melt->amount_with_fee),
"melt_fee",
TALER_JSON_from_amount (
&melt->melt_fee),
"rc", GNUNET_JSON_from_data_auto (
&melt->rc),
TALER_JSON_from_amount (&melt->melt_fee),
"rc",
GNUNET_JSON_from_data_auto (&melt->rc),
"coin_sig",
GNUNET_JSON_from_data_auto (
&melt->coin_sig))))
GNUNET_JSON_from_data_auto (&melt->coin_sig))))
{
GNUNET_break (0);
json_decref (history);
@ -215,26 +210,24 @@ TEH_RESPONSE_compile_transaction_history (
return NULL;
}
if (0 !=
json_array_append_new (history,
json_array_append_new (
history,
json_pack (
"{s:s, s:o, s:o, s:o, s:o, s:I, s:o}",
"type", "REFUND",
"amount", TALER_JSON_from_amount (
&value),
"type",
"REFUND",
"amount",
TALER_JSON_from_amount (&value),
"refund_fee",
TALER_JSON_from_amount (
&refund->refund_fee),
TALER_JSON_from_amount (&refund->refund_fee),
"h_contract_terms",
GNUNET_JSON_from_data_auto (
&refund->h_contract_terms),
GNUNET_JSON_from_data_auto (&refund->h_contract_terms),
"merchant_pub",
GNUNET_JSON_from_data_auto (
&refund->merchant_pub),
GNUNET_JSON_from_data_auto (&refund->merchant_pub),
"rtransaction_id",
(json_int_t) refund->rtransaction_id,
"merchant_sig",
GNUNET_JSON_from_data_auto (
&refund->merchant_sig))))
GNUNET_JSON_from_data_auto (&refund->merchant_sig))))
{
GNUNET_break (0);
json_decref (history);
@ -274,23 +267,21 @@ TEH_RESPONSE_compile_transaction_history (
check or do anything with it anyway if it doesn't), it seems
strictly unnecessary. *///
if (0 !=
json_array_append_new (history,
json_array_append_new (
history,
json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}",
"type", "OLD-COIN-RECOUP",
"amount", TALER_JSON_from_amount (
&pr->value),
"type",
"OLD-COIN-RECOUP",
"amount",
TALER_JSON_from_amount (&pr->value),
"exchange_sig",
GNUNET_JSON_from_data_auto (
&esig),
GNUNET_JSON_from_data_auto (&esig),
"exchange_pub",
GNUNET_JSON_from_data_auto (
&epub),
GNUNET_JSON_from_data_auto (&epub),
"coin_pub",
GNUNET_JSON_from_data_auto (
&pr->coin.coin_pub),
GNUNET_JSON_from_data_auto (&pr->coin.coin_pub),
"timestamp",
GNUNET_JSON_from_time_abs (
pr->timestamp))))
GNUNET_JSON_from_time_abs (pr->timestamp))))
{
GNUNET_break (0);
json_decref (history);
@ -324,23 +315,21 @@ TEH_RESPONSE_compile_transaction_history (
return NULL;
}
if (0 !=
json_array_append_new (history,
json_array_append_new (
history,
json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}",
"type", "RECOUP",
"amount", TALER_JSON_from_amount (
&recoup->value),
"type",
"RECOUP",
"amount",
TALER_JSON_from_amount (&recoup->value),
"exchange_sig",
GNUNET_JSON_from_data_auto (
&esig),
GNUNET_JSON_from_data_auto (&esig),
"exchange_pub",
GNUNET_JSON_from_data_auto (
&epub),
GNUNET_JSON_from_data_auto (&epub),
"reserve_pub",
GNUNET_JSON_from_data_auto (
&recoup->reserve_pub),
GNUNET_JSON_from_data_auto (&recoup->reserve_pub),
"timestamp",
GNUNET_JSON_from_time_abs (
recoup->timestamp))))
GNUNET_JSON_from_time_abs (recoup->timestamp))))
{
GNUNET_break (0);
json_decref (history);
@ -380,23 +369,21 @@ TEH_RESPONSE_compile_transaction_history (
check or do anything with it anyway if it doesn't), it seems
strictly unnecessary. *///
if (0 !=
json_array_append_new (history,
json_array_append_new (
history,
json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}",
"type", "RECOUP-REFRESH",
"amount", TALER_JSON_from_amount (
&pr->value),
"type",
"RECOUP-REFRESH",
"amount",
TALER_JSON_from_amount (&pr->value),
"exchange_sig",
GNUNET_JSON_from_data_auto (
&esig),
GNUNET_JSON_from_data_auto (&esig),
"exchange_pub",
GNUNET_JSON_from_data_auto (
&epub),
GNUNET_JSON_from_data_auto (&epub),
"old_coin_pub",
GNUNET_JSON_from_data_auto (
&pr->old_coin_pub),
GNUNET_JSON_from_data_auto (&pr->old_coin_pub),
"timestamp",
GNUNET_JSON_from_time_abs (
pr->timestamp))))
GNUNET_JSON_from_time_abs (pr->timestamp))))
{
GNUNET_break (0);
json_decref (history);
@ -486,49 +473,52 @@ TEH_RESPONSE_compile_reserve_history (
switch (pos->type)
{
case TALER_EXCHANGEDB_RO_BANK_TO_EXCHANGE:
{
const struct TALER_EXCHANGEDB_BankTransfer *bank =
pos->details.bank;
if (0 == (IA_DEPOSIT & init))
{
deposit_total = pos->details.bank->amount;
deposit_total = bank->amount;
init |= IA_DEPOSIT;
}
else if (GNUNET_OK !=
TALER_amount_add (&deposit_total,
&deposit_total,
&pos->details.bank->amount))
&bank->amount))
{
GNUNET_break (0);
json_decref (json_history);
return NULL;
}
if (0 !=
json_array_append_new (json_history,
json_array_append_new (
json_history,
json_pack ("{s:s, s:o, s:s, s:o, s:o}",
"type", "DEPOSIT",
"type",
"DEPOSIT",
"timestamp",
GNUNET_JSON_from_time_abs (
pos->details.bank->execution_date),
GNUNET_JSON_from_time_abs (bank->execution_date),
"sender_account_url",
pos->details.bank->
sender_account_details,
bank->sender_account_details,
"wire_reference",
GNUNET_JSON_from_data (
pos->details.bank->wire_reference,
pos
->details.
GNUNET_JSON_from_data (bank->wire_reference,
bank->wire_reference_size),
"amount", TALER_JSON_from_amount (
&pos->details.bank->amount))))
"amount",
TALER_JSON_from_amount (&bank->amount))))
{
GNUNET_break (0);
json_decref (json_history);
return NULL;
}
break;
}
case TALER_EXCHANGEDB_RO_WITHDRAW_COIN:
{
const struct TALER_EXCHANGEDB_CollectableBlindcoin *withdraw
= pos->details.withdraw;
struct TALER_Amount value;
value = pos->details.withdraw->amount_with_fee;
value = withdraw->amount_with_fee;
if (0 == (IA_WITHDRAW & init))
{
withdraw_total = value;
@ -547,27 +537,22 @@ TEH_RESPONSE_compile_reserve_history (
}
}
if (0 !=
json_array_append_new (json_history,
json_array_append_new (
json_history,
json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}",
"type", "WITHDRAW",
"type",
"WITHDRAW",
"reserve_sig",
GNUNET_JSON_from_data_auto (
&pos->details.withdraw->
reserve_sig),
GNUNET_JSON_from_data_auto (&withdraw->reserve_sig),
"h_coin_envelope",
GNUNET_JSON_from_data_auto (
&pos->details.withdraw->
h_coin_envelope),
&withdraw->h_coin_envelope),
"h_denom_pub",
GNUNET_JSON_from_data_auto (
&pos->details.withdraw->
denom_pub_hash),
GNUNET_JSON_from_data_auto (&withdraw->denom_pub_hash),
"withdraw_fee",
TALER_JSON_from_amount (
&pos->details.withdraw->
withdraw_fee),
"amount", TALER_JSON_from_amount (
&value))))
TALER_JSON_from_amount (&withdraw->withdraw_fee),
"amount",
TALER_JSON_from_amount (&value))))
{
GNUNET_break (0);
json_decref (json_history);
@ -577,11 +562,11 @@ TEH_RESPONSE_compile_reserve_history (
break;
case TALER_EXCHANGEDB_RO_RECOUP_COIN:
{
const struct TALER_EXCHANGEDB_Recoup *recoup;
const struct TALER_EXCHANGEDB_Recoup *recoup
= pos->details.recoup;
struct TALER_ExchangePublicKeyP pub;
struct TALER_ExchangeSignatureP sig;
recoup = pos->details.recoup;
if (0 == (IA_DEPOSIT & init))
{
deposit_total = recoup->value;
@ -643,11 +628,13 @@ TEH_RESPONSE_compile_reserve_history (
break;
case TALER_EXCHANGEDB_RO_EXCHANGE_TO_BANK:
{
const struct TALER_EXCHANGEDB_ClosingTransfer *closing =
pos->details.closing;
struct TALER_ExchangePublicKeyP pub;
struct TALER_ExchangeSignatureP sig;
struct TALER_Amount value;
value = pos->details.closing->amount;
value = closing->amount;
if (0 == (IA_WITHDRAW & init))
{
withdraw_total = value;
@ -669,20 +656,17 @@ TEH_RESPONSE_compile_reserve_history (
struct TALER_ReserveCloseConfirmationPS rcc = {
.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_RESERVE_CLOSED),
.purpose.size = htonl (sizeof (rcc)),
.timestamp = GNUNET_TIME_absolute_hton (
pos->details.closing->execution_date),
.timestamp = GNUNET_TIME_absolute_hton (closing->execution_date),
.reserve_pub = pos->details.closing->reserve_pub,
.wtid = pos->details.closing->wtid
.wtid = closing->wtid
};
TALER_amount_hton (&rcc.closing_amount,
&value);
TALER_amount_hton (&rcc.closing_fee,
&pos->details.closing->closing_fee);
GNUNET_CRYPTO_hash (pos->details.closing->receiver_account_details,
strlen (
pos->details.closing->receiver_account_details)
+ 1,
&closing->closing_fee);
GNUNET_CRYPTO_hash (closing->receiver_account_details,
strlen (closing->receiver_account_details) + 1,
&rcc.h_wire);
if (GNUNET_OK !=
TEH_KS_sign (&rcc.purpose,
@ -695,28 +679,26 @@ TEH_RESPONSE_compile_reserve_history (
}
}
if (0 !=
json_array_append_new (json_history,
json_array_append_new (
json_history,
json_pack (
"{s:s, s:s, s:o, s:o, s:o, s:o, s:o, s:o}",
"type", "CLOSING",
"type",
"CLOSING",
"receiver_account_details",
pos->details.closing->
receiver_account_details,
closing->receiver_account_details,
"wtid",
GNUNET_JSON_from_data_auto (
&pos->details.closing->wtid),
GNUNET_JSON_from_data_auto (&closing->wtid),
"exchange_pub",
GNUNET_JSON_from_data_auto (&pub),
"exchange_sig",
GNUNET_JSON_from_data_auto (&sig),
"timestamp",
GNUNET_JSON_from_time_abs (
pos->details.closing->execution_date),
"amount", TALER_JSON_from_amount (
&value),
GNUNET_JSON_from_time_abs (closing->execution_date),
"amount",
TALER_JSON_from_amount (&value),
"closing_fee",
TALER_JSON_from_amount (
&pos->details.closing->closing_fee))))
TALER_JSON_from_amount (&closing->closing_fee))))
{
GNUNET_break (0);
json_decref (json_history);