-add draft handler for purse merge client request
This commit is contained in:
parent
d30b7f8eeb
commit
c8c1005297
@ -1 +1 @@
|
|||||||
Subproject commit 80d310529425013bc47d1b9ab36e9b60f3ed4ed0
|
Subproject commit f794cafbc16ce0eae2826695235275e1e16c64db
|
@ -2881,7 +2881,7 @@ TALER_wallet_account_merge_sign (
|
|||||||
struct GNUNET_TIME_Timestamp merge_timestamp,
|
struct GNUNET_TIME_Timestamp merge_timestamp,
|
||||||
const struct TALER_PurseContractPublicKeyP *purse_pub,
|
const struct TALER_PurseContractPublicKeyP *purse_pub,
|
||||||
struct GNUNET_TIME_Timestamp purse_expiration,
|
struct GNUNET_TIME_Timestamp purse_expiration,
|
||||||
struct TALER_PrivateContractHashP *h_contract_terms,
|
const struct TALER_PrivateContractHashP *h_contract_terms,
|
||||||
const struct TALER_Amount *amount,
|
const struct TALER_Amount *amount,
|
||||||
uint32_t min_age,
|
uint32_t min_age,
|
||||||
const struct TALER_ReservePrivateKeyP *reserve_priv,
|
const struct TALER_ReservePrivateKeyP *reserve_priv,
|
||||||
@ -2906,7 +2906,7 @@ TALER_wallet_account_merge_verify (
|
|||||||
struct GNUNET_TIME_Timestamp merge_timestamp,
|
struct GNUNET_TIME_Timestamp merge_timestamp,
|
||||||
const struct TALER_PurseContractPublicKeyP *purse_pub,
|
const struct TALER_PurseContractPublicKeyP *purse_pub,
|
||||||
struct GNUNET_TIME_Timestamp purse_expiration,
|
struct GNUNET_TIME_Timestamp purse_expiration,
|
||||||
struct TALER_PrivateContractHashP *h_contract_terms,
|
const struct TALER_PrivateContractHashP *h_contract_terms,
|
||||||
const struct TALER_Amount *amount,
|
const struct TALER_Amount *amount,
|
||||||
uint32_t min_age,
|
uint32_t min_age,
|
||||||
const struct TALER_ReservePublicKeyP *reserve_pub,
|
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||||
|
@ -4391,6 +4391,7 @@ struct TALER_EXCHANGE_AccountMergeHandle;
|
|||||||
* @param h_contract_terms hash of the purses' contract
|
* @param h_contract_terms hash of the purses' contract
|
||||||
* @param min_age minimum age of deposits into the purse
|
* @param min_age minimum age of deposits into the purse
|
||||||
* @param purse_value_after_fees amount that should be in the purse
|
* @param purse_value_after_fees amount that should be in the purse
|
||||||
|
* @paran purse_expiration when will the purse expire
|
||||||
* @param merge_timestamp when is the merge happening (current time)
|
* @param merge_timestamp when is the merge happening (current time)
|
||||||
* @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
|
||||||
@ -4406,6 +4407,7 @@ TALER_EXCHANGE_account_merge (
|
|||||||
const struct TALER_PrivateContractHashP *h_contract_terms,
|
const struct TALER_PrivateContractHashP *h_contract_terms,
|
||||||
uint8_t min_age,
|
uint8_t min_age,
|
||||||
const struct TALER_Amount *purse_value_after_fees,
|
const struct TALER_Amount *purse_value_after_fees,
|
||||||
|
struct GNUNET_TIME_Timestamp purse_expiration,
|
||||||
struct GNUNET_TIME_Timestamp merge_timestamp,
|
struct GNUNET_TIME_Timestamp merge_timestamp,
|
||||||
TALER_EXCHANGE_AccountMergeCallback cb,
|
TALER_EXCHANGE_AccountMergeCallback cb,
|
||||||
void *cb_cls);
|
void *cb_cls);
|
||||||
|
@ -46,6 +46,7 @@ libtalerexchange_la_SOURCES = \
|
|||||||
exchange_api_management_wire_enable.c \
|
exchange_api_management_wire_enable.c \
|
||||||
exchange_api_melt.c \
|
exchange_api_melt.c \
|
||||||
exchange_api_purse_create_with_deposit.c \
|
exchange_api_purse_create_with_deposit.c \
|
||||||
|
exchange_api_purse_merge.c \
|
||||||
exchange_api_recoup.c \
|
exchange_api_recoup.c \
|
||||||
exchange_api_recoup_refresh.c \
|
exchange_api_recoup_refresh.c \
|
||||||
exchange_api_refresh_common.c exchange_api_refresh_common.h \
|
exchange_api_refresh_common.c exchange_api_refresh_common.h \
|
||||||
|
@ -70,15 +70,20 @@ struct TALER_EXCHANGE_AccountMergeHandle
|
|||||||
*/
|
*/
|
||||||
void *cb_cls;
|
void *cb_cls;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base URL of the provider hosting the @e reserve_pub.
|
||||||
|
*/
|
||||||
|
char *provider_url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expected value in the purse after fees.
|
* Expected value in the purse after fees.
|
||||||
*/
|
*/
|
||||||
struct TALER_Amount purse_value_after_fees;
|
struct TALER_Amount purse_value_after_fees;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public key of the merge capability.
|
* Public key of the reserve public key.
|
||||||
*/
|
*/
|
||||||
struct TALER_AccountMergePublicKeyP merge_pub;
|
struct TALER_ReservePublicKeyP reserve_pub;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public key of the purse.
|
* Public key of the purse.
|
||||||
@ -168,10 +173,10 @@ handle_purse_merge_finished (void *cls,
|
|||||||
etime,
|
etime,
|
||||||
pch->purse_expiration,
|
pch->purse_expiration,
|
||||||
&pch->purse_value_after_fees,
|
&pch->purse_value_after_fees,
|
||||||
&total_deposited,
|
|
||||||
&pch->purse_pub,
|
&pch->purse_pub,
|
||||||
&pch->merge_pub,
|
|
||||||
&pch->h_contract_terms,
|
&pch->h_contract_terms,
|
||||||
|
&pch->reserve_pub,
|
||||||
|
pch->provider_url,
|
||||||
&exchange_pub,
|
&exchange_pub,
|
||||||
&exchange_sig))
|
&exchange_sig))
|
||||||
{
|
{
|
||||||
@ -231,7 +236,7 @@ handle_purse_merge_finished (void *cls,
|
|||||||
}
|
}
|
||||||
pch->cb (pch->cb_cls,
|
pch->cb (pch->cb_cls,
|
||||||
&dr);
|
&dr);
|
||||||
TALER_EXCHANGE_purse_merge_with_deposit_cancel (pch);
|
TALER_EXCHANGE_account_merge_cancel (pch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -255,20 +260,22 @@ TALER_EXCHANGE_account_merge (
|
|||||||
json_t *merge_obj;
|
json_t *merge_obj;
|
||||||
CURL *eh;
|
CURL *eh;
|
||||||
struct TALER_PurseMergeSignatureP merge_sig;
|
struct TALER_PurseMergeSignatureP merge_sig;
|
||||||
struct TALER_ReserveSignatureP account_sig;
|
struct TALER_ReserveSignatureP reserve_sig;
|
||||||
char arg_str[sizeof (pch->purse_pub) * 2 + 32];
|
char arg_str[sizeof (pch->purse_pub) * 2 + 32];
|
||||||
char *url;
|
|
||||||
char *reserve_url;
|
char *reserve_url;
|
||||||
|
|
||||||
pch = GNUNET_new (struct TALER_EXCHANGE_AccountMergeHandle);
|
pch = GNUNET_new (struct TALER_EXCHANGE_AccountMergeHandle);
|
||||||
pch->exchange = exchange;
|
pch->exchange = exchange;
|
||||||
pch->cb = cb;
|
pch->cb = cb;
|
||||||
pch->cb_cls = cb_cls;
|
pch->cb_cls = cb_cls;
|
||||||
pch->merge_timestamp = merge_timestamp;
|
|
||||||
pch->purse_pub = *purse_pub;
|
pch->purse_pub = *purse_pub;
|
||||||
pch->h_contract_terms = *h_contract_terms;
|
pch->h_contract_terms = *h_contract_terms;
|
||||||
pch->purse_expiration = purse_expiration;
|
pch->purse_expiration = purse_expiration;
|
||||||
pch->purse_value_after_fees = *purse_value_after_fees;
|
pch->purse_value_after_fees = *purse_value_after_fees;
|
||||||
|
pch->provider_url = GNUNET_strdup (reserve_exchange_url);
|
||||||
|
GNUNET_CRYPTO_eddsa_key_get_public (&reserve_priv->eddsa_priv,
|
||||||
|
&pch->reserve_pub.eddsa_pub);
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_YES ==
|
GNUNET_assert (GNUNET_YES ==
|
||||||
TEAH_handle_is_ready (exchange));
|
TEAH_handle_is_ready (exchange));
|
||||||
{
|
{
|
||||||
@ -287,18 +294,14 @@ TALER_EXCHANGE_account_merge (
|
|||||||
pub_str);
|
pub_str);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
struct TALER_ReservePublicKeyP reserve_pub;
|
char pub_str[sizeof (pch->reserve_pub) * 2];
|
||||||
char pub_str[sizeof (reserve_pub) * 2];
|
|
||||||
char *end;
|
char *end;
|
||||||
const char *exchange_url;
|
const char *exchange_url;
|
||||||
bool is_http;
|
bool is_http;
|
||||||
|
|
||||||
GNUNET_CRYPTO_eddsa_key_get_public (&reserve_priv->eddsa_priv,
|
|
||||||
&reserve_pub.eddsa_pub);
|
|
||||||
|
|
||||||
end = GNUNET_STRINGS_data_to_string (
|
end = GNUNET_STRINGS_data_to_string (
|
||||||
&reserve_pub,
|
&pch->reserve_pub,
|
||||||
sizeof (reserve_pub),
|
sizeof (pch->reserve_pub),
|
||||||
pub_str,
|
pub_str,
|
||||||
sizeof (pub_str));
|
sizeof (pub_str));
|
||||||
*end = '\0';
|
*end = '\0';
|
||||||
@ -336,8 +339,6 @@ TALER_EXCHANGE_account_merge (
|
|||||||
GNUNET_free (pch);
|
GNUNET_free (pch);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
GNUNET_CRYPTO_eddsa_key_get_public (&merge_priv->eddsa_priv,
|
|
||||||
&pch->merge_pub.eddsa_pub);
|
|
||||||
TALER_wallet_purse_merge_sign (reserve_url,
|
TALER_wallet_purse_merge_sign (reserve_url,
|
||||||
merge_timestamp,
|
merge_timestamp,
|
||||||
purse_pub,
|
purse_pub,
|
||||||
@ -378,13 +379,13 @@ TALER_EXCHANGE_account_merge (
|
|||||||
}
|
}
|
||||||
json_decref (merge_obj);
|
json_decref (merge_obj);
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
||||||
"URL for purse merge with deposit: `%s'\n",
|
"URL for purse merge: `%s'\n",
|
||||||
pch->url);
|
pch->url);
|
||||||
ctx = TEAH_handle_to_context (exchange);
|
ctx = TEAH_handle_to_context (exchange);
|
||||||
pch->job = GNUNET_CURL_job_add2 (ctx,
|
pch->job = GNUNET_CURL_job_add2 (ctx,
|
||||||
eh,
|
eh,
|
||||||
pch->ctx.headers,
|
pch->ctx.headers,
|
||||||
&handle_purse_merge_deposit_finished,
|
&handle_purse_merge_finished,
|
||||||
pch);
|
pch);
|
||||||
return pch;
|
return pch;
|
||||||
}
|
}
|
||||||
@ -400,6 +401,7 @@ TALER_EXCHANGE_account_merge_cancel (
|
|||||||
pch->job = NULL;
|
pch->job = NULL;
|
||||||
}
|
}
|
||||||
GNUNET_free (pch->url);
|
GNUNET_free (pch->url);
|
||||||
|
GNUNET_free (pch->provider_url);
|
||||||
TALER_curl_easy_post_finished (&pch->ctx);
|
TALER_curl_easy_post_finished (&pch->ctx);
|
||||||
GNUNET_free (pch);
|
GNUNET_free (pch);
|
||||||
}
|
}
|
||||||
|
@ -1088,7 +1088,7 @@ TALER_wallet_account_merge_sign (
|
|||||||
struct GNUNET_TIME_Timestamp merge_timestamp,
|
struct GNUNET_TIME_Timestamp merge_timestamp,
|
||||||
const struct TALER_PurseContractPublicKeyP *purse_pub,
|
const struct TALER_PurseContractPublicKeyP *purse_pub,
|
||||||
struct GNUNET_TIME_Timestamp purse_expiration,
|
struct GNUNET_TIME_Timestamp purse_expiration,
|
||||||
struct TALER_PrivateContractHashP *h_contract_terms,
|
const struct TALER_PrivateContractHashP *h_contract_terms,
|
||||||
const struct TALER_Amount *amount,
|
const struct TALER_Amount *amount,
|
||||||
uint32_t min_age,
|
uint32_t min_age,
|
||||||
const struct TALER_ReservePrivateKeyP *reserve_priv,
|
const struct TALER_ReservePrivateKeyP *reserve_priv,
|
||||||
@ -1117,7 +1117,7 @@ TALER_wallet_account_merge_verify (
|
|||||||
struct GNUNET_TIME_Timestamp merge_timestamp,
|
struct GNUNET_TIME_Timestamp merge_timestamp,
|
||||||
const struct TALER_PurseContractPublicKeyP *purse_pub,
|
const struct TALER_PurseContractPublicKeyP *purse_pub,
|
||||||
struct GNUNET_TIME_Timestamp purse_expiration,
|
struct GNUNET_TIME_Timestamp purse_expiration,
|
||||||
struct TALER_PrivateContractHashP *h_contract_terms,
|
const struct TALER_PrivateContractHashP *h_contract_terms,
|
||||||
const struct TALER_Amount *amount,
|
const struct TALER_Amount *amount,
|
||||||
uint32_t min_age,
|
uint32_t min_age,
|
||||||
const struct TALER_ReservePublicKeyP *reserve_pub,
|
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||||
|
Loading…
Reference in New Issue
Block a user