From 5f333f817c0fe4d66d1223833f8b8f7f22ad174c Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 14 Oct 2022 00:29:32 +0200 Subject: [PATCH] add reserve-open-deposit transactions to coin histories --- src/auditor/taler-auditor-sync.c | 1 - src/exchange/taler-exchange-httpd_responses.c | 25 +++++++++++++++++++ src/exchangedb/exchangedb_transactions.c | 11 ++++++++ src/exchangedb/plugin_exchangedb_common.c | 8 ++++++ 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/auditor/taler-auditor-sync.c b/src/auditor/taler-auditor-sync.c index 9666ec33a..16ace8fa5 100644 --- a/src/auditor/taler-auditor-sync.c +++ b/src/auditor/taler-auditor-sync.c @@ -99,7 +99,6 @@ static struct Table tables[] = { { .rt = TALER_EXCHANGEDB_RT_RESERVES_CLOSE}, { .rt = TALER_EXCHANGEDB_RT_RESERVES_OPEN_REQUESTS}, { .rt = TALER_EXCHANGEDB_RT_RESERVES_OPEN_DEPOSITS}, - { .rt = TALER_EXCHANGEDB_RT_RESERVES_CLOSE_REQUESTS}, { .rt = TALER_EXCHANGEDB_RT_RESERVES_OUT}, { .rt = TALER_EXCHANGEDB_RT_AUDITORS}, { .rt = TALER_EXCHANGEDB_RT_AUDITOR_DENOM_SIGS}, diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c index 516b36460..77f01de60 100644 --- a/src/exchange/taler-exchange-httpd_responses.c +++ b/src/exchange/taler-exchange-httpd_responses.c @@ -424,6 +424,31 @@ TEH_RESPONSE_compile_transaction_history ( } break; } + + case TALER_EXCHANGEDB_TT_RESERVE_OPEN: + { + struct TALER_EXCHANGEDB_ReserveOpenListEntry *role + = pos->details.reserve_open; + + if (0 != + json_array_append_new ( + history, + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("type", + "RESERVE-OPEN-DEPOSIT"), + TALER_JSON_pack_amount ("coin_contribution", + &role->coin_contribution), + GNUNET_JSON_pack_data_auto ("reserve_sig", + &role->reserve_sig), + GNUNET_JSON_pack_data_auto ("coin_sig", + &role->coin_sig)))) + { + GNUNET_break (0); + json_decref (history); + return NULL; + } + break; + } } } return history; diff --git a/src/exchangedb/exchangedb_transactions.c b/src/exchangedb/exchangedb_transactions.c index ef46bace6..60b95d6f6 100644 --- a/src/exchangedb/exchangedb_transactions.c +++ b/src/exchangedb/exchangedb_transactions.c @@ -131,6 +131,17 @@ TALER_EXCHANGEDB_calculate_transaction_list_totals ( } deposit_fee = pos->details.purse_deposit->deposit_fee; break; + case TALER_EXCHANGEDB_TT_RESERVE_OPEN: + /* spent += pos->amount_with_fee */ + if (0 > + TALER_amount_add (&spent, + &spent, + &pos->details.reserve_open->coin_contribution)) + { + GNUNET_break (0); + return GNUNET_SYSERR; + } + break; } } if (have_refund) diff --git a/src/exchangedb/plugin_exchangedb_common.c b/src/exchangedb/plugin_exchangedb_common.c index 10263adff..84198dddf 100644 --- a/src/exchangedb/plugin_exchangedb_common.c +++ b/src/exchangedb/plugin_exchangedb_common.c @@ -152,6 +152,14 @@ TEH_COMMON_free_coin_transaction_list ( GNUNET_free (deposit); break; } + case TALER_EXCHANGEDB_TT_RESERVE_OPEN: + { + struct TALER_EXCHANGEDB_ReserveOpenListEntry *role; + + role = tl->details.reserve_open; + GNUNET_free (role); + break; + } } { struct TALER_EXCHANGEDB_TransactionList *next;