[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] 79/152: fix FIXME by exposing deposit permission signin
From: |
gnunet |
Subject: |
[taler-exchange] 79/152: fix FIXME by exposing deposit permission signing in API instead of doing it inside of the testing logic |
Date: |
Sun, 05 Jul 2020 20:47:15 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository exchange.
commit d5ba2437f130e642da35b5320d6852552f42b6a4
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Jun 27 18:49:12 2020 +0200
fix FIXME by exposing deposit permission signing in API instead of doing it
inside of the testing logic
---
src/include/taler_exchange_service.h | 26 +++++++++++++++++
src/lib/exchange_api_deposit.c | 53 +++++++++++++++++++++++++++++++++++
src/testing/testing_api_cmd_deposit.c | 39 +++++++++-----------------
3 files changed, 92 insertions(+), 26 deletions(-)
diff --git a/src/include/taler_exchange_service.h
b/src/include/taler_exchange_service.h
index e61a07c9..02ab182f 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -744,6 +744,32 @@ TALER_EXCHANGE_wire_cancel (struct
TALER_EXCHANGE_WireHandle *wh);
/* ********************* /coins/$COIN_PUB/deposit *********************** */
+/**
+ * Sign a deposit permission. Function for wallets.
+ *
+ * @param amount the amount to be deposited
+ * @param deposit_fee the deposit fee we expect to pay
+ * @param h_wire hash of the merchant’s account details
+ * @param h_contract_terms hash of the contact of the merchant with the
customer (further details are never disclosed to the exchange)
+ * @param coin_priv coin’s private key
+ * @param wallet_timestamp timestamp when the contract was finalized, must not
be too far in the future
+ * @param merchant_pub the public key of the merchant (used to identify the
merchant for refund requests)
+ * @param refund_deadline date until which the merchant can issue a refund to
the customer via the exchange (can be zero if refunds are not allowed); must
not be after the @a wire_deadline
+ * @param[out] coin_sig set to the signature made with purpose
#TALER_SIGNATURE_WALLET_COIN_DEPOSIT
+ */
+void
+TALER_EXCHANGE_deposit_permission_sign (
+ const struct TALER_Amount *amount,
+ const struct TALER_Amount *deposit_fee,
+ const struct GNUNET_HashCode *h_wire,
+ const struct GNUNET_HashCode *h_contract_terms,
+ const struct TALER_CoinSpendPrivateKeyP *coin_priv,
+ struct GNUNET_TIME_Absolute wallet_timestamp,
+ const struct TALER_MerchantPublicKeyP *merchant_pub,
+ struct GNUNET_TIME_Absolute refund_deadline,
+ struct TALER_CoinSpendSignatureP *coin_sig);
+
+
/**
* @brief A Deposit Handle
*/
diff --git a/src/lib/exchange_api_deposit.c b/src/lib/exchange_api_deposit.c
index 27605365..351fa7a1 100644
--- a/src/lib/exchange_api_deposit.c
+++ b/src/lib/exchange_api_deposit.c
@@ -490,6 +490,59 @@ verify_signatures (const struct
TALER_EXCHANGE_DenomPublicKey *dki,
}
+/**
+ * Sign a deposit permission. Function for wallets.
+ *
+ * @param amount the amount to be deposited
+ * @param deposit_fee the deposit fee we expect to pay
+ * @param h_wire hash of the merchant’s account details
+ * @param h_contract_terms hash of the contact of the merchant with the
customer (further details are never disclosed to the exchange)
+ * @param coin_priv coin’s private key
+ * @param wallet_timestamp timestamp when the contract was finalized, must not
be too far in the future
+ * @param merchant_pub the public key of the merchant (used to identify the
merchant for refund requests)
+ * @param refund_deadline date until which the merchant can issue a refund to
the customer via the exchange (can be zero if refunds are not allowed); must
not be after the @a wire_deadline
+ * @param[out] coin_sig set to the signature made with purpose
#TALER_SIGNATURE_WALLET_COIN_DEPOSIT
+ */
+void
+TALER_EXCHANGE_deposit_permission_sign (
+ const struct TALER_Amount *amount,
+ const struct TALER_Amount *deposit_fee,
+ const struct GNUNET_HashCode *h_wire,
+ const struct GNUNET_HashCode *h_contract_terms,
+ const struct TALER_CoinSpendPrivateKeyP *coin_priv,
+ struct GNUNET_TIME_Absolute wallet_timestamp,
+ const struct TALER_MerchantPublicKeyP *merchant_pub,
+ struct GNUNET_TIME_Absolute refund_deadline,
+ struct TALER_CoinSpendSignatureP *coin_sig)
+{
+ struct TALER_DepositRequestPS dr = {
+ .purpose.size = htonl
+ (sizeof (dr)),
+ .purpose.purpose = htonl
+ (TALER_SIGNATURE_WALLET_COIN_DEPOSIT),
+ .h_contract_terms = *h_contract_terms,
+ .h_wire = *h_wire,
+ .wallet_timestamp = GNUNET_TIME_absolute_hton (wallet_timestamp),
+ .refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline),
+ .merchant = *merchant_pub
+ };
+
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_TIME_round_abs (&wallet_timestamp));
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_TIME_round_abs (&refund_deadline));
+ GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv,
+ &dr.coin_pub.eddsa_pub);
+ TALER_amount_hton (&dr.amount_with_fee,
+ amount);
+ TALER_amount_hton (&dr.deposit_fee,
+ deposit_fee);
+ GNUNET_CRYPTO_eddsa_sign (&coin_priv->eddsa_priv,
+ &dr,
+ &coin_sig->eddsa_signature);
+}
+
+
/**
* Submit a deposit permission to the exchange and get the exchange's response.
* Note that while we return the response verbatim to the caller for
diff --git a/src/testing/testing_api_cmd_deposit.c
b/src/testing/testing_api_cmd_deposit.c
index f302a218..e7a4c298 100644
--- a/src/testing/testing_api_cmd_deposit.c
+++ b/src/testing/testing_api_cmd_deposit.c
@@ -394,39 +394,26 @@ deposit_run (void *cls,
else
{
ds->refund_deadline = ds->wallet_timestamp;
- wire_deadline = GNUNET_TIME_relative_to_absolute
- (GNUNET_TIME_UNIT_ZERO);
+ wire_deadline = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_ZERO);
}
GNUNET_CRYPTO_eddsa_key_get_public (&ds->merchant_priv.eddsa_priv,
&merchant_pub.eddsa_pub);
-
(void) GNUNET_TIME_round_abs (&wire_deadline);
-
- // FIXME: This should be part of TALER_EXCHANGE_deposit()!
{
- struct TALER_DepositRequestPS dr;
-
- memset (&dr, 0, sizeof (dr));
- dr.purpose.size = htonl
- (sizeof (struct TALER_DepositRequestPS));
- dr.purpose.purpose = htonl
- (TALER_SIGNATURE_WALLET_COIN_DEPOSIT);
- dr.h_contract_terms = h_contract_terms;
+ struct GNUNET_HashCode h_wire;
+
GNUNET_assert (GNUNET_OK ==
TALER_JSON_merchant_wire_signature_hash (ds->wire_details,
- &dr.h_wire));
- dr.wallet_timestamp = GNUNET_TIME_absolute_hton (ds->wallet_timestamp);
- dr.refund_deadline = GNUNET_TIME_absolute_hton
- (ds->refund_deadline);
- TALER_amount_hton (&dr.amount_with_fee,
- &ds->amount);
- TALER_amount_hton (&dr.deposit_fee,
- &denom_pub->fee_deposit);
- dr.merchant = merchant_pub;
- dr.coin_pub = coin_pub;
- GNUNET_CRYPTO_eddsa_sign (&coin_priv->eddsa_priv,
- &dr,
- &coin_sig.eddsa_signature);
+ &h_wire));
+ TALER_EXCHANGE_deposit_permission_sign (&ds->amount,
+ &denom_pub->fee_deposit,
+ &h_wire,
+ &h_contract_terms,
+ coin_priv,
+ ds->wallet_timestamp,
+ &merchant_pub,
+ ds->refund_deadline,
+ &coin_sig);
}
ds->dh = TALER_EXCHANGE_deposit (is->exchange,
&ds->amount,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-exchange] 45/152: modify TALER_EXCHANGE_deposits_get() API to combine returned arguments into a struct (simplifies merchant later), (continued)
- [taler-exchange] 45/152: modify TALER_EXCHANGE_deposits_get() API to combine returned arguments into a struct (simplifies merchant later), gnunet, 2020/07/05
- [taler-exchange] 33/152: fix status code, gnunet, 2020/07/05
- [taler-exchange] 36/152: void basedb due to signature format change, gnunet, 2020/07/05
- [taler-exchange] 63/152: update gana, gnunet, 2020/07/05
- [taler-exchange] 67/152: add TALER_yna_to_string(), gnunet, 2020/07/05
- [taler-exchange] 65/152: sync gana, gnunet, 2020/07/05
- [taler-exchange] 70/152: synchronize with latest GANA, gnunet, 2020/07/05
- [taler-exchange] 71/152: add TALER_MHD_parse_internal_json_data(), gnunet, 2020/07/05
- [taler-exchange] 73/152: testing traits for uint32_t and GNUNET_TIME_Relative, gnunet, 2020/07/05
- [taler-exchange] 76/152: Merge branch 'protocolv8' of git+ssh://git.taler.net/exchange into protocolv8, gnunet, 2020/07/05
- [taler-exchange] 79/152: fix FIXME by exposing deposit permission signing in API instead of doing it inside of the testing logic,
gnunet <=
- [taler-exchange] 86/152: fix error reporting/handling, gnunet, 2020/07/05
- [taler-exchange] 85/152: move rewind command to exchange, add proper support for rewinding in batches, modify API to rewind to label, gnunet, 2020/07/05
- [taler-exchange] 81/152: response to CB, gnunet, 2020/07/05
- [taler-exchange] 92/152: make tests skip until we have a wallet to regen the DB, gnunet, 2020/07/05
- [taler-exchange] 95/152: modify TALER_EXCHANGE_deposits_get() API to avoid NULL pointers and need for deep copies, gnunet, 2020/07/05
- [taler-exchange] 97/152: return fee as well, gnunet, 2020/07/05
- [taler-exchange] 98/152: towards changing timestamp in deposit confirmation (tests failing), gnunet, 2020/07/05
- [taler-exchange] 90/152: implement #6181, gnunet, 2020/07/05
- [taler-exchange] 105/152: use unregister, gnunet, 2020/07/05
- [taler-exchange] 91/152: void basedb due to signature format change, gnunet, 2020/07/05