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