gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: -update to new spec parsers for


From: gnunet
Subject: [taler-merchant] branch master updated: -update to new spec parsers for better error checking
Date: Sat, 25 Nov 2023 14:50:59 +0100

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 7782a680 -update to new spec parsers for better error checking
7782a680 is described below

commit 7782a680228b6e76ae2598cacfc65ff250e8e020
Author: Christian Grothoff <grothoff@gnunet.org>
AuthorDate: Sat Nov 25 16:05:05 2023 +0900

    -update to new spec parsers for better error checking
---
 src/backend/taler-merchant-httpd.c                 |  9 ++----
 src/backend/taler-merchant-httpd_get-orders-ID.c   |  5 +--
 src/backend/taler-merchant-httpd_helper.c          | 12 +++----
 .../taler-merchant-httpd_post-orders-ID-abort.c    |  2 +-
 .../taler-merchant-httpd_post-orders-ID-pay.c      |  3 +-
 ...aler-merchant-httpd_private-patch-accounts-ID.c |  4 +--
 ...aler-merchant-httpd_private-patch-webhooks-ID.c |  2 +-
 .../taler-merchant-httpd_private-post-account.c    |  4 +--
 .../taler-merchant-httpd_private-post-orders.c     |  2 +-
 .../taler-merchant-httpd_private-post-reserves.c   |  2 +-
 .../taler-merchant-httpd_private-post-transfers.c  |  6 ++--
 .../taler-merchant-httpd_private-post-webhooks.c   |  2 +-
 src/lib/merchant_api_get_account.c                 |  6 ++--
 src/lib/merchant_api_get_accounts.c                |  4 +--
 src/lib/merchant_api_get_config.c                  | 37 +++++++---------------
 src/lib/merchant_api_get_kyc.c                     | 23 ++++++--------
 src/lib/merchant_api_get_transfers.c               |  6 ++--
 src/lib/merchant_api_get_webhook.c                 |  2 +-
 src/lib/merchant_api_merchant_get_order.c          | 21 +++++-------
 src/lib/merchant_api_post_transfers.c              |  9 ++----
 src/lib/merchant_api_reward_authorize.c            |  2 +-
 src/lib/merchant_api_wallet_get_reward.c           |  3 +-
 22 files changed, 69 insertions(+), 97 deletions(-)

