gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: return merchant signature as par


From: gnunet
Subject: [taler-merchant] branch master updated: return merchant signature as part of payment callback (for #5210)
Date: Sat, 18 Jul 2020 21:59:05 +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 02b21f6  return merchant signature as part of payment callback (for 
#5210)
02b21f6 is described below

commit 02b21f6612f5150a686b6df0120fe3dd0722b58f
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Jul 18 21:59:01 2020 +0200

    return merchant signature as part of payment callback (for #5210)
---
 src/include/taler_merchant_service.h     |  5 ++-
 src/include/taler_merchant_testing_lib.h |  1 +
 src/lib/merchant_api_post_order_pay.c    |  7 +++-
 src/testing/testing_api_cmd_pay_order.c  | 69 +++++---------------------------
 4 files changed, 21 insertions(+), 61 deletions(-)

diff --git a/src/include/taler_merchant_service.h 
b/src/include/taler_merchant_service.h
index 42cecb9..8cee7da 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -1832,11 +1832,14 @@ struct TALER_MERCHANT_OrderPayHandle;
  *
  * @param cls closure
  * @param hr HTTP response details
+ * @param merchant_sig signature from the merchant
+ *        affirming payment, or NULL on errors
  */
 typedef void
 (*TALER_MERCHANT_OrderPayCallback) (
   void *cls,
-  const struct TALER_MERCHANT_HttpResponse *hr);
+  const struct TALER_MERCHANT_HttpResponse *hr,
+  const struct TALER_MerchantSignatureP *merchant_sig);
 
 
 /**
diff --git a/src/include/taler_merchant_testing_lib.h 
b/src/include/taler_merchant_testing_lib.h
index c5ca390..1e36e27 100644
--- a/src/include/taler_merchant_testing_lib.h
+++ b/src/include/taler_merchant_testing_lib.h
@@ -514,6 +514,7 @@ TALER_TESTING_cmd_merchant_post_orders_no_claim (const char 
*label,
                                                  struct GNUNET_TIME_Absolute
                                                  pay_deadline,
                                                  const char *amount);
+
 /**
  * Make the "proposal" command.
  *
diff --git a/src/lib/merchant_api_post_order_pay.c 
b/src/lib/merchant_api_post_order_pay.c
index 3675ca6..12b3312 100644
--- a/src/lib/merchant_api_post_order_pay.c
+++ b/src/lib/merchant_api_post_order_pay.c
@@ -248,6 +248,8 @@ handle_pay_finished (void *cls,
     .http_status = (unsigned int) response_code,
     .reply = json
   };
+  struct TALER_MerchantSignatureP *merchant_sigp = NULL;
+  struct TALER_MerchantSignatureP merchant_sig;
 
   oph->job = NULL;
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -267,7 +269,6 @@ handle_pay_finished (void *cls,
         .purpose.size = htonl (sizeof (pr)),
         .h_contract_terms = oph->h_contract_terms
       };
-      struct TALER_MerchantSignatureP merchant_sig;
       struct GNUNET_JSON_Specification spec[] = {
         GNUNET_JSON_spec_fixed_auto ("sig",
                                      &merchant_sig),
@@ -297,6 +298,7 @@ handle_pay_finished (void *cls,
         hr.http_status = 0;
         hr.hint = "signature invalid";
       }
+      merchant_sigp = &merchant_sig;
     }
     break;
   /* Tolerating Not Acceptable because sometimes
@@ -398,7 +400,8 @@ handle_pay_finished (void *cls,
     break;
   }
   oph->pay_cb (oph->pay_cb_cls,
-               &hr);
+               &hr,
+               merchant_sigp);
   TALER_MERCHANT_order_pay_cancel (oph);
 }
 
diff --git a/src/testing/testing_api_cmd_pay_order.c 
b/src/testing/testing_api_cmd_pay_order.c
index 62105b4..dca4437 100644
--- a/src/testing/testing_api_cmd_pay_order.c
+++ b/src/testing/testing_api_cmd_pay_order.c
@@ -82,6 +82,10 @@ struct PayState
    */
   struct TALER_MERCHANT_OrderPayHandle *oph;
 
+  /**
+   * Signature from the merchant, set on success.
+   */
+  struct TALER_MerchantSignatureP merchant_sig;
 };
 
 
@@ -203,16 +207,15 @@ build_coins (struct TALER_MERCHANT_PayCoin **pc,
  *
  * @param cls closure with the interpreter state
  * @param hr HTTP response
+ * @param merchant_sig signature affirming payment,
+ *        NULL on errors
  */
 static void
 pay_cb (void *cls,
-        const struct TALER_MERCHANT_HttpResponse *hr)
+        const struct TALER_MERCHANT_HttpResponse *hr,
+        const struct TALER_MerchantSignatureP *merchant_sig)
 {
   struct PayState *ps = cls;
-  struct GNUNET_CRYPTO_EddsaSignature sig;
-  const char *error_name;
-  unsigned int error_line;
-  const struct TALER_MerchantPublicKeyP *merchant_pub;
 
   ps->oph = NULL;
   if (ps->http_status != hr->http_status)
@@ -226,60 +229,8 @@ pay_cb (void *cls,
   }
   if (MHD_HTTP_OK == hr->http_status)
   {
-    /* Check signature */
-    struct PaymentResponsePS mr;
-    struct GNUNET_JSON_Specification spec[] = {
-      GNUNET_JSON_spec_fixed_auto ("sig",
-                                   &sig),
-      GNUNET_JSON_spec_end ()
-    };
-    const struct TALER_TESTING_Command *proposal_cmd;
-
-    if (GNUNET_OK !=
-        GNUNET_JSON_parse (hr->reply,
-                           spec,
-                           &error_name,
-                           &error_line))
-    {
-      char *js;
-
-      js = json_dumps (hr->reply,
-                       JSON_INDENT (1));
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  "Parser failed on %s:%u for input `%s'\n",
-                  error_name,
-                  error_line,
-                  js);
-      free (js);
-      TALER_TESTING_FAIL (ps->is);
-    }
-    mr.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_PAYMENT_OK);
-    mr.purpose.size = htonl (sizeof (mr));
-    mr.h_contract_terms = ps->h_contract_terms;
-
-    /* proposal reference was used at least once, at this point */
-    GNUNET_assert (NULL !=
-                   (proposal_cmd =
-                      TALER_TESTING_interpreter_lookup_command (ps->is,
-                                                                ps->
-                                                                
proposal_reference)));
-    if (GNUNET_OK !=
-        TALER_TESTING_get_trait_merchant_pub (proposal_cmd,
-                                              0,
-                                              &merchant_pub))
-      TALER_TESTING_FAIL (ps->is);
-    if (GNUNET_OK !=
-        GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_PAYMENT_OK,
-                                    &mr,
-                                    &sig,
-                                    &merchant_pub->eddsa_pub))
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  "Merchant signature given in response to /pay invalid\n");
-      TALER_TESTING_FAIL (ps->is);
-    }
+    ps->merchant_sig = *merchant_sig;
   }
-
   TALER_TESTING_interpreter_next (ps->is);
 }
 
@@ -508,6 +459,8 @@ pay_traits (void *cls,
                                          order_id),
       TALER_TESTING_make_trait_merchant_pub (0,
                                              merchant_pub),
+      TALER_TESTING_make_trait_merchant_sig (0,
+                                             &ps->merchant_sig),
       TALER_TESTING_make_trait_string (0,
                                        ps->amount_with_fee),
       TALER_TESTING_trait_end ()

-- 
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]