gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-merchant] branch master updated: fix #6568


From: gnunet
Subject: [taler-merchant] branch master updated: fix #6568
Date: Sat, 05 Sep 2020 01:25:56 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new c0f9922  fix #6568
c0f9922 is described below

commit c0f992290a61e67f08e720649673951ef86638b5
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Sep 5 01:25:54 2020 +0200

    fix #6568
---
 .../taler-merchant-httpd_post-orders-ID-abort.c    | 53 ++++++++++++++++++----
 src/lib/merchant_api_post_order_abort.c            | 50 ++++++++++----------
 2 files changed, 68 insertions(+), 35 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-abort.c 
b/src/backend/taler-merchant-httpd_post-orders-ID-abort.c
index 7ac1665..1498bca 100644
--- a/src/backend/taler-merchant-httpd_post-orders-ID-abort.c
+++ b/src/backend/taler-merchant-httpd_post-orders-ID-abort.c
@@ -56,6 +56,18 @@ struct RefundDetails
    */
   struct TALER_CoinSpendPublicKeyP coin_pub;
 
+  /**
+   * Signature from the exchange confirming the refund.
+   * Set if we were successful (status 200).
+   */
+  struct TALER_ExchangeSignatureP exchange_sig;
+
+  /**
+   * Public key used for @e exchange_sig.
+   * Set if we were successful (status 200).
+   */
+  struct TALER_ExchangePublicKeyP exchange_pub;
+
   /**
    * Reference to the main AbortContext
    */
@@ -348,15 +360,31 @@ generate_success_response (struct AbortContext *ac)
   for (unsigned int i = 0; i<ac->coins_cnt; i++)
   {
     struct RefundDetails *rdi = &ac->rd[i];
-
-    if (0 !=
-        json_array_append_new (
-          refunds,
-          json_pack ("{s:I, s:O}",
-                     "exchange_http_status",
-                     (json_int_t) rdi->http_status,
-                     "exchange_reply",
-                     rdi->exchange_reply)))
+    json_t *detail;
+
+    detail = (MHD_HTTP_OK != rdi->http_status)
+             ? json_pack ("{s:s, s:I, s:I, s:O}",
+                          "type",
+                          "failure",
+                          "exchange_status",
+                          (json_int_t) rdi->http_status,
+                          "exchange_code",
+                          (json_int_t) TALER_JSON_get_error_code (
+                            rdi->exchange_reply),
+                          "exchange_reply",
+                          rdi->exchange_reply)
+             : json_pack ("{s:s, s:I, s:o, s:o}",
+                          "type",
+                          "success",
+                          "exchange_status",
+                          (json_int_t) rdi->http_status,
+                          "exchange_sig",
+                          GNUNET_JSON_from_data_auto (&rdi->exchange_sig),
+                          "exchange_pub",
+                          GNUNET_JSON_from_data_auto (&rdi->exchange_pub));
+    if ( (NULL == detail) ||
+         (0 != json_array_append_new (refunds,
+                                      detail)) )
     {
       json_decref (refunds);
       GNUNET_break (0);
@@ -455,6 +483,13 @@ refund_cb (void *cls,
   rd->rh = NULL;
   rd->http_status = hr->http_status;
   rd->exchange_reply = json_incref ((json_t*) hr->reply);
+  if (MHD_HTTP_OK == hr->http_status)
+  {
+    GNUNET_assert (NULL != sign_key);
+    GNUNET_assert (NULL != signature);
+    rd->exchange_pub = *sign_key;
+    rd->exchange_sig = *signature;
+  }
   ac->pending_at_ce--;
   if (0 == ac->pending_at_ce)
     find_next_exchange (ac);
diff --git a/src/lib/merchant_api_post_order_abort.c 
b/src/lib/merchant_api_post_order_abort.c
index 98752af..05896d4 100644
--- a/src/lib/merchant_api_post_order_abort.c
+++ b/src/lib/merchant_api_post_order_abort.c
@@ -136,12 +136,9 @@ check_abort_refund (struct TALER_MERCHANT_OrderAbortHandle 
*oah,
     {
       json_t *refund = json_array_get (refunds, i);
       uint32_t exchange_status;
-      json_t *exchange_reply;
       struct GNUNET_JSON_Specification spec_es[] = {
-        GNUNET_JSON_spec_uint32 ("exchange_http_status",
+        GNUNET_JSON_spec_uint32 ("exchange_status",
                                  &exchange_status),
-        GNUNET_JSON_spec_json ("exchange_reply",
-                               &exchange_reply),
         GNUNET_JSON_spec_end ()
       };
 
@@ -165,7 +162,7 @@ check_abort_refund (struct TALER_MERCHANT_OrderAbortHandle 
*oah,
         };
 
         if (GNUNET_OK !=
-            GNUNET_JSON_parse (exchange_reply,
+            GNUNET_JSON_parse (refund,
                                spec_detail,
                                NULL, NULL))
         {
@@ -173,29 +170,30 @@ check_abort_refund (struct 
TALER_MERCHANT_OrderAbortHandle *oah,
           GNUNET_JSON_parse_free (spec);
           return GNUNET_SYSERR;
         }
-      }
-
-      {
-        struct TALER_RefundConfirmationPS rr = {
-          .purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_REFUND),
-          .purpose.size = htonl (sizeof (rr)),
-          .h_contract_terms = oah->h_contract_terms,
-          .coin_pub = oah->coins[i].coin_pub,
-          .merchant = oah->merchant_pub,
-          .rtransaction_id = GNUNET_htonll (0)
-        };
 
-        TALER_amount_hton (&rr.refund_amount,
-                           &oah->coins[i].amount_with_fee);
-        if (GNUNET_OK !=
-            GNUNET_CRYPTO_eddsa_verify 
(TALER_SIGNATURE_EXCHANGE_CONFIRM_REFUND,
-                                        &rr,
-                                        &res[i].exchange_sig.eddsa_signature,
-                                        &res[i].exchange_pub.eddsa_pub))
         {
-          GNUNET_break_op (0);
-          GNUNET_JSON_parse_free (spec);
-          return GNUNET_SYSERR;
+          struct TALER_RefundConfirmationPS rr = {
+            .purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_REFUND),
+            .purpose.size = htonl (sizeof (rr)),
+            .h_contract_terms = oah->h_contract_terms,
+            .coin_pub = oah->coins[i].coin_pub,
+            .merchant = oah->merchant_pub,
+            .rtransaction_id = GNUNET_htonll (0)
+          };
+
+          TALER_amount_hton (&rr.refund_amount,
+                             &oah->coins[i].amount_with_fee);
+          if (GNUNET_OK !=
+              GNUNET_CRYPTO_eddsa_verify (
+                TALER_SIGNATURE_EXCHANGE_CONFIRM_REFUND,
+                &rr,
+                &res[i].exchange_sig.eddsa_signature,
+                &res[i].exchange_pub.eddsa_pub))
+          {
+            GNUNET_break_op (0);
+            GNUNET_JSON_parse_free (spec);
+            return GNUNET_SYSERR;
+          }
         }
       }
     }

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]