[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] branch master updated: handle case where purse expirati
From: |
gnunet |
Subject: |
[taler-exchange] branch master updated: handle case where purse expiration refunded the coin's deposited amount |
Date: |
Sat, 04 Jun 2022 14:04:31 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository exchange.
The following commit(s) were added to refs/heads/master by this push:
new d04769b7 handle case where purse expiration refunded the coin's
deposited amount
d04769b7 is described below
commit d04769b729a6a7153c76d56ab3764efe2ca28667
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Jun 4 14:04:27 2022 +0200
handle case where purse expiration refunded the coin's deposited amount
---
src/exchange/taler-exchange-httpd_responses.c | 52 ++-------------------------
src/exchangedb/plugin_exchangedb_postgres.c | 5 +++
src/include/taler_exchangedb_plugin.h | 5 +++
src/lib/exchange_api_common.c | 20 +++++++++++
4 files changed, 32 insertions(+), 50 deletions(-)
diff --git a/src/exchange/taler-exchange-httpd_responses.c
b/src/exchange/taler-exchange-httpd_responses.c
index 450a9bab..11cc0b93 100644
--- a/src/exchange/taler-exchange-httpd_responses.c
+++ b/src/exchange/taler-exchange-httpd_responses.c
@@ -411,6 +411,8 @@ TEH_RESPONSE_compile_transaction_history (
: pd->exchange_base_url),
GNUNET_JSON_pack_data_auto ("purse_pub",
&pd->purse_pub),
+ GNUNET_JSON_pack_bool ("refunded",
+ pd->refunded),
GNUNET_JSON_pack_data_auto ("coin_sig",
&pd->coin_sig))))
{
@@ -420,56 +422,6 @@ TEH_RESPONSE_compile_transaction_history (
}
break;
}
-
-#if FIXME_PURSE_REFUND
- case TALER_EXCHANGEDB_TT_PURSE_REFUND:
- {
- struct TALER_EXCHANGEDB_PurseRefundListEntry *pr
- = pos->details.purse_refund;
- struct TALER_ExchangePublicKeyP epub;
- struct TALER_ExchangeSignatureP esig;
-
- if (TALER_EC_NONE !=
- TALER_exchange_online_purse_refund_sign (
- &TEH_keys_exchange_sign_,
- &pr->amount,
- &pr->refund_fee,
- &pr->purse_share_fee,
- &pr->purse_pub,
- coin_pub,
- &epub,
- &esig))
- {
- GNUNET_break (0);
- json_decref (history);
- return NULL;
- }
- if (0 !=
- json_array_append_new (
- history,
- GNUNET_JSON_PACK (
- GNUNET_JSON_pack_string ("type",
- "PURSE-REFUND"),
- TALER_JSON_pack_amount ("amount",
- &pd->amount),
- TALER_JSON_pack_amount ("refund_fee",
- &pd->refund_fee),
- TALER_JSON_pack_amount ("purse_share_fee",
- &pd->purse_share_fee),
- GNUNET_JSON_pack_data_auto ("purse_pub",
- &pd->purse_pub),
- GNUNET_JSON_pack_data_auto ("exchange_sig",
- &esig),
- GNUNET_JSON_pack_data_auto ("exchange_pub",
- &epub))))
- {
- GNUNET_break (0);
- json_decref (history);
- return NULL;
- }
- break;
- }
-#endif
}
}
return history;
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c
b/src/exchangedb/plugin_exchangedb_postgres.c
index 83f99f46..2d99311a 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -1269,9 +1269,12 @@ prepare_statements (struct PostgresClosure *pg)
",purse_pub"
",coin_sig"
",purse_deposit_serial_id"
+ ",pr.refunded"
" FROM purse_deposits pd"
" LEFT JOIN partners"
" USING (partner_serial_id)"
+ " JOIN purse_requests pr"
+ " USING (purse_pub)"
" JOIN known_coins kc"
" ON (pd.coin_pub = kc.coin_pub)"
" JOIN denominations denoms"
@@ -8314,6 +8317,8 @@ add_coin_purse_deposit (void *cls,
NULL),
GNUNET_PQ_result_spec_auto_from_type ("coin_sig",
&deposit->coin_sig),
+ GNUNET_PQ_result_spec_bool ("refunded",
+ &deposit->refunded),
GNUNET_PQ_result_spec_end
};
diff --git a/src/include/taler_exchangedb_plugin.h
b/src/include/taler_exchangedb_plugin.h
index 0bc53e1e..707ce311 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -1679,6 +1679,11 @@ struct TALER_EXCHANGEDB_PurseDepositListEntry
*/
struct TALER_CoinSpendSignatureP coin_sig;
+ /**
+ * Set to true if the coin was refunded.
+ */
+ bool refunded;
+
};
/**
diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c
index 78dea63e..d6032783 100644
--- a/src/lib/exchange_api_common.c
+++ b/src/lib/exchange_api_common.c
@@ -1185,6 +1185,7 @@ help_purse_deposit (struct CoinHistoryParseContext *pc,
struct TALER_PurseContractPublicKeyP purse_pub;
struct TALER_CoinSpendSignatureP coin_sig;
const char *exchange_base_url;
+ bool refunded;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("purse_pub",
&purse_pub),
@@ -1192,6 +1193,8 @@ help_purse_deposit (struct CoinHistoryParseContext *pc,
&coin_sig),
GNUNET_JSON_spec_string ("exchange_base_url",
&exchange_base_url),
+ GNUNET_JSON_spec_bool ("refunded",
+ &refunded),
GNUNET_JSON_spec_end ()
};
@@ -1214,6 +1217,23 @@ help_purse_deposit (struct CoinHistoryParseContext *pc,
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
+ if (refunded)
+ {
+ /* We add the amount to refunds here, the original
+ deposit will be added to the balance later because
+ we still return GNUNET_YES, thus effectively
+ cancelling out this operation with respect to
+ the final balance. */
+ if (0 >
+ TALER_amount_add (&pc->rtotal,
+ &pc->rtotal,
+ amount))
+ {
+ /* overflow in refund history? inconceivable! Bad exchange! */
+ GNUNET_break_op (0);
+ return GNUNET_SYSERR;
+ }
+ }
return GNUNET_YES;
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-exchange] branch master updated: handle case where purse expiration refunded the coin's deposited amount,
gnunet <=