diff options
| author | Christian Grothoff <christian@grothoff.org> | 2015-03-22 16:17:22 +0100 | 
|---|---|---|
| committer | Christian Grothoff <christian@grothoff.org> | 2015-03-22 16:17:22 +0100 | 
| commit | 3fe9a76098607656d95b6d9843dc77bc948a46a2 (patch) | |
| tree | c0569e981d573acdbcb29fba40d4c93402662901 | |
| parent | 4ec78fba4e4cc4d1c3cc6e44da42dc43bef20ef7 (diff) | |
move refresh fee check to earlier
| -rw-r--r-- | src/mint/taler-mint-httpd_db.c | 18 | ||||
| -rw-r--r-- | src/mint/taler-mint-httpd_refresh.c | 19 | 
2 files changed, 17 insertions, 20 deletions
diff --git a/src/mint/taler-mint-httpd_db.c b/src/mint/taler-mint-httpd_db.c index cd418fa5..f99a9859 100644 --- a/src/mint/taler-mint-httpd_db.c +++ b/src/mint/taler-mint-httpd_db.c @@ -510,8 +510,6 @@ refresh_accept_melts (struct MHD_Connection *connection,  {    struct TALER_MINT_DenomKeyIssue *dki;    struct TALER_MINT_DB_TransactionList *tl; -  struct TALER_Amount fee_deposit; -  struct TALER_Amount fee_refresh;    struct TALER_Amount coin_value;    struct TALER_Amount coin_residual;    struct TALER_Amount spent; @@ -530,22 +528,10 @@ refresh_accept_melts (struct MHD_Connection *connection,                                          "denom not found"))        ? GNUNET_NO : GNUNET_SYSERR; -  TALER_amount_ntoh (&fee_deposit, -                     &dki->fee_deposit); -  TALER_amount_ntoh (&fee_refresh, -                     &dki->fee_refresh);    TALER_amount_ntoh (&coin_value,                       &dki->value);    /* fee for THIS transaction; the melt amount includes the fee! */    spent = coin_details->melt_amount_with_fee; -  if (TALER_amount_cmp (&fee_refresh, -                        &spent) < 0) -  { -    return (MHD_YES == -            TALER_MINT_reply_external_error (connection, -                                             "melt amount smaller than melting fee")) -      ? GNUNET_NO : GNUNET_SYSERR; -  }    /* add historic transaction costs of this coin */    tl = plugin->get_coin_transactions (plugin->cls,                                        session, @@ -560,8 +546,8 @@ refresh_accept_melts (struct MHD_Connection *connection,                                          tl);      return TALER_MINT_reply_internal_db_error (connection);    } -  /* Refuse to refresh when the coin does not have enough money left to -   * pay the refreshing fees of the coin. */ +  /* Refuse to refresh when the coin's value is insufficient +     for the cost of all transactions. */    if (TALER_amount_cmp (&coin_value,                          &spent) < 0)    { diff --git a/src/mint/taler-mint-httpd_refresh.c b/src/mint/taler-mint-httpd_refresh.c index 602fc67f..ed229bf6 100644 --- a/src/mint/taler-mint-httpd_refresh.c +++ b/src/mint/taler-mint-httpd_refresh.c @@ -282,9 +282,8 @@ verify_coin_public_info (struct MHD_Connection *connection,    struct RefreshMeltCoinSignature body;    struct MintKeyState *key_state;    struct TALER_MINT_DenomKeyIssuePriv *dki; +  struct TALER_Amount fee_refresh; -  /* FIXME: include amount of coin value to be melted here (#3636!) and -    in what we return!? */    body.purpose.size = htonl (sizeof (struct RefreshMeltCoinSignature));    body.purpose.purpose = htonl (TALER_SIGNATURE_REFRESH_MELT_COIN);    body.melt_hash = *melt_hash; @@ -308,8 +307,6 @@ verify_coin_public_info (struct MHD_Connection *connection,    key_state = TALER_MINT_key_state_acquire ();    dki = TALER_MINT_get_denom_key (key_state,                                    r_public_info->denom_pub); -  /* FIXME: need to check if denomination key is still -     valid for issuing! (#3634) */    if (NULL == dki)    {      TALER_MINT_key_state_release (key_state); @@ -317,6 +314,20 @@ verify_coin_public_info (struct MHD_Connection *connection,      return TALER_MINT_reply_arg_invalid (connection,                                           "denom_pub");    } +  /* FIXME: need to check if denomination key is still +     valid for issuing! (#3634) */ +  TALER_amount_ntoh (&fee_refresh, +                     &dki->issue.fee_refresh); +  if (TALER_amount_cmp (&fee_refresh, +                        &r_melt_detail->melt_amount_with_fee) < 0) +  { +    TALER_MINT_key_state_release (key_state); +    return (MHD_YES == +            TALER_MINT_reply_external_error (connection, +                                             "melt amount smaller than melting fee")) +      ? GNUNET_NO : GNUNET_SYSERR; +  } +    TALER_MINT_key_state_release (key_state);    return GNUNET_OK;  }  | 
