summaryrefslogtreecommitdiff
path: root/src/exchange
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-10-04 19:18:43 +0200
committerChristian Grothoff <christian@grothoff.org>2022-10-04 19:18:43 +0200
commitf7b06e308fdc77d4fe22216834136d18fc341ab3 (patch)
tree770cb9da9e660072e2cade1bd3c1af18136c95ca /src/exchange
parent856b8e26c2b83ebce31eb35c9fc9f23641187be9 (diff)
downloadexchange-f7b06e308fdc77d4fe22216834136d18fc341ab3.tar.gz
exchange-f7b06e308fdc77d4fe22216834136d18fc341ab3.tar.bz2
exchange-f7b06e308fdc77d4fe22216834136d18fc341ab3.zip
-work on reserve_open DB API
Diffstat (limited to 'src/exchange')
-rw-r--r--src/exchange/taler-exchange-httpd_reserves_open.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/exchange/taler-exchange-httpd_reserves_open.c b/src/exchange/taler-exchange-httpd_reserves_open.c
index d446d9b40..d3ff37d67 100644
--- a/src/exchange/taler-exchange-httpd_reserves_open.c
+++ b/src/exchange/taler-exchange-httpd_reserves_open.c
@@ -102,6 +102,12 @@ struct ReserveOpenContext
* Desired minimum purse limit.
*/
uint32_t purse_limit;
+
+ /**
+ * Set to true if the reserve balance is too low
+ * for the operation.
+ */
+ bool no_funds;
};
@@ -223,12 +229,14 @@ reserve_open_transaction (void *cls,
/* inputs */
rsc->reserve_pub,
&rsc->total,
+ &rsc->reserve_payment,
rsc->purse_limit,
&rsc->reserve_sig,
rsc->desired_expiration,
rsc->timestamp,
&rsc->gf->fees.account,
/* outputs */
+ &rsc->no_funds,
&rsc->open_cost,
&rsc->reserve_expiration);
switch (qs)
@@ -253,6 +261,15 @@ reserve_open_transaction (void *cls,
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
break;
}
+ if (rsc->no_funds)
+ {
+ *mhd_ret
+ = TEH_RESPONSE_reply_reserve_insufficient_balance (
+ connection,
+ &rsc->reserve_payment,
+ rsc->reserve_pub);
+ return GNUNET_DB_STATUS_HARD_ERROR;
+ }
return qs;
}
@@ -342,13 +359,10 @@ TEH_handler_reserves_open (struct TEH_RequestContext *rc,
cleanup_rsc (&rsc);
return MHD_YES; /* failure */
}
- /* FIXME-DOLD: Alternatively, we could here add coin->amount_minus_fee and
- thereby charge the deposit fee even when paying the reserve-open fee.
- To be decided... */
if (0 >
TALER_amount_add (&rsc.total,
&rsc.total,
- &coin->amount))
+ &coin->amount_minus_fee))
{
GNUNET_break (0);
cleanup_rsc (&rsc);