gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-exchange] 05/07: Ask to withdraw on a expired reserv


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] 05/07: Ask to withdraw on a expired reserve.
Date: Fri, 18 May 2018 17:25:17 +0200

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

marcello pushed a commit to branch master
in repository exchange.

commit 5019bd69146824f3c6ec72e4dec1bb23dddf61ee
Author: Marcello Stanisci <address@hidden>
AuthorDate: Fri May 18 16:54:36 2018 +0200

    Ask to withdraw on a expired reserve.
---
 src/exchange-lib/exchange_api_reserve.c            | 21 ++++-------
 .../test_exchange_api_expire_reserve_now.conf      |  4 ++
 src/exchange-lib/test_exchange_api_new.c           | 43 ++++++++++++++++++++++
 src/exchange/taler-exchange-aggregator.c           |  1 +
 src/exchange/taler-exchange-httpd_responses.c      |  4 +-
 src/include/taler_exchange_service.h               |  2 +-
 6 files changed, 60 insertions(+), 15 deletions(-)

diff --git a/src/exchange-lib/exchange_api_reserve.c 
b/src/exchange-lib/exchange_api_reserve.c
index 86a83fd..e6da8cf 100644
--- a/src/exchange-lib/exchange_api_reserve.c
+++ b/src/exchange-lib/exchange_api_reserve.c
@@ -333,7 +333,7 @@ parse_reserve_history (struct TALER_EXCHANGE_Handle 
*exchange,
       struct TALER_ReserveCloseConfirmationPS rcc;
       struct GNUNET_TIME_Absolute timestamp;
       struct GNUNET_JSON_Specification closing_spec[] = {
-        GNUNET_JSON_spec_json ("receiver_account_details",
+        GNUNET_JSON_spec_string ("receiver_account_details",
                               
&rhistory[off].details.close_details.receiver_account_details),
         GNUNET_JSON_spec_fixed_auto ("wtid",
                                     &rhistory[off].details.close_details.wtid),
@@ -360,13 +360,9 @@ parse_reserve_history (struct TALER_EXCHANGE_Handle 
*exchange,
       }
       TALER_amount_hton (&rcc.closing_amount,
                         &amount);
-      if (GNUNET_OK !=
-          TALER_JSON_wire_signature_hash 
(rhistory[off].details.close_details.receiver_account_details,
-                                          &rcc.h_wire))
-      {
-        GNUNET_break (0);
-        return GNUNET_SYSERR;
-      }
+      GNUNET_CRYPTO_hash 
(rhistory[off].details.close_details.receiver_account_details,
+                          strlen 
(rhistory[off].details.close_details.receiver_account_details) + 1,
+                          &rcc.h_wire);
       rcc.wtid = rhistory[off].details.close_details.wtid;
       rcc.purpose.size = htonl (sizeof (rcc));
       rcc.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_RESERVE_CLOSED);
@@ -377,7 +373,7 @@ parse_reserve_history (struct TALER_EXCHANGE_Handle 
*exchange,
       key_state = TALER_EXCHANGE_get_keys (exchange);
       if (GNUNET_OK !=
           TALER_EXCHANGE_test_signing_key (key_state,
-                                           
&rhistory[off].details.payback_details.exchange_pub))
+                                           
&rhistory[off].details.close_details.exchange_pub))
       {
         GNUNET_break_op (0);
         return GNUNET_SYSERR;
@@ -385,8 +381,8 @@ parse_reserve_history (struct TALER_EXCHANGE_Handle 
*exchange,
       if (GNUNET_OK !=
           GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_RESERVE_CLOSED,
                                       &rcc.purpose,
-                                      
&rhistory[off].details.payback_details.exchange_sig.eddsa_signature,
-                                      
&rhistory[off].details.payback_details.exchange_pub.eddsa_pub))
+                                      
&rhistory[off].details.close_details.exchange_sig.eddsa_signature,
+                                      
&rhistory[off].details.close_details.exchange_pub.eddsa_pub))
       {
         GNUNET_break_op (0);
         return GNUNET_SYSERR;
@@ -447,8 +443,7 @@ free_rhistory (struct TALER_EXCHANGE_ReserveHistory 
*rhistory,
     case TALER_EXCHANGE_RTT_PAYBACK:
       break;
     case TALER_EXCHANGE_RTT_CLOSE:
-      if (NULL != rhistory[i].details.close_details.receiver_account_details)
-        json_decref 
(rhistory[i].details.close_details.receiver_account_details);
+      // should we free "receiver_account_details" ?
       break;
     }
   }
diff --git a/src/exchange-lib/test_exchange_api_expire_reserve_now.conf 
b/src/exchange-lib/test_exchange_api_expire_reserve_now.conf
new file mode 100644
index 0000000..05bca95
--- /dev/null
+++ b/src/exchange-lib/test_exchange_api_expire_reserve_now.conf
@@ -0,0 +1,4 @@
address@hidden@ test_exchange_api.conf
+
+[exchangedb]
+IDLE_RESERVE_EXPIRATION_TIME = 0 s
diff --git a/src/exchange-lib/test_exchange_api_new.c 
b/src/exchange-lib/test_exchange_api_new.c
index 0e48000..75f5fe6 100644
--- a/src/exchange-lib/test_exchange_api_new.c
+++ b/src/exchange-lib/test_exchange_api_new.c
@@ -42,6 +42,8 @@
  */
 #define CONFIG_FILE "test_exchange_api.conf"
 
