-more exchange API atomization
This commit is contained in:
parent
999dae7c5d
commit
720783b66a
@ -3286,7 +3286,8 @@ typedef void
|
||||
* This API is typically not used by anyone, it is more a threat against those
|
||||
* trying to receive a funds transfer by abusing the refresh protocol.
|
||||
*
|
||||
* @param exchange the exchange handle; the exchange must be ready to operate
|
||||
* @param ctx CURL context
|
||||
* @param url exchange base URL
|
||||
* @param coin_priv private key to request link data for
|
||||
* @param age_commitment_proof age commitment to the corresponding coin, might be NULL
|
||||
* @param link_cb the callback to call with the useful result of the
|
||||
@ -3296,7 +3297,8 @@ typedef void
|
||||
*/
|
||||
struct TALER_EXCHANGE_LinkHandle *
|
||||
TALER_EXCHANGE_link (
|
||||
struct TALER_EXCHANGE_Handle *exchange,
|
||||
struct GNUNET_CURL_Context *ctx,
|
||||
const char *url,
|
||||
const struct TALER_CoinSpendPrivateKeyP *coin_priv,
|
||||
const struct TALER_AgeCommitmentProof *age_commitment_proof,
|
||||
TALER_EXCHANGE_LinkCallback link_cb,
|
||||
@ -4025,7 +4027,8 @@ struct TALER_EXCHANGE_KycProofHandle;
|
||||
/**
|
||||
* Run interaction with exchange to provide proof of KYC status.
|
||||
*
|
||||
* @param eh exchange handle to use
|
||||
* @param ctx CURL context
|
||||
* @param url exchange base URL
|
||||
* @param h_payto hash of payto URI identifying the target account
|
||||
* @param logic name of the KYC logic to run
|
||||
* @param args additional args to pass, can be NULL
|
||||
@ -4035,7 +4038,9 @@ struct TALER_EXCHANGE_KycProofHandle;
|
||||
* @return NULL on error
|
||||
*/
|
||||
struct TALER_EXCHANGE_KycProofHandle *
|
||||
TALER_EXCHANGE_kyc_proof (struct TALER_EXCHANGE_Handle *eh,
|
||||
TALER_EXCHANGE_kyc_proof (
|
||||
struct GNUNET_CURL_Context *ctx,
|
||||
const char *url,
|
||||
const struct TALER_PaytoHashP *h_payto,
|
||||
const char *logic,
|
||||
const char *args,
|
||||
@ -4118,7 +4123,8 @@ typedef void
|
||||
* Run interaction with exchange to find out the wallet's KYC
|
||||
* identifier.
|
||||
*
|
||||
* @param eh exchange handle to use
|
||||
* @param ctx CURL context
|
||||
* @param url exchange base URL
|
||||
* @param reserve_priv wallet private key to check
|
||||
* @param balance balance (or balance threshold) crossed by the wallet
|
||||
* @param cb function to call with the result
|
||||
@ -4126,7 +4132,9 @@ typedef void
|
||||
* @return NULL on error
|
||||
*/
|
||||
struct TALER_EXCHANGE_KycWalletHandle *
|
||||
TALER_EXCHANGE_kyc_wallet (struct TALER_EXCHANGE_Handle *eh,
|
||||
TALER_EXCHANGE_kyc_wallet (
|
||||
struct GNUNET_CURL_Context *ctx,
|
||||
const char *url,
|
||||
const struct TALER_ReservePrivateKeyP *reserve_priv,
|
||||
const struct TALER_Amount *balance,
|
||||
TALER_EXCHANGE_KycWalletCallback cb,
|
||||
@ -6250,7 +6258,7 @@ struct TALER_EXCHANGE_PurseCreateMergeResponse
|
||||
union
|
||||
{
|
||||
/**
|
||||
* Detailed returned on #MHD_HTTP_OK.
|
||||
* Details returned on #MHD_HTTP_OK.
|
||||
*/
|
||||
struct
|
||||
{
|
||||
@ -6746,7 +6754,8 @@ typedef void
|
||||
/**
|
||||
* Submit a request to attest attributes about the owner of a reserve.
|
||||
*
|
||||
* @param exchange the exchange handle; the exchange must be ready to operate
|
||||
* @param ctx CURL context
|
||||
* @param url exchange base URL
|
||||
* @param reserve_priv private key of the reserve to attest
|
||||
* @param attributes_length length of the @a attributes array
|
||||
* @param attributes array of names of attributes to get attestations for
|
||||
@ -6757,7 +6766,8 @@ typedef void
|
||||
*/
|
||||
struct TALER_EXCHANGE_ReservesAttestHandle *
|
||||
TALER_EXCHANGE_reserves_attest (
|
||||
struct TALER_EXCHANGE_Handle *exchange,
|
||||
struct GNUNET_CURL_Context *ctx,
|
||||
const char *url,
|
||||
const struct TALER_ReservePrivateKeyP *reserve_priv,
|
||||
unsigned int attributes_length,
|
||||
const char *const*attributes,
|
||||
|
@ -36,11 +36,6 @@
|
||||
struct TALER_EXCHANGE_KycProofHandle
|
||||
{
|
||||
|
||||
/**
|
||||
* The connection to exchange this request handle will use
|
||||
*/
|
||||
struct TALER_EXCHANGE_Handle *exchange;
|
||||
|
||||
/**
|
||||
* The url for this request.
|
||||
*/
|
||||
@ -140,7 +135,9 @@ handle_kyc_proof_finished (void *cls,
|
||||
|
||||
|
||||
struct TALER_EXCHANGE_KycProofHandle *
|
||||
TALER_EXCHANGE_kyc_proof (struct TALER_EXCHANGE_Handle *exchange,
|
||||
TALER_EXCHANGE_kyc_proof (
|
||||
struct GNUNET_CURL_Context *ctx,
|
||||
const char *url,
|
||||
const struct TALER_PaytoHashP *h_payto,
|
||||
const char *logic,
|
||||
const char *args,
|
||||
@ -148,19 +145,12 @@ TALER_EXCHANGE_kyc_proof (struct TALER_EXCHANGE_Handle *exchange,
|
||||
void *cb_cls)
|
||||
{
|
||||
struct TALER_EXCHANGE_KycProofHandle *kph;
|
||||
struct GNUNET_CURL_Context *ctx;
|
||||
char *arg_str;
|
||||
|
||||
if (NULL == args)
|
||||
args = "";
|
||||
else
|
||||
GNUNET_assert (args[0] == '&');
|
||||
if (GNUNET_YES !=
|
||||
TEAH_handle_is_ready (exchange))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
char hstr[sizeof (struct TALER_PaytoHashP) * 2];
|
||||
char *end;
|
||||
@ -171,17 +161,17 @@ TALER_EXCHANGE_kyc_proof (struct TALER_EXCHANGE_Handle *exchange,
|
||||
sizeof (hstr));
|
||||
*end = '\0';
|
||||
GNUNET_asprintf (&arg_str,
|
||||
"/kyc-proof/%s?state=%s%s",
|
||||
"kyc-proof/%s?state=%s%s",
|
||||
logic,
|
||||
hstr,
|
||||
args);
|
||||
}
|
||||
kph = GNUNET_new (struct TALER_EXCHANGE_KycProofHandle);
|
||||
kph->exchange = exchange;
|
||||
kph->cb = cb;
|
||||
kph->cb_cls = cb_cls;
|
||||
kph->url = TEAH_path_to_url (exchange,
|
||||
arg_str);
|
||||
kph->url = TALER_url_join (url,
|
||||
arg_str,
|
||||
NULL);
|
||||
GNUNET_free (arg_str);
|
||||
if (NULL == kph->url)
|
||||
{
|
||||
@ -202,7 +192,6 @@ TALER_EXCHANGE_kyc_proof (struct TALER_EXCHANGE_Handle *exchange,
|
||||
curl_easy_setopt (kph->eh,
|
||||
CURLOPT_FOLLOWLOCATION,
|
||||
0L));
|
||||
ctx = TEAH_handle_to_context (exchange);
|
||||
kph->job = GNUNET_CURL_job_add_raw (ctx,
|
||||
kph->eh,
|
||||
NULL,
|
||||
|
@ -42,11 +42,6 @@ struct TALER_EXCHANGE_KycWalletHandle
|
||||
*/
|
||||
struct TALER_CURL_PostContext ctx;
|
||||
|
||||
/**
|
||||
* The connection to exchange this request handle will use
|
||||
*/
|
||||
struct TALER_EXCHANGE_Handle *exchange;
|
||||
|
||||
/**
|
||||
* The url for this request.
|
||||
*/
|
||||
@ -154,7 +149,9 @@ handle_kyc_wallet_finished (void *cls,
|
||||
|
||||
|
||||
struct TALER_EXCHANGE_KycWalletHandle *
|
||||
TALER_EXCHANGE_kyc_wallet (struct TALER_EXCHANGE_Handle *exchange,
|
||||
TALER_EXCHANGE_kyc_wallet (
|
||||
struct GNUNET_CURL_Context *ctx,
|
||||
const char *url,
|
||||
const struct TALER_ReservePrivateKeyP *reserve_priv,
|
||||
const struct TALER_Amount *balance,
|
||||
TALER_EXCHANGE_KycWalletCallback cb,
|
||||
@ -163,7 +160,6 @@ TALER_EXCHANGE_kyc_wallet (struct TALER_EXCHANGE_Handle *exchange,
|
||||
struct TALER_EXCHANGE_KycWalletHandle *kwh;
|
||||
CURL *eh;
|
||||
json_t *req;
|
||||
struct GNUNET_CURL_Context *ctx;
|
||||
struct TALER_ReservePublicKeyP reserve_pub;
|
||||
struct TALER_ReserveSignatureP reserve_sig;
|
||||
|
||||
@ -181,18 +177,17 @@ TALER_EXCHANGE_kyc_wallet (struct TALER_EXCHANGE_Handle *exchange,
|
||||
&reserve_sig));
|
||||
GNUNET_assert (NULL != req);
|
||||
kwh = GNUNET_new (struct TALER_EXCHANGE_KycWalletHandle);
|
||||
kwh->exchange = exchange;
|
||||
kwh->cb = cb;
|
||||
kwh->cb_cls = cb_cls;
|
||||
kwh->url = TEAH_path_to_url (exchange,
|
||||
"/kyc-wallet");
|
||||
kwh->url = TALER_url_join (url,
|
||||
"kyc-wallet",
|
||||
NULL);
|
||||
if (NULL == kwh->url)
|
||||
{
|
||||
json_decref (req);
|
||||
GNUNET_free (kwh);
|
||||
return NULL;
|
||||
}
|
||||
ctx = TEAH_handle_to_context (exchange);
|
||||
eh = TALER_EXCHANGE_curl_easy_get_ (kwh->url);
|
||||
if ( (NULL == eh) ||
|
||||
(GNUNET_OK !=
|
||||
|
@ -447,7 +447,8 @@ handle_link_finished (void *cls,
|
||||
|
||||
struct TALER_EXCHANGE_LinkHandle *
|
||||
TALER_EXCHANGE_link (
|
||||
struct TALER_EXCHANGE_Handle *exchange,
|
||||
struct GNUNET_CURL_Context *ctx,
|
||||
const char *url,
|
||||
const struct TALER_CoinSpendPrivateKeyP *coin_priv,
|
||||
const struct TALER_AgeCommitmentProof *age_commitment_proof,
|
||||
TALER_EXCHANGE_LinkCallback link_cb,
|
||||
@ -455,17 +456,9 @@ TALER_EXCHANGE_link (
|
||||
{
|
||||
struct TALER_EXCHANGE_LinkHandle *lh;
|
||||
CURL *eh;
|
||||
struct GNUNET_CURL_Context *ctx;
|
||||
struct TALER_CoinSpendPublicKeyP coin_pub;
|
||||
char arg_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2 + 32];
|
||||
|
||||
if (GNUNET_YES !=
|
||||
TEAH_handle_is_ready (exchange))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv,
|
||||
&coin_pub.eddsa_pub);
|
||||
{
|
||||
@ -480,7 +473,7 @@ TALER_EXCHANGE_link (
|
||||
*end = '\0';
|
||||
GNUNET_snprintf (arg_str,
|
||||
sizeof (arg_str),
|
||||
"/coins/%s/link",
|
||||
"coins/%s/link",
|
||||
pub_str);
|
||||
}
|
||||
lh = GNUNET_new (struct TALER_EXCHANGE_LinkHandle);
|
||||
@ -488,8 +481,9 @@ TALER_EXCHANGE_link (
|
||||
lh->link_cb_cls = link_cb_cls;
|
||||
lh->coin_priv = *coin_priv;
|
||||
lh->age_commitment_proof = age_commitment_proof;
|
||||
lh->url = TEAH_path_to_url (exchange,
|
||||
arg_str);
|
||||
lh->url = TALER_url_join (url,
|
||||
arg_str,
|
||||
NULL);
|
||||
if (NULL == lh->url)
|
||||
{
|
||||
GNUNET_free (lh);
|
||||
@ -503,7 +497,6 @@ TALER_EXCHANGE_link (
|
||||
GNUNET_free (lh);
|
||||
return NULL;
|
||||
}
|
||||
ctx = TEAH_handle_to_context (exchange);
|
||||
lh->job = GNUNET_CURL_job_add_with_ct_json (ctx,
|
||||
eh,
|
||||
&handle_link_finished,
|
||||
|
@ -38,11 +38,6 @@
|
||||
struct TALER_EXCHANGE_ReservesAttestHandle
|
||||
{
|
||||
|
||||
/**
|
||||
* The connection to exchange this request handle will use
|
||||
*/
|
||||
struct TALER_EXCHANGE_Handle *exchange;
|
||||
|
||||
/**
|
||||
* The url for this request.
|
||||
*/
|
||||
@ -131,6 +126,8 @@ handle_reserves_attest_ok (struct TALER_EXCHANGE_ReservesAttestHandle *rsh,
|
||||
GNUNET_JSON_parse_free (spec);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
/* FIXME: validate exchange_pub is actually
|
||||
a good exchange signing key */
|
||||
rsh->cb (rsh->cb_cls,
|
||||
&rs);
|
||||
rsh->cb = NULL;
|
||||
@ -228,7 +225,8 @@ handle_reserves_attest_finished (void *cls,
|
||||
|
||||
struct TALER_EXCHANGE_ReservesAttestHandle *
|
||||
TALER_EXCHANGE_reserves_attest (
|
||||
struct TALER_EXCHANGE_Handle *exchange,
|
||||
struct GNUNET_CURL_Context *ctx,
|
||||
const char *url,
|
||||
const struct TALER_ReservePrivateKeyP *reserve_priv,
|
||||
unsigned int attributes_length,
|
||||
const char *const*attributes,
|
||||
@ -236,7 +234,6 @@ TALER_EXCHANGE_reserves_attest (
|
||||
void *cb_cls)
|
||||
{
|
||||
struct TALER_EXCHANGE_ReservesAttestHandle *rsh;
|
||||
struct GNUNET_CURL_Context *ctx;
|
||||
CURL *eh;
|
||||
char arg_str[sizeof (struct TALER_ReservePublicKeyP) * 2 + 32];
|
||||
struct TALER_ReserveSignatureP reserve_sig;
|
||||
@ -248,12 +245,6 @@ TALER_EXCHANGE_reserves_attest (
|
||||
GNUNET_break (0);
|
||||
return NULL;
|
||||
}
|
||||
if (GNUNET_YES !=
|
||||
TEAH_handle_is_ready (exchange))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
return NULL;
|
||||
}
|
||||
details = json_array ();
|
||||
GNUNET_assert (NULL != details);
|
||||
for (unsigned int i = 0; i<attributes_length; i++)
|
||||
@ -263,7 +254,6 @@ TALER_EXCHANGE_reserves_attest (
|
||||
json_string (attributes[i])));
|
||||
}
|
||||
rsh = GNUNET_new (struct TALER_EXCHANGE_ReservesAttestHandle);
|
||||
rsh->exchange = exchange;
|
||||
rsh->cb = cb;
|
||||
rsh->cb_cls = cb_cls;
|
||||
GNUNET_CRYPTO_eddsa_key_get_public (&reserve_priv->eddsa_priv,
|
||||
@ -280,11 +270,12 @@ TALER_EXCHANGE_reserves_attest (
|
||||
*end = '\0';
|
||||
GNUNET_snprintf (arg_str,
|
||||
sizeof (arg_str),
|
||||
"/reserves-attest/%s",
|
||||
"reserves-attest/%s",
|
||||
pub_str);
|
||||
}
|
||||
rsh->url = TEAH_path_to_url (exchange,
|
||||
arg_str);
|
||||
rsh->url = TALER_url_join (url,
|
||||
arg_str,
|
||||
NULL);
|
||||
if (NULL == rsh->url)
|
||||
{
|
||||
json_decref (details);
|
||||
@ -328,7 +319,6 @@ TALER_EXCHANGE_reserves_attest (
|
||||
}
|
||||
json_decref (attest_obj);
|
||||
}
|
||||
ctx = TEAH_handle_to_context (exchange);
|
||||
rsh->job = GNUNET_CURL_job_add2 (ctx,
|
||||
eh,
|
||||
rsh->post_ctx.headers,
|
||||
|
@ -127,13 +127,16 @@ proof_kyc_run (void *cls,
|
||||
const struct TALER_TESTING_Command *res_cmd;
|
||||
const struct TALER_PaytoHashP *h_payto;
|
||||
char *uargs;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
const char *exchange_url;
|
||||
|
||||
(void) cmd;
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
kps->is = is;
|
||||
exchange_url = TALER_TESTING_get_exchange_url (is);
|
||||
if (NULL == exchange_url)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
return;
|
||||
}
|
||||
res_cmd = TALER_TESTING_interpreter_lookup_command (
|
||||
kps->is,
|
||||
kps->payment_target_reference);
|
||||
@ -157,7 +160,9 @@ proof_kyc_run (void *cls,
|
||||
GNUNET_asprintf (&uargs,
|
||||
"&code=%s",
|
||||
kps->code);
|
||||
kps->kph = TALER_EXCHANGE_kyc_proof (exchange,
|
||||
kps->kph = TALER_EXCHANGE_kyc_proof (
|
||||
TALER_TESTING_interpreter_get_context (is),
|
||||
exchange_url,
|
||||
h_payto,
|
||||
kps->logic,
|
||||
uargs,
|
||||
|
@ -147,13 +147,16 @@ wallet_kyc_run (void *cls,
|
||||
struct TALER_TESTING_Interpreter *is)
|
||||
{
|
||||
struct KycWalletGetState *kwg = cls;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
const char *exchange_url;
|
||||
|
||||
kwg->cmd = cmd;
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
kwg->is = is;
|
||||
exchange_url = TALER_TESTING_get_exchange_url (is);
|
||||
if (NULL == exchange_url)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
return;
|
||||
}
|
||||
if (NULL != kwg->reserve_reference)
|
||||
{
|
||||
const struct TALER_TESTING_Command *res_cmd;
|
||||
@ -185,9 +188,11 @@ wallet_kyc_run (void *cls,
|
||||
GNUNET_CRYPTO_eddsa_key_get_public (&kwg->reserve_priv.eddsa_priv,
|
||||
&kwg->reserve_pub.eddsa_pub);
|
||||
kwg->reserve_payto_uri
|
||||
= TALER_reserve_make_payto (TALER_EXCHANGE_get_base_url (exchange),
|
||||
= TALER_reserve_make_payto (exchange_url,
|
||||
&kwg->reserve_pub);
|
||||
kwg->kwh = TALER_EXCHANGE_kyc_wallet (exchange,
|
||||
kwg->kwh = TALER_EXCHANGE_kyc_wallet (
|
||||
TALER_TESTING_interpreter_get_context (is),
|
||||
exchange_url,
|
||||
&kwg->reserve_priv,
|
||||
&kwg->balance,
|
||||
&wallet_kyc_cb,
|
||||
|
@ -783,13 +783,16 @@ refresh_link_run (void *cls,
|
||||
const struct TALER_TESTING_Command *reveal_cmd;
|
||||
const struct TALER_TESTING_Command *melt_cmd;
|
||||
const struct TALER_TESTING_Command *coin_cmd;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
const char *exchange_url;
|
||||
|
||||
rls->cmd = cmd;
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
rls->is = is;
|
||||
exchange_url = TALER_TESTING_get_exchange_url (is);
|
||||
if (NULL == exchange_url)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
return;
|
||||
}
|
||||
reveal_cmd = TALER_TESTING_interpreter_lookup_command (rls->is,
|
||||
rls->reveal_reference);
|
||||
if (NULL == reveal_cmd)
|
||||
@ -832,7 +835,9 @@ refresh_link_run (void *cls,
|
||||
}
|
||||
|
||||
/* finally, use private key from withdraw sign command */
|
||||
rls->rlh = TALER_EXCHANGE_link (exchange,
|
||||
rls->rlh = TALER_EXCHANGE_link (
|
||||
TALER_TESTING_interpreter_get_context (is),
|
||||
exchange_url,
|
||||
coin_priv,
|
||||
rms->refresh_data.melt_age_commitment_proof,
|
||||
&link_cb,
|
||||
|
@ -152,12 +152,15 @@ attest_run (void *cls,
|
||||
{
|
||||
struct AttestState *ss = cls;
|
||||
const struct TALER_TESTING_Command *create_reserve;
|
||||
struct TALER_EXCHANGE_Handle *exchange
|
||||
= TALER_TESTING_get_exchange (is);
|
||||
const char *exchange_url;
|
||||
|
||||
if (NULL == exchange)
|
||||
return;
|
||||
ss->is = is;
|
||||
exchange_url = TALER_TESTING_get_exchange_url (is);
|
||||
if (NULL == exchange_url)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
return;
|
||||
}
|
||||
create_reserve
|
||||
= TALER_TESTING_interpreter_lookup_command (is,
|
||||
ss->reserve_reference);
|
||||
@ -179,7 +182,9 @@ attest_run (void *cls,
|
||||
}
|
||||
GNUNET_CRYPTO_eddsa_key_get_public (&ss->reserve_priv->eddsa_priv,
|
||||
&ss->reserve_pub.eddsa_pub);
|
||||
ss->rsh = TALER_EXCHANGE_reserves_attest (exchange,
|
||||
ss->rsh = TALER_EXCHANGE_reserves_attest (
|
||||
TALER_TESTING_interpreter_get_context (is),
|
||||
exchange_url,
|
||||
ss->reserve_priv,
|
||||
ss->attrs_len,
|
||||
ss->attrs,
|
||||
|
Loading…
Reference in New Issue
Block a user