summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-11-07 19:35:29 +0100
committerChristian Grothoff <christian@grothoff.org>2021-11-07 19:35:29 +0100
commit6ffb32aaab11b8c21de8c457b438044c4a2b37c3 (patch)
tree053f24b2f4809f2b22542c7846a57c228fa05a3a
parent98c30bee88762acfc236c918fd2fa6151c0808ff (diff)
downloadexchange-6ffb32aaab11b8c21de8c457b438044c4a2b37c3.tar.gz
exchange-6ffb32aaab11b8c21de8c457b438044c4a2b37c3.tar.bz2
exchange-6ffb32aaab11b8c21de8c457b438044c4a2b37c3.zip
add required payto URI traits
-rw-r--r--src/testing/testing_api_cmd_deposits_get.c12
-rw-r--r--src/testing/testing_api_cmd_kyc_wallet_get.c11
-rw-r--r--src/testing/testing_api_cmd_withdraw.c112
3 files changed, 73 insertions, 62 deletions
diff --git a/src/testing/testing_api_cmd_deposits_get.c b/src/testing/testing_api_cmd_deposits_get.c
index e0c7f47d0..baddb2d00 100644
--- a/src/testing/testing_api_cmd_deposits_get.c
+++ b/src/testing/testing_api_cmd_deposits_get.c
@@ -62,6 +62,11 @@ struct TrackTransactionState
const char *transaction_reference;
/**
+ * Payto URI of the merchant receiving the deposit.
+ */
+ char *merchant_payto_uri;
+
+ /**
* Index of the coin involved in the transaction. Recall:
* at the exchange, the tracking is done _per coin_.
*/
@@ -222,7 +227,9 @@ track_transaction_run (void *cls,
TALER_TESTING_interpreter_fail (tts->is);
return;
}
-
+ tts->merchant_payto_uri
+ = GNUNET_strdup (json_string_value (json_object_get (wire_details,
+ "payto_uri")));
if (GNUNET_OK !=
TALER_TESTING_get_trait_contract_terms (transaction_cmd,
&contract_terms))
@@ -291,6 +298,7 @@ track_transaction_cleanup (void *cls,
TALER_EXCHANGE_deposits_get_cancel (tts->tth);
tts->tth = NULL;
}
+ GNUNET_free (tts->merchant_payto_uri);
GNUNET_free (tts);
}
@@ -314,6 +322,8 @@ track_transaction_traits (void *cls,
struct TALER_TESTING_Trait traits[] = {
TALER_TESTING_make_trait_wtid (&tts->wtid),
TALER_TESTING_make_trait_payment_target_uuid (&tts->kyc_uuid),
+ TALER_TESTING_make_trait_payto_uri (
+ (const char **) &tts->merchant_payto_uri),
TALER_TESTING_trait_end ()
};
diff --git a/src/testing/testing_api_cmd_kyc_wallet_get.c b/src/testing/testing_api_cmd_kyc_wallet_get.c
index 9fd4d22b9..e686590e8 100644
--- a/src/testing/testing_api_cmd_kyc_wallet_get.c
+++ b/src/testing/testing_api_cmd_kyc_wallet_get.c
@@ -44,6 +44,11 @@ struct KycWalletGetState
struct TALER_ReservePublicKeyP reserve_pub;
/**
+ * Payto URI of the reserve of the wallet.
+ */
+ char *reserve_payto_uri;
+
+ /**
* Command to get a reserve private key from.
*/
const char *reserve_reference;
@@ -161,6 +166,9 @@ wallet_kyc_run (void *cls,
{
GNUNET_CRYPTO_eddsa_key_create (&kwg->reserve_priv.eddsa_priv);
}
+ kwg->reserve_payto_uri
+ = TALER_payto_from_reserve (TALER_EXCHANGE_get_base_url (is->exchange),
+ &kwg->reserve_pub);
GNUNET_CRYPTO_eddsa_key_get_public (&kwg->reserve_priv.eddsa_priv,
&kwg->reserve_pub.eddsa_pub);
kwg->kwh = TALER_EXCHANGE_kyc_wallet (is->exchange,
@@ -193,6 +201,7 @@ wallet_kyc_cleanup (void *cls,
TALER_EXCHANGE_kyc_wallet_cancel (kwg->kwh);
kwg->kwh = NULL;
}
+ GNUNET_free (kwg->reserve_payto_uri);
GNUNET_free (kwg);
}
@@ -217,6 +226,8 @@ wallet_kyc_traits (void *cls,
TALER_TESTING_make_trait_reserve_priv (&kwg->reserve_priv),
TALER_TESTING_make_trait_reserve_pub (&kwg->reserve_pub),
TALER_TESTING_make_trait_payment_target_uuid (&kwg->kyc_uuid),
+ TALER_TESTING_make_trait_payto_uri (
+ (const char **) &kwg->reserve_payto_uri),
TALER_TESTING_trait_end ()
};
diff --git a/src/testing/testing_api_cmd_withdraw.c b/src/testing/testing_api_cmd_withdraw.c
index a9c599a40..ecb1a6eb6 100644
--- a/src/testing/testing_api_cmd_withdraw.c
+++ b/src/testing/testing_api_cmd_withdraw.c
@@ -85,6 +85,21 @@ struct WithdrawState
char *exchange_url;
/**
+ * URI if the reserve we are withdrawing from.
+ */
+ char *reserve_payto_uri;
+
+ /**
+ * Private key of the reserve we are withdrawing from.
+ */
+ struct TALER_ReservePrivateKeyP reserve_priv;
+
+ /**
+ * Public key of the reserve we are withdrawing from.
+ */
+ struct TALER_ReservePublicKeyP reserve_pub;
+
+ /**
* Interpreter state (during command).
*/
struct TALER_TESTING_Interpreter *is;
@@ -361,6 +376,15 @@ withdraw_run (void *cls,
TALER_TESTING_interpreter_fail (is);
return;
}
+ if (NULL == ws->exchange_url)
+ ws->exchange_url
+ = GNUNET_strdup (TALER_EXCHANGE_get_base_url (ws->is->exchange));
+ ws->reserve_priv = *rp;
+ GNUNET_CRYPTO_eddsa_key_get_public (&ws->reserve_priv.eddsa_priv,
+ &ws->reserve_pub.eddsa_pub);
+ ws->reserve_payto_uri
+ = TALER_payto_from_reserve (ws->exchange_url,
+ &ws->reserve_pub);
if (NULL == ws->reuse_coin_key_ref)
{
TALER_planchet_setup_random (&ws->ps);
@@ -463,6 +487,7 @@ withdraw_cleanup (void *cls,
ws->pk = NULL;
}
GNUNET_free (ws->exchange_url);
+ GNUNET_free (ws->reserve_payto_uri);
GNUNET_free (ws);
}
@@ -484,69 +509,34 @@ withdraw_traits (void *cls,
unsigned int index)
{
struct WithdrawState *ws = cls;
- const struct TALER_TESTING_Command *reserve_cmd;
- const struct TALER_ReservePrivateKeyP *reserve_priv;
- const struct TALER_ReservePublicKeyP *reserve_pub;
-
- /* We offer the reserve key where these coins were withdrawn
- * from. */
- reserve_cmd = TALER_TESTING_interpreter_lookup_command (ws->is,
- ws->reserve_reference);
-
- if (NULL == reserve_cmd)
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (ws->is);
- return GNUNET_SYSERR;
- }
-
- if (GNUNET_OK !=
- TALER_TESTING_get_trait_reserve_priv (reserve_cmd,
- &reserve_priv))
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (ws->is);
- return GNUNET_SYSERR;
- }
- if (GNUNET_OK !=
- TALER_TESTING_get_trait_reserve_pub (reserve_cmd,
- &reserve_pub))
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (ws->is);
- return GNUNET_SYSERR;
- }
- if (NULL == ws->exchange_url)
- ws->exchange_url
- = GNUNET_strdup (TALER_EXCHANGE_get_base_url (ws->is->exchange));
- {
- struct TALER_TESTING_Trait traits[] = {
- /* history entry MUST be first due to response code logic below! */
- TALER_TESTING_make_trait_reserve_history (&ws->reserve_history),
- TALER_TESTING_make_trait_coin_priv (0 /* only one coin */,
- &ws->ps.coin_priv),
- TALER_TESTING_make_trait_blinding_key (0 /* only one coin */,
- &ws->ps.blinding_key),
- TALER_TESTING_make_trait_denom_pub (0 /* only one coin */,
- ws->pk),
- TALER_TESTING_make_trait_denom_sig (0 /* only one coin */,
- &ws->sig),
- TALER_TESTING_make_trait_reserve_priv (reserve_priv),
- TALER_TESTING_make_trait_reserve_pub (reserve_pub),
- TALER_TESTING_make_trait_amount (&ws->amount),
- TALER_TESTING_make_trait_payment_target_uuid (&ws->kyc_uuid),
- TALER_TESTING_make_trait_exchange_url (
- (const char **) &ws->exchange_url),
- TALER_TESTING_trait_end ()
- };
-
- return TALER_TESTING_get_trait ((ws->expected_response_code == MHD_HTTP_OK)
+ struct TALER_TESTING_Trait traits[] = {
+ /* history entry MUST be first due to response code logic below! */
+ TALER_TESTING_make_trait_reserve_history (&ws->reserve_history),
+ TALER_TESTING_make_trait_coin_priv (0 /* only one coin */,
+ &ws->ps.coin_priv),
+ TALER_TESTING_make_trait_blinding_key (0 /* only one coin */,
+ &ws->ps.blinding_key),
+ TALER_TESTING_make_trait_denom_pub (0 /* only one coin */,
+ ws->pk),
+ TALER_TESTING_make_trait_denom_sig (0 /* only one coin */,
+ &ws->sig),
+ TALER_TESTING_make_trait_reserve_priv (&ws->reserve_priv),
+ TALER_TESTING_make_trait_reserve_pub (&ws->reserve_pub),
+ TALER_TESTING_make_trait_amount (&ws->amount),
+ TALER_TESTING_make_trait_payment_target_uuid (&ws->kyc_uuid),
+ TALER_TESTING_make_trait_payto_uri (
+ (const char **) &ws->reserve_payto_uri),
+ TALER_TESTING_make_trait_exchange_url (
+ (const char **) &ws->exchange_url),
+ TALER_TESTING_trait_end ()
+ };
+
+ return TALER_TESTING_get_trait ((ws->expected_response_code == MHD_HTTP_OK)
? &traits[0] /* we have reserve history */
: &traits[1],/* skip reserve history */
- ret,
- trait,
- index);
- }
+ ret,
+ trait,
+ index);
}