aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-09-01 23:59:16 +0200
committerChristian Grothoff <christian@grothoff.org>2020-09-01 23:59:16 +0200
commitee4f1c1002f84118b7f0de592e505d3915437ad5 (patch)
treeeee0aae650e90739fc9d102b4d3e62d15325c76d /src
parentd453c47a74e521b2887e214a7c35c96c3663d0bf (diff)
fix #6553: compute residual coin value correctly in melt conflict response
Diffstat (limited to 'src')
-rw-r--r--src/exchange/taler-exchange-httpd_melt.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/exchange/taler-exchange-httpd_melt.c b/src/exchange/taler-exchange-httpd_melt.c
index f276a72b5..872389543 100644
--- a/src/exchange/taler-exchange-httpd_melt.c
+++ b/src/exchange/taler-exchange-httpd_melt.c
@@ -254,11 +254,20 @@ refresh_check_melt (struct MHD_Connection *connection,
&spent))
{
struct TALER_Amount coin_residual;
+ struct TALER_Amount spent_already;
+ /* First subtract the melt cost from 'spent' to
+ compute the total amount already spent of the coin */
GNUNET_assert (0 <=
- TALER_amount_subtract (&coin_residual,
+ TALER_amount_subtract (&spent_already,
&spent,
&rmc->refresh_session.amount_with_fee));
+ /* The residual coin value is the original coin value minus
+ what we have spent (before the melt) */
+ GNUNET_assert (0 <=
+ TALER_amount_subtract (&coin_residual,
+ &rmc->coin_value,
+ &spent_already));
*mhd_ret = reply_melt_insufficient_funds (
connection,
&rmc->refresh_session.coin.coin_pub,