diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-05-21 19:22:03 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-05-21 19:22:03 +0200 |
commit | 8dfb3b87b47ca2d25f6bdcbdfa2acc517fbe6ae2 (patch) | |
tree | 913b31d9e4c59050d68214298801403e293bf344 /src/exchange | |
parent | 9160245167ded9b2b7c11716dfa1a1e8887187f4 (diff) | |
download | exchange-8dfb3b87b47ca2d25f6bdcbdfa2acc517fbe6ae2.tar.xz |
testing refund, fixing bugs, refund test passes
Diffstat (limited to 'src/exchange')
-rw-r--r-- | src/exchange/taler-exchange-httpd_db.c | 15 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_refund.c | 22 |
2 files changed, 22 insertions, 15 deletions
diff --git a/src/exchange/taler-exchange-httpd_db.c b/src/exchange/taler-exchange-httpd_db.c index 712df02a9..981c97289 100644 --- a/src/exchange/taler-exchange-httpd_db.c +++ b/src/exchange/taler-exchange-httpd_db.c @@ -340,11 +340,13 @@ TMH_DB_execute_refund (struct MHD_Connection *connection, MHD_HTTP_NOT_FOUND); } deposit_found = GNUNET_NO; + refund_found = GNUNET_NO; for (tlp = tl; NULL != tlp; tlp = tlp->next) { switch (tlp->type) { case TALER_EXCHANGEDB_TT_DEPOSIT: + if (GNUNET_NO == deposit_found) { dep = tlp->details.deposit; if ( (0 == memcmp (&dep->merchant_pub, @@ -364,6 +366,7 @@ TMH_DB_execute_refund (struct MHD_Connection *connection, /* Melts cannot be refunded, ignore here */ break; case TALER_EXCHANGEDB_TT_REFUND: + if (GNUNET_NO == refund_found) { ref = tlp->details.refund; /* First, check if existing refund request is identical */ @@ -476,15 +479,13 @@ TMH_DB_execute_refund (struct MHD_Connection *connection, MHD_HTTP_GONE); } - /* We no longer need 'tl' or 'dep' or 'ref' */ - TMH_plugin->free_coin_transaction_list (TMH_plugin->cls, - tl); - /* check refund amount is sufficiently low */ if (1 == TALER_amount_cmp (&refund->refund_amount, &dep->amount_with_fee) ) { GNUNET_break_op (0); /* cannot refund more than original value */ + TMH_plugin->free_coin_transaction_list (TMH_plugin->cls, + tl); return TMH_RESPONSE_reply_refund_failure (connection, MHD_HTTP_PRECONDITION_FAILED); } @@ -500,6 +501,8 @@ TMH_DB_execute_refund (struct MHD_Connection *connection, not good... */ GNUNET_break (0); TMH_KS_release (mks); + TMH_plugin->free_coin_transaction_list (TMH_plugin->cls, + tl); return TMH_RESPONSE_reply_internal_error (connection, "denomination key not found"); } @@ -513,6 +516,8 @@ TMH_DB_execute_refund (struct MHD_Connection *connection, { TMH_plugin->rollback (TMH_plugin->cls, session); + TMH_plugin->free_coin_transaction_list (TMH_plugin->cls, + tl); return TMH_RESPONSE_reply_arg_invalid (connection, "refund_fee"); } @@ -521,6 +526,8 @@ TMH_DB_execute_refund (struct MHD_Connection *connection, GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Refund fee proposed by merchant is higher than necessary.\n"); } + TMH_plugin->free_coin_transaction_list (TMH_plugin->cls, + tl); /* Finally, store new refund data */ if (GNUNET_OK != diff --git a/src/exchange/taler-exchange-httpd_refund.c b/src/exchange/taler-exchange-httpd_refund.c index d8c9a6eed..d6d769134 100644 --- a/src/exchange/taler-exchange-httpd_refund.c +++ b/src/exchange/taler-exchange-httpd_refund.c @@ -50,18 +50,18 @@ static int verify_and_execute_refund (struct MHD_Connection *connection, const struct TALER_EXCHANGEDB_Refund *refund) { - struct TALER_RefundRequestPS dr; + struct TALER_RefundRequestPS rr; - dr.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_REFUND); - dr.purpose.size = htonl (sizeof (struct TALER_RefundRequestPS)); - dr.h_contract = refund->h_contract; - dr.transaction_id = GNUNET_htonll (refund->transaction_id); - dr.coin_pub = refund->coin.coin_pub; - dr.merchant = refund->merchant_pub; - dr.rtransaction_id = GNUNET_htonll (refund->rtransaction_id); - TALER_amount_hton (&dr.refund_amount, + rr.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_REFUND); + rr.purpose.size = htonl (sizeof (struct TALER_RefundRequestPS)); + rr.h_contract = refund->h_contract; + rr.transaction_id = GNUNET_htonll (refund->transaction_id); + rr.coin_pub = refund->coin.coin_pub; + rr.merchant = refund->merchant_pub; + rr.rtransaction_id = GNUNET_htonll (refund->rtransaction_id); + TALER_amount_hton (&rr.refund_amount, &refund->refund_amount); - TALER_amount_hton (&dr.refund_fee, + TALER_amount_hton (&rr.refund_fee, &refund->refund_fee); if (GNUNET_YES != TALER_amount_cmp_currency (&refund->refund_amount, @@ -80,7 +80,7 @@ verify_and_execute_refund (struct MHD_Connection *connection, } if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_REFUND, - &dr.purpose, + &rr.purpose, &refund->merchant_sig.eddsa_sig, &refund->merchant_pub.eddsa_pub)) { |