-more exchange API atomization
This commit is contained in:
parent
7bb9547599
commit
d4a65faad4
@ -5785,7 +5785,8 @@ struct TALER_EXCHANGE_ContractsGetHandle;
|
|||||||
/**
|
/**
|
||||||
* Request information about a contract from the exchange.
|
* Request information about a contract from the exchange.
|
||||||
*
|
*
|
||||||
* @param exchange exchange handle
|
* @param ctx CURL context
|
||||||
|
* @param url exchange base URL
|
||||||
* @param contract_priv private key of the contract
|
* @param contract_priv private key of the contract
|
||||||
* @param cb function to call with the exchange's result
|
* @param cb function to call with the exchange's result
|
||||||
* @param cb_cls closure for @a cb
|
* @param cb_cls closure for @a cb
|
||||||
@ -5793,7 +5794,8 @@ struct TALER_EXCHANGE_ContractsGetHandle;
|
|||||||
*/
|
*/
|
||||||
struct TALER_EXCHANGE_ContractsGetHandle *
|
struct TALER_EXCHANGE_ContractsGetHandle *
|
||||||
TALER_EXCHANGE_contract_get (
|
TALER_EXCHANGE_contract_get (
|
||||||
struct TALER_EXCHANGE_Handle *exchange,
|
struct GNUNET_CURL_Context *ctx,
|
||||||
|
const char *url,
|
||||||
const struct TALER_ContractDiffiePrivateP *contract_priv,
|
const struct TALER_ContractDiffiePrivateP *contract_priv,
|
||||||
TALER_EXCHANGE_ContractGetCallback cb,
|
TALER_EXCHANGE_ContractGetCallback cb,
|
||||||
void *cb_cls);
|
void *cb_cls);
|
||||||
@ -6637,7 +6639,8 @@ typedef void
|
|||||||
/**
|
/**
|
||||||
* Submit a request to get the list of attestable attributes for a reserve.
|
* Submit a request to get the list of attestable attributes for 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_pub public key of the reserve to get available attributes for
|
* @param reserve_pub public key of the reserve to get available attributes for
|
||||||
* @param cb the callback to call when a reply for this request is available
|
* @param cb the callback to call when a reply for this request is available
|
||||||
* @param cb_cls closure for the above callback
|
* @param cb_cls closure for the above callback
|
||||||
@ -6646,7 +6649,8 @@ typedef void
|
|||||||
*/
|
*/
|
||||||
struct TALER_EXCHANGE_ReservesGetAttestHandle *
|
struct TALER_EXCHANGE_ReservesGetAttestHandle *
|
||||||
TALER_EXCHANGE_reserves_get_attestable (
|
TALER_EXCHANGE_reserves_get_attestable (
|
||||||
struct TALER_EXCHANGE_Handle *exchange,
|
struct GNUNET_CURL_Context *ctx,
|
||||||
|
const char *url,
|
||||||
const struct TALER_ReservePublicKeyP *reserve_pub,
|
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||||
TALER_EXCHANGE_ReservesGetAttestCallback cb,
|
TALER_EXCHANGE_ReservesGetAttestCallback cb,
|
||||||
void *cb_cls);
|
void *cb_cls);
|
||||||
|
@ -38,11 +38,6 @@
|
|||||||
struct TALER_EXCHANGE_ContractsGetHandle
|
struct TALER_EXCHANGE_ContractsGetHandle
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* The connection to exchange this request handle will use
|
|
||||||
*/
|
|
||||||
struct TALER_EXCHANGE_Handle *exchange;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The url for this request.
|
* The url for this request.
|
||||||
*/
|
*/
|
||||||
@ -194,7 +189,8 @@ handle_contract_get_finished (void *cls,
|
|||||||
|
|
||||||
struct TALER_EXCHANGE_ContractsGetHandle *
|
struct TALER_EXCHANGE_ContractsGetHandle *
|
||||||
TALER_EXCHANGE_contract_get (
|
TALER_EXCHANGE_contract_get (
|
||||||
struct TALER_EXCHANGE_Handle *exchange,
|
struct GNUNET_CURL_Context *ctx,
|
||||||
|
const char *url,
|
||||||
const struct TALER_ContractDiffiePrivateP *contract_priv,
|
const struct TALER_ContractDiffiePrivateP *contract_priv,
|
||||||
TALER_EXCHANGE_ContractGetCallback cb,
|
TALER_EXCHANGE_ContractGetCallback cb,
|
||||||
void *cb_cls)
|
void *cb_cls)
|
||||||
@ -203,14 +199,7 @@ TALER_EXCHANGE_contract_get (
|
|||||||
CURL *eh;
|
CURL *eh;
|
||||||
char arg_str[sizeof (cgh->cpub) * 2 + 48];
|
char arg_str[sizeof (cgh->cpub) * 2 + 48];
|
||||||
|
|
||||||
if (GNUNET_YES !=
|
|
||||||
TEAH_handle_is_ready (exchange))
|
|
||||||
{
|
|
||||||
GNUNET_break (0);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
cgh = GNUNET_new (struct TALER_EXCHANGE_ContractsGetHandle);
|
cgh = GNUNET_new (struct TALER_EXCHANGE_ContractsGetHandle);
|
||||||
cgh->exchange = exchange;
|
|
||||||
cgh->cb = cb;
|
cgh->cb = cb;
|
||||||
cgh->cb_cls = cb_cls;
|
cgh->cb_cls = cb_cls;
|
||||||
GNUNET_CRYPTO_ecdhe_key_get_public (&contract_priv->ecdhe_priv,
|
GNUNET_CRYPTO_ecdhe_key_get_public (&contract_priv->ecdhe_priv,
|
||||||
@ -226,12 +215,13 @@ TALER_EXCHANGE_contract_get (
|
|||||||
*end = '\0';
|
*end = '\0';
|
||||||
GNUNET_snprintf (arg_str,
|
GNUNET_snprintf (arg_str,
|
||||||
sizeof (arg_str),
|
sizeof (arg_str),
|
||||||
"/contracts/%s",
|
"contracts/%s",
|
||||||
cpub_str);
|
cpub_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
cgh->url = TEAH_path_to_url (exchange,
|
cgh->url = TALER_url_join (url,
|
||||||
arg_str);
|
arg_str,
|
||||||
|
NULL);
|
||||||
if (NULL == cgh->url)
|
if (NULL == cgh->url)
|
||||||
{
|
{
|
||||||
GNUNET_free (cgh);
|
GNUNET_free (cgh);
|
||||||
@ -247,7 +237,7 @@ TALER_EXCHANGE_contract_get (
|
|||||||
GNUNET_free (cgh);
|
GNUNET_free (cgh);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
cgh->job = GNUNET_CURL_job_add (TEAH_handle_to_context (exchange),
|
cgh->job = GNUNET_CURL_job_add (ctx,
|
||||||
eh,
|
eh,
|
||||||
&handle_contract_get_finished,
|
&handle_contract_get_finished,
|
||||||
cgh);
|
cgh);
|
||||||
|
@ -226,7 +226,8 @@ TALER_EXCHANGE_reserves_get (
|
|||||||
rgh->cb_cls = cb_cls;
|
rgh->cb_cls = cb_cls;
|
||||||
rgh->reserve_pub = *reserve_pub;
|
rgh->reserve_pub = *reserve_pub;
|
||||||
rgh->url = TALER_url_join (url,
|
rgh->url = TALER_url_join (url,
|
||||||
arg_str);
|
arg_str,
|
||||||
|
NULL);
|
||||||
if (NULL == rgh->url)
|
if (NULL == rgh->url)
|
||||||
{
|
{
|
||||||
GNUNET_free (rgh);
|
GNUNET_free (rgh);
|
||||||
|
@ -38,11 +38,6 @@
|
|||||||
struct TALER_EXCHANGE_ReservesGetAttestHandle
|
struct TALER_EXCHANGE_ReservesGetAttestHandle
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* The connection to exchange this request handle will use
|
|
||||||
*/
|
|
||||||
struct TALER_EXCHANGE_Handle *exchange;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The url for this request.
|
* The url for this request.
|
||||||
*/
|
*/
|
||||||
@ -211,22 +206,16 @@ handle_reserves_get_attestable_finished (void *cls,
|
|||||||
|
|
||||||
struct TALER_EXCHANGE_ReservesGetAttestHandle *
|
struct TALER_EXCHANGE_ReservesGetAttestHandle *
|
||||||
TALER_EXCHANGE_reserves_get_attestable (
|
TALER_EXCHANGE_reserves_get_attestable (
|
||||||
struct TALER_EXCHANGE_Handle *exchange,
|
struct GNUNET_CURL_Context *ctx,
|
||||||
|
const char *url,
|
||||||
const struct TALER_ReservePublicKeyP *reserve_pub,
|
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||||
TALER_EXCHANGE_ReservesGetAttestCallback cb,
|
TALER_EXCHANGE_ReservesGetAttestCallback cb,
|
||||||
void *cb_cls)
|
void *cb_cls)
|
||||||
{
|
{
|
||||||
struct TALER_EXCHANGE_ReservesGetAttestHandle *rgah;
|
struct TALER_EXCHANGE_ReservesGetAttestHandle *rgah;
|
||||||
struct GNUNET_CURL_Context *ctx;
|
|
||||||
CURL *eh;
|
CURL *eh;
|
||||||
char arg_str[sizeof (struct TALER_ReservePublicKeyP) * 2 + 32];
|
char arg_str[sizeof (struct TALER_ReservePublicKeyP) * 2 + 32];
|
||||||
|
|
||||||
if (GNUNET_YES !=
|
|
||||||
TEAH_handle_is_ready (exchange))
|
|
||||||
{
|
|
||||||
GNUNET_break (0);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
char pub_str[sizeof (struct TALER_ReservePublicKeyP) * 2];
|
char pub_str[sizeof (struct TALER_ReservePublicKeyP) * 2];
|
||||||
char *end;
|
char *end;
|
||||||
@ -239,16 +228,16 @@ TALER_EXCHANGE_reserves_get_attestable (
|
|||||||
*end = '\0';
|
*end = '\0';
|
||||||
GNUNET_snprintf (arg_str,
|
GNUNET_snprintf (arg_str,
|
||||||
sizeof (arg_str),
|
sizeof (arg_str),
|
||||||
"/reserves-attest/%s",
|
"reserves-attest/%s",
|
||||||
pub_str);
|
pub_str);
|
||||||
}
|
}
|
||||||
rgah = GNUNET_new (struct TALER_EXCHANGE_ReservesGetAttestHandle);
|
rgah = GNUNET_new (struct TALER_EXCHANGE_ReservesGetAttestHandle);
|
||||||
rgah->exchange = exchange;
|
|
||||||
rgah->cb = cb;
|
rgah->cb = cb;
|
||||||
rgah->cb_cls = cb_cls;
|
rgah->cb_cls = cb_cls;
|
||||||
rgah->reserve_pub = *reserve_pub;
|
rgah->reserve_pub = *reserve_pub;
|
||||||
rgah->url = TEAH_path_to_url (exchange,
|
rgah->url = TALER_url_join (url,
|
||||||
arg_str);
|
arg_str,
|
||||||
|
NULL);
|
||||||
if (NULL == rgah->url)
|
if (NULL == rgah->url)
|
||||||
{
|
{
|
||||||
GNUNET_free (rgah);
|
GNUNET_free (rgah);
|
||||||
@ -262,7 +251,6 @@ TALER_EXCHANGE_reserves_get_attestable (
|
|||||||
GNUNET_free (rgah);
|
GNUNET_free (rgah);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ctx = TEAH_handle_to_context (exchange);
|
|
||||||
rgah->job = GNUNET_CURL_job_add (ctx,
|
rgah->job = GNUNET_CURL_job_add (ctx,
|
||||||
eh,
|
eh,
|
||||||
&handle_reserves_get_attestable_finished,
|
&handle_reserves_get_attestable_finished,
|
||||||
|
@ -190,13 +190,16 @@ get_run (void *cls,
|
|||||||
struct ContractGetState *ds = cls;
|
struct ContractGetState *ds = cls;
|
||||||
const struct TALER_ContractDiffiePrivateP *contract_priv;
|
const struct TALER_ContractDiffiePrivateP *contract_priv;
|
||||||
const struct TALER_TESTING_Command *ref;
|
const struct TALER_TESTING_Command *ref;
|
||||||
struct TALER_EXCHANGE_Handle *exchange
|
const char *exchange_url;
|
||||||
= TALER_TESTING_get_exchange (is);
|
|
||||||
|
|
||||||
(void) cmd;
|
(void) cmd;
|
||||||
if (NULL == exchange)
|
|
||||||
return;
|
|
||||||
ds->is = is;
|
ds->is = is;
|
||||||
|
exchange_url = TALER_TESTING_get_exchange_url (is);
|
||||||
|
if (NULL == exchange_url)
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
ref = TALER_TESTING_interpreter_lookup_command (ds->is,
|
ref = TALER_TESTING_interpreter_lookup_command (ds->is,
|
||||||
ds->contract_ref);
|
ds->contract_ref);
|
||||||
GNUNET_assert (NULL != ref);
|
GNUNET_assert (NULL != ref);
|
||||||
@ -210,7 +213,8 @@ get_run (void *cls,
|
|||||||
}
|
}
|
||||||
ds->contract_priv = *contract_priv;
|
ds->contract_priv = *contract_priv;
|
||||||
ds->dh = TALER_EXCHANGE_contract_get (
|
ds->dh = TALER_EXCHANGE_contract_get (
|
||||||
exchange,
|
TALER_TESTING_interpreter_get_context (is),
|
||||||
|
exchange_url,
|
||||||
contract_priv,
|
contract_priv,
|
||||||
&get_cb,
|
&get_cb,
|
||||||
ds);
|
ds);
|
||||||
|
@ -125,12 +125,15 @@ get_attestable_run (void *cls,
|
|||||||
const struct TALER_TESTING_Command *ref_reserve;
|
const struct TALER_TESTING_Command *ref_reserve;
|
||||||
const struct TALER_ReservePrivateKeyP *reserve_priv;
|
const struct TALER_ReservePrivateKeyP *reserve_priv;
|
||||||
const struct TALER_ReservePublicKeyP *reserve_pub;
|
const struct TALER_ReservePublicKeyP *reserve_pub;
|
||||||
struct TALER_EXCHANGE_Handle *exchange
|
const char *exchange_url;
|
||||||
= TALER_TESTING_get_exchange (is);
|
|
||||||
|
|
||||||
if (NULL == exchange)
|
|
||||||
return;
|
|
||||||
ss->is = is;
|
ss->is = is;
|
||||||
|
exchange_url = TALER_TESTING_get_exchange_url (is);
|
||||||
|
if (NULL == exchange_url)
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
ref_reserve
|
ref_reserve
|
||||||
= TALER_TESTING_interpreter_lookup_command (is,
|
= TALER_TESTING_interpreter_lookup_command (is,
|
||||||
ss->reserve_reference);
|
ss->reserve_reference);
|
||||||
@ -162,7 +165,9 @@ get_attestable_run (void *cls,
|
|||||||
}
|
}
|
||||||
ss->reserve_pub = *reserve_pub;
|
ss->reserve_pub = *reserve_pub;
|
||||||
}
|
}
|
||||||
ss->rgah = TALER_EXCHANGE_reserves_get_attestable (exchange,
|
ss->rgah = TALER_EXCHANGE_reserves_get_attestable (
|
||||||
|
TALER_TESTING_interpreter_get_context (is),
|
||||||
|
exchange_url,
|
||||||
&ss->reserve_pub,
|
&ss->reserve_pub,
|
||||||
&reserve_get_attestable_cb,
|
&reserve_get_attestable_cb,
|
||||||
ss);
|
ss);
|
||||||
|
Loading…
Reference in New Issue
Block a user