diff --git a/src/backend/taler-merchant-httpd.c 
b/src/backend/taler-merchant-httpd.c
index 9cb1661c..3a8a9412 100644
--- a/src/backend/taler-merchant-httpd.c
+++ b/src/backend/taler-merchant-httpd.c
@@ -2224,13 +2224,8 @@ run (void *cls,
                                              "BASE_URL",
                                              &TMH_base_url))
   {
-    if ( (0 != strncasecmp (TMH_base_url,
-                            "https://";,
-                            strlen ("https://";))) &&
-         (0 != strncasecmp (TMH_base_url,
-                            "http://";,
-                            strlen ("http://";))) )
-    {
+    if (! TALER_is_web_url (TMH_base_url))
+   {
       GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
                                  "merchant",
                                  "BASE_URL",
diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.c 
b/src/backend/taler-merchant-httpd_get-orders-ID.c
index af5513d9..0943e022 100644
--- a/src/backend/taler-merchant-httpd_get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_get-orders-ID.c
@@ -1078,14 +1078,15 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh,
     struct GNUNET_JSON_Specification espec[] = {
       TALER_JSON_spec_amount_any ("amount",
                                   &god->contract_total),
-      GNUNET_JSON_spec_string ("merchant_base_url",
+      TALER_JSON_spec_web_url ("merchant_base_url",
                                &god->merchant_base_url),
       GNUNET_JSON_spec_mark_optional (
+        /* this one does NOT have to be a Web URL! */
         GNUNET_JSON_spec_string ("fulfillment_url",
                                  &god->fulfillment_url),
         NULL),
       GNUNET_JSON_spec_mark_optional (
-        GNUNET_JSON_spec_string ("public_reorder_url",
+        TALER_JSON_spec_web_url ("public_reorder_url",
                                  &god->public_reorder_url),
         NULL),
       GNUNET_JSON_spec_end ()
diff --git a/src/backend/taler-merchant-httpd_helper.c 
b/src/backend/taler-merchant-httpd_helper.c
index ac181234..9261df91 100644
--- a/src/backend/taler-merchant-httpd_helper.c
+++ b/src/backend/taler-merchant-httpd_helper.c
@@ -37,10 +37,10 @@ TMH_cmp_wire_account (
   const json_t *credit_facade_credentials = NULL;
   const char *uri;
   struct GNUNET_JSON_Specification ispec[] = {
-    GNUNET_JSON_spec_string ("payto_uri",
-                             &uri),
+    TALER_JSON_spec_payto_uri ("payto_uri",
+                               &uri),
     GNUNET_JSON_spec_mark_optional (
-      GNUNET_JSON_spec_string ("credit_facade_url",
+      TALER_JSON_spec_web_url ("credit_facade_url",
                                &credit_facade_url),
       NULL),
     GNUNET_JSON_spec_mark_optional (
@@ -113,10 +113,10 @@ TMH_accounts_array_valid (const json_t *accounts)
     const json_t *credit_facade_credentials = NULL;
     const char *uri;
     struct GNUNET_JSON_Specification ispec[] = {
-      GNUNET_JSON_spec_string ("payto_uri",
-                               &uri),
+      TALER_JSON_spec_payto_uri ("payto_uri",
+                                 &uri),
       GNUNET_JSON_spec_mark_optional (
-        GNUNET_JSON_spec_string ("credit_facade_url",
+        TALER_JSON_spec_web_url ("credit_facade_url",
                                  &credit_facade_url),
         NULL),
       GNUNET_JSON_spec_mark_optional (
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 7b6bc7b5..e7baf540 100644
--- a/src/backend/taler-merchant-httpd_post-orders-ID-abort.c
+++ b/src/backend/taler-merchant-httpd_post-orders-ID-abort.c
@@ -885,7 +885,7 @@ parse_abort (struct MHD_Connection *connection,
         TALER_JSON_spec_amount ("contribution",
                                 TMH_currency,
                                 &rd->amount_with_fee),
-        GNUNET_JSON_spec_string ("exchange_url",
+        TALER_JSON_spec_web_url ("exchange_url",
                                  &exchange_url),
         GNUNET_JSON_spec_fixed_auto ("coin_pub",
                                      &rd->coin_pub),
diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c 
b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
index 9edc553c..c942847f 100644
--- a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
+++ b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
@@ -2306,7 +2306,7 @@ parse_pay (struct PayContext *pc)
                                      &dc->cdd.h_denom_pub),
         TALER_JSON_spec_amount_any ("contribution",
                                     &dc->cdd.amount),
-        GNUNET_JSON_spec_string ("exchange_url",
+        TALER_JSON_spec_web_url ("exchange_url",
                                  &exchange_url),
         /* if a minimum age was required, the minimum_age_sig and
          * age_commitment must be provided */
@@ -2658,6 +2658,7 @@ check_contract (struct PayContext *pc)
       TALER_JSON_spec_amount_any ("amount",
                                   &pc->amount),
       GNUNET_JSON_spec_mark_optional (
+        /* This one does not have to be a Web URL */
         GNUNET_JSON_spec_string ("fulfillment_url",
                                  &fulfillment_url),
         NULL),
diff --git a/src/backend/taler-merchant-httpd_private-patch-accounts-ID.c 
b/src/backend/taler-merchant-httpd_private-patch-accounts-ID.c
index 04fe4ce5..dd18281f 100644
--- a/src/backend/taler-merchant-httpd_private-patch-accounts-ID.c
+++ b/src/backend/taler-merchant-httpd_private-patch-accounts-ID.c
@@ -49,8 +49,8 @@ TMH_private_patch_accounts_ID (const struct 
TMH_RequestHandler *rh,
   struct TALER_MerchantWireHashP h_wire;
   struct GNUNET_JSON_Specification spec[] = {
     GNUNET_JSON_spec_mark_optional (
-      GNUNET_JSON_spec_string ("credit_facade_url",
-                               (const char **) &cfu),
+      TALER_JSON_spec_web_url ("credit_facade_url",
+                               &cfu),
       NULL),
     GNUNET_JSON_spec_mark_optional (
       GNUNET_JSON_spec_object_const ("credit_facade_credentials",
diff --git a/src/backend/taler-merchant-httpd_private-patch-webhooks-ID.c 
b/src/backend/taler-merchant-httpd_private-patch-webhooks-ID.c
index 5b73b16e..80d889fa 100644
--- a/src/backend/taler-merchant-httpd_private-patch-webhooks-ID.c
+++ b/src/backend/taler-merchant-httpd_private-patch-webhooks-ID.c
@@ -112,7 +112,7 @@ TMH_private_patch_webhooks_ID (const struct 
TMH_RequestHandler *rh,
   struct GNUNET_JSON_Specification spec[] = {
     GNUNET_JSON_spec_string ("event_type",
                              (const char **) &wb.event_type),
-    GNUNET_JSON_spec_string ("url",
+    TALER_JSON_spec_web_url ("url",
                              (const char **) &wb.url),
     GNUNET_JSON_spec_string ("http_method",
                              (const char **) &wb.http_method),
diff --git a/src/backend/taler-merchant-httpd_private-post-account.c 
b/src/backend/taler-merchant-httpd_private-post-account.c
index 793e6c79..7c9ffa0f 100644
--- a/src/backend/taler-merchant-httpd_private-post-account.c
+++ b/src/backend/taler-merchant-httpd_private-post-account.c
@@ -40,10 +40,10 @@ TMH_private_post_account (const struct TMH_RequestHandler 
*rh,
   const json_t *credit_facade_credentials = NULL;
   const char *uri;
   struct GNUNET_JSON_Specification ispec[] = {
-    GNUNET_JSON_spec_string ("payto_uri",
+    TALER_JSON_spec_payto_uri ("payto_uri",
                              &uri),
     GNUNET_JSON_spec_mark_optional (
-      GNUNET_JSON_spec_string ("credit_facade_url",
+      TALER_JSON_spec_web_url ("credit_facade_url",
                                &credit_facade_url),
       NULL),
     GNUNET_JSON_spec_mark_optional (
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c 
b/src/backend/taler-merchant-httpd_private-post-orders.c
index 4d60fa2d..11b9abcd 100644
--- a/src/backend/taler-merchant-httpd_private-post-orders.c
+++ b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -1214,7 +1214,7 @@ patch_order (struct OrderContext *oc)
   bool no_fee;
   struct GNUNET_JSON_Specification spec[] = {
     GNUNET_JSON_spec_mark_optional (
-      GNUNET_JSON_spec_string ("merchant_base_url",
+      TALER_JSON_spec_web_url ("merchant_base_url",
                                &merchant_base_url),
       NULL),
     GNUNET_JSON_spec_mark_optional (
diff --git a/src/backend/taler-merchant-httpd_private-post-reserves.c 
b/src/backend/taler-merchant-httpd_private-post-reserves.c
index 027e2996..4d1ea3c9 100644
--- a/src/backend/taler-merchant-httpd_private-post-reserves.c
+++ b/src/backend/taler-merchant-httpd_private-post-reserves.c
@@ -305,7 +305,7 @@ TMH_private_post_reserves (const struct TMH_RequestHandler 
*rh,
 
     {
       struct GNUNET_JSON_Specification spec[] = {
-        GNUNET_JSON_spec_string ("exchange_url",
+        TALER_JSON_spec_web_url ("exchange_url",
                                  &rc->exchange_url),
         GNUNET_JSON_spec_string ("wire_method",
                                  &rc->wire_method),
diff --git a/src/backend/taler-merchant-httpd_private-post-transfers.c 
b/src/backend/taler-merchant-httpd_private-post-transfers.c
index 11f76e29..2fe46fbd 100644
--- a/src/backend/taler-merchant-httpd_private-post-transfers.c
+++ b/src/backend/taler-merchant-httpd_private-post-transfers.c
@@ -49,9 +49,9 @@ TMH_private_post_transfers (const struct TMH_RequestHandler 
*rh,
                                 &amount),
     GNUNET_JSON_spec_fixed_auto ("wtid",
                                  &wtid),
-    GNUNET_JSON_spec_string ("payto_uri",
-                             &payto_uri),
-    GNUNET_JSON_spec_string ("exchange_url",
+    TALER_JSON_spec_payto_uri ("payto_uri",
+                               &payto_uri),
+    TALER_JSON_spec_web_url ("exchange_url",
                              &exchange_url),
     GNUNET_JSON_spec_end ()
   };
diff --git a/src/backend/taler-merchant-httpd_private-post-webhooks.c 
b/src/backend/taler-merchant-httpd_private-post-webhooks.c
index 1115811e..391c7ea9 100644
--- a/src/backend/taler-merchant-httpd_private-post-webhooks.c
+++ b/src/backend/taler-merchant-httpd_private-post-webhooks.c
@@ -80,7 +80,7 @@ TMH_private_post_webhooks (const struct TMH_RequestHandler 
*rh,
                              &webhook_id),
     GNUNET_JSON_spec_string ("event_type",
                              (const char **) &wb.event_type),
-    GNUNET_JSON_spec_string ("url",
+    TALER_JSON_spec_web_url ("url",
                              (const char **) &wb.url),
     GNUNET_JSON_spec_string ("http_method",
                              (const char **) &wb.http_method),
diff --git a/src/lib/merchant_api_get_account.c 
b/src/lib/merchant_api_get_account.c
index e9a13b33..84595e80 100644
--- a/src/lib/merchant_api_get_account.c
+++ b/src/lib/merchant_api_get_account.c
@@ -96,11 +96,11 @@ handle_get_account_finished (void *cls,
         GNUNET_JSON_spec_fixed_auto ("salt",
                                      &tgr.details.ok.ad.salt),
         GNUNET_JSON_spec_mark_optional (
-          GNUNET_JSON_spec_string ("credit_facade_url",
+          TALER_JSON_spec_web_url ("credit_facade_url",
                                    &tgr.details.ok.ad.credit_facade_url),
           NULL),
-        GNUNET_JSON_spec_string ("payto_uri",
-                                 &tgr.details.ok.ad.payto_uri),
+        TALER_JSON_spec_payto_uri ("payto_uri",
+                                   &tgr.details.ok.ad.payto_uri),
         GNUNET_JSON_spec_fixed_auto ("h_wire",
                                      &tgr.details.ok.ad.h_wire),
         GNUNET_JSON_spec_bool ("active",
diff --git a/src/lib/merchant_api_get_accounts.c 
b/src/lib/merchant_api_get_accounts.c
index 9d09463b..95238827 100644
--- a/src/lib/merchant_api_get_accounts.c
+++ b/src/lib/merchant_api_get_accounts.c
@@ -85,8 +85,8 @@ parse_accounts (const json_t *ia,
   json_array_foreach (ia, index, value) {
     struct TALER_MERCHANT_AccountEntry *ie = &tmpl[index];
     struct GNUNET_JSON_Specification spec[] = {
-      GNUNET_JSON_spec_string ("payto_uri",
-                               &ie->payto_uri),
+      TALER_JSON_spec_payto_uri ("payto_uri",
+                                 &ie->payto_uri),
       GNUNET_JSON_spec_fixed_auto ("h_wire",
                                    &ie->h_wire),
       GNUNET_JSON_spec_end ()
diff --git a/src/lib/merchant_api_get_config.c 
b/src/lib/merchant_api_get_config.c
index 708b7907..93b7c863 100644
--- a/src/lib/merchant_api_get_config.c
+++ b/src/lib/merchant_api_get_config.c
@@ -105,11 +105,14 @@ handle_config_finished (void *cls,
   case MHD_HTTP_OK:
     {
       const json_t *jcs;
+      struct TALER_JSON_ProtocolVersion pv;
       struct GNUNET_JSON_Specification spec[] = {
         GNUNET_JSON_spec_object_const ("currencies",
                                        &jcs),
         GNUNET_JSON_spec_string ("currency",
                                  &cr.details.ok.ci.currency),
+        TALER_JSON_spec_version ("version",
+                                 &pv),
         GNUNET_JSON_spec_string ("version",
                                  &cr.details.ok.ci.version),
         GNUNET_JSON_spec_end ()
@@ -126,34 +129,18 @@ handle_config_finished (void *cls,
       }
       else
       {
-        unsigned int age;
-        unsigned int revision;
-        unsigned int current;
-
-        if (3 != sscanf (cr.details.ok.ci.version,
-                         "%u:%u:%u",
-                         &current,
-                         &revision,
-                         &age))
+        cr.details.ok.compat = TALER_MERCHANT_VC_MATCH;
+        if (MERCHANT_PROTOCOL_CURRENT < pv.current)
         {
-          cr.hr.http_status = 0;
-          cr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
+          cr.details.ok.compat |= TALER_MERCHANT_VC_NEWER;
+          if (MERCHANT_PROTOCOL_CURRENT < pv.current - pv.age)
+            cr.details.ok.compat |= TALER_MERCHANT_VC_INCOMPATIBLE;
         }
-        else
+        if (MERCHANT_PROTOCOL_CURRENT > pv.current)
         {
-          cr.details.ok.compat = TALER_MERCHANT_VC_MATCH;
-          if (MERCHANT_PROTOCOL_CURRENT < current)
-          {
-            cr.details.ok.compat |= TALER_MERCHANT_VC_NEWER;
-            if (MERCHANT_PROTOCOL_CURRENT < current - age)
-              cr.details.ok.compat |= TALER_MERCHANT_VC_INCOMPATIBLE;
-          }
-          if (MERCHANT_PROTOCOL_CURRENT > current)
-          {
-            cr.details.ok.compat |= TALER_MERCHANT_VC_OLDER;
-            if (MERCHANT_PROTOCOL_CURRENT - MERCHANT_PROTOCOL_AGE > current)
-              cr.details.ok.compat |= TALER_MERCHANT_VC_INCOMPATIBLE;
-          }
+          cr.details.ok.compat |= TALER_MERCHANT_VC_OLDER;
+          if (MERCHANT_PROTOCOL_CURRENT - MERCHANT_PROTOCOL_AGE > pv.current)
+            cr.details.ok.compat |= TALER_MERCHANT_VC_INCOMPATIBLE;
         }
       }
       {
diff --git a/src/lib/merchant_api_get_kyc.c b/src/lib/merchant_api_get_kyc.c
index c394590a..b3008ef6 100644
--- a/src/lib/merchant_api_get_kyc.c
+++ b/src/lib/merchant_api_get_kyc.c
@@ -91,18 +91,17 @@ parse_kyc (struct TALER_MERCHANT_KycGetHandle *kyc,
           sizeof (pending_kycs));
   for (unsigned int i = 0; i<num_pends; i++)
   {
-    uint32_t status;
     struct GNUNET_JSON_Specification spec[] = {
       GNUNET_JSON_spec_mark_optional (
-        GNUNET_JSON_spec_string ("kyc_url",
+        TALER_JSON_spec_web_url ("kyc_url",
                                  &pending_kycs[i].kyc_url),
         NULL),
-      GNUNET_JSON_spec_uint32 ("aml_status",
-                               &status),
-      GNUNET_JSON_spec_string ("exchange_url",
+      TALER_JSON_spec_aml_decision ("aml_status",
+                                    &pending_kycs[i].aml_status),
+      TALER_JSON_spec_web_url ("exchange_url",
                                &pending_kycs[i].exchange_url),
-      GNUNET_JSON_spec_string ("payto_uri",
-                               &pending_kycs[i].payto_uri),
+      TALER_JSON_spec_payto_uri ("payto_uri",
+                                 &pending_kycs[i].payto_uri),
       GNUNET_JSON_spec_end ()
     };
 
@@ -115,18 +114,15 @@ parse_kyc (struct TALER_MERCHANT_KycGetHandle *kyc,
       GNUNET_break (0);
       return GNUNET_SYSERR;
     }
-    pending_kycs[i].aml_status
-      = (enum TALER_AmlDecisionState) status;
   }
   for (unsigned int i = 0; i<num_touts; i++)
   {
     uint32_t hs;
-    uint32_t ec;
     struct GNUNET_JSON_Specification spec[] = {
-      GNUNET_JSON_spec_string ("exchange_url",
+      TALER_JSON_spec_web_url ("exchange_url",
                                &timeout_kycs[i].exchange_url),
-      GNUNET_JSON_spec_uint32 ("exchange_code",
-                               &ec),
+      TALER_JSON_spec_ec ("exchange_code",
+                          &timeout_kycs[i].exchange_code),
       GNUNET_JSON_spec_uint32 ("exchange_http_status",
                                &hs),
       GNUNET_JSON_spec_end ()
@@ -142,7 +138,6 @@ parse_kyc (struct TALER_MERCHANT_KycGetHandle *kyc,
       return GNUNET_SYSERR;
     }
     timeout_kycs[i].exchange_http_status = (unsigned int) hs;
-    timeout_kycs[i].exchange_code = (enum TALER_ErrorCode) ec;
   }
   kr->details.kyc_status.pending_kycs = pending_kycs;
   kr->details.kyc_status.timeout_kycs = timeout_kycs;
diff --git a/src/lib/merchant_api_get_transfers.c 
b/src/lib/merchant_api_get_transfers.c
index 473d23a2..66a11edb 100644
--- a/src/lib/merchant_api_get_transfers.c
+++ b/src/lib/merchant_api_get_transfers.c
@@ -130,9 +130,9 @@ handle_transfers_get_finished (void *cls,
                                         &td->credit_amount),
             GNUNET_JSON_spec_fixed_auto ("wtid",
                                          &td->wtid),
-            GNUNET_JSON_spec_string ("payto_uri",
-                                     &td->payto_uri),
-            GNUNET_JSON_spec_string ("exchange_url",
+            TALER_JSON_spec_payto_uri ("payto_uri",
+                                       &td->payto_uri),
+            TALER_JSON_spec_web_url ("exchange_url",
                                      &td->exchange_url),
             GNUNET_JSON_spec_uint64 ("transfer_serial_id",
                                      &td->credit_serial),
diff --git a/src/lib/merchant_api_get_webhook.c 
b/src/lib/merchant_api_get_webhook.c
index 0e9abc6f..551aa915 100644
--- a/src/lib/merchant_api_get_webhook.c
+++ b/src/lib/merchant_api_get_webhook.c
@@ -101,7 +101,7 @@ handle_get_webhook_finished (void *cls,
       struct GNUNET_JSON_Specification spec[] = {
         GNUNET_JSON_spec_string ("event_type",
                                  &event_type),
-        GNUNET_JSON_spec_string ("url",
+        TALER_JSON_spec_web_url ("url",
                                  &url),
         GNUNET_JSON_spec_string ("http_method",
                                  &http_method),
diff --git a/src/lib/merchant_api_merchant_get_order.c 
b/src/lib/merchant_api_merchant_get_order.c
index a8a50738..5e3a5ead 100644
--- a/src/lib/merchant_api_merchant_get_order.c
+++ b/src/lib/merchant_api_merchant_get_order.c
@@ -166,7 +166,6 @@ static void
 handle_paid (struct TALER_MERCHANT_OrderMerchantGetHandle *omgh,
              struct TALER_MERCHANT_OrderStatusResponse *osr)
 {
-  uint32_t ec32;
   uint32_t hc32;
   const json_t *wire_details;
   const json_t *wire_reports;
@@ -180,8 +179,8 @@ handle_paid (struct TALER_MERCHANT_OrderMerchantGetHandle 
*omgh,
                            &osr->details.ok.details.paid.wired),
     TALER_JSON_spec_amount_any ("deposit_total",
                                 &osr->details.ok.details.paid.deposit_total),
-    GNUNET_JSON_spec_uint32 ("exchange_code",
-                             &ec32),
+    TALER_JSON_spec_ec ("exchange_code",
+                        &osr->details.ok.details.paid.exchange_ec),
     GNUNET_JSON_spec_uint32 ("exchange_http_status",
                              &hc32),
     TALER_JSON_spec_amount_any ("refund_amount",
@@ -211,7 +210,7 @@ handle_paid (struct TALER_MERCHANT_OrderMerchantGetHandle 
*omgh,
     return;
   }
   osr->details.ok.status = TALER_MERCHANT_OSC_PAID;
-  osr->details.ok.details.paid.exchange_ec = (enum TALER_ErrorCode) ec32;
+  
   osr->details.ok.details.paid.exchange_hc = (unsigned int) hc32;
   {
     unsigned int wts_len = json_array_size (wire_details);
@@ -227,7 +226,7 @@ handle_paid (struct TALER_MERCHANT_OrderMerchantGetHandle 
*omgh,
       const json_t *w = json_array_get (wire_details,
                                         i);
       struct GNUNET_JSON_Specification ispec[] = {
-        GNUNET_JSON_spec_string ("exchange_url",
+        TALER_JSON_spec_web_url ("exchange_url",
                                  &wt->exchange_url),
         GNUNET_JSON_spec_fixed_auto ("wtid",
                                      &wt->wtid),
@@ -258,16 +257,14 @@ handle_paid (struct TALER_MERCHANT_OrderMerchantGetHandle 
*omgh,
     {
       struct TALER_MERCHANT_WireReport *wr = &wrs[i];
       const json_t *w = json_array_get (wire_reports, i);
-      uint32_t c32;
-      uint32_t eec32;
       uint32_t ehs32;
       struct GNUNET_JSON_Specification ispec[] = {
-        GNUNET_JSON_spec_uint32 ("code",
-                                 &c32),
+        TALER_JSON_spec_ec ("code",
+                            &wr->code),
         GNUNET_JSON_spec_string ("hint",
                                  &wr->hint),
-        GNUNET_JSON_spec_uint32 ("exchange_code",
-                                 &eec32),
+        TALER_JSON_spec_ec ("exchange_code",
+                            &wr->hr.ec),
         GNUNET_JSON_spec_uint32 ("exchange_http_status",
                                  &ehs32),
         GNUNET_JSON_spec_fixed_auto ("coin_pub",
@@ -287,8 +284,6 @@ handle_paid (struct TALER_MERCHANT_OrderMerchantGetHandle 
*omgh,
                   osr);
         return;
       }
-      wr->code = (enum TALER_ErrorCode) c32;
-      wr->hr.ec = (enum TALER_ErrorCode) eec32;
       wr->hr.http_status = (unsigned int) ehs32;
     }
 
diff --git a/src/lib/merchant_api_post_transfers.c 
b/src/lib/merchant_api_post_transfers.c
index 4a4ad2ac..615453fa 100644
--- a/src/lib/merchant_api_post_transfers.c
+++ b/src/lib/merchant_api_post_transfers.c
@@ -123,11 +123,10 @@ handle_post_transfers_finished (void *cls,
     ptr.hr.ec = TALER_JSON_get_error_code (ptr.hr.reply);
     ptr.hr.hint = TALER_JSON_get_error_hint (ptr.hr.reply);
     {
-      uint32_t eec;
       uint32_t ehc;
       struct GNUNET_JSON_Specification ispec[] = {
-        GNUNET_JSON_spec_uint32 ("exchange_code",
-                                 &eec),
+        TALER_JSON_spec_ec ("exchange_code",
+                            &ptr.details.bad_gateway.exchange_ec),
         GNUNET_JSON_spec_uint32 ("exchange_http_status",
                                  &ehc),
         GNUNET_JSON_spec_end ()
@@ -147,11 +146,9 @@ handle_post_transfers_finished (void *cls,
       {
         ptr.details.bad_gateway.exchange_http_status
           = (unsigned int) ehc;
-        ptr.details.bad_gateway.exchange_ec
-          = (enum TALER_ErrorCode) eec;
         GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                     "Exchange returned %u/%u\n",
-                    (unsigned int) eec,
+                    (unsigned int) ptr.details.bad_gateway.exchange_ec,
                     (unsigned int) ehc);
       }
     }
diff --git a/src/lib/merchant_api_reward_authorize.c 
b/src/lib/merchant_api_reward_authorize.c
index a695e378..c81b2eb2 100644
--- a/src/lib/merchant_api_reward_authorize.c
+++ b/src/lib/merchant_api_reward_authorize.c
@@ -91,7 +91,7 @@ check_ok (struct TALER_MERCHANT_RewardAuthorizeHandle *tao,
     .hr.reply = json
   };
   struct GNUNET_JSON_Specification spec[] = {
-    GNUNET_JSON_spec_string ("reward_status_url",
+    TALER_JSON_spec_web_url ("reward_status_url",
                              &reward_status_url),
     GNUNET_JSON_spec_string ("taler_reward_uri",
                              &tar.details.ok.reward_uri),
diff --git a/src/lib/merchant_api_wallet_get_reward.c 
b/src/lib/merchant_api_wallet_get_reward.c
index 534eb7f4..1f6f6176 100644
--- a/src/lib/merchant_api_wallet_get_reward.c
+++ b/src/lib/merchant_api_wallet_get_reward.c
@@ -97,8 +97,9 @@ handle_wallet_reward_get_finished (void *cls,
       struct GNUNET_JSON_Specification spec[] = {
         GNUNET_JSON_spec_timestamp ("expiration",
                                     &wgr.details.ok.expiration),
-        GNUNET_JSON_spec_string ("exchange_url",
+        TALER_JSON_spec_web_url ("exchange_url",
                                  &wgr.details.ok.exchange_url),
+        /* Does not have to be a Web URL */
         GNUNET_JSON_spec_string ("next_url",
                                  &wgr.details.ok.next_url),
         TALER_JSON_spec_amount_any ("reward_amount",

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