LCOV - code coverage report
Current view: top level - exchange - taler-exchange-httpd_deposit.c (source / functions) Hit Total Coverage
Test: rcoverage.info Lines: 105 154 68.2 %
Date: 2017-11-25 11:31:41 Functions: 5 5 100.0 %

          Line data    Source code
       1             : /*
       2             :   This file is part of TALER
       3             :   Copyright (C) 2014-2017 Inria and GNUnet e.V.
       4             : 
       5             :   TALER is free software; you can redistribute it and/or modify it under the
       6             :   terms of the GNU Affero General Public License as published by the Free Software
       7             :   Foundation; either version 3, or (at your option) any later version.
       8             : 
       9             :   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
      10             :   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
      11             :   A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.
      12             : 
      13             :   You should have received a copy of the GNU Affero General Public License along with
      14             :   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
      15             : */
      16             : /**
      17             :  * @file taler-exchange-httpd_deposit.c
      18             :  * @brief Handle /deposit requests; parses the POST and JSON and
      19             :  *        verifies the coin signature before handing things off
      20             :  *        to the database.
      21             :  * @author Florian Dold
      22             :  * @author Benedikt Mueller
      23             :  * @author Christian Grothoff
      24             :  */
      25             : #include "platform.h"
      26             : #include <gnunet/gnunet_util_lib.h>
      27             : #include <gnunet/gnunet_json_lib.h>
      28             : #include <jansson.h>
      29             : #include <microhttpd.h>
      30             : #include <pthread.h>
      31             : #include "taler_json_lib.h"
      32             : #include "taler-exchange-httpd_parsing.h"
      33             : #include "taler-exchange-httpd_deposit.h"
      34             : #include "taler-exchange-httpd_responses.h"
      35             : #include "taler-exchange-httpd_keystate.h"
      36             : #include "taler-exchange-httpd_validation.h"
      37             : 
      38             : 
      39             : /**
      40             :  * Send confirmation of deposit success to client.  This function
      41             :  * will create a signed message affirming the given information
      42             :  * and return it to the client.  By this, the exchange affirms that
      43             :  * the coin had sufficient (residual) value for the specified
      44             :  * transaction and that it will execute the requested deposit
      45             :  * operation with the given wiring details.
      46             :  *
      47             :  * @param connection connection to the client
      48             :  * @param coin_pub public key of the coin
      49             :  * @param h_wire hash of wire details
      50             :  * @param h_contract_terms hash of contract details
      51             :  * @param timestamp client's timestamp
      52             :  * @param refund_deadline until when this deposit be refunded
      53             :  * @param merchant merchant public key
      54             :  * @param amount_without_fee fraction of coin value to deposit, without the fee
      55             :  * @return MHD result code
      56             :  */
      57             : static int
      58           7 : reply_deposit_success (struct MHD_Connection *connection,
      59             :                        const struct TALER_CoinSpendPublicKeyP *coin_pub,
      60             :                        const struct GNUNET_HashCode *h_wire,
      61             :                        const struct GNUNET_HashCode *h_contract_terms,
      62             :                        struct GNUNET_TIME_Absolute timestamp,
      63             :                        struct GNUNET_TIME_Absolute refund_deadline,
      64             :                        const struct TALER_MerchantPublicKeyP *merchant,
      65             :                        const struct TALER_Amount *amount_without_fee)
      66             : {
      67             :   struct TALER_DepositConfirmationPS dc;
      68             :   struct TALER_ExchangePublicKeyP pub;
      69             :   struct TALER_ExchangeSignatureP sig;
      70             : 
      71           7 :   dc.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_DEPOSIT);
      72           7 :   dc.purpose.size = htonl (sizeof (struct TALER_DepositConfirmationPS));
      73           7 :   dc.h_contract_terms = *h_contract_terms;
      74           7 :   dc.h_wire = *h_wire;
      75           7 :   dc.timestamp = GNUNET_TIME_absolute_hton (timestamp);
      76           7 :   dc.refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline);
      77           7 :   TALER_amount_hton (&dc.amount_without_fee,
      78             :                      amount_without_fee);
      79           7 :   dc.coin_pub = *coin_pub;
      80           7 :   dc.merchant = *merchant;
      81           7 :   if (GNUNET_OK !=
      82           7 :       TEH_KS_sign (&dc.purpose,
      83             :                    &pub,
      84             :                    &sig))
      85             :   {
      86           0 :     return TEH_RESPONSE_reply_internal_error (connection,
      87             :                                               TALER_EC_EXCHANGE_BAD_CONFIGURATION,
      88             :                                               "no keys");
      89             :   }
      90           7 :   return TEH_RESPONSE_reply_json_pack (connection,
      91             :                                        MHD_HTTP_OK,
      92             :                                        "{s:s, s:o, s:o}",
      93             :                                        "status", "DEPOSIT_OK",
      94             :                                        "sig", GNUNET_JSON_from_data_auto (&sig),
      95             :                                        "pub", GNUNET_JSON_from_data_auto (&pub));
      96             : }
      97             : 
      98             : 
      99             : /**
     100             :  * Closure for #deposit_transaction.
     101             :  */
     102             : struct DepositContext
     103             : {
     104             :   /**
     105             :    * Information about the deposit request.
     106             :    */
     107             :   const struct TALER_EXCHANGEDB_Deposit *deposit;
     108             : 
     109             :   /**
     110             :    * Value of the coin.
     111             :    */
     112             :   struct TALER_Amount value;
     113             : 
     114             : };
     115             : 
     116             : 
     117             : /**
     118             :  * Execute database transaction for /deposit.  Runs the transaction
     119             :  * logic; IF it returns a non-error code, the transaction logic MUST
     120             :  * NOT queue a MHD response.  IF it returns an hard error, the
     121             :  * transaction logic MUST queue a MHD response and set @a mhd_ret.  IF
     122             :  * it returns the soft error code, the function MAY be called again to
     123             :  * retry and MUST not queue a MHD response.
     124             :  *
     125             :  * @param cls a `struct DepositContext`
     126             :  * @param connection MHD request context
     127             :  * @param session database session and transaction to use
     128             :  * @param[out] mhd_ret set to MHD status on error
     129             :  * @return transaction status
     130             :  */
     131             : static enum GNUNET_DB_QueryStatus
     132          10 : deposit_transaction (void *cls,
     133             :                      struct MHD_Connection *connection,
     134             :                      struct TALER_EXCHANGEDB_Session *session,
     135             :                      int *mhd_ret)
     136             : {
     137          10 :   struct DepositContext *dc = cls;
     138          10 :   const struct TALER_EXCHANGEDB_Deposit *deposit = dc->deposit;
     139             :   struct TALER_EXCHANGEDB_TransactionList *tl;
     140             :   struct TALER_Amount spent;
     141             :   enum GNUNET_DB_QueryStatus qs;
     142             : 
     143          10 :   qs = TEH_plugin->have_deposit (TEH_plugin->cls,
     144             :                                  session,
     145             :                                  deposit);
     146          10 :   if (qs < 0)
     147           0 :     return qs;
     148          10 :   if (1 == qs)
     149             :   {
     150             :     struct TALER_Amount amount_without_fee;
     151             : 
     152           0 :     GNUNET_assert (GNUNET_OK ==
     153             :                    TALER_amount_subtract (&amount_without_fee,
     154             :                                           &deposit->amount_with_fee,
     155             :                                           &deposit->deposit_fee));
     156           0 :     *mhd_ret = reply_deposit_success (connection,
     157             :                                       &deposit->coin.coin_pub,
     158             :                                       &deposit->h_wire,
     159             :                                       &deposit->h_contract_terms,
     160             :                                       deposit->timestamp,
     161             :                                       deposit->refund_deadline,
     162             :                                       &deposit->merchant_pub,
     163             :                                       &amount_without_fee);
     164             :     /* Treat as 'hard' DB error as we want to rollback and
     165             :        never try again. */
     166           0 :     return GNUNET_DB_STATUS_HARD_ERROR;
     167             :   }
     168             : 
     169             :   /* Start with fee for THIS transaction */
     170          10 :   spent = deposit->amount_with_fee;
     171             :   /* add cost of all previous transactions */
     172          10 :   qs = TEH_plugin->get_coin_transactions (TEH_plugin->cls,
     173             :                                           session,
     174             :                                           &deposit->coin.coin_pub,
     175             :                                           &tl);
     176          10 :   if (0 > qs)
     177           0 :     return qs;
     178          10 :   if (GNUNET_OK !=
     179          10 :       TEH_DB_calculate_transaction_list_totals (tl,
     180             :                                                 &spent,
     181             :                                                 &spent))
     182             :   {
     183           0 :     TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
     184             :                                             tl);
     185           0 :     *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection,
     186             :                                                      TALER_EC_DEPOSIT_HISTORY_DB_ERROR);
     187           0 :     return GNUNET_DB_STATUS_HARD_ERROR;
     188             :   }
     189             :   /* Check that cost of all transactions is smaller than
     190             :      the value of the coin. */
     191          10 :   if (0 < TALER_amount_cmp (&spent,
     192          10 :                             &dc->value))
     193             :   {
     194           3 :     *mhd_ret = TEH_RESPONSE_reply_coin_insufficient_funds (connection,
     195             :                                                            TALER_EC_DEPOSIT_INSUFFICIENT_FUNDS,
     196             :                                                            tl);
     197           3 :     TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
     198             :                                             tl);
     199           3 :     return GNUNET_DB_STATUS_HARD_ERROR;
     200             :   }
     201           7 :   TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
     202             :                                           tl);
     203           7 :   qs = TEH_plugin->insert_deposit (TEH_plugin->cls,
     204             :                                    session,
     205             :                                    deposit);
     206           7 :   if (GNUNET_DB_STATUS_HARD_ERROR == qs)
     207             :   {
     208           0 :     TALER_LOG_WARNING ("Failed to store /deposit information in database\n");
     209           0 :     *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection,
     210             :                                                      TALER_EC_DEPOSIT_STORE_DB_ERROR);
     211             :   }
     212           7 :   return qs;
     213             : }
     214             : 
     215             : 
     216             : /**
     217             :  * We have parsed the JSON information about the deposit, do some
     218             :  * basic sanity checks (especially that the signature on the coin is
     219             :  * valid, and that this type of coin exists) and then execute the
     220             :  * deposit.
     221             :  *
     222             :  * @param connection the MHD connection to handle
     223             :  * @param deposit information about the deposit
     224             :  * @return MHD result code
     225             :  */
     226             : static int
     227          10 : verify_and_execute_deposit (struct MHD_Connection *connection,
     228             :                             const struct TALER_EXCHANGEDB_Deposit *deposit)
     229             : {
     230             :   struct TALER_DepositRequestPS dr;
     231             :   int mhd_ret;
     232             :   struct TALER_Amount amount_without_fee;
     233             :   struct DepositContext dc;
     234             :   struct TEH_KS_StateHandle *mks;
     235             :   struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki;
     236             : 
     237             :   /* check signature */
     238          10 :   dr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_DEPOSIT);
     239          10 :   dr.purpose.size = htonl (sizeof (struct TALER_DepositRequestPS));
     240          10 :   dr.h_contract_terms = deposit->h_contract_terms;
     241          10 :   dr.h_wire = deposit->h_wire;
     242          10 :   dr.timestamp = GNUNET_TIME_absolute_hton (deposit->timestamp);
     243          10 :   dr.refund_deadline = GNUNET_TIME_absolute_hton (deposit->refund_deadline);
     244          10 :   TALER_amount_hton (&dr.amount_with_fee,
     245             :                      &deposit->amount_with_fee);
     246          10 :   TALER_amount_hton (&dr.deposit_fee,
     247             :                      &deposit->deposit_fee);
     248          10 :   dr.merchant = deposit->merchant_pub;
     249          10 :   dr.coin_pub = deposit->coin.coin_pub;
     250          10 :   if (GNUNET_OK !=
     251          10 :       GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_COIN_DEPOSIT,
     252             :                                   &dr.purpose,
     253             :                                   &deposit->csig.eddsa_signature,
     254             :                                   &deposit->coin.coin_pub.eddsa_pub))
     255             :   {
     256           0 :     TALER_LOG_WARNING ("Invalid signature on /deposit request\n");
     257           0 :     return TEH_RESPONSE_reply_signature_invalid (connection,
     258             :                                                  TALER_EC_DEPOSIT_COIN_SIGNATURE_INVALID,
     259             :                                                  "coin_sig");
     260             :   }
     261             : 
     262             :   /* check denomination */
     263          10 :   mks = TEH_KS_acquire ();
     264          10 :   if (NULL == mks)
     265             :   {
     266           0 :     TALER_LOG_ERROR ("Lacking keys to operate\n");
     267           0 :     return TEH_RESPONSE_reply_internal_error (connection,
     268             :                                               TALER_EC_EXCHANGE_BAD_CONFIGURATION,
     269             :                                               "no keys");
     270             :   }
     271          10 :   dki = TEH_KS_denomination_key_lookup (mks,
     272             :                                         &deposit->coin.denom_pub,
     273             :                                         TEH_KS_DKU_DEPOSIT);
     274          10 :   if (NULL == dki)
     275             :   {
     276           0 :     TEH_KS_release (mks);
     277           0 :     return TEH_RESPONSE_reply_internal_db_error (connection,
     278             :                                                  TALER_EC_DEPOSIT_DB_DENOMINATION_KEY_UNKNOWN);
     279             :   }
     280          10 :   TALER_amount_ntoh (&dc.value,
     281          10 :                      &dki->issue.properties.value);
     282          10 :   TEH_KS_release (mks);
     283             : 
     284             :   /* execute transaction */
     285          10 :   dc.deposit = deposit;
     286          10 :   if (GNUNET_OK !=
     287          10 :       TEH_DB_run_transaction (connection,
     288             :                               &mhd_ret,
     289             :                               &deposit_transaction,
     290             :                               &dc))
     291           3 :     return mhd_ret;
     292             : 
     293             :   /* generate regular response */
     294           7 :   GNUNET_assert (GNUNET_SYSERR !=
     295             :                  TALER_amount_subtract (&amount_without_fee,
     296             :                                         &deposit->amount_with_fee,
     297             :                                         &deposit->deposit_fee));
     298           7 :   return reply_deposit_success (connection,
     299             :                                 &deposit->coin.coin_pub,
     300             :                                 &deposit->h_wire,
     301             :                                 &deposit->h_contract_terms,
     302             :                                 deposit->timestamp,
     303             :                                 deposit->refund_deadline,
     304             :                                 &deposit->merchant_pub,
     305             :                                 &amount_without_fee);
     306             : }
     307             : 
     308             : 
     309             : /**
     310             :  * Check that @a ts is reasonably close to our own RTC.
     311             :  *
     312             :  * @param ts timestamp to check
     313             :  * @return #GNUNET_OK if @a ts is reasonable
     314             :  */
     315             : static int
     316          12 : check_timestamp_current (struct GNUNET_TIME_Absolute ts)
     317             : {
     318             :   struct GNUNET_TIME_Relative r;
     319             :   struct GNUNET_TIME_Relative tolerance;
     320             : 
     321             :   /* Let's be VERY generous */
     322          12 :   tolerance = GNUNET_TIME_UNIT_MONTHS;
     323          12 :   r = GNUNET_TIME_absolute_get_duration (ts);
     324          12 :   if (r.rel_value_us > tolerance.rel_value_us)
     325             :   {
     326           0 :     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
     327             :                 "Deposit timestamp too old: %llu vs %llu > %llu\n",
     328             :                 (unsigned long long) ts.abs_value_us,
     329             :                 (unsigned long long) GNUNET_TIME_absolute_get().abs_value_us,
     330             :                 (unsigned long long) tolerance.rel_value_us);
     331           0 :     return GNUNET_SYSERR;
     332             :   }
     333          12 :   r = GNUNET_TIME_absolute_get_remaining (ts);
     334          12 :   if (r.rel_value_us > tolerance.rel_value_us)
     335             :   {
     336           0 :     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
     337             :                 "Deposit timestamp too new: %llu vs %llu < - %llu\n",
     338             :                 (unsigned long long) ts.abs_value_us,
     339             :                 (unsigned long long) GNUNET_TIME_absolute_get().abs_value_us,
     340             :                 (unsigned long long) tolerance.rel_value_us);
     341           0 :     return GNUNET_SYSERR;
     342             :   }
     343          12 :   return GNUNET_OK;
     344             : }
     345             : 
     346             : 
     347             : /**
     348             :  * Handle a "/deposit" request.  Parses the JSON, and, if successful,
     349             :  * passes the JSON data to #verify_and_execute_deposit() to further
     350             :  * check the details of the operation specified.  If everything checks
     351             :  * out, this will ultimately lead to the "/deposit" being executed, or
     352             :  * rejected.
     353             :  *
     354             :  * @param rh context of the handler
     355             :  * @param connection the MHD connection to handle
     356             :  * @param[in,out] connection_cls the connection's closure (can be updated)
     357             :  * @param upload_data upload data
     358             :  * @param[in,out] upload_data_size number of bytes (left) in @a upload_data
     359             :  * @return MHD result code
     360             :   */
     361             : int
     362          36 : TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh,
     363             :                              struct MHD_Connection *connection,
     364             :                              void **connection_cls,
     365             :                              const char *upload_data,
     366             :                              size_t *upload_data_size)
     367             : {
     368             :   json_t *json;
     369             :   int res;
     370             :   json_t *wire;
     371             :   char *emsg;
     372             :   enum TALER_ErrorCode ec;
     373             :   struct TALER_EXCHANGEDB_Deposit deposit;
     374             :   struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki;
     375             :   struct TEH_KS_StateHandle *key_state;
     376             :   struct GNUNET_HashCode my_h_wire;
     377          36 :   struct GNUNET_JSON_Specification spec[] = {
     378             :     GNUNET_JSON_spec_json ("wire", &wire),
     379             :     TALER_JSON_spec_amount ("f", &deposit.amount_with_fee),
     380             :     TALER_JSON_spec_denomination_public_key ("denom_pub", &deposit.coin.denom_pub),
     381             :     TALER_JSON_spec_denomination_signature ("ub_sig", &deposit.coin.denom_sig),
     382             :     GNUNET_JSON_spec_fixed_auto ("coin_pub", &deposit.coin.coin_pub),
     383             :     GNUNET_JSON_spec_fixed_auto ("merchant_pub", &deposit.merchant_pub),
     384             :     GNUNET_JSON_spec_fixed_auto ("h_contract_terms", &deposit.h_contract_terms),
     385             :     GNUNET_JSON_spec_fixed_auto ("H_wire", &deposit.h_wire),
     386             :     GNUNET_JSON_spec_fixed_auto ("coin_sig",  &deposit.csig),
     387             :     GNUNET_JSON_spec_absolute_time ("timestamp", &deposit.timestamp),
     388             :     GNUNET_JSON_spec_absolute_time ("refund_deadline", &deposit.refund_deadline),
     389             :     GNUNET_JSON_spec_absolute_time ("wire_transfer_deadline", &deposit.wire_deadline),
     390             :     GNUNET_JSON_spec_end ()
     391             :   };
     392             : 
     393          36 :   res = TEH_PARSE_post_json (connection,
     394             :                              connection_cls,
     395             :                              upload_data,
     396             :                              upload_data_size,
     397             :                              &json);
     398          36 :   if (GNUNET_SYSERR == res)
     399           0 :     return MHD_NO;
     400          36 :   if ( (GNUNET_NO == res) || (NULL == json) )
     401          24 :     return MHD_YES;
     402          12 :   memset (&deposit, 0, sizeof (deposit));
     403          12 :   res = TEH_PARSE_json_data (connection,
     404             :                              json,
     405             :                              spec);
     406          12 :   json_decref (json);
     407          12 :   if (GNUNET_SYSERR == res)
     408           0 :     return MHD_NO; /* hard failure */
     409          12 :   if (GNUNET_NO == res)
     410           0 :     return MHD_YES; /* failure */
     411             : 
     412          12 :   deposit.receiver_wire_account = wire;
     413          12 :   if (deposit.refund_deadline.abs_value_us > deposit.wire_deadline.abs_value_us)
     414             :   {
     415           0 :     GNUNET_break_op (0);
     416           0 :     GNUNET_JSON_parse_free (spec);
     417           0 :     return TEH_RESPONSE_reply_arg_invalid (connection,
     418             :                                            TALER_EC_DEPOSIT_REFUND_DEADLINE_AFTER_WIRE_DEADLINE,
     419             :                                            "refund_deadline");
     420             :   }
     421             : 
     422          12 :   if (TALER_EC_NONE !=
     423          12 :       (ec = TEH_json_validate_wireformat (wire,
     424             :                                           GNUNET_NO,
     425             :                                           &emsg)))
     426             :   {
     427           0 :     GNUNET_JSON_parse_free (spec);
     428           0 :     res = TEH_RESPONSE_reply_external_error (connection,
     429             :                                              ec,
     430             :                                              emsg);
     431           0 :     GNUNET_free (emsg);
     432           0 :     return res;
     433             :   }
     434          12 :   if (GNUNET_OK !=
     435          12 :       check_timestamp_current (deposit.timestamp))
     436             :   {
     437           0 :     GNUNET_break_op (0);
     438           0 :     GNUNET_JSON_parse_free (spec);
     439           0 :     return TEH_RESPONSE_reply_arg_invalid (connection,
     440             :                                            TALER_EC_DEPOSIT_INVALID_TIMESTAMP,
     441             :                                            "timestamp");
     442             :   }
     443          12 :   if (GNUNET_OK !=
     444          12 :       TALER_JSON_hash (wire,
     445             :                        &my_h_wire))
     446             :   {
     447           0 :     TALER_LOG_WARNING ("Failed to parse JSON wire format specification for /deposit request\n");
     448           0 :     GNUNET_JSON_parse_free (spec);
     449           0 :     return TEH_RESPONSE_reply_arg_invalid (connection,
     450             :                                            TALER_EC_DEPOSIT_INVALID_WIRE_FORMAT_JSON,
     451             :                                            "wire");
     452             :   }
     453          12 :   if (0 != memcmp (&deposit.h_wire,
     454             :                    &my_h_wire,
     455             :                    sizeof (struct GNUNET_HashCode)))
     456             :   {
     457             :     /* Client hashed contract differently than we did, reject */
     458           0 :     GNUNET_JSON_parse_free (spec);
     459           0 :     return TEH_RESPONSE_reply_arg_invalid (connection,
     460             :                                            TALER_EC_DEPOSIT_INVALID_WIRE_FORMAT_CONTRACT_HASH_CONFLICT,
     461             :                                            "H_wire");
     462             :   }
     463             : 
     464             :   /* check denomination exists and is valid */
     465          12 :   key_state = TEH_KS_acquire ();
     466          12 :   if (NULL == key_state)
     467             :   {
     468           0 :     TALER_LOG_ERROR ("Lacking keys to operate\n");
     469           0 :     GNUNET_JSON_parse_free (spec);
     470           0 :     return TEH_RESPONSE_reply_internal_error (connection,
     471             :                                               TALER_EC_EXCHANGE_BAD_CONFIGURATION,
     472             :                                               "no keys");
     473             :   }
     474          12 :   dki = TEH_KS_denomination_key_lookup (key_state,
     475             :                                         &deposit.coin.denom_pub,
     476             :                                         TEH_KS_DKU_DEPOSIT);
     477          12 :   if (NULL == dki)
     478             :   {
     479             :     /* FIXME: #3887: if DK was revoked, we might want to give a 403 and not a 404! */
     480           2 :     TEH_KS_release (key_state);
     481           2 :     TALER_LOG_WARNING ("Unknown denomination key in /deposit request\n");
     482           2 :     GNUNET_JSON_parse_free (spec);
     483           2 :     return TEH_RESPONSE_reply_arg_unknown (connection,
     484             :                                            TALER_EC_DEPOSIT_DENOMINATION_KEY_UNKNOWN,
     485             :                                            "denom_pub");
     486             :   }
     487          10 :   TALER_amount_ntoh (&deposit.deposit_fee,
     488          10 :                      &dki->issue.properties.fee_deposit);
     489             :   /* check coin signature */
     490          10 :   if (GNUNET_YES !=
     491          10 :       TALER_test_coin_valid (&deposit.coin))
     492             :   {
     493           0 :     TALER_LOG_WARNING ("Invalid coin passed for /deposit\n");
     494           0 :     TEH_KS_release (key_state);
     495           0 :     GNUNET_JSON_parse_free (spec);
     496           0 :     return TEH_RESPONSE_reply_signature_invalid (connection,
     497             :                                                  TALER_EC_DEPOSIT_DENOMINATION_SIGNATURE_INVALID,
     498             :                                                  "ub_sig");
     499             :   }
     500          10 :   TALER_amount_ntoh (&deposit.deposit_fee,
     501          10 :                      &dki->issue.properties.fee_deposit);
     502          10 :   TEH_KS_release (key_state);
     503             : 
     504          10 :   if (0 < TALER_amount_cmp (&deposit.deposit_fee,
     505             :                             &deposit.amount_with_fee))
     506             :   {
     507           0 :     GNUNET_break_op (0);
     508           0 :     GNUNET_JSON_parse_free (spec);
     509           0 :     return TEH_RESPONSE_reply_external_error (connection,
     510             :                                               TALER_EC_DEPOSIT_NEGATIVE_VALUE_AFTER_FEE,
     511             :                                               "deposited amount smaller than depositing fee");
     512             :   }
     513             : 
     514          10 :   res = verify_and_execute_deposit (connection,
     515             :                                     &deposit);
     516          10 :   GNUNET_JSON_parse_free (spec);
     517          10 :   return res;
     518             : }
     519             : 
     520             : 
     521             : /* end of taler-exchange-httpd_deposit.c */

Generated by: LCOV version 1.13