gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-exchange] 03/06: handle base32-wire transfer subject


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] 03/06: handle base32-wire transfer subject being followed by space+exchange base url in wire plugin and fakebank
Date: Tue, 16 May 2017 11:05:14 +0200

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

grothoff pushed a commit to branch master
in repository exchange.

commit 7c28823cafa0692849deae506e81efdbc07f2ed3
Author: Christian Grothoff <address@hidden>
AuthorDate: Mon May 15 15:53:21 2017 +0200

    handle base32-wire transfer subject being followed by space+exchange base 
url in wire plugin and fakebank
---
 src/bank-lib/fakebank.c                    | 13 +++++++++++--
 src/bank-lib/test_bank_api.c               |  4 ++--
 src/bank-lib/test_bank_api_with_fakebank.c |  6 +++---
 src/bank-lib/test_bank_interpreter.c       | 14 +++++++++++---
 src/include/taler_bank_service.h           |  3 ++-
 src/wire/plugin_wire_test.c                | 18 ++++++++++++++++--
 6 files changed, 45 insertions(+), 13 deletions(-)

diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c
index fb51216..8d16567 100644
--- a/src/bank-lib/fakebank.c
+++ b/src/bank-lib/fakebank.c
@@ -512,8 +512,17 @@ handle_history (struct TALER_FAKEBANK_Handle *h,
       continue;
     }
 
-    subject = GNUNET_STRINGS_data_to_string_alloc (&pos->wtid,
-                                                   sizeof (pos->wtid));
+    {
+      char *ws;
+
+      ws = GNUNET_STRINGS_data_to_string_alloc (&pos->wtid,
+                                                sizeof (pos->wtid));
+      GNUNET_asprintf (&subject,
+                       "%s %s",
+                       ws,
+                       pos->exchange_base_url);
+      GNUNET_free (ws);
+    }
     trans = json_pack ("{s:I, s:o, s:o, s:s, s:I, s:s}",
                        "row_id", (json_int_t) pos->serial_id,
                        "date", GNUNET_JSON_from_time_abs (pos->date),
diff --git a/src/bank-lib/test_bank_api.c b/src/bank-lib/test_bank_api.c
index 800dc56..9904f37 100644
--- a/src/bank-lib/test_bank_api.c
+++ b/src/bank-lib/test_bank_api.c
@@ -53,7 +53,7 @@ run (void *cls)
       .details.admin_add_incoming.expected_response_code = MHD_HTTP_OK,
       .details.admin_add_incoming.credit_account_no = 1,
       .details.admin_add_incoming.debit_account_no = 2, /* Ignored */
-      .details.admin_add_incoming.amount = "PUDOS:5.01" },
+      .details.admin_add_incoming.amount = "KUDOS:5.01" },
     /* Move money from Exchange to Bank */
     { .oc = TBI_OC_ADMIN_ADD_INCOMING,
       .label = "deposit-2",
@@ -61,7 +61,7 @@ run (void *cls)
       .details.admin_add_incoming.expected_response_code = MHD_HTTP_OK,
       .details.admin_add_incoming.credit_account_no = 1,
       .details.admin_add_incoming.debit_account_no = 2, /* Ignored */
-      .details.admin_add_incoming.amount = "PUDOS:5.01" },
+      .details.admin_add_incoming.amount = "KUDOS:5.01" },
     #if 0
     /* Ask Exchange's incoming history */
     { .oc = TBI_OC_HISTORY,
diff --git a/src/bank-lib/test_bank_api_with_fakebank.c 
b/src/bank-lib/test_bank_api_with_fakebank.c
index 01ab30c..e16c3a9 100644
--- a/src/bank-lib/test_bank_api_with_fakebank.c
+++ b/src/bank-lib/test_bank_api_with_fakebank.c
@@ -52,7 +52,7 @@ run (void *cls)
       .details.admin_add_incoming.credit_account_no = 1,
       .details.admin_add_incoming.debit_account_no = 2,
       .details.admin_add_incoming.exchange_base_url = "https://exchange.net/";,
-      .details.admin_add_incoming.amount = "PUDOS:5.01" },
+      .details.admin_add_incoming.amount = "KUDOS:5.01" },
     /* Add EUR:3.21 to account 3 */
     { .oc = TBI_OC_HISTORY,
       .label = "history-1c",
@@ -72,14 +72,14 @@ run (void *cls)
       .details.admin_add_incoming.credit_account_no = 3,
       .details.admin_add_incoming.debit_account_no = 2,
       .details.admin_add_incoming.exchange_base_url = "https://exchange.org/";,
-      .details.admin_add_incoming.amount = "PUDOS:3.21" },
+      .details.admin_add_incoming.amount = "KUDOS:3.21" },
     { .oc = TBI_OC_ADMIN_ADD_INCOMING,
       .label = "credit-2",
       .details.admin_add_incoming.expected_response_code = MHD_HTTP_OK,
       .details.admin_add_incoming.credit_account_no = 2,
       .details.admin_add_incoming.debit_account_no = 3,
       .details.admin_add_incoming.exchange_base_url = "https://exchange.org/";,
-      .details.admin_add_incoming.amount = "PUDOS:3.22" },
+      .details.admin_add_incoming.amount = "KUDOS:3.22" },
     { .oc = TBI_OC_HISTORY,
       .label = "history-2b",
       .details.history.account_number = 2,
diff --git a/src/bank-lib/test_bank_interpreter.c 
b/src/bank-lib/test_bank_interpreter.c
index bfd744a..94b3b0e 100644
--- a/src/bank-lib/test_bank_interpreter.c
+++ b/src/bank-lib/test_bank_interpreter.c
@@ -323,9 +323,17 @@ build_history (struct InterpreterState *is,
       /* h[total].execution_date; // unknown here */
       h[total].serial_id
         = pos->details.admin_add_incoming.serial_id;
-      h[total].details.wire_transfer_subject
-        = GNUNET_STRINGS_data_to_string_alloc 
(&pos->details.admin_add_incoming.wtid,
-                                               sizeof (struct 
TALER_WireTransferIdentifierRawP));
+      {
+        char *ws;
+
+        ws = GNUNET_STRINGS_data_to_string_alloc 
(&pos->details.admin_add_incoming.wtid,
+                                                  sizeof (struct 
TALER_WireTransferIdentifierRawP));
+        GNUNET_asprintf (&h[total].details.wire_transfer_subject,
+                         "%s %s",
+                         ws,
+                         pos->details.admin_add_incoming.exchange_base_url);
+        GNUNET_free (ws);
+      }
       total++;
     }
   }
