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 (346c351 -> ff0d4bb)


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated (346c351 -> ff0d4bb)
Date: Tue, 02 Jan 2018 00:07:46 +0100

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

grothoff pushed a change to branch master
in repository exchange.

    from 346c351  redefining/adding bank error codes
     new 4f2ad10  change 'f' to 'contribution' in /deposit
     new 2d08d61  refuse endian conversion for invalid amounts
     new ff0d4bb  add TALER_EXCHANGE_refund2, make sure fee test initializes 
all amounts; update ChangeLog

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 ChangeLog                                   | 10 ++++
 src/exchange-lib/exchange_api_deposit.c     |  2 +-
 src/exchange-lib/exchange_api_refund.c      | 73 +++++++++++++++++++++++++----
 src/exchange/taler-exchange-httpd_deposit.c |  6 ++-
 src/exchangedb/test_exchangedb_fees.c       |  6 +++
 src/include/taler_error_codes.h             |  1 +
 src/include/taler_exchange_service.h        | 44 +++++++++++++++++
 src/util/amount.c                           |  4 ++
 8 files changed, 136 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2948a76..2c18ef5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Mon Jan  1 23:15:37 CET 2018
+       Add TALER_EXCHANGE_refund2() API call to libtalerexchange. -CG
+
+Tue Dec 14 23:15:37 CET 2018
+       Eliminated /admin/add/incoming.
+       Add taler-bank-transfer tool. -CG
+
+Sun Dec 10 19:03:11 CET 2018
+       Implement support for optimized refresh protocol. -CG
+
 Thu Nov  2 17:39:40 CET 2017
        Limit amount values to 2^53 as we always wanted (#5167). -CG
 
diff --git a/src/exchange-lib/exchange_api_deposit.c 
b/src/exchange-lib/exchange_api_deposit.c
index d90b1aa..76e3e4d 100644
--- a/src/exchange-lib/exchange_api_deposit.c
+++ b/src/exchange-lib/exchange_api_deposit.c
@@ -454,7 +454,7 @@ TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle 
*exchange,
                            " s:o," /* merchant_pub */
                            " s:o, s:o," /* refund_deadline, wire_deadline */
                            " s:o}",     /* coin_sig */
-                           "f", TALER_JSON_from_amount (amount),
+                           "contribution", TALER_JSON_from_amount (amount),
                            "wire", wire_details,
                            "H_wire", GNUNET_JSON_from_data_auto (&h_wire),
                            "h_contract_terms", GNUNET_JSON_from_data_auto 
(h_contract_terms),
diff --git a/src/exchange-lib/exchange_api_refund.c 
b/src/exchange-lib/exchange_api_refund.c
index a39dd23..ef1d66b 100644
--- a/src/exchange-lib/exchange_api_refund.c
+++ b/src/exchange-lib/exchange_api_refund.c
@@ -243,12 +243,8 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle 
*exchange,
                       TALER_EXCHANGE_RefundResultCallback cb,
                       void *cb_cls)
 {
-  struct TALER_EXCHANGE_RefundHandle *rh;
-  struct GNUNET_CURL_Context *ctx;
   struct TALER_RefundRequestPS rr;
   struct TALER_MerchantSignatureP merchant_sig;
-  json_t *refund_obj;
-  CURL *eh;
 
   GNUNET_assert (GNUNET_YES ==
                 MAH_handle_is_ready (exchange));
@@ -267,7 +263,68 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle 
*exchange,
                  GNUNET_CRYPTO_eddsa_sign (&merchant_priv->eddsa_priv,
                                            &rr.purpose,
                                            &merchant_sig.eddsa_sig));
