LCOV - code coverage report
Current view: top level - exchange - taler-exchange-httpd_reserve_withdraw.c (source / functions) Hit Total Coverage
Test: rcoverage.info Lines: 0 136 0.0 %
Date: 2019-12-06 06:02:21 Functions: 0 4 0.0 %

          Line data    Source code
       1             : /*
       2             :   This file is part of TALER
       3             :   Copyright (C) 2014-2019 Taler Systems SA
       4             : 
       5             :   TALER is free software; you can redistribute it and/or modify
       6             :   it under the terms of the GNU Affero General Public License as
       7             :   published by the Free Software Foundation; either version 3,
       8             :   or (at your option) any later version.
       9             : 
      10             :   TALER is distributed in the hope that it will be useful,
      11             :   but WITHOUT ANY WARRANTY; without even the implied warranty
      12             :   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
      13             :   See the GNU Affero General Public License for more details.
      14             : 
      15             :   You should have received a copy of the GNU Affero General
      16             :   Public License along with TALER; see the file COPYING.  If not,
      17             :   see <http://www.gnu.org/licenses/>
      18             : */
      19             : /**
      20             :  * @file taler-exchange-httpd_reserve_withdraw.c
      21             :  * @brief Handle /reserve/withdraw requests
      22             :  * @author Florian Dold
      23             :  * @author Benedikt Mueller
      24             :  * @author Christian Grothoff
      25             :  */
      26             : #include "platform.h"
      27             : #include <gnunet/gnunet_util_lib.h>
      28             : #include <jansson.h>
      29             : #include "taler_json_lib.h"
      30             : #include "taler_mhd_lib.h"
      31             : #include "taler-exchange-httpd_reserve_withdraw.h"
      32             : #include "taler-exchange-httpd_responses.h"
      33             : #include "taler-exchange-httpd_keystate.h"
      34             : 
      35             : 
      36             : /**
      37             :  * Perform RSA signature before checking with the database?
      38             :  * Reduces time spent in transaction, but may cause us to
      39             :  * waste CPU time if DB check fails.
      40             :  */
      41             : #define OPTIMISTIC_SIGN 1
      42             : 
      43             : 
      44             : /**
      45             :  * Send reserve status information to client with the
      46             :  * message that we have insufficient funds for the
      47             :  * requested /reserve/withdraw operation.
      48             :  *
      49             :  * @param connection connection to the client
      50             :  * @param rh reserve history to return
      51             :  * @return MHD result code
      52             :  */
      53             : static int
      54           0 : reply_reserve_withdraw_insufficient_funds (struct MHD_Connection *connection,
      55             :                                            const struct
      56             :                                            TALER_EXCHANGEDB_ReserveHistory *rh)
      57             : {
      58             :   json_t *json_balance;
      59             :   json_t *json_history;
      60             :   struct TALER_Amount balance;
      61             : 
      62           0 :   json_history = TEH_RESPONSE_compile_reserve_history (rh,
      63             :                                                        &balance);
      64           0 :   if ((NULL == json_history)
      65             :       /* Address the case where the ptr is not null, but
      66             :        * it fails "internally" to dump as string (= corrupted).  */
      67           0 :       || (0 == json_dumpb (json_history, NULL, 0, 0)))
      68           0 :     return TALER_MHD_reply_with_error (connection,
      69             :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
      70             :                                        TALER_EC_WITHDRAW_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS,
      71             :                                        "balance calculation failure");
      72           0 :   json_balance = TALER_JSON_from_amount (&balance);
      73             : 
      74           0 :   return TALER_MHD_reply_json_pack (connection,
      75             :                                     MHD_HTTP_CONFLICT,
      76             :                                     "{s:s, s:I, s:o, s:o}",
      77             :                                     "error", "Insufficient funds",
      78             :                                     "code",
      79             :                                     (json_int_t)
      80             :                                     TALER_EC_WITHDRAW_INSUFFICIENT_FUNDS,
      81             :                                     "balance", json_balance,
      82             :                                     "history", json_history);
      83             : }
      84             : 
      85             : 
      86             : /**
      87             :  * Send blinded coin information to client.
      88             :  *
      89             :  * @param connection connection to the client
      90             :  * @param collectable blinded coin to return
      91             :  * @return MHD result code
      92             :  */
      93             : static int
      94           0 : reply_reserve_withdraw_success (struct MHD_Connection *connection,
      95             :                                 const struct
      96             :                                 TALER_EXCHANGEDB_CollectableBlindcoin *
      97             :                                 collectable)
      98             : {
      99             :   json_t *sig_json;
     100             : 
     101           0 :   sig_json = GNUNET_JSON_from_rsa_signature (collectable->sig.rsa_signature);
     102           0 :   return TALER_MHD_reply_json_pack (connection,
     103             :                                     MHD_HTTP_OK,
     104             :                                     "{s:o}",
     105             :                                     "ev_sig", sig_json);
     106             : }
     107             : 
     108             : 
     109             : /**
     110             :  * Context for #withdraw_transaction.
     111             :  */
     112             : struct WithdrawContext
     113             : {
     114             :   /**
     115             :    * Details about the withdrawal request.
     116             :    */
     117             :   struct TALER_WithdrawRequestPS wsrd;
     118             : 
     119             :   /**
     120             :    * Value of the coin plus withdraw fee.
     121             :    */
     122             :   struct TALER_Amount amount_required;
     123             : 
     124             :   /**
     125             :    * Hash of the denomination public key.
     126             :    */
     127             :   struct GNUNET_HashCode denom_pub_hash;
     128             : 
     129             :   /**
     130             :    * Signature over the request.
     131             :    */
     132             :   struct TALER_ReserveSignatureP signature;
     133             : 
     134             :   /**
     135             :    * Blinded planchet.
     136             :    */
     137             :   char *blinded_msg;
     138             : 
     139             :   /**
     140             :    * Key state to use to inspect previous withdrawal values.
     141             :    */
     142             :   struct TEH_KS_StateHandle *key_state;
     143             : 
     144             :   /**
     145             :    * Number of bytes in @e blinded_msg.
     146             :    */
     147             :   size_t blinded_msg_len;
     148             : 
     149             :   /**
     150             :    * Details about denomination we are about to withdraw.
     151             :    */
     152             :   struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki;
     153             : 
     154             :   /**
     155             :    * Set to the resulting signed coin data to be returned to the client.
     156             :    */
     157             :   struct TALER_EXCHANGEDB_CollectableBlindcoin collectable;
     158             : 
     159             : };
     160             : 
     161             : 
     162             : /**
     163             :  * Function implementing /reserve/withdraw transaction.  Runs the
     164             :  * transaction logic; IF it returns a non-error code, the transaction
     165             :  * logic MUST NOT queue a MHD response.  IF it returns an hard error,
     166             :  * the transaction logic MUST queue a MHD response and set @a mhd_ret.
     167             :  * IF it returns the soft error code, the function MAY be called again
     168             :  * to retry and MUST not queue a MHD response.
     169             :  *
     170             :  * Note that "wc->collectable.sig" may already be set before entering
     171             :  * this function, either because OPTIMISTIC_SIGN was used and we signed
     172             :  * before entering the transaction, or because this function is run
     173             :  * twice (!) by #TEH_DB_run_transaction() and the first time created
     174             :  * the signature and then failed to commit.  Furthermore, we may get
     175             :  * a 2nd correct signature briefly if "get_withdraw_info" suceeds and
     176             :  * finds one in the DB.  To avoid signing twice, the function may
     177             :  * return a valid signature in "wc->collectable.sig" even if it failed.
     178             :  * The caller must thus free the signature in either case.
     179             :  *
     180             :  * @param cls a `struct WithdrawContext *`
     181             :  * @param connection MHD request which triggered the transaction
     182             :  * @param session database session to use
     183             :  * @param[out] mhd_ret set to MHD response status for @a connection,
     184             :  *             if transaction failed (!)
     185             :  * @return transaction status
     186             :  */
     187             : static enum GNUNET_DB_QueryStatus
     188           0 : withdraw_transaction (void *cls,
     189             :                       struct MHD_Connection *connection,
     190             :                       struct TALER_EXCHANGEDB_Session *session,
     191             :                       int *mhd_ret)
     192             : {
     193           0 :   struct WithdrawContext *wc = cls;
     194             :   struct TALER_EXCHANGEDB_Reserve r;
     195             :   enum GNUNET_DB_QueryStatus qs;
     196             :   struct TALER_Amount fee_withdraw;
     197             :   struct TALER_DenominationSignature denom_sig;
     198             : 
     199             : #if OPTIMISTIC_SIGN
     200             :   /* store away optimistic signature to protect
     201             :      it from being overwritten by get_withdraw_info */
     202           0 :   denom_sig = wc->collectable.sig;
     203           0 :   wc->collectable.sig.rsa_signature = NULL;
     204             : #endif
     205           0 :   qs = TEH_plugin->get_withdraw_info (TEH_plugin->cls,
     206             :                                       session,
     207           0 :                                       &wc->wsrd.h_coin_envelope,
     208             :                                       &wc->collectable);
     209           0 :   if (0 > qs)
     210             :   {
     211           0 :     GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
     212           0 :     if (GNUNET_DB_STATUS_HARD_ERROR == qs)
     213           0 :       *mhd_ret = TALER_MHD_reply_with_error (connection,
     214             :                                              MHD_HTTP_INTERNAL_SERVER_ERROR,
     215             :                                              TALER_EC_WITHDRAW_DB_FETCH_ERROR,
     216             :                                              "failed to fetch withdraw data");
     217           0 :     wc->collectable.sig = denom_sig;
     218           0 :     return qs;
     219             :   }
     220             : 
     221             :   /* Don't sign again if we have already signed the coin */
     222           0 :   if (1 == qs)
     223             :   {
     224             : #if OPTIMISTIC_SIGN
     225           0 :     GNUNET_CRYPTO_rsa_signature_free (denom_sig.rsa_signature);
     226             : #endif
     227           0 :     return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
     228             :   }
     229           0 :   GNUNET_assert (0 == qs);
     230           0 :   wc->collectable.sig = denom_sig;
     231             : 
     232             :   /* Check if balance is sufficient */
     233           0 :   r.pub = wc->wsrd.reserve_pub;
     234             : 
     235             :   /**
     236             :    * Debug block.
     237             :    */
     238             :   {
     239             : #define PUBSIZE 80
     240             :     char pub_s[PUBSIZE];
     241             : 
     242           0 :     GNUNET_break
     243             :       (NULL != GNUNET_STRINGS_data_to_string (&r.pub,
     244             :                                               sizeof (r.pub),
     245             :                                               &pub_s[0],
     246             :                                               PUBSIZE));
     247           0 :     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
     248             :                 "Trying to withdraw from reserve: %s\n",
     249             :                 pub_s);
     250             :   }
     251             : 
     252           0 :   qs = TEH_plugin->reserve_get (TEH_plugin->cls,
     253             :                                 session,
     254             :                                 &r);
     255           0 :   if (0 > qs)
     256             :   {
     257           0 :     if (GNUNET_DB_STATUS_HARD_ERROR == qs)
     258           0 :       *mhd_ret = TALER_MHD_reply_with_error (connection,
     259             :                                              MHD_HTTP_INTERNAL_SERVER_ERROR,
     260             :                                              TALER_EC_WITHDRAW_DB_FETCH_ERROR,
     261             :                                              "failed to fetch reserve data");
     262           0 :     return qs;
     263             :   }
     264           0 :   if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
     265             :   {
     266           0 :     *mhd_ret = TALER_MHD_reply_with_error (connection,
     267             :                                            MHD_HTTP_NOT_FOUND,
     268             :                                            TALER_EC_WITHDRAW_RESERVE_UNKNOWN,
     269             :                                            "reserve_pub");
     270           0 :     return GNUNET_DB_STATUS_HARD_ERROR;
     271             :   }
     272           0 :   if (0 < TALER_amount_cmp (&wc->amount_required,
     273             :                             &r.balance))
     274             :   {
     275             :     char *amount_required;
     276             :     char *r_balance;
     277             :     struct TALER_EXCHANGEDB_ReserveHistory *rh;
     278             :     /* The reserve does not have the required amount (actual
     279             :      * amount + withdraw fee) */
     280           0 :     GNUNET_break_op (0);
     281           0 :     amount_required = TALER_amount_to_string (&wc->amount_required);
     282           0 :     r_balance = TALER_amount_to_string (&r.balance);
     283           0 :     TALER_LOG_WARNING ("Asked %s over a reserve worth %s\n",
     284             :                        amount_required,
     285             :                        r_balance);
     286           0 :     GNUNET_free (amount_required);
     287           0 :     GNUNET_free (r_balance);
     288           0 :     qs = TEH_plugin->get_reserve_history (TEH_plugin->cls,
     289             :                                           session,
     290           0 :                                           &wc->wsrd.reserve_pub,
     291             :                                           &rh);
     292           0 :     if (NULL == rh)
     293             :     {
     294           0 :       if (GNUNET_DB_STATUS_HARD_ERROR == qs)
     295           0 :         *mhd_ret = TALER_MHD_reply_with_error (connection,
     296             :                                                MHD_HTTP_INTERNAL_SERVER_ERROR,
     297             :                                                TALER_EC_WITHDRAW_DB_FETCH_ERROR,
     298             :                                                "failed to fetch reserve history");
     299           0 :       return GNUNET_DB_STATUS_HARD_ERROR;
     300             :     }
     301           0 :     *mhd_ret = reply_reserve_withdraw_insufficient_funds (connection,
     302             :                                                           rh);
     303           0 :     TEH_plugin->free_reserve_history (TEH_plugin->cls,
     304             :                                       rh);
     305           0 :     return GNUNET_DB_STATUS_HARD_ERROR;
     306             :   }
     307             : 
     308             :   /* Balance is good, sign the coin! */
     309             : #if ! OPTIMISTIC_SIGN
     310             :   if (NULL == wc->collectable.sig.rsa_signature)
     311             :   {
     312             :     wc->collectable.sig.rsa_signature
     313             :       = GNUNET_CRYPTO_rsa_sign_blinded (wc->dki->denom_priv.rsa_private_key,
     314             :                                         wc->blinded_msg,
     315             :                                         wc->blinded_msg_len);
     316             :     if (NULL == wc->collectable.sig.rsa_signature)
     317             :     {
     318             :       GNUNET_break (0);
     319             :       *mhd_ret = TALER_MHD_reply_with_error (connection,
     320             :                                              MHD_HTTP_INTERNAL_SERVER_ERROR,
     321             :                                              TALER_EC_WITHDRAW_SIGNATURE_FAILED,
     322             :                                              "Failed to create signature");
     323             :       return GNUNET_DB_STATUS_HARD_ERROR;
     324             :     }
     325             :   }
     326             : #endif
     327           0 :   TALER_amount_ntoh (&fee_withdraw,
     328           0 :                      &wc->dki->issue.properties.fee_withdraw);
     329           0 :   wc->collectable.denom_pub_hash = wc->denom_pub_hash;
     330           0 :   wc->collectable.amount_with_fee = wc->amount_required;
     331           0 :   wc->collectable.withdraw_fee = fee_withdraw;
     332           0 :   wc->collectable.reserve_pub = wc->wsrd.reserve_pub;
     333           0 :   wc->collectable.h_coin_envelope = wc->wsrd.h_coin_envelope;
     334           0 :   wc->collectable.reserve_sig = wc->signature;
     335           0 :   qs = TEH_plugin->insert_withdraw_info (TEH_plugin->cls,
     336             :                                          session,
     337           0 :                                          &wc->collectable);
     338           0 :   if (0 > qs)
     339             :   {
     340           0 :     GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
     341           0 :     if (GNUNET_DB_STATUS_HARD_ERROR == qs)
     342           0 :       *mhd_ret = TALER_MHD_reply_with_error (connection,
     343             :                                              MHD_HTTP_INTERNAL_SERVER_ERROR,
     344             :                                              TALER_EC_WITHDRAW_DB_STORE_ERROR,
     345             :                                              "failed to persist withdraw data");
     346           0 :     return qs;
     347             :   }
     348           0 :   return qs;
     349             : }
     350             : 
     351             : 
     352             : /**
     353             :  * Handle a "/reserve/withdraw" request.  Parses the "reserve_pub"
     354             :  * EdDSA key of the reserve and the requested "denom_pub" which
     355             :  * specifies the key/value of the coin to be withdrawn, and checks
     356             :  * that the signature "reserve_sig" makes this a valid withdrawal
     357             :  * request from the specified reserve.  If so, the envelope
     358             :  * with the blinded coin "coin_ev" is passed down to execute the
     359             :  * withdrawl operation.
     360             :  *
     361             :  * @param rh context of the handler
     362             :  * @param connection the MHD connection to handle
     363             :  * @param[in,out] connection_cls the connection's closure (can be updated)
     364             :  * @param upload_data upload data
     365             :  * @param[in,out] upload_data_size number of bytes (left) in @a upload_data
     366             :  * @return MHD result code
     367             :  */
     368             : int
     369           0 : TEH_RESERVE_handler_reserve_withdraw (struct TEH_RequestHandler *rh,
     370             :                                       struct MHD_Connection *connection,
     371             :                                       void **connection_cls,
     372             :                                       const char *upload_data,
     373             :                                       size_t *upload_data_size)
     374             : {
     375             :   struct WithdrawContext wc;
     376             :   json_t *root;
     377             :   int res;
     378             :   int mhd_ret;
     379             :   unsigned int hc;
     380             :   enum TALER_ErrorCode ec;
     381             :   struct TALER_Amount amount;
     382             :   struct TALER_Amount fee_withdraw;
     383             :   struct GNUNET_JSON_Specification spec[] = {
     384           0 :     GNUNET_JSON_spec_varsize ("coin_ev",
     385             :                               (void **) &wc.blinded_msg,
     386             :                               &wc.blinded_msg_len),
     387           0 :     GNUNET_JSON_spec_fixed_auto ("reserve_pub",
     388             :                                  &wc.wsrd.reserve_pub),
     389           0 :     GNUNET_JSON_spec_fixed_auto ("reserve_sig",
     390             :                                  &wc.signature),
     391           0 :     GNUNET_JSON_spec_fixed_auto ("denom_pub_hash",
     392             :                                  &wc.denom_pub_hash),
     393           0 :     GNUNET_JSON_spec_end ()
     394             :   };
     395             : 
     396             :   (void) rh;
     397           0 :   res = TALER_MHD_parse_post_json (connection,
     398             :                                    connection_cls,
     399             :                                    upload_data,
     400             :                                    upload_data_size,
     401             :                                    &root);
     402           0 :   if (GNUNET_SYSERR == res)
     403           0 :     return MHD_NO;
     404           0 :   if ( (GNUNET_NO == res) || (NULL == root) )
     405           0 :     return MHD_YES;
     406           0 :   res = TALER_MHD_parse_json_data (connection,
     407             :                                    root,
     408             :                                    spec);
     409           0 :   json_decref (root);
     410           0 :   if (GNUNET_OK != res)
     411           0 :     return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
     412           0 :   wc.key_state = TEH_KS_acquire (GNUNET_TIME_absolute_get ());
     413           0 :   if (NULL == wc.key_state)
     414             :   {
     415           0 :     TALER_LOG_ERROR ("Lacking keys to operate\n");
     416           0 :     GNUNET_JSON_parse_free (spec);
     417           0 :     return TALER_MHD_reply_with_error (connection,
     418             :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
     419             :                                        TALER_EC_EXCHANGE_BAD_CONFIGURATION,
     420             :                                        "no keys");
     421             :   }
     422           0 :   wc.dki = TEH_KS_denomination_key_lookup_by_hash (wc.key_state,
     423             :                                                    &wc.denom_pub_hash,
     424             :                                                    TEH_KS_DKU_WITHDRAW,
     425             :                                                    &ec,
     426             :                                                    &hc);
     427           0 :   if (NULL == wc.dki)
     428             :   {
     429           0 :     GNUNET_JSON_parse_free (spec);
     430           0 :     TEH_KS_release (wc.key_state);
     431           0 :     return TALER_MHD_reply_with_error (connection,
     432             :                                        hc,
     433             :                                        ec,
     434             :                                        "could not find denomination key");
     435             :   }
     436           0 :   GNUNET_assert (NULL != wc.dki->denom_priv.rsa_private_key);
     437           0 :   TALER_amount_ntoh (&amount,
     438           0 :                      &wc.dki->issue.properties.value);
     439           0 :   TALER_amount_ntoh (&fee_withdraw,
     440           0 :                      &wc.dki->issue.properties.fee_withdraw);
     441           0 :   if (GNUNET_OK !=
     442           0 :       TALER_amount_add (&wc.amount_required,
     443             :                         &amount,
     444             :                         &fee_withdraw))
     445             :   {
     446           0 :     GNUNET_JSON_parse_free (spec);
     447           0 :     TEH_KS_release (wc.key_state);
     448           0 :     return TALER_MHD_reply_with_error (connection,
     449             :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
     450             :                                        TALER_EC_WITHDRAW_AMOUNT_FEE_OVERFLOW,
     451             :                                        "amount overflow for value plus withdraw fee");
     452             :   }
     453           0 :   TALER_amount_hton (&wc.wsrd.amount_with_fee,
     454             :                      &wc.amount_required);
     455           0 :   TALER_amount_hton (&wc.wsrd.withdraw_fee,
     456             :                      &fee_withdraw);
     457             :   /* verify signature! */
     458             :   wc.wsrd.purpose.size
     459           0 :     = htonl (sizeof (struct TALER_WithdrawRequestPS));
     460             :   wc.wsrd.purpose.purpose
     461           0 :     = htonl (TALER_SIGNATURE_WALLET_RESERVE_WITHDRAW);
     462             :   wc.wsrd.h_denomination_pub
     463           0 :     = wc.denom_pub_hash;
     464           0 :   GNUNET_CRYPTO_hash (wc.blinded_msg,
     465             :                       wc.blinded_msg_len,
     466             :                       &wc.wsrd.h_coin_envelope);
     467           0 :   if (GNUNET_OK !=
     468           0 :       GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_RESERVE_WITHDRAW,
     469             :                                   &wc.wsrd.purpose,
     470             :                                   &wc.signature.eddsa_signature,
     471             :                                   &wc.wsrd.reserve_pub.eddsa_pub))
     472             :   {
     473           0 :     TALER_LOG_WARNING (
     474             :       "Client supplied invalid signature for /reserve/withdraw request\n");
     475           0 :     GNUNET_JSON_parse_free (spec);
     476           0 :     TEH_KS_release (wc.key_state);
     477           0 :     return TALER_MHD_reply_with_error (connection,
     478             :                                        MHD_HTTP_FORBIDDEN,
     479             :                                        TALER_EC_WITHDRAW_RESERVE_SIGNATURE_INVALID,
     480             :                                        "reserve_sig");
     481             :   }
     482             : 
     483             : #if OPTIMISTIC_SIGN
     484             :   /* Sign before transaction! */
     485             :   wc.collectable.sig.rsa_signature
     486           0 :     = GNUNET_CRYPTO_rsa_sign_blinded (wc.dki->denom_priv.rsa_private_key,
     487           0 :                                       wc.blinded_msg,
     488             :                                       wc.blinded_msg_len);
     489           0 :   if (NULL == wc.collectable.sig.rsa_signature)
     490             :   {
     491           0 :     GNUNET_break (0);
     492           0 :     GNUNET_JSON_parse_free (spec);
     493           0 :     TEH_KS_release (wc.key_state);
     494           0 :     return TALER_MHD_reply_with_error (connection,
     495             :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
     496             :                                        TALER_EC_WITHDRAW_SIGNATURE_FAILED,
     497             :                                        "Failed to sign");
     498             :   }
     499             : #endif
     500             : 
     501           0 :   if (GNUNET_OK !=
     502           0 :       TEH_DB_run_transaction (connection,
     503             :                               "run reserve withdraw",
     504             :                               &mhd_ret,
     505             :                               &withdraw_transaction,
     506             :                               &wc))
     507             :   {
     508           0 :     TEH_KS_release (wc.key_state);
     509             :     /* Even if #withdraw_transaction() failed, it may have created a signature
     510             :        (or we might have done it optimistically above). */
     511           0 :     if (NULL != wc.collectable.sig.rsa_signature)
     512           0 :       GNUNET_CRYPTO_rsa_signature_free (wc.collectable.sig.rsa_signature);
     513           0 :     GNUNET_JSON_parse_free (spec);
     514           0 :     return mhd_ret;
     515             :   }
     516           0 :   TEH_KS_release (wc.key_state);
     517           0 :   GNUNET_JSON_parse_free (spec);
     518             : 
     519           0 :   mhd_ret = reply_reserve_withdraw_success (connection,
     520             :                                             &wc.collectable);
     521           0 :   GNUNET_CRYPTO_rsa_signature_free (wc.collectable.sig.rsa_signature);
     522           0 :   return mhd_ret;
     523             : }
     524             : 
     525             : 
     526             : /* end of taler-exchange-httpd_reserve_withdraw.c */

Generated by: LCOV version 1.14