diff --git a/src/include/taler_bank_service.h b/src/include/taler_bank_service.h
index 803250d..246174d 100644
--- a/src/include/taler_bank_service.h
+++ b/src/include/taler_bank_service.h
@@ -200,7 +200,8 @@ struct TALER_BANK_TransferDetails
   struct GNUNET_TIME_Absolute execution_date;
 
   /**
-   * Wire transfer subject
+   * Wire transfer subject.  Usually a reserve public key
+   * followed by the BASE URI of the exchange.
    */
   char *wire_transfer_subject;
 
diff --git a/src/wire/plugin_wire_test.c b/src/wire/plugin_wire_test.c
index de3a6ab..8d625ce 100644
--- a/src/wire/plugin_wire_test.c
+++ b/src/wire/plugin_wire_test.c
@@ -822,16 +822,29 @@ bhist_cb (void *cls,
 
   if (MHD_HTTP_OK == http_status)
   {
+    char *subject;
+    char *space;
+
     wd.amount = details->amount;
     wd.execution_date = details->execution_date;
+    subject = GNUNET_strdup (details->wire_transfer_subject);
+    space = strchr (subject, (int) ' ');
+    if (NULL != space)
+    {
+      /* Space separates the actual wire transfer subject from the
+         exchange base URL (if present, expected only for outgoing
+         transactions).  So we cut the string off at the space. */
+      *space = '\0';
+    }
     /* NOTE: For a real bank, the subject should include a checksum! */
     if (GNUNET_OK !=
-        GNUNET_STRINGS_string_to_data (details->wire_transfer_subject,
-                                       strlen (details->wire_transfer_subject),
+        GNUNET_STRINGS_string_to_data (subject,
+                                       strlen (subject),
                                        &wd.reserve_pub,
                                        sizeof (wd.reserve_pub)))
     {
       GNUNET_break (0);
+      GNUNET_free (subject);
       /* NOTE: for a "real" bank, we would want to trigger logic to undo the
          wire transfer. However, for the "demo" bank, it should currently
          be "impossible" to do wire transfers with invalid subjects, and
@@ -839,6 +852,7 @@ bhist_cb (void *cls,
          that nicely either right now). So we don't handle this case for now. 
*/
       return;
     }
+    GNUNET_free (subject);
     wd.account_details = details->account_details;
 
     if ( (NULL != whh->hres_cb) &&

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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