[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] branch master updated: add support for wallet_data_hash
From: |
gnunet |
Subject: |
[taler-exchange] branch master updated: add support for wallet_data_hash in API |
Date: |
Mon, 11 Sep 2023 13:22: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 3b99f246 add support for wallet_data_hash in API
3b99f246 is described below
commit 3b99f24648f477a2b7afd890657bb2675e211d31
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon Sep 11 13:22:15 2023 +0200
add support for wallet_data_hash in API
---
src/bank-lib/bank_api_common.h | 2 +-
src/exchange/taler-exchange-httpd_batch-deposit.c | 9 +-
src/exchangedb/pg_do_deposit.c | 2 +-
src/include/taler_exchange_service.h | 48 +++++-----
src/include/taler_exchangedb_plugin.h | 102 +++++++++++-----------
src/lib/exchange_api_batch_deposit.c | 20 ++++-
src/lib/exchange_api_common.c | 2 +-
src/testing/testing_api_cmd_batch_deposit.c | 2 +-
src/testing/testing_api_cmd_deposit.c | 3 +-
9 files changed, 107 insertions(+), 83 deletions(-)
diff --git a/src/bank-lib/bank_api_common.h b/src/bank-lib/bank_api_common.h
index ac059e9e..e288a7e6 100644
--- a/src/bank-lib/bank_api_common.h
+++ b/src/bank-lib/bank_api_common.h
@@ -36,7 +36,7 @@
* @param auth authentication data to use
* @return #GNUNET_OK in success
*/
-int
+enum GNUNET_GenericReturnValue
TALER_BANK_setup_auth_ (CURL *easy,
const struct TALER_BANK_AuthenticationData *auth);
diff --git a/src/exchange/taler-exchange-httpd_batch-deposit.c
b/src/exchange/taler-exchange-httpd_batch-deposit.c
index ca206d23..e2aac1f2 100644
--- a/src/exchange/taler-exchange-httpd_batch-deposit.c
+++ b/src/exchange/taler-exchange-httpd_batch-deposit.c
@@ -153,9 +153,8 @@ again:
GNUNET_memcmp (&pub,
&pubi))
{
- /* note: in the future, maybe have batch
- sign API to avoid having to handle
- key rollover... */
+ /* note: in the future, maybe have batch sign API to avoid having to
+ handle key rollover... */
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Exchange public key changed during batch deposit, trying
again\n");
json_decref (arr);
@@ -511,6 +510,10 @@ TEH_handler_batch_deposit (struct TEH_RequestContext *rc,
&bd->merchant_pub),
GNUNET_JSON_spec_fixed_auto ("h_contract_terms",
&bd->h_contract_terms),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_fixed_auto ("wallet_data_hash",
+ &bd->wallet_data_hash),
+ &bd->no_wallet_data_hash),
GNUNET_JSON_spec_array_const ("coins",
&coins),
GNUNET_JSON_spec_mark_optional (
diff --git a/src/exchangedb/pg_do_deposit.c b/src/exchangedb/pg_do_deposit.c
index 3513ba2b..1e2d1c3c 100644
--- a/src/exchangedb/pg_do_deposit.c
+++ b/src/exchangedb/pg_do_deposit.c
@@ -50,7 +50,7 @@ TEH_PG_do_deposit (
GNUNET_PQ_query_param_timestamp (&bd->refund_deadline),
GNUNET_PQ_query_param_timestamp (&bd->wire_deadline),
GNUNET_PQ_query_param_auto_from_type (&bd->h_contract_terms),
- (0 == bd->has_wallet_data_hash)
+ (bd->no_wallet_data_hash)
? GNUNET_PQ_query_param_null ()
: GNUNET_PQ_query_param_auto_from_type (&bd->wallet_data_hash),
GNUNET_PQ_query_param_auto_from_type (&bd->wire_salt),
diff --git a/src/include/taler_exchange_service.h
b/src/include/taler_exchange_service.h
index a1a1e399..31f41e17 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -1054,18 +1054,16 @@ struct TALER_EXCHANGE_DepositContractDetail
{
/**
- * Execution date, until which the merchant would like the exchange to
- * settle the balance (advisory, the exchange cannot be forced to settle in
- * the past or upon very short notice, but of course a well-behaved exchange
- * will limit aggregation based on the advice received).
+ * Hash of the contact of the merchant with the customer (further details
+ * are never disclosed to the exchange)
*/
- struct GNUNET_TIME_Timestamp wire_deadline;
+ struct TALER_PrivateContractHashP h_contract_terms;
/**
- * The merchant’s account details, in the payto://-format supported by the
- * exchange.
+ * The public key of the merchant (used to identify the merchant for refund
+ * requests).
*/
- const char *merchant_payto_uri;
+ struct TALER_MerchantPublicKeyP merchant_pub;
/**
* Salt used to hash the @e merchant_payto_uri.
@@ -1073,34 +1071,42 @@ struct TALER_EXCHANGE_DepositContractDetail
struct TALER_WireSaltP wire_salt;
/**
- * Hash of the contact of the merchant with the customer (further details
- * are never disclosed to the exchange)
+ * Hash over data provided by the wallet to customize the contract.
+ * All zero if not used.
*/
- struct TALER_PrivateContractHashP h_contract_terms;
+ struct GNUNET_HashCode wallet_data_hash;
/**
- * Policy extension specific details about the deposit relevant to the
exchange.
+ * 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
+ * @e wire_deadline.
*/
- json_t *policy_details;
+ struct GNUNET_TIME_Timestamp refund_deadline;
+
+ /**
+ * Execution date, until which the merchant would like the exchange to
+ * settle the balance (advisory, the exchange cannot be forced to settle in
+ * the past or upon very short notice, but of course a well-behaved exchange
+ * will limit aggregation based on the advice received).
+ */
+ struct GNUNET_TIME_Timestamp wire_deadline;
/**
* Timestamp when the contract was finalized, must match approximately the
* current time of the exchange.
*/
- struct GNUNET_TIME_Timestamp timestamp;
+ struct GNUNET_TIME_Timestamp wallet_timestamp;
/**
- * The public key of the merchant (used to identify the merchant for refund
- * requests).
+ * The merchant’s account details, in the payto://-format supported by the
+ * exchange.
*/
- struct TALER_MerchantPublicKeyP merchant_pub;
+ const char *merchant_payto_uri;
/**
- * 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
- * @e wire_deadline.
+ * Policy extension specific details about the deposit relevant to the
exchange.
*/
- struct GNUNET_TIME_Timestamp refund_deadline;
+ const json_t *policy_details;
};
diff --git a/src/include/taler_exchangedb_plugin.h
b/src/include/taler_exchangedb_plugin.h
index 36ce7474..c3be78b4 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -1727,15 +1727,6 @@ struct TALER_EXCHANGEDB_CoinDepositInformation
*/
struct TALER_EXCHANGEDB_BatchDeposit
{
- /**
- * Array about the coins that are being deposited.
- */
- const struct TALER_EXCHANGEDB_CoinDepositInformation *cdis;
-
- /**
- * Length of the @e cdis array.
- */
- unsigned int num_cdis;
/**
* Public key of the merchant. Enables later identification
@@ -1750,20 +1741,19 @@ struct TALER_EXCHANGEDB_BatchDeposit
struct TALER_PrivateContractHashP h_contract_terms;
/**
- * Salt used by the merchant to compute "h_wire".
+ * Hash over additional inputs by the wallet.
*/
- struct TALER_WireSaltP wire_salt;
+ struct GNUNET_HashCode wallet_data_hash;
/**
- * Information about the receiver for executing the transaction. URI in
- * payto://-format.
+ * Unsalted hash over @e receiver_wire_account.
*/
- const char *receiver_wire_account;
+ struct TALER_PaytoHashP wire_target_h_payto;
/**
- * Unsalted hash over @e receiver_wire_account.
+ * Salt used by the merchant to compute "h_wire".
*/
- struct TALER_PaytoHashP wire_target_h_payto;
+ struct TALER_WireSaltP wire_salt;
/**
* Time when this request was generated. Used, for example, to
@@ -1796,19 +1786,30 @@ struct TALER_EXCHANGEDB_BatchDeposit
struct GNUNET_TIME_Timestamp wire_deadline;
/**
- * Hash over additional inputs by the wallet.
+ * Row ID of the policy details; 0 if no policy applies.
*/
- struct GNUNET_HashCode wallet_data_hash;
+ uint64_t policy_details_serial_id;
/**
- * Row ID of the policy details; 0 if no policy applies.
+ * Information about the receiver for executing the transaction. URI in
+ * payto://-format.
*/
- uint64_t policy_details_serial_id;
+ const char *receiver_wire_account;
+
+ /**
+ * Array about the coins that are being deposited.
+ */
+ const struct TALER_EXCHANGEDB_CoinDepositInformation *cdis;
/**
- * True if @e wallet_data_hash was provided
+ * Length of the @e cdis array.
+ */
+ unsigned int num_cdis;
+
+ /**
+ * False if @e wallet_data_hash was provided
*/
- bool has_wallet_data_hash;
+ bool no_wallet_data_hash;
/**
* True if further processing is blocked by policy.
@@ -1861,10 +1862,10 @@ struct TALER_EXCHANGEDB_Deposit
struct TALER_WireSaltP wire_salt;
/**
- * Information about the receiver for executing the transaction. URI in
- * payto://-format.
+ * Hash over the policy data for this deposit (remains unknown to the
+ * Exchange). Needed for the verification of the deposit's signature
*/
- char *receiver_wire_account;
+ struct TALER_ExtensionPolicyHashP h_policy;
/**
* Time when this request was generated. Used, for example, to
@@ -1907,16 +1908,17 @@ struct TALER_EXCHANGEDB_Deposit
*/
struct TALER_Amount deposit_fee;
- /*
- * True if @e policy_json was provided
+ /**
+ * Information about the receiver for executing the transaction. URI in
+ * payto://-format.
*/
- bool has_policy;
+ char *receiver_wire_account;
/**
- * Hash over the policy data for this deposit (remains unknown to the
- * Exchange). Needed for the verification of the deposit's signature
+ * True if @e policy_json was provided
*/
- struct TALER_ExtensionPolicyHashP h_policy;
+ bool has_policy;
+
};
@@ -1959,20 +1961,26 @@ struct TALER_EXCHANGEDB_DepositListEntry
struct TALER_AgeCommitmentHash h_age_commitment;
/**
- * true, if age commitment is not applicable
+ * Salt used to compute h_wire from the @e receiver_wire_account.
*/
- bool no_age_commitment;
+ struct TALER_WireSaltP wire_salt;
/**
- * Detailed information about the receiver for executing the transaction.
- * URL in payto://-format.
+ * Hash over the policy data for this deposit (remains unknown to the
+ * Exchange). Needed for the verification of the deposit's signature
*/
- char *receiver_wire_account;
+ struct TALER_ExtensionPolicyHashP h_policy;
/**
- * Salt used to compute h_wire from the @e receiver_wire_account.
+ * Fraction of the coin's remaining value to be deposited, including
+ * depositing fee (if any). The coin is identified by @e coin_pub.
*/
- struct TALER_WireSaltP wire_salt;
+ struct TALER_Amount amount_with_fee;
+
+ /**
+ * Depositing fee.
+ */
+ struct TALER_Amount deposit_fee;
/**
* Time when this request was generated. Used, for example, to
@@ -2005,27 +2013,21 @@ struct TALER_EXCHANGEDB_DepositListEntry
struct GNUNET_TIME_Timestamp wire_deadline;
/**
- * Fraction of the coin's remaining value to be deposited, including
- * depositing fee (if any). The coin is identified by @e coin_pub.
+ * Detailed information about the receiver for executing the transaction.
+ * URL in payto://-format.
*/
- struct TALER_Amount amount_with_fee;
+ char *receiver_wire_account;
/**
- * Depositing fee.
+ * true, if age commitment is not applicable
*/
- struct TALER_Amount deposit_fee;
+ bool no_age_commitment;
- /*
+ /**
* True if a policy was provided with the deposit request
*/
bool has_policy;
- /**
- * Hash over the policy data for this deposit (remains unknown to the
- * Exchange). Needed for the verification of the deposit's signature
- */
- struct TALER_ExtensionPolicyHashP h_policy;
-
/**
* Has the deposit been wired?
*/
diff --git a/src/lib/exchange_api_batch_deposit.c
b/src/lib/exchange_api_batch_deposit.c
index 1fc9c44d..3aea22b6 100644
--- a/src/lib/exchange_api_batch_deposit.c
+++ b/src/lib/exchange_api_batch_deposit.c
@@ -569,6 +569,7 @@ TALER_EXCHANGE_batch_deposit (
json_t *deposits;
CURL *eh;
struct TALER_Amount amount_without_fee;
+ const struct GNUNET_HashCode *wallet_data_hashp;
if (GNUNET_TIME_timestamp_cmp (dcd->refund_deadline,
>,
@@ -599,6 +600,7 @@ TALER_EXCHANGE_batch_deposit (
{
const struct TALER_EXCHANGE_CoinDepositDetail *cdd = &cdds[i];
const struct TALER_EXCHANGE_DenomPublicKey *dki;
+ const struct TALER_AgeCommitmentHash *h_age_commitmentp;
dki = TALER_EXCHANGE_get_denomination_key_by_hash (keys,
&cdd->h_denom_pub);
@@ -639,6 +641,10 @@ TALER_EXCHANGE_batch_deposit (
GNUNET_free (dh);
return NULL;
}
+ if (GNUNET_is_zero (&cdd->h_age_commitment))
+ h_age_commitmentp = NULL;
+ else
+ h_age_commitmentp = &cdd->h_age_commitment;
GNUNET_assert (
0 ==
json_array_append_new (
@@ -654,7 +660,7 @@ TALER_EXCHANGE_batch_deposit (
&cdd->coin_pub),
GNUNET_JSON_pack_allow_null (
GNUNET_JSON_pack_data_auto ("h_age_commitment",
- &cdd->h_age_commitment)),
+ h_age_commitmentp)),
GNUNET_JSON_pack_data_auto ("coin_sig",
&cdd->coin_sig)
)));
@@ -672,6 +678,11 @@ TALER_EXCHANGE_batch_deposit (
return NULL;
}
+ if (GNUNET_is_zero (&dcd->wallet_data_hash))
+ wallet_data_hashp = NULL;
+ else
+ wallet_data_hashp = &dcd->wallet_data_hash;
+
deposit_obj = GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("merchant_payto_uri",
dcd->merchant_payto_uri),
@@ -681,11 +692,14 @@ TALER_EXCHANGE_batch_deposit (
&dcd->h_contract_terms),
GNUNET_JSON_pack_array_steal ("coins",
deposits),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_data_auto ("wallet_data_hash",
+ wallet_data_hashp)),
GNUNET_JSON_pack_allow_null (
GNUNET_JSON_pack_object_steal ("policy_details",
- dcd->policy_details)),
+ (json_t *) dcd->policy_details)),
GNUNET_JSON_pack_timestamp ("timestamp",
- dcd->timestamp),
+ dcd->wallet_timestamp),
GNUNET_JSON_pack_data_auto ("merchant_pub",
&dcd->merchant_pub),
GNUNET_JSON_pack_allow_null (
diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c
index 08ca4b4e..ac0c4617 100644
--- a/src/lib/exchange_api_common.c
+++ b/src/lib/exchange_api_common.c
@@ -2148,7 +2148,7 @@ TALER_EXCHANGE_verify_deposit_signature_ (
&cdd->h_age_commitment,
ech,
&cdd->h_denom_pub,
- dcd->timestamp,
+ dcd->wallet_timestamp,
&dcd->merchant_pub,
dcd->refund_deadline,
&cdd->coin_pub,
diff --git a/src/testing/testing_api_cmd_batch_deposit.c
b/src/testing/testing_api_cmd_batch_deposit.c
index 77bfd4d5..c1e973cb 100644
--- a/src/testing/testing_api_cmd_batch_deposit.c
+++ b/src/testing/testing_api_cmd_batch_deposit.c
@@ -382,7 +382,7 @@ batch_deposit_run (void *cls,
.wire_salt = wire_salt,
.h_contract_terms = h_contract_terms,
.policy_details = NULL /* FIXME #7270-OEC */,
- .timestamp = ds->wallet_timestamp,
+ .wallet_timestamp = ds->wallet_timestamp,
.merchant_pub = merchant_pub,
.refund_deadline = ds->refund_deadline
};
diff --git a/src/testing/testing_api_cmd_deposit.c
b/src/testing/testing_api_cmd_deposit.c
index 5c98f91a..0e17dc2f 100644
--- a/src/testing/testing_api_cmd_deposit.c
+++ b/src/testing/testing_api_cmd_deposit.c
@@ -465,8 +465,7 @@ deposit_run (void *cls,
.merchant_payto_uri = payto_uri,
.wire_salt = wire_salt,
.h_contract_terms = h_contract_terms,
- .policy_details = NULL /* FIXME #7270-OEC */,
- .timestamp = ds->wallet_timestamp,
+ .wallet_timestamp = ds->wallet_timestamp,
.merchant_pub = merchant_pub,
.refund_deadline = ds->refund_deadline
};
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-exchange] branch master updated: add support for wallet_data_hash in API,
gnunet <=