gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-exchange] branch master updated: move responsibility


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated: move responsibility of converting to wire subject to reserve_pub into wire plugin
Date: Mon, 08 May 2017 12:57:02 +0200

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

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new 2dcaffe  move responsibility of converting to wire subject to 
reserve_pub  into wire plugin
2dcaffe is described below

commit 2dcaffe4510410e568d637c1e251e230e2df41d9
Author: Christian Grothoff <address@hidden>
AuthorDate: Mon May 8 12:57:00 2017 +0200

    move responsibility of converting to wire subject to reserve_pub  into wire 
plugin
---
 src/exchange/taler-exchange-wirewatch.c | 21 ++++-----------------
 src/include/taler_wire_plugin.h         | 31 ++++++++++++++++++++++++++++++-
 src/wire/plugin_wire_test.c             | 22 +++++++++++++++++++++-
 3 files changed, 55 insertions(+), 19 deletions(-)

diff --git a/src/exchange/taler-exchange-wirewatch.c 
b/src/exchange/taler-exchange-wirewatch.c
index a7f3cd7..918eb59 100644
--- a/src/exchange/taler-exchange-wirewatch.c
+++ b/src/exchange/taler-exchange-wirewatch.c
@@ -210,18 +210,17 @@ history_cb (void *cls,
            enum TALER_BANK_Direction dir,
            const void *row_off,
            size_t row_off_size,
-           const struct TALER_BANK_TransferDetails *details)
+           const struct TALER_WIRE_TransferDetails *details)
 {
   struct TALER_EXCHANGEDB_Session *session = cls;
   int ret;
-  struct TALER_ReservePublicKeyP reserve_pub;
 
   if (TALER_BANK_DIRECTION_NONE == dir)
   {
     hh = NULL;
 
-    /* FIXME: commit last_off to DB! */
-
+    /* FIXME: commit last_off to DB!?
+       (or just select via 'reserves_in' by SERIAL ID!?) */
     ret = db_plugin->commit (db_plugin->cls,
                             session);
     if (GNUNET_OK == ret)
@@ -239,22 +238,10 @@ history_cb (void *cls,
                                       NULL);
     return GNUNET_OK; /* will be ignored anyway */
   }
-  /* TODO: We should expect a checksum! */
-  if (GNUNET_OK !=
-      GNUNET_STRINGS_string_to_data (details->wire_transfer_subject,
-                                    strlen (details->wire_transfer_subject),
-                                    &reserve_pub,
-                                    sizeof (reserve_pub)))
-  {
-    /* FIXME: need way to wire money back immediately... */
-    GNUNET_break (0); // not implemented
-
-    return GNUNET_OK;
-  }
   // FIXME: create json!
   ret = db_plugin->reserves_in_insert (db_plugin->cls,
                                       session,
-                                      &reserve_pub,
+                                      &details->reserve_pub,
                                       &details->amount,
                                       details->execution_date,
                                       details->account_details,
diff --git a/src/include/taler_wire_plugin.h b/src/include/taler_wire_plugin.h
index 5b2bec3..4134afc 100644
--- a/src/include/taler_wire_plugin.h
+++ b/src/include/taler_wire_plugin.h
@@ -42,6 +42,35 @@ typedef void
 
 
 /**
+ * Details about a valid wire transfer to the exchange.
+ * It is the plugin's responsibility to filter and undo
+ * invalid transfers.
+ */
+struct TALER_WIRE_TransferDetails
+{
+  /**
+   * Amount that was transferred
+   */
+  struct TALER_Amount amount;
+
+  /**
+   * Time of the the transfer
+   */
+  struct GNUNET_TIME_Absolute execution_date;
+
+  /**
+   * Reserve public key that was encoded in the wire transfer subject
+   */
+  struct TALER_ReservePublicKeyP reserve_pub;
+
+  /**
+   * The other account that was involved
+   */
+  json_t *account_details;
+};
+
+
+/**
  * Callbacks of this type are used to serve the result of asking
  * the bank for the transaction history.
  *
@@ -57,7 +86,7 @@ typedef int
                                      enum TALER_BANK_Direction dir,
                                      const void *row_off,
                                      size_t row_off_size,
-                                     const struct TALER_BANK_TransferDetails 
*details);
+                                     const struct TALER_WIRE_TransferDetails 
*details);
 
 
 /**
diff --git a/src/wire/plugin_wire_test.c b/src/wire/plugin_wire_test.c
index 6f0acce..de3a6ab 100644
--- a/src/wire/plugin_wire_test.c
+++ b/src/wire/plugin_wire_test.c
@@ -818,16 +818,36 @@ bhist_cb (void *cls,
 {
   struct TALER_WIRE_HistoryHandle *whh = cls;
   uint64_t bserial_id = GNUNET_htonll (serial_id);
+  struct TALER_WIRE_TransferDetails wd;
 
   if (MHD_HTTP_OK == http_status)
   {
+    wd.amount = details->amount;
+    wd.execution_date = details->execution_date;
+    /* 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),
+                                       &wd.reserve_pub,
+                                       sizeof (wd.reserve_pub)))
+    {
+      GNUNET_break (0);
+      /* 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
+         equally we thus don't need to undo them (and there is no API to do
+         that nicely either right now). So we don't handle this case for now. 
*/
+      return;
+    }
+    wd.account_details = details->account_details;
+
     if ( (NULL != whh->hres_cb) &&
         (GNUNET_OK !=
          whh->hres_cb (whh->hres_cb_cls,
                        dir,
                        &bserial_id,
                        sizeof (bserial_id),
-                       details)) )
+                       &wd)) )
       whh->hres_cb = NULL;
   }
   else

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



reply via email to

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