-  refund_obj = json_pack ("{s:o, s:o," /* amount/fee */
+  return TALER_EXCHANGE_refund2 (exchange,
+                                amount,
+                                refund_fee,
+                                h_contract_terms,
+                                coin_pub,
+                                rtransaction_id,
+                                &rr.merchant,
+                                &merchant_sig,
+                                cb,
+                                cb_cls);
+}
+
+  
+/**
+ * Submit a refund request to the exchange and get the exchange's
+ * response.  This API is used by a merchant.  Note that
+ * while we return the response verbatim to the caller for further
+ * processing, we do already verify that the response is well-formed
+ * (i.e. that signatures included in the response are all valid).  If
+ * the exchange's reply is not well-formed, we return an HTTP status code
+ * of zero to @a cb.
+ *
+ * The @a exchange must be ready to operate (i.e.  have
+ * finished processing the /keys reply).  If this check fails, we do
+ * NOT initiate the transaction with the exchange and instead return NULL.
+ *
+ * @param exchange the exchange handle; the exchange must be ready to operate
+ * @param amount the amount to be refunded; must be larger than the refund fee
+ *        (as that fee is still being subtracted), and smaller than the amount
+ *        (with deposit fee) of the original deposit contribution of this coin
+ * @param refund_fee fee applicable to this coin for the refund
+ * @param h_contract_terms hash of the contact of the merchant with the 
customer that is being refunded
+ * @param coin_pub coin’s public key of the coin from the original deposit 
operation
+ * @param rtransaction_id transaction id for the transaction between merchant 
and customer (of refunding operation);
+ *                        this is needed as we may first do a partial refund 
and later a full refund.  If both
+ *                        refunds are also over the same amount, we need the 
@a rtransaction_id to make the disjoint
+ *                        refund requests different (as requests are 
idempotent and otherwise the 2nd refund might not work).
+ * @param merchant_pub public key of the merchant
+ * @param merchant_sig signature affirming the refund from the merchant
+ * @param cb the callback to call when a reply for this request is available
+ * @param cb_cls closure for the above callback
+ * @return a handle for this request; NULL if the inputs are invalid (i.e.
+ *         signatures fail to verify).  In this case, the callback is not 
called.
+ */
+struct TALER_EXCHANGE_RefundHandle *
+TALER_EXCHANGE_refund2 (struct TALER_EXCHANGE_Handle *exchange,
+                      const struct TALER_Amount *amount,
+                      const struct TALER_Amount *refund_fee,
+                      const struct GNUNET_HashCode *h_contract_terms,
+                      const struct TALER_CoinSpendPublicKeyP *coin_pub,
+                      uint64_t rtransaction_id,
+                      const struct TALER_MerchantPublicKeyP *merchant_pub,
+                      const struct TALER_MerchantSignatureP *merchant_sig,
+                      TALER_EXCHANGE_RefundResultCallback cb,
+                      void *cb_cls)
+{
+  struct TALER_EXCHANGE_RefundHandle *rh;
+  struct GNUNET_CURL_Context *ctx;
+  json_t *refund_obj;
+  CURL *eh;
+
+refund_obj = json_pack ("{s:o, s:o," /* amount/fee */
                          " s:o, s:o," /* h_contract_terms, coin_pub */
                          " s:I," /* rtransaction id */
                          " s:o, s:o}", /* merchant_pub, merchant_sig */
@@ -276,8 +333,8 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle 
*exchange,
                          "h_contract_terms", GNUNET_JSON_from_data_auto 
(h_contract_terms),
                          "coin_pub", GNUNET_JSON_from_data_auto (coin_pub),
                          "rtransaction_id", (json_int_t) rtransaction_id,
-                         "merchant_pub", GNUNET_JSON_from_data_auto 
(&rr.merchant),
-                         "merchant_sig", GNUNET_JSON_from_data_auto 
(&merchant_sig)
+                         "merchant_pub", GNUNET_JSON_from_data_auto 
(merchant_pub),
+                         "merchant_sig", GNUNET_JSON_from_data_auto 
(merchant_sig)
                          );
   if (NULL == refund_obj)
   {
@@ -294,7 +351,7 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle 
*exchange,
   rh->depconf.purpose.purpose = htonl 
(TALER_SIGNATURE_EXCHANGE_CONFIRM_REFUND);
   rh->depconf.h_contract_terms = *h_contract_terms;
   rh->depconf.coin_pub = *coin_pub;
-  rh->depconf.merchant = rr.merchant;
+  rh->depconf.merchant = *merchant_pub;
   rh->depconf.rtransaction_id = GNUNET_htonll (rtransaction_id);
   TALER_amount_hton (&rh->depconf.refund_amount,
                      amount);
diff --git a/src/exchange/taler-exchange-httpd_deposit.c 
b/src/exchange/taler-exchange-httpd_deposit.c
index b7fb345..542c56c 100644
--- a/src/exchange/taler-exchange-httpd_deposit.c
+++ b/src/exchange/taler-exchange-httpd_deposit.c
@@ -149,6 +149,8 @@ deposit_transaction (void *cls,
   {
     struct TALER_Amount amount_without_fee;
 
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+               "/deposit replay, accepting again!\n");
     GNUNET_assert (GNUNET_OK ==
                    TALER_amount_subtract (&amount_without_fee,
                                           &deposit->amount_with_fee,
@@ -191,6 +193,8 @@ deposit_transaction (void *cls,
   if (0 < TALER_amount_cmp (&spent,
                             &dc->value))
   {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+               "Deposited coin has insufficient funds left!\n");
     *mhd_ret = TEH_RESPONSE_reply_coin_insufficient_funds (connection,
                                                           
TALER_EC_DEPOSIT_INSUFFICIENT_FUNDS,
                                                           tl);
@@ -376,7 +380,7 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh,
   struct GNUNET_HashCode my_h_wire;
   struct GNUNET_JSON_Specification spec[] = {
     GNUNET_JSON_spec_json ("wire", &wire),
-    TALER_JSON_spec_amount ("f", &deposit.amount_with_fee),
+    TALER_JSON_spec_amount ("contribution", &deposit.amount_with_fee),
     TALER_JSON_spec_denomination_public_key ("denom_pub", 
&deposit.coin.denom_pub),
     TALER_JSON_spec_denomination_signature ("ub_sig", &deposit.coin.denom_sig),
     GNUNET_JSON_spec_fixed_auto ("coin_pub", &deposit.coin.coin_pub),
diff --git a/src/exchangedb/test_exchangedb_fees.c 
b/src/exchangedb/test_exchangedb_fees.c
index 2bee774..0c9ecea 100644
--- a/src/exchangedb/test_exchangedb_fees.c
+++ b/src/exchangedb/test_exchangedb_fees.c
@@ -86,6 +86,9 @@ main (int argc,
   GNUNET_assert (GNUNET_OK ==
                  TALER_string_to_amount ("EUR:1.0",
                                          &af->wire_fee));
+  GNUNET_assert (GNUNET_OK ==
+                 TALER_string_to_amount ("EUR:1.0",
+                                         &af->closing_fee));
   sign_af (af,
            priv);
   n = GNUNET_new (struct TALER_EXCHANGEDB_AggregateFees);
@@ -94,6 +97,9 @@ main (int argc,
   GNUNET_assert (GNUNET_OK ==
                  TALER_string_to_amount ("EUR:0.1",
                                          &n->wire_fee));
+  GNUNET_assert (GNUNET_OK ==
+                 TALER_string_to_amount ("EUR:0.1",
+                                         &n->closing_fee));
   sign_af (n,
            priv);
   af->next = n;
diff --git a/src/include/taler_error_codes.h b/src/include/taler_error_codes.h
index 759e6fc..d90bd4f 100644
--- a/src/include/taler_error_codes.h
+++ b/src/include/taler_error_codes.h
@@ -1001,6 +1001,7 @@ enum TALER_ErrorCode
   TALER_EC_PAY_REFUND_DEADLINE_PAST_WIRE_TRANSFER_DEADLINE = 2114,
 
   /**
+
    * The request fails to provide coins for the payment.
    * This response is provided with HTTP status code
    * MHD_HTTP_BAD_REQUEST.
diff --git a/src/include/taler_exchange_service.h 
b/src/include/taler_exchange_service.h
index da39a17..f1af114 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -717,6 +717,50 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle 
*exchange,
 
 
 /**
+ * Submit a refund request to the exchange and get the exchange's
+ * response.  This API is used by a merchant.  Note that
+ * while we return the response verbatim to the caller for further
+ * processing, we do already verify that the response is well-formed
+ * (i.e. that signatures included in the response are all valid).  If
+ * the exchange's reply is not well-formed, we return an HTTP status code
+ * of zero to @a cb.
+ *
+ * The @a exchange must be ready to operate (i.e.  have
+ * finished processing the /keys reply).  If this check fails, we do
+ * NOT initiate the transaction with the exchange and instead return NULL.
+ *
+ * @param exchange the exchange handle; the exchange must be ready to operate
+ * @param amount the amount to be refunded; must be larger than the refund fee
+ *        (as that fee is still being subtracted), and smaller than the amount
+ *        (with deposit fee) of the original deposit contribution of this coin
+ * @param refund_fee fee applicable to this coin for the refund
+ * @param h_contract_terms hash of the contact of the merchant with the 
customer that is being refunded
+ * @param coin_pub coin’s public key of the coin from the original deposit 
operation
+ * @param rtransaction_id transaction id for the transaction between merchant 
and customer (of refunding operation);
+ *                        this is needed as we may first do a partial refund 
and later a full refund.  If both
+ *                        refunds are also over the same amount, we need the 
@a rtransaction_id to make the disjoint
+ *                        refund requests different (as requests are 
idempotent and otherwise the 2nd refund might not work).
+ * @param merchant_pub public key of the merchant
+ * @param merchant_sig signature affirming the refund from the merchant
+ * @param cb the callback to call when a reply for this request is available
+ * @param cb_cls closure for the above callback
+ * @return a handle for this request; NULL if the inputs are invalid (i.e.
+ *         signatures fail to verify).  In this case, the callback is not 
called.
+ */
+struct TALER_EXCHANGE_RefundHandle *
+TALER_EXCHANGE_refund2 (struct TALER_EXCHANGE_Handle *exchange,
+                       const struct TALER_Amount *amount,
+                       const struct TALER_Amount *refund_fee,
+                       const struct GNUNET_HashCode *h_contract_terms,
+                       const struct TALER_CoinSpendPublicKeyP *coin_pub,
+                       uint64_t rtransaction_id,
+                       const struct TALER_MerchantPublicKeyP *merchant_pub,
+                       const struct TALER_MerchantSignatureP *merchant_sig,
+                       TALER_EXCHANGE_RefundResultCallback cb,
+                       void *cb_cls);
+
+
+/**
  * Cancel a refund permission request.  This function cannot be used
  * on a request handle if a response is already served for it.  If
  * this function is called, the refund may or may not have happened.
diff --git a/src/util/amount.c b/src/util/amount.c
index 7765c74..20d0642 100644
--- a/src/util/amount.c
+++ b/src/util/amount.c
@@ -207,6 +207,8 @@ void
 TALER_amount_hton (struct TALER_AmountNBO *res,
                    const struct TALER_Amount *d)
 {
+  GNUNET_assert (GNUNET_YES ==
+                TALER_amount_is_valid (d));
   res->value = GNUNET_htonll (d->value);
   res->fraction = htonl (d->fraction);
   memcpy (res->currency,
@@ -230,6 +232,8 @@ TALER_amount_ntoh (struct TALER_Amount *res,
   memcpy (res->currency,
           dn->currency,
           TALER_CURRENCY_LEN);
+  GNUNET_assert (GNUNET_YES ==
+                TALER_amount_is_valid (res));
 }
 
 

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



reply via email to

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