+#define CONFIG_FILE_EXPIRE_RESERVE_NOW 
"test_exchange_api_expire_reserve_now.conf"
+
 /**
  * Is the configuration file is set to include wire format 'ebics'?
  * Requires that EBICS /history function is implemented, which it
@@ -639,6 +641,47 @@ run (void *cls,
                               MHD_HTTP_OK),
 
     /**
+     * These commands should close the reserve because
+     * the aggregator is given a config file that ovverrides
+     * the reserve expiration time (making it now-ish)
+     */
+    CMD_TRANSFER_TO_EXCHANGE
+      ("short-lived-reserve",
+       "EUR:5.01"),
+
+    TALER_TESTING_cmd_exec_wirewatch
+      ("short-lived-aggregation",
+       CONFIG_FILE_EXPIRE_RESERVE_NOW),
+
+    TALER_TESTING_cmd_exec_aggregator
+      ("close-reserves",
+       CONFIG_FILE_EXPIRE_RESERVE_NOW),
+
+    TALER_TESTING_cmd_withdraw_amount
+      ("expired-withdraw",
+       is->exchange,
+       "short-lived-reserve",
+       "EUR:1",
+       MHD_HTTP_FORBIDDEN),
+
+    /* Should also test a "insufficient funds" error
+     * after payback happened.  */
+
+    TALER_TESTING_cmd_check_bank_transfer
+      ("check_bank_short-lived_transfer",
+       exchange_url,
+       "EUR:5.01",
+       42,
+       2),
+
+    TALER_TESTING_cmd_check_bank_transfer
+      ("check_bank_short-lived_reimburse",
+       exchange_url,
+       "EUR:5",
+       2,
+       42),
+
+    /**
      * Fill reserve with EUR:2.02, as withdraw fee is 1 ct per
      * config, then withdraw two coin, partially spend one, and
      * then have the rest paid back.  Check deposit of other coin
diff --git a/src/exchange/taler-exchange-aggregator.c 
b/src/exchange/taler-exchange-aggregator.c
index b466a83..6d36369 100644
--- a/src/exchange/taler-exchange-aggregator.c
+++ b/src/exchange/taler-exchange-aggregator.c
@@ -1133,6 +1133,7 @@ expired_reserve_cb (void *cls,
                                         &wtid,
                                         left,
                                         closing_fee);
+
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Closing reserve %s over %s (%d, %d)\n",
               TALER_B2S (reserve_pub),
diff --git a/src/exchange/taler-exchange-httpd_responses.c 
b/src/exchange/taler-exchange-httpd_responses.c
index f13352e..d5d7e94 100644
--- a/src/exchange/taler-exchange-httpd_responses.c
+++ b/src/exchange/taler-exchange-httpd_responses.c
@@ -835,6 +835,7 @@ TEH_RESPONSE_compile_reserve_history (const struct 
TALER_EXCHANGEDB_ReserveHisto
       break;
     case TALER_EXCHANGEDB_RO_EXCHANGE_TO_BANK:
       {
+
        struct TALER_ReserveCloseConfirmationPS rcc;
        struct TALER_ExchangePublicKeyP pub;
        struct TALER_ExchangeSignatureP sig;
@@ -880,7 +881,7 @@ TEH_RESPONSE_compile_reserve_history (const struct 
TALER_EXCHANGEDB_ReserveHisto
        }
        GNUNET_assert (0 ==
                       json_array_append_new (json_history,
-                                             json_pack ("{s:s, s:O, s:o, s:o, 
s:o, s:o, s:o, s:o}",
+                                             json_pack ("{s:s, s:s, s:o, s:o, 
s:o, s:o, s:o, s:o}",
                                                         "type", "CLOSING",
                                                         
"receiver_account_details", pos->details.closing->receiver_account_details,
                                                         "wtid", 
GNUNET_JSON_from_data_auto (&pos->details.closing->wtid),
@@ -893,6 +894,7 @@ TEH_RESPONSE_compile_reserve_history (const struct 
TALER_EXCHANGEDB_ReserveHisto
       break;
     }
   }
+
   if (0 == (1 & ret))
   {
     GNUNET_break (0);
diff --git a/src/include/taler_exchange_service.h 
b/src/include/taler_exchange_service.h
index e5a26e2..98223fa 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -912,7 +912,7 @@ struct TALER_EXCHANGE_ReserveHistory
       /**
        * Receiver account information for the outgoing wire transfer.
        */
-      json_t *receiver_account_details;
+      const char *receiver_account_details;
 
       /**
        * Wire transfer details for the outgoing wire transfer.

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



reply via email to

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