This commit is contained in:
Christian Grothoff 2019-07-28 15:39:28 +02:00
parent fbf94ee666
commit 5b2efa2b06
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
11 changed files with 156 additions and 130 deletions

View File

@ -153,7 +153,7 @@ verify_and_execute_deposit_confirmation (struct MHD_Connection *connection,
{ {
TALER_LOG_WARNING ("Invalid signature on exchange signing key\n"); TALER_LOG_WARNING ("Invalid signature on exchange signing key\n");
return TAH_RESPONSE_reply_signature_invalid (connection, return TAH_RESPONSE_reply_signature_invalid (connection,
TALER_EC_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, TALER_EC_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID,
"master_sig"); "master_sig");
} }
@ -161,9 +161,9 @@ verify_and_execute_deposit_confirmation (struct MHD_Connection *connection,
if (GNUNET_OK != if (GNUNET_OK !=
TAH_DB_run_transaction (connection, TAH_DB_run_transaction (connection,
"persist exchange signing key", "persist exchange signing key",
&mhd_ret, &mhd_ret,
&store_exchange_signing_key_transaction, &store_exchange_signing_key_transaction,
(void *) es)) (void *) es))
return mhd_ret; return mhd_ret;
/* check deposit confirmation signature */ /* check deposit confirmation signature */
@ -185,7 +185,7 @@ verify_and_execute_deposit_confirmation (struct MHD_Connection *connection,
{ {
TALER_LOG_WARNING ("Invalid signature on /deposit-confirmation request\n"); TALER_LOG_WARNING ("Invalid signature on /deposit-confirmation request\n");
return TAH_RESPONSE_reply_signature_invalid (connection, return TAH_RESPONSE_reply_signature_invalid (connection,
TALER_EC_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, TALER_EC_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID,
"exchange_sig"); "exchange_sig");
} }
@ -193,9 +193,9 @@ verify_and_execute_deposit_confirmation (struct MHD_Connection *connection,
if (GNUNET_OK != if (GNUNET_OK !=
TAH_DB_run_transaction (connection, TAH_DB_run_transaction (connection,
"store deposit confirmation", "store deposit confirmation",
&mhd_ret, &mhd_ret,
&deposit_confirmation_transaction, &deposit_confirmation_transaction,
(void *) dc)) (void *) dc))
return mhd_ret; return mhd_ret;
return reply_deposit_confirmation_success (connection); return reply_deposit_confirmation_success (connection);
} }

View File

@ -80,7 +80,7 @@ TAH_PARSE_post_json (struct MHD_Connection *connection,
case GNUNET_JSON_PR_OUT_OF_MEMORY: case GNUNET_JSON_PR_OUT_OF_MEMORY:
return (MHD_NO == return (MHD_NO ==
TAH_RESPONSE_reply_internal_error (connection, TAH_RESPONSE_reply_internal_error (connection,
TALER_EC_PARSER_OUT_OF_MEMORY, TALER_EC_PARSER_OUT_OF_MEMORY,
"out of memory")) "out of memory"))
? GNUNET_SYSERR : GNUNET_NO; ? GNUNET_SYSERR : GNUNET_NO;
case GNUNET_JSON_PR_CONTINUE: case GNUNET_JSON_PR_CONTINUE:

View File

@ -80,8 +80,8 @@ reply_deposit_success (struct MHD_Connection *connection,
dc.merchant = *merchant; dc.merchant = *merchant;
if (GNUNET_OK != if (GNUNET_OK !=
TEH_KS_sign (&dc.purpose, TEH_KS_sign (&dc.purpose,
&pub, &pub,
&sig)) &sig))
{ {
return TEH_RESPONSE_reply_internal_error (connection, return TEH_RESPONSE_reply_internal_error (connection,
TALER_EC_EXCHANGE_BAD_CONFIGURATION, TALER_EC_EXCHANGE_BAD_CONFIGURATION,

View File

@ -189,7 +189,6 @@ verify_signatures (const struct GNUNET_HashCode *h_wire,
TALER_LOG_DEBUG ("... amount_without_fee was %s\n", TALER_LOG_DEBUG ("... amount_without_fee was %s\n",
TALER_amount2s (amount_without_fee)); TALER_amount2s (amount_without_fee));
} }
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
sv.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY); sv.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY);
@ -268,8 +267,8 @@ TALER_AUDITOR_deposit_confirmation (struct TALER_AUDITOR_Handle *auditor,
struct GNUNET_TIME_Absolute ep_expire, struct GNUNET_TIME_Absolute ep_expire,
struct GNUNET_TIME_Absolute ep_end, struct GNUNET_TIME_Absolute ep_end,
const struct TALER_MasterSignatureP *master_sig, const struct TALER_MasterSignatureP *master_sig,
TALER_AUDITOR_DepositConfirmationResultCallback cb, TALER_AUDITOR_DepositConfirmationResultCallback cb,
void *cb_cls) void *cb_cls)
{ {
struct TALER_AUDITOR_DepositConfirmationHandle *dh; struct TALER_AUDITOR_DepositConfirmationHandle *dh;
struct GNUNET_CURL_Context *ctx; struct GNUNET_CURL_Context *ctx;
@ -282,7 +281,7 @@ TALER_AUDITOR_deposit_confirmation (struct TALER_AUDITOR_Handle *auditor,
(void) GNUNET_TIME_round_abs (&ep_expire); (void) GNUNET_TIME_round_abs (&ep_expire);
(void) GNUNET_TIME_round_abs (&ep_end); (void) GNUNET_TIME_round_abs (&ep_end);
GNUNET_assert (GNUNET_YES == GNUNET_assert (GNUNET_YES ==
MAH_handle_is_ready (auditor)); MAH_handle_is_ready (auditor));
if (GNUNET_OK != if (GNUNET_OK !=
verify_signatures (h_wire, verify_signatures (h_wire,
h_contract_terms, h_contract_terms,
@ -305,26 +304,26 @@ TALER_AUDITOR_deposit_confirmation (struct TALER_AUDITOR_Handle *auditor,
deposit_confirmation_obj deposit_confirmation_obj
= json_pack ("{s:o, s:o," /* H_wire, h_contract_terms */ = json_pack ("{s:o, s:o," /* H_wire, h_contract_terms */
" s:o, s:o," /* timestamp, refund_deadline */ " s:o, s:o," /* timestamp, refund_deadline */
" s:o, s:o," /* amount_without_fees, coin_pub */ " s:o, s:o," /* amount_without_fees, coin_pub */
" s:o, s:o," /* merchant_pub, exchange_sig */ " s:o, s:o," /* merchant_pub, exchange_sig */
" s:o, s:o," /* master_pub, ep_start */ " s:o, s:o," /* master_pub, ep_start */
" s:o, s:o," /* ep_expire, ep_end */ " s:o, s:o," /* ep_expire, ep_end */
" s:o, s:o}", /* master_sig, exchange_pub */ " s:o, s:o}", /* master_sig, exchange_pub */
"h_wire", GNUNET_JSON_from_data_auto (h_wire), "h_wire", GNUNET_JSON_from_data_auto (h_wire),
"h_contract_terms", GNUNET_JSON_from_data_auto (h_contract_terms), "h_contract_terms", GNUNET_JSON_from_data_auto (h_contract_terms),
"timestamp", GNUNET_JSON_from_time_abs (timestamp), "timestamp", GNUNET_JSON_from_time_abs (timestamp),
"refund_deadline", GNUNET_JSON_from_time_abs (refund_deadline), "refund_deadline", GNUNET_JSON_from_time_abs (refund_deadline),
"amount_without_fee", TALER_JSON_from_amount (amount_without_fee), "amount_without_fee", TALER_JSON_from_amount (amount_without_fee),
"coin_pub", GNUNET_JSON_from_data_auto (coin_pub), "coin_pub", GNUNET_JSON_from_data_auto (coin_pub),
"merchant_pub", GNUNET_JSON_from_data_auto (merchant_pub), "merchant_pub", GNUNET_JSON_from_data_auto (merchant_pub),
"exchange_sig", GNUNET_JSON_from_data_auto (exchange_sig), "exchange_sig", GNUNET_JSON_from_data_auto (exchange_sig),
"master_pub", GNUNET_JSON_from_data_auto (master_pub), "master_pub", GNUNET_JSON_from_data_auto (master_pub),
"ep_start", GNUNET_JSON_from_time_abs (ep_start), "ep_start", GNUNET_JSON_from_time_abs (ep_start),
"ep_expire", GNUNET_JSON_from_time_abs (ep_expire), "ep_expire", GNUNET_JSON_from_time_abs (ep_expire),
"ep_end", GNUNET_JSON_from_time_abs (ep_end), "ep_end", GNUNET_JSON_from_time_abs (ep_end),
"master_sig", GNUNET_JSON_from_data_auto (master_sig), "master_sig", GNUNET_JSON_from_data_auto (master_sig),
"exchange_pub", GNUNET_JSON_from_data_auto (exchange_pub)); "exchange_pub", GNUNET_JSON_from_data_auto (exchange_pub));
if (NULL == deposit_confirmation_obj) if (NULL == deposit_confirmation_obj)
{ {
@ -360,11 +359,11 @@ TALER_AUDITOR_deposit_confirmation (struct TALER_AUDITOR_Handle *auditor,
"URL for deposit-confirmation: `%s'\n", "URL for deposit-confirmation: `%s'\n",
dh->url); dh->url);
ctx = MAH_handle_to_context (auditor); ctx = MAH_handle_to_context (auditor);
dh->job = GNUNET_CURL_job_add (ctx, dh->job = GNUNET_CURL_job_add2 (ctx,
eh, eh,
GNUNET_YES, dh->ctx.headers,
&handle_deposit_confirmation_finished, &handle_deposit_confirmation_finished,
dh); dh);
return dh; return dh;
} }

View File

@ -385,9 +385,10 @@ int
MAH_handle_is_ready (struct TALER_AUDITOR_Handle *h) MAH_handle_is_ready (struct TALER_AUDITOR_Handle *h)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Checking if auditor %p is now ready: %s\n", "Checking if auditor %p (%s) is now ready: %s\n",
h, h,
(MHD_VERSION == h->state) ? "yes" : "no"); h->url,
(MHD_VERSION == h->state) ? "yes" : "no");
return (MHS_VERSION == h->state) ? GNUNET_YES : GNUNET_NO; return (MHS_VERSION == h->state) ? GNUNET_YES : GNUNET_NO;
} }
@ -453,15 +454,12 @@ MAH_path_to_url2 (const char *base_url,
*/ */
struct TALER_AUDITOR_Handle * struct TALER_AUDITOR_Handle *
TALER_AUDITOR_connect (struct GNUNET_CURL_Context *ctx, TALER_AUDITOR_connect (struct GNUNET_CURL_Context *ctx,
const char *url, const char *url,
TALER_AUDITOR_VersionCallback version_cb, TALER_AUDITOR_VersionCallback version_cb,
void *version_cb_cls) void *version_cb_cls)
{ {
struct TALER_AUDITOR_Handle *auditor; struct TALER_AUDITOR_Handle *auditor;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Connecting to auditor at URL `%s'.\n",
url);
/* Disable 100 continue processing */ /* Disable 100 continue processing */
GNUNET_break (GNUNET_OK == GNUNET_break (GNUNET_OK ==
GNUNET_CURL_append_header (ctx, GNUNET_CURL_append_header (ctx,
@ -472,7 +470,11 @@ TALER_AUDITOR_connect (struct GNUNET_CURL_Context *ctx,
auditor->version_cb = version_cb; auditor->version_cb = version_cb;
auditor->version_cb_cls = version_cb_cls; auditor->version_cb_cls = version_cb_cls;
auditor->retry_task = GNUNET_SCHEDULER_add_now (&request_version, auditor->retry_task = GNUNET_SCHEDULER_add_now (&request_version,
auditor); auditor);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Connecting to auditor at URL `%s' (%p).\n",
url,
auditor);
return auditor; return auditor;
} }
@ -520,6 +522,10 @@ request_version (void *cls)
void void
TALER_AUDITOR_disconnect (struct TALER_AUDITOR_Handle *auditor) TALER_AUDITOR_disconnect (struct TALER_AUDITOR_Handle *auditor)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Disconnecting from auditor at URL `%s' (%p).\n",
auditor->url,
auditor);
if (NULL != auditor->vr) if (NULL != auditor->vr)
{ {
GNUNET_CURL_job_cancel (auditor->vr->job); GNUNET_CURL_job_cancel (auditor->vr->job);

View File

@ -37,8 +37,8 @@
*/ */
int int
TALER_EXCHANGE_verify_coin_history (const char *currency, TALER_EXCHANGE_verify_coin_history (const char *currency,
const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_CoinSpendPublicKeyP *coin_pub,
json_t *history, json_t *history,
struct TALER_Amount *total) struct TALER_Amount *total)
{ {
size_t len; size_t len;
@ -241,8 +241,8 @@ TALER_EXCHANGE_verify_coin_history (const char *currency,
&exchange_pub), &exchange_pub),
GNUNET_JSON_spec_fixed_auto ("reserve_pub", GNUNET_JSON_spec_fixed_auto ("reserve_pub",
&pc.reserve_pub), &pc.reserve_pub),
GNUNET_JSON_spec_absolute_time_nbo ("timestamp", GNUNET_JSON_spec_absolute_time_nbo ("timestamp",
&pc.timestamp), &pc.timestamp),
GNUNET_JSON_spec_end() GNUNET_JSON_spec_end()
}; };
@ -335,7 +335,7 @@ TALER_EXCHANGE_verify_coin_history (const char *currency,
*/ */
const struct TALER_EXCHANGE_SigningPublicKey * const struct TALER_EXCHANGE_SigningPublicKey *
TALER_EXCHANGE_get_exchange_signing_key_info (const struct TALER_EXCHANGE_Keys *keys, TALER_EXCHANGE_get_exchange_signing_key_info (const struct TALER_EXCHANGE_Keys *keys,
const struct TALER_ExchangePublicKeyP *exchange_pub) const struct TALER_ExchangePublicKeyP *exchange_pub)
{ {
for (unsigned int i=0;i<keys->num_sign_keys;i++) for (unsigned int i=0;i<keys->num_sign_keys;i++)
{ {

View File

@ -600,10 +600,10 @@ TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle *exchange,
dh->url); dh->url);
ctx = TEAH_handle_to_context (exchange); ctx = TEAH_handle_to_context (exchange);
dh->job = GNUNET_CURL_job_add2 (ctx, dh->job = GNUNET_CURL_job_add2 (ctx,
eh, eh,
dh->ctx.headers, dh->ctx.headers,
&handle_deposit_finished, &handle_deposit_finished,
dh); dh);
return dh; return dh;
} }

View File

@ -31,8 +31,7 @@
/** /**
* Add the @a body as POST data to the easy handle in * Add the @a body as POST data to the easy handle in @a ctx.
* @a ctx.
* *
* @param ctx[in,out] a request context (updated) * @param ctx[in,out] a request context (updated)
* @param eh easy handle to use * @param eh easy handle to use
@ -41,8 +40,8 @@
*/ */
int int
TALER_curl_easy_post (struct TEAH_PostContext *ctx, TALER_curl_easy_post (struct TEAH_PostContext *ctx,
CURL *eh, CURL *eh,
const json_t *body) const json_t *body)
{ {
char *str; char *str;
size_t slen; size_t slen;

View File

@ -555,47 +555,38 @@ run (void *cls,
"massive-reserve", "massive-reserve",
"EUR:1", "EUR:1",
MHD_HTTP_OK), MHD_HTTP_OK),
TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-2", TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-2",
"massive-reserve", "massive-reserve",
"EUR:1", "EUR:1",
MHD_HTTP_OK), MHD_HTTP_OK),
TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-3", TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-3",
"massive-reserve", "massive-reserve",
"EUR:1", "EUR:1",
MHD_HTTP_OK), MHD_HTTP_OK),
TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-4", TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-4",
"massive-reserve", "massive-reserve",
"EUR:1", "EUR:1",
MHD_HTTP_OK), MHD_HTTP_OK),
TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-5", TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-5",
"massive-reserve", "massive-reserve",
"EUR:1", "EUR:1",
MHD_HTTP_OK), MHD_HTTP_OK),
TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-6", TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-6",
"massive-reserve", "massive-reserve",
"EUR:1", "EUR:1",
MHD_HTTP_OK), MHD_HTTP_OK),
TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-7", TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-7",
"massive-reserve", "massive-reserve",
"EUR:1", "EUR:1",
MHD_HTTP_OK), MHD_HTTP_OK),
TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-8", TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-8",
"massive-reserve", "massive-reserve",
"EUR:1", "EUR:1",
MHD_HTTP_OK), MHD_HTTP_OK),
TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-9", TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-9",
"massive-reserve", "massive-reserve",
"EUR:1", "EUR:1",
MHD_HTTP_OK), MHD_HTTP_OK),
TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-10", TALER_TESTING_cmd_withdraw_amount ("massive-withdraw-10",
"massive-reserve", "massive-reserve",
"EUR:1", "EUR:1",
@ -710,6 +701,12 @@ run (void *cls,
GNUNET_TIME_UNIT_ZERO, GNUNET_TIME_UNIT_ZERO,
"EUR:1", "EUR:1",
MHD_HTTP_OK), MHD_HTTP_OK),
TALER_TESTING_cmd_deposit_confirmation ("deposit-confirmation",
is->auditor,
"massive-deposit-10",
0,
"EUR:0.99",
MHD_HTTP_OK),
CMD_RUN_AUDITOR("massive-auditor"), CMD_RUN_AUDITOR("massive-auditor"),
TALER_TESTING_cmd_end () TALER_TESTING_cmd_end ()
@ -752,7 +749,6 @@ int
main (int argc, main (int argc,
char * const *argv) char * const *argv)
{ {
/* These environment variables get in the way... */ /* These environment variables get in the way... */
unsetenv ("XDG_DATA_HOME"); unsetenv ("XDG_DATA_HOME");
unsetenv ("XDG_CONFIG_HOME"); unsetenv ("XDG_CONFIG_HOME");
@ -770,8 +766,8 @@ main (int argc,
* fetches the port number from config in order to see * fetches the port number from config in order to see
* if it's available. */ * if it's available. */
switch (TALER_TESTING_prepare_exchange (CONFIG_FILE, switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
&auditor_url, &auditor_url,
&exchange_url)) &exchange_url))
{ {
case GNUNET_SYSERR: case GNUNET_SYSERR:
GNUNET_break (0); GNUNET_break (0);

View File

@ -66,10 +66,9 @@ struct DepositState
json_t *contract_terms; json_t *contract_terms;
/** /**
* Relative time (to add to 'now') to compute the refund * Refund deadline. Zero for no refunds.
* deadline. Zero for no refunds.
*/ */
struct GNUNET_TIME_Relative refund_deadline; struct GNUNET_TIME_Absolute refund_deadline;
/** /**
* Set (by the interpreter) to a fresh private key. This * Set (by the interpreter) to a fresh private key. This
@ -82,6 +81,11 @@ struct DepositState
*/ */
struct TALER_EXCHANGE_DepositHandle *dh; struct TALER_EXCHANGE_DepositHandle *dh;
/**
* Timestamp of the /deposit operation.
*/
struct GNUNET_TIME_Absolute timestamp;
/** /**
* Interpreter state. * Interpreter state.
*/ */
@ -245,9 +249,7 @@ deposit_run (void *cls,
const struct TALER_EXCHANGE_DenomPublicKey *denom_pub; const struct TALER_EXCHANGE_DenomPublicKey *denom_pub;
const struct TALER_DenominationSignature *denom_pub_sig; const struct TALER_DenominationSignature *denom_pub_sig;
struct TALER_CoinSpendSignatureP coin_sig; struct TALER_CoinSpendSignatureP coin_sig;
struct GNUNET_TIME_Absolute refund_deadline;
struct GNUNET_TIME_Absolute wire_deadline; struct GNUNET_TIME_Absolute wire_deadline;
struct GNUNET_TIME_Absolute timestamp;
struct GNUNET_CRYPTO_EddsaPrivateKey *merchant_priv; struct GNUNET_CRYPTO_EddsaPrivateKey *merchant_priv;
struct TALER_MerchantPublicKeyP merchant_pub; struct TALER_MerchantPublicKeyP merchant_pub;
struct GNUNET_HashCode h_contract_terms; struct GNUNET_HashCode h_contract_terms;
@ -307,17 +309,17 @@ deposit_run (void *cls,
ds->merchant_priv.eddsa_priv = *merchant_priv; ds->merchant_priv.eddsa_priv = *merchant_priv;
GNUNET_free (merchant_priv); GNUNET_free (merchant_priv);
if (0 != ds->refund_deadline.rel_value_us) if (0 != ds->refund_deadline.abs_value_us)
{ {
refund_deadline = GNUNET_TIME_relative_to_absolute struct GNUNET_TIME_Relative refund_deadline;
(ds->refund_deadline);
refund_deadline = GNUNET_TIME_absolute_get_remaining (ds->refund_deadline);
wire_deadline = GNUNET_TIME_relative_to_absolute wire_deadline = GNUNET_TIME_relative_to_absolute
(GNUNET_TIME_relative_multiply (GNUNET_TIME_relative_multiply (refund_deadline, 2));
(ds->refund_deadline, 2));
} }
else else
{ {
refund_deadline = GNUNET_TIME_UNIT_ZERO_ABS; ds->refund_deadline = ds->timestamp;
wire_deadline = GNUNET_TIME_relative_to_absolute wire_deadline = GNUNET_TIME_relative_to_absolute
(GNUNET_TIME_UNIT_ZERO); (GNUNET_TIME_UNIT_ZERO);
} }
@ -325,10 +327,7 @@ deposit_run (void *cls,
(&ds->merchant_priv.eddsa_priv, (&ds->merchant_priv.eddsa_priv,
&merchant_pub.eddsa_pub); &merchant_pub.eddsa_pub);
timestamp = GNUNET_TIME_absolute_get (); (void) GNUNET_TIME_round_abs (&wire_deadline);
GNUNET_TIME_round_abs (&timestamp);
GNUNET_TIME_round_abs (&refund_deadline);
GNUNET_TIME_round_abs (&wire_deadline);
{ {
struct TALER_DepositRequestPS dr; struct TALER_DepositRequestPS dr;
@ -343,9 +342,9 @@ deposit_run (void *cls,
(GNUNET_OK == (GNUNET_OK ==
TALER_JSON_merchant_wire_signature_hash (ds->wire_details, TALER_JSON_merchant_wire_signature_hash (ds->wire_details,
&dr.h_wire)); &dr.h_wire));
dr.timestamp = GNUNET_TIME_absolute_hton (timestamp); dr.timestamp = GNUNET_TIME_absolute_hton (ds->timestamp);
dr.refund_deadline = GNUNET_TIME_absolute_hton dr.refund_deadline = GNUNET_TIME_absolute_hton
(refund_deadline); (ds->refund_deadline);
TALER_amount_hton (&dr.amount_with_fee, &amount); TALER_amount_hton (&dr.amount_with_fee, &amount);
TALER_amount_hton TALER_amount_hton
(&dr.deposit_fee, &denom_pub->fee_deposit); (&dr.deposit_fee, &denom_pub->fee_deposit);
@ -365,9 +364,9 @@ deposit_run (void *cls,
&coin_pub, &coin_pub,
denom_pub_sig, denom_pub_sig,
&denom_pub->key, &denom_pub->key,
timestamp, ds->timestamp,
&merchant_pub, &merchant_pub,
refund_deadline, ds->refund_deadline,
&coin_sig, &coin_sig,
&deposit_cb, &deposit_cb,
ds); ds);
@ -537,8 +536,20 @@ TALER_TESTING_cmd_deposit
label); label);
GNUNET_assert (0); GNUNET_assert (0);
} }
ds->timestamp = GNUNET_TIME_absolute_get ();
(void) GNUNET_TIME_round_abs (&ds->timestamp);
ds->refund_deadline = refund_deadline; json_object_set (ds->contract_terms,
"timestamp",
GNUNET_JSON_from_time_abs (ds->timestamp));
if (0 != refund_deadline.rel_value_us)
{
ds->refund_deadline = GNUNET_TIME_relative_to_absolute (refund_deadline);
(void) GNUNET_TIME_round_abs (&ds->refund_deadline);
json_object_set (ds->contract_terms,
"refund_deadline",
GNUNET_JSON_from_time_abs (ds->refund_deadline));
}
ds->amount = amount; ds->amount = amount;
ds->expected_response_code = expected_response_code; ds->expected_response_code = expected_response_code;

View File

@ -101,8 +101,8 @@ struct DepositConfirmationState
*/ */
static void static void
deposit_confirmation_run (void *cls, deposit_confirmation_run (void *cls,
const struct TALER_TESTING_Command *cmd, const struct TALER_TESTING_Command *cmd,
struct TALER_TESTING_Interpreter *is); struct TALER_TESTING_Interpreter *is);
/** /**
@ -133,9 +133,9 @@ do_retry (void *cls)
*/ */
static void static void
deposit_confirmation_cb (void *cls, deposit_confirmation_cb (void *cls,
unsigned int http_status, unsigned int http_status,
enum TALER_ErrorCode ec, enum TALER_ErrorCode ec,
const json_t *obj) const json_t *obj)
{ {
struct DepositConfirmationState *dcs = cls; struct DepositConfirmationState *dcs = cls;
@ -152,14 +152,14 @@ deposit_confirmation_cb (void *cls,
"Retrying deposit confirmation failed with %u/%d\n", "Retrying deposit confirmation failed with %u/%d\n",
http_status, http_status,
(int) ec); (int) ec);
/* on DB conflicts, do not use backoff */ /* on DB conflicts, do not use backoff */
if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec)
dcs->backoff = GNUNET_TIME_UNIT_ZERO; dcs->backoff = GNUNET_TIME_UNIT_ZERO;
else else
dcs->backoff = EXCHANGE_LIB_BACKOFF (dcs->backoff); dcs->backoff = EXCHANGE_LIB_BACKOFF (dcs->backoff);
dcs->retry_task = GNUNET_SCHEDULER_add_delayed (dcs->backoff, dcs->retry_task = GNUNET_SCHEDULER_add_delayed (dcs->backoff,
&do_retry, &do_retry,
dcs); dcs);
return; return;
} }
} }
@ -186,8 +186,8 @@ deposit_confirmation_cb (void *cls,
*/ */
static void static void
deposit_confirmation_run (void *cls, deposit_confirmation_run (void *cls,
const struct TALER_TESTING_Command *cmd, const struct TALER_TESTING_Command *cmd,
struct TALER_TESTING_Interpreter *is) struct TALER_TESTING_Interpreter *is)
{ {
struct DepositConfirmationState *dcs = cls; struct DepositConfirmationState *dcs = cls;
const struct TALER_TESTING_Command *deposit_cmd; const struct TALER_TESTING_Command *deposit_cmd;
@ -211,7 +211,7 @@ deposit_confirmation_run (void *cls,
GNUNET_assert (NULL != dcs->deposit_reference); GNUNET_assert (NULL != dcs->deposit_reference);
deposit_cmd deposit_cmd
= TALER_TESTING_interpreter_lookup_command (is, = TALER_TESTING_interpreter_lookup_command (is,
dcs->deposit_reference); dcs->deposit_reference);
if (NULL == deposit_cmd) if (NULL == deposit_cmd)
{ {
GNUNET_break (0); GNUNET_break (0);
@ -221,41 +221,41 @@ deposit_confirmation_run (void *cls,
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_exchange_pub (deposit_cmd, TALER_TESTING_get_trait_exchange_pub (deposit_cmd,
dcs->coin_index, dcs->coin_index,
&exchange_pub)); &exchange_pub));
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_exchange_sig (deposit_cmd, TALER_TESTING_get_trait_exchange_sig (deposit_cmd,
dcs->coin_index, dcs->coin_index,
&exchange_sig)); &exchange_sig));
keys = TALER_EXCHANGE_get_keys (dcs->is->exchange); keys = TALER_EXCHANGE_get_keys (dcs->is->exchange);
GNUNET_assert (NULL != keys); GNUNET_assert (NULL != keys);
spk = TALER_EXCHANGE_get_exchange_signing_key_info (keys, spk = TALER_EXCHANGE_get_exchange_signing_key_info (keys,
exchange_pub); exchange_pub);
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_contract_terms (deposit_cmd, TALER_TESTING_get_trait_contract_terms (deposit_cmd,
dcs->coin_index, dcs->coin_index,
&contract_terms)); &contract_terms));
/* Very unlikely to fail */ /* Very unlikely to fail */
GNUNET_assert (NULL != contract_terms); GNUNET_assert (NULL != contract_terms);
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_JSON_hash (contract_terms, TALER_JSON_hash (contract_terms,
&h_contract_terms)); &h_contract_terms));
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_wire_details (deposit_cmd, TALER_TESTING_get_trait_wire_details (deposit_cmd,
dcs->coin_index, dcs->coin_index,
&wire_details)); &wire_details));
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_JSON_hash (wire_details, TALER_JSON_merchant_wire_signature_hash (wire_details,
&h_wire)); &h_wire));
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_coin_priv (deposit_cmd, TALER_TESTING_get_trait_coin_priv (deposit_cmd,
dcs->coin_index, dcs->coin_index,
&coin_priv)); &coin_priv));
GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv, GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv,
&coin_pub.eddsa_pub); &coin_pub.eddsa_pub);
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_TESTING_get_trait_peer_key (deposit_cmd, TALER_TESTING_get_trait_peer_key (deposit_cmd,
dcs->coin_index, dcs->coin_index,
&merchant_priv)); &merchant_priv));
GNUNET_CRYPTO_eddsa_key_get_public (merchant_priv, GNUNET_CRYPTO_eddsa_key_get_public (merchant_priv,
@ -263,10 +263,10 @@ deposit_confirmation_run (void *cls,
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount (dcs->amount_without_fee, TALER_string_to_amount (dcs->amount_without_fee,
&amount_without_fee)); &amount_without_fee));
/* timestamp is mandatory */
{ {
struct GNUNET_JSON_Specification spec[] = { struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_absolute_time ("timestamp", &timestamp), GNUNET_JSON_spec_absolute_time ("timestamp", &timestamp),
GNUNET_JSON_spec_absolute_time ("refund_deadline", &refund_deadline),
GNUNET_JSON_spec_end() GNUNET_JSON_spec_end()
}; };
@ -280,6 +280,21 @@ deposit_confirmation_run (void *cls,
return; return;
} }
} }
/* refund deadline is optional, defaults to zero */
{
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_absolute_time ("refund_deadline", &refund_deadline),
GNUNET_JSON_spec_end()
};
if (GNUNET_OK !=
GNUNET_JSON_parse (contract_terms,
spec,
NULL, NULL))
{
refund_deadline = timestamp;
}
}
dcs->dc = TALER_AUDITOR_deposit_confirmation dcs->dc = TALER_AUDITOR_deposit_confirmation
(dcs->auditor, (dcs->auditor,
&h_wire, &h_wire,
@ -318,7 +333,7 @@ deposit_confirmation_run (void *cls,
*/ */
static void static void
deposit_confirmation_cleanup (void *cls, deposit_confirmation_cleanup (void *cls,
const struct TALER_TESTING_Command *cmd) const struct TALER_TESTING_Command *cmd)
{ {
struct DepositConfirmationState *dcs = cls; struct DepositConfirmationState *dcs = cls;
@ -352,9 +367,9 @@ deposit_confirmation_cleanup (void *cls,
*/ */
static int static int
deposit_confirmation_traits (void *cls, deposit_confirmation_traits (void *cls,
const void **ret, const void **ret,
const char *trait, const char *trait,
unsigned int index) unsigned int index)
{ {
/* Must define this function because some callbacks /* Must define this function because some callbacks
* look for certain traits on _all_ the commands. */ * look for certain traits on _all_ the commands. */