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: implementing #4956-


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated: implementing #4956-support in libtalerexchange
Date: Wed, 19 Apr 2017 14:16:19 +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 c15ff78  implementing #4956-support in libtalerexchange
c15ff78 is described below

commit c15ff78f0c723c2d455c3d60dccc21fd321ae84e
Author: Christian Grothoff <address@hidden>
AuthorDate: Wed Apr 19 14:15:48 2017 +0200

    implementing #4956-support in libtalerexchange
---
 src/exchange-lib/exchange_api_reserve.c | 68 ++++++++++++++++++++++++++++++++-
 src/include/taler_exchange_service.h    | 16 ++++++++
 src/include/taler_signatures.h          |  5 +++
 3 files changed, 88 insertions(+), 1 deletion(-)

diff --git a/src/exchange-lib/exchange_api_reserve.c 
b/src/exchange-lib/exchange_api_reserve.c
index 98f15dc..1a1262f 100644
--- a/src/exchange-lib/exchange_api_reserve.c
+++ b/src/exchange-lib/exchange_api_reserve.c
@@ -329,7 +329,73 @@ parse_reserve_history (struct TALER_EXCHANGE_Handle 
*exchange,
     else if (0 == strcasecmp (type,
                               "CLOSING"))
     {
-      GNUNET_break (0); /* FIXME: implement with #4956 */
+      const struct TALER_EXCHANGE_Keys *key_state;
+      struct TALER_ReserveCloseConfirmationPS rcc;
+      struct GNUNET_TIME_Absolute timestamp;
+      struct GNUNET_JSON_Specification closing_spec[] = {
+        GNUNET_JSON_spec_json ("receiver_account_details",
+                              
&rhistory[off].details.close_details.receiver_account_details),
+        GNUNET_JSON_spec_json ("wire_transfer",
+                              
&rhistory[off].details.close_details.transfer_details),
+        GNUNET_JSON_spec_fixed_auto ("exchange_sig",
+                                     
&rhistory[off].details.close_details.exchange_sig),
+        GNUNET_JSON_spec_fixed_auto ("exchange_pub",
+                                     
&rhistory[off].details.close_details.exchange_pub),
+       TALER_JSON_spec_amount_nbo ("closing_fee",
+                                   &rcc.closing_fee),
+        GNUNET_JSON_spec_absolute_time_nbo ("timestamp",
+                                           &rcc.timestamp),
+        GNUNET_JSON_spec_end()
+      };
+
+      rhistory[off].type = TALER_EXCHANGE_RTT_CLOSE;
+      rhistory[off].amount = amount;
+      if (GNUNET_OK !=
+          GNUNET_JSON_parse (transaction,
+                             closing_spec,
+                             NULL, NULL))
+      {
+        GNUNET_break_op (0);
+        return GNUNET_SYSERR;
+      }
+      TALER_amount_hton (&rcc.closing_amount,
+                        &amount);
+      TALER_JSON_hash 
(rhistory[off].details.close_details.receiver_account_details,
+                      &rcc.h_wire);
+      TALER_JSON_hash 
(rhistory[off].details.close_details.receiver_account_details,
+                      &rcc.h_transfer);
+      rcc.purpose.size = htonl (sizeof (rcc));
+      rcc.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_RESERVE_CLOSED);
+      rcc.reserve_pub = *reserve_pub;
+      timestamp = GNUNET_TIME_absolute_ntoh (rcc.timestamp);
+      rhistory[off].details.close_details.timestamp = timestamp;
+
+      key_state = TALER_EXCHANGE_get_keys (exchange);
+      if (GNUNET_OK !=
+          TALER_EXCHANGE_test_signing_key (key_state,
+                                           
&rhistory[off].details.payback_details.exchange_pub))
+      {
+        GNUNET_break_op (0);
+        return GNUNET_SYSERR;
+      }
+      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))
+      {
+        GNUNET_break_op (0);
+        return GNUNET_SYSERR;
+      }
+      if (GNUNET_OK !=
+          TALER_amount_add (&total_out,
+                            &total_out,
+                            &rhistory[off].amount))
+      {
+        /* overflow in history already!? inconceivable! Bad exchange! */
+        GNUNET_break_op (0);
+        return GNUNET_SYSERR;
+      }
       /* end type==CLOSING */
     }
     else
diff --git a/src/include/taler_exchange_service.h 
b/src/include/taler_exchange_service.h
index 9e8caab..554d98b 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -767,6 +767,22 @@ struct TALER_EXCHANGE_ReserveHistory
        */
       json_t *transfer_details;
 
+      /**
+       * Signature of the coin of type
+       * #TALER_SIGNATURE_EXCHANGE_RESERVE_CLOSED.
+       */
+      struct TALER_ExchangeSignatureP exchange_sig;
+
+      /**
+       * Public key of the exchange that was used for @e exchange_sig.
+       */
+      struct TALER_ExchangePublicKeyP exchange_pub;
+
+      /**
+       * When did the wire transfer happen?
+       */
+      struct GNUNET_TIME_Absolute timestamp;
+
     } close_details;
 
   } details;
diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h
index 0b1c7ac..de9a2f7 100644
--- a/src/include/taler_signatures.h
+++ b/src/include/taler_signatures.h
@@ -1267,6 +1267,11 @@ struct TALER_ReserveCloseConfirmationPS
    * Hash of the receiver's bank account.
    */
   struct GNUNET_HashCode h_wire;
+
+  /**
+   * Hash of the transfer details.
+   */
+  struct GNUNET_HashCode h_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]