do return fees in history

This commit is contained in:
Christian Grothoff 2020-03-28 20:46:57 +01:00
parent 82b18857e2
commit ae9f751a7c
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
2 changed files with 26 additions and 8 deletions

View File

@ -946,7 +946,7 @@ enum TALER_EXCHANGE_ReserveTransactionType
/** /**
* Deposit into the reserve. * Deposit into the reserve.
*/ */
TALER_EXCHANGE_RTT_DEPOSIT, TALER_EXCHANGE_RTT_CREDIT,
/** /**
* Withdrawal from the reserve. * Withdrawal from the reserve.
@ -990,7 +990,7 @@ struct TALER_EXCHANGE_ReserveHistory
/** /**
* Information about a deposit that filled this reserve. * Information about a deposit that filled this reserve.
* @e type is #TALER_EXCHANGE_RTT_DEPOSIT. * @e type is #TALER_EXCHANGE_RTT_CREDIT.
*/ */
struct struct
{ {
@ -1017,11 +1017,22 @@ struct TALER_EXCHANGE_ReserveHistory
} in_details; } in_details;
/** /**
* Signature authorizing the withdrawal for outgoing transaction. * Information about withdraw operation.
* @e type is #TALER_EXCHANGE_RTT_WITHDRAWAL. * @e type is #TALER_EXCHANGE_RTT_WITHDRAWAL.
*/ */
struct
{
/**
* Signature authorizing the withdrawal for outgoing transaction.
*/
json_t *out_authorization_sig; json_t *out_authorization_sig;
/**
* Fee that was charged for the withdrawal.
*/
struct TALER_Amount fee;
} withdraw;
/** /**
* Information provided if the reserve was filled via /recoup. * Information provided if the reserve was filled via /recoup.
* @e type is #TALER_EXCHANGE_RTT_RECOUP. * @e type is #TALER_EXCHANGE_RTT_RECOUP.
@ -1084,6 +1095,11 @@ struct TALER_EXCHANGE_ReserveHistory
*/ */
struct GNUNET_TIME_Absolute timestamp; struct GNUNET_TIME_Absolute timestamp;
/**
* Fee that was charged for the closing.
*/
struct TALER_Amount fee;
} close_details; } close_details;
} details; } details;

View File

@ -109,7 +109,7 @@ TALER_EXCHANGE_parse_reserve_history (
GNUNET_JSON_spec_end () GNUNET_JSON_spec_end ()
}; };
rhistory[off].type = TALER_EXCHANGE_RTT_DEPOSIT; rhistory[off].type = TALER_EXCHANGE_RTT_CREDIT;
if (GNUNET_OK != if (GNUNET_OK !=
TALER_amount_add (&total_in, TALER_amount_add (&total_in,
&total_in, &total_in,
@ -201,8 +201,9 @@ TALER_EXCHANGE_parse_reserve_history (
GNUNET_JSON_parse_free (withdraw_spec); GNUNET_JSON_parse_free (withdraw_spec);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
rhistory[off].details.withdraw.fee = fee;
} }
rhistory[off].details.out_authorization_sig rhistory[off].details.withdraw.out_authorization_sig
= json_object_get (transaction, = json_object_get (transaction,
"signature"); "signature");
/* Check check that the same withdraw transaction /* Check check that the same withdraw transaction
@ -355,7 +356,8 @@ TALER_EXCHANGE_parse_reserve_history (
rcc.reserve_pub = *reserve_pub; rcc.reserve_pub = *reserve_pub;
timestamp = GNUNET_TIME_absolute_ntoh (rcc.timestamp); timestamp = GNUNET_TIME_absolute_ntoh (rcc.timestamp);
rhistory[off].details.close_details.timestamp = timestamp; rhistory[off].details.close_details.timestamp = timestamp;
TALER_amount_ntoh (&rhistory[off].details.close_details.fee,
&rcc.closing_fee);
key_state = TALER_EXCHANGE_get_keys (exchange); key_state = TALER_EXCHANGE_get_keys (exchange);
if (GNUNET_OK != if (GNUNET_OK !=
TALER_EXCHANGE_test_signing_key (key_state, TALER_EXCHANGE_test_signing_key (key_state,
@ -424,7 +426,7 @@ TALER_EXCHANGE_free_reserve_history (
{ {
switch (rhistory[i].type) switch (rhistory[i].type)
{ {
case TALER_EXCHANGE_RTT_DEPOSIT: case TALER_EXCHANGE_RTT_CREDIT:
GNUNET_free_non_null (rhistory[i].details.in_details.wire_reference); GNUNET_free_non_null (rhistory[i].details.in_details.wire_reference);
GNUNET_free_non_null (rhistory[i].details.in_details.sender_url); GNUNET_free_non_null (rhistory[i].details.in_details.sender_url);
break; break;