summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-09-16 22:11:04 +0200
committerChristian Grothoff <christian@grothoff.org>2019-09-16 22:11:04 +0200
commit2a84699d90ed4780c8a816eccaac3229e9543e40 (patch)
treefa50f83d60807f729c565accffca2e02c6454dcd /src
parent27720961219c16cd11890634ce7934850219511e (diff)
downloadmerchant-2a84699d90ed4780c8a816eccaac3229e9543e40.tar.gz
merchant-2a84699d90ed4780c8a816eccaac3229e9543e40.tar.bz2
merchant-2a84699d90ed4780c8a816eccaac3229e9543e40.zip
fixing misc memory leaks related to json, including #5769, as well as an unrelated use-after-free
Diffstat (limited to 'src')
-rw-r--r--src/backend/taler-merchant-httpd_history.c31
-rw-r--r--src/lib/merchant_api_pay.c413
-rw-r--r--src/lib/merchant_api_proposal.c32
-rw-r--r--src/lib/merchant_api_tip_authorize.c13
-rw-r--r--src/lib/merchant_api_tip_pickup.c13
-rw-r--r--src/lib/merchant_api_track_transfer.c29
-rw-r--r--src/lib/testing_api_cmd_pay.c202
-rw-r--r--src/lib/testing_api_cmd_proposal.c110
8 files changed, 432 insertions, 411 deletions
diff --git a/src/backend/taler-merchant-httpd_history.c b/src/backend/taler-merchant-httpd_history.c
index c9674e86..2d620890 100644
--- a/src/backend/taler-merchant-httpd_history.c
+++ b/src/backend/taler-merchant-httpd_history.c
@@ -89,13 +89,13 @@ pd_cb (void *cls,
summary = json_string (order_id);
if (NULL == (entry =
- json_pack ("{s:I, s:s, s:O, s:O, s:O, s:O}",
- "row_id", row_id,
- "order_id", order_id,
- "amount", amount,
- "timestamp", timestamp,
- "instance", instance,
- "summary", summary)))
+ json_pack ("{s:I, s:s, s:O, s:O, s:O, s:O}",
+ "row_id", row_id,
+ "order_id", order_id,
+ "amount", amount,
+ "timestamp", timestamp,
+ "instance", instance,
+ "summary", summary)))
{
GNUNET_break (0);
pcc->failure = GNUNET_SYSERR;
@@ -154,8 +154,8 @@ MH_handler_history (struct TMH_RequestHandler *rh,
if (NULL != str)
{
if (1 != sscanf (str,
- "%llu",
- &seconds))
+ "%llu",
+ &seconds))
{
json_decref (response);
return TMH_RESPONSE_reply_arg_invalid (connection,
@@ -274,7 +274,8 @@ MH_handler_history (struct TMH_RequestHandler *rh,
&mi->pubkey,
start,
llabs (delta),
- (delta < 0) ? GNUNET_YES : GNUNET_NO,
+ (delta < 0) ? GNUNET_YES :
+ GNUNET_NO,
ascending,
&pd_cb,
&pcc);
@@ -288,16 +289,16 @@ MH_handler_history (struct TMH_RequestHandler *rh,
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
json_decref (response);
return TMH_RESPONSE_reply_internal_error (connection,
- TALER_EC_HISTORY_DB_FETCH_ERROR,
- "db error to get history");
+ TALER_EC_HISTORY_DB_FETCH_ERROR,
+ "db error to get history");
}
- ret = TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_OK,
+ ret = TMH_RESPONSE_reply_json_pack (connection,
+ MHD_HTTP_OK,
"{ s:o }",
"history",
- response);
+ response /* consumes 'response' */);
LOG_INFO ("/history, http code: %d\n",
MHD_HTTP_OK);
- json_decref (response);
return ret;
}
diff --git a/src/lib/merchant_api_pay.c b/src/lib/merchant_api_pay.c
index 8d473564..0505e950 100644
--- a/src/lib/merchant_api_pay.c
+++ b/src/lib/merchant_api_pay.c
@@ -124,7 +124,7 @@ check_abort_refund (struct TALER_MERCHANT_Pay *ph,
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_json ("refund_permissions", &refunds),
GNUNET_JSON_spec_fixed_auto ("merchant_pub", &merchant_pub),
- GNUNET_JSON_spec_end()
+ GNUNET_JSON_spec_end ()
};
if (GNUNET_OK !=
@@ -137,9 +137,9 @@ check_abort_refund (struct TALER_MERCHANT_Pay *ph,
}
num_refunds = json_array_size (refunds);
{
- struct TALER_MERCHANT_RefundEntry res[GNUNET_NZL(num_refunds)];
+ struct TALER_MERCHANT_RefundEntry res[GNUNET_NZL (num_refunds)];
- for (unsigned int i=0;i<num_refunds;i++)
+ for (unsigned int i = 0; i<num_refunds; i++)
{
struct TALER_MerchantSignatureP *sig = &res[i].merchant_sig;
json_t *refund = json_array_get (refunds, i);
@@ -150,7 +150,7 @@ check_abort_refund (struct TALER_MERCHANT_Pay *ph,
&res[i].coin_pub),
GNUNET_JSON_spec_uint64 ("rtransaction_id",
&res[i].rtransaction_id),
- GNUNET_JSON_spec_end()
+ GNUNET_JSON_spec_end ()
};
struct TALER_RefundRequestPS rr;
int found;
@@ -166,53 +166,55 @@ check_abort_refund (struct TALER_MERCHANT_Pay *ph,
}
rr.purpose.purpose = htonl
- (TALER_SIGNATURE_MERCHANT_REFUND);
+ (TALER_SIGNATURE_MERCHANT_REFUND);
rr.purpose.size = htonl
- (sizeof (struct TALER_RefundRequestPS));
+ (sizeof (struct TALER_RefundRequestPS));
rr.h_contract_terms = ph->h_contract_terms;
rr.coin_pub = res[i].coin_pub;
rr.merchant = merchant_pub;
rr.rtransaction_id = GNUNET_htonll (res[i].rtransaction_id);
found = -1;
- for (unsigned int j=0;j<ph->num_coins;j++)
+ for (unsigned int j = 0; j<ph->num_coins; j++)
{
- if (0 == memcmp (&ph->coins[j].coin_pub,
- &res[i].coin_pub,
- sizeof
- (struct TALER_CoinSpendPublicKeyP)))
- {
- TALER_amount_hton (&rr.refund_amount,
- &ph->coins[j].amount_with_fee);
- TALER_amount_hton (&rr.refund_fee,
- &ph->coins[j].refund_fee);
- found = j;
- }
+ if (0 == memcmp (&ph->coins[j].coin_pub,
+ &res[i].coin_pub,
+ sizeof
+ (struct TALER_CoinSpendPublicKeyP)))
+ {
+ TALER_amount_hton (&rr.refund_amount,
+ &ph->coins[j].amount_with_fee);
+ TALER_amount_hton (&rr.refund_fee,
+ &ph->coins[j].refund_fee);
+ found = j;
+ }
}
if (-1 == found)
{
GNUNET_break_op (0);
+ GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_verify
(TALER_SIGNATURE_MERCHANT_REFUND,
- &rr.purpose,
- &sig->eddsa_sig,
- &merchant_pub.eddsa_pub))
+ &rr.purpose,
+ &sig->eddsa_sig,
+ &merchant_pub.eddsa_pub))
{
GNUNET_break_op (0);
+ GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
}
ph->abort_cb (ph->abort_cb_cls,
- MHD_HTTP_OK,
- TALER_EC_NONE,
- &merchant_pub,
- &ph->h_contract_terms,
- num_refunds,
- res,
- json);
+ MHD_HTTP_OK,
+ TALER_EC_NONE,
+ &merchant_pub,
+ &ph->h_contract_terms,
+ num_refunds,
+ res,
+ json);
ph->abort_cb = NULL;
}
GNUNET_JSON_parse_free (spec);
@@ -240,9 +242,9 @@ check_coin_history (const struct TALER_MERCHANT_PaidCoin *pc,
if (GNUNET_OK !=
TALER_EXCHANGE_verify_coin_history
(pc->amount_with_fee.currency,
- &pc->coin_pub,
- json,
- &spent))
+ &pc->coin_pub,
+ json,
+ &spent))
{
/* Exchange's history fails to verify */
GNUNET_break_op (0);
@@ -290,7 +292,7 @@ check_forbidden (struct TALER_MERCHANT_Pay *ph,
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_json ("history", &history),
GNUNET_JSON_spec_fixed_auto ("coin_pub", &coin_pub),
- GNUNET_JSON_spec_end()
+ GNUNET_JSON_spec_end ()
};
int ret;
@@ -302,7 +304,7 @@ check_forbidden (struct TALER_MERCHANT_Pay *ph,
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
- for (unsigned int i=0;i<ph->num_coins;i++)
+ for (unsigned int i = 0; i<ph->num_coins; i++)
{
if (0 == memcmp (&ph->coins[i].coin_pub,
&coin_pub,
@@ -339,10 +341,10 @@ handle_pay_finished (void *cls,
ph->job = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "/pay completed with response code %u\n",
- (unsigned int) response_code);
+ "/pay completed with response code %u\n",
+ (unsigned int) response_code);
if (0 == strcasecmp (ph->mode,
- "pay"))
+ "pay"))
{
switch (response_code)
{
@@ -361,7 +363,7 @@ handle_pay_finished (void *cls,
break;
case MHD_HTTP_FORBIDDEN:
if (GNUNET_OK != check_forbidden (ph,
- json))
+ json))
{
GNUNET_break_op (0);
response_code = 0;
@@ -375,7 +377,7 @@ handle_pay_finished (void *cls,
break;
case MHD_HTTP_NOT_FOUND:
/* Nothing really to verify, this should never
- happen, we should pass the JSON reply to the
+ happen, we should pass the JSON reply to the
application */
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
@@ -389,21 +391,21 @@ handle_pay_finished (void *cls,
default:
/* unexpected response code */
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u\n",
- (unsigned int) response_code);
+ "Unexpected response code %u\n",
+ (unsigned int) response_code);
GNUNET_break (0);
response_code = 0;
break;
}
ph->pay_cb (ph->pay_cb_cls,
- response_code,
- TALER_JSON_get_error_code (json),
- json);
+ response_code,
+ TALER_JSON_get_error_code (json),
+ json);
}
else
{
GNUNET_assert (0 == strcasecmp (ph->mode,
- "abort-refund"));
+ "abort-refund"));
switch (response_code)
{
@@ -434,7 +436,7 @@ handle_pay_finished (void *cls,
break;
case MHD_HTTP_NOT_FOUND:
/* Nothing really to verify, this should never
- happen, we should pass the JSON reply to the
+ happen, we should pass the JSON reply to the
application */
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
@@ -444,20 +446,20 @@ handle_pay_finished (void *cls,
default:
/* unexpected response code */
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u\n",
- (unsigned int) response_code);
+ "Unexpected response code %u\n",
+ (unsigned int) response_code);
GNUNET_break (0);
response_code = 0;
break;
}
ph->abort_cb (ph->abort_cb_cls,
- response_code,
- TALER_JSON_get_error_code (json),
- NULL,
- NULL,
- 0,
- NULL,
- json);
+ response_code,
+ TALER_JSON_get_error_code (json),
+ NULL,
+ NULL,
+ 0,
+ NULL,
+ json);
}
TALER_MERCHANT_pay_cancel (ph);
@@ -484,16 +486,16 @@ handle_pay_finished (void *cls,
static struct TALER_MERCHANT_Pay *
request_pay_generic
(struct GNUNET_CURL_Context *ctx,
- const char *merchant_url,
- const struct TALER_MerchantPublicKeyP *merchant_pub,
- const char *order_id,
- unsigned int num_coins,
- const struct TALER_MERCHANT_PaidCoin *coins,
- const char *mode,
- TALER_MERCHANT_PayCallback pay_cb,
- void *pay_cb_cls,
- TALER_MERCHANT_PayRefundCallback abort_cb,
- void *abort_cb_cls)
+ const char *merchant_url,
+ const struct TALER_MerchantPublicKeyP *merchant_pub,
+ const char *order_id,
+ unsigned int num_coins,
+ const struct TALER_MERCHANT_PaidCoin *coins,
+ const char *mode,
+ TALER_MERCHANT_PayCallback pay_cb,
+ void *pay_cb_cls,
+ TALER_MERCHANT_PayRefundCallback abort_cb,
+ void *abort_cb_cls)
{
struct TALER_MERCHANT_Pay *ph;
json_t *pay_obj;
@@ -508,19 +510,19 @@ request_pay_generic
return NULL;
}
j_coins = json_array ();
- for (unsigned int i=0;i<num_coins;i++)
+ for (unsigned int i = 0; i<num_coins; i++)
{
json_t *j_coin;
const struct TALER_MERCHANT_PaidCoin *pc = &coins[i];
struct TALER_Amount fee;
if (GNUNET_SYSERR ==
- TALER_amount_subtract (&fee,
- &pc->amount_with_fee,
- &pc->amount_without_fee))
+ TALER_amount_subtract (&fee,
+ &pc->amount_with_fee,
+ &pc->amount_without_fee))
{
/* Integer underflow, fee larger than total amount?
- This should not happen (client violated API!) */
+ This should not happen (client violated API!) */
GNUNET_break (0);
json_decref (j_coins);
return NULL;
@@ -533,36 +535,36 @@ request_pay_generic
else
{
if ( (GNUNET_OK !=
- TALER_amount_add (&total_fee,
- &total_fee,
- &fee)) ||
- (GNUNET_OK !=
- TALER_amount_add (&total_amount,
- &total_amount,
- &pc->amount_with_fee)) )
+ TALER_amount_add (&total_fee,
+ &total_fee,
+ &fee)) ||
+ (GNUNET_OK !=
+ TALER_amount_add (&total_amount,
+ &total_amount,
+ &pc->amount_with_fee)) )
{
- /* integer overflow */
- GNUNET_break (0);
- json_decref (j_coins);
- return NULL;
+ /* integer overflow */
+ GNUNET_break (0);
+ json_decref (j_coins);
+ return NULL;
}
}
/* create JSON for this coin */
j_coin = json_pack
- ("{s:o, s:o," /* contribution/coin_pub */
- " s:s, s:o," /* exchange_url / denom_pub */
- " s:o, s:o}", /* ub_sig / coin_sig */
- "contribution", TALER_JSON_from_amount
- (&pc->amount_with_fee),
- "coin_pub", GNUNET_JSON_from_data_auto
- (&pc->coin_pub),
- "exchange_url", pc->exchange_url,
- "denom_pub", GNUNET_JSON_from_rsa_public_key
- (pc->denom_pub.rsa_public_key),
- "ub_sig", GNUNET_JSON_from_rsa_signature
- (pc->denom_sig.rsa_signature),
- "coin_sig", GNUNET_JSON_from_data_auto (&pc->coin_sig));
+ ("{s:o, s:o," /* contribution/coin_pub */
+ " s:s, s:o," /* exchange_url / denom_pub */
+ " s:o, s:o}", /* ub_sig / coin_sig */
+ "contribution", TALER_JSON_from_amount
+ (&pc->amount_with_fee),
+ "coin_pub", GNUNET_JSON_from_data_auto
+ (&pc->coin_pub),
+ "exchange_url", pc->exchange_url,
+ "denom_pub", GNUNET_JSON_from_rsa_public_key
+ (pc->denom_pub.rsa_public_key),
+ "ub_sig", GNUNET_JSON_from_rsa_signature
+ (pc->denom_sig.rsa_signature),
+ "coin_sig", GNUNET_JSON_from_data_auto (&pc->coin_sig));
if (0 !=
json_array_append_new (j_coins,
j_coin))
@@ -574,13 +576,13 @@ request_pay_generic
}
pay_obj = json_pack ("{"
- " s:s," /* mode */
+ " s:s," /* mode */
" s:o," /* coins */
" s:s," /* order_id */
" s:o," /* merchant_pub */
"}",
- "mode", mode,
- "coins", j_coins,
+ "mode", mode,
+ "coins", j_coins,
"order_id", order_id,
"merchant_pub", GNUNET_JSON_from_data_auto
(merchant_pub));
@@ -665,25 +667,25 @@ request_pay_generic
*/
static struct TALER_MERCHANT_Pay *
prepare_pay_generic (struct GNUNET_CURL_Context *ctx,
- const char *merchant_url,
- const char *instance,
- const struct GNUNET_HashCode *h_contract_terms,
- const struct TALER_Amount *amount,
- const struct TALER_Amount *max_fee,
- const struct TALER_MerchantPublicKeyP *merchant_pub,
- const struct TALER_MerchantSignatureP *merchant_sig,
- struct GNUNET_TIME_Absolute timestamp,
- struct GNUNET_TIME_Absolute refund_deadline,
- struct GNUNET_TIME_Absolute pay_deadline,
- const struct GNUNET_HashCode *h_wire,
- const char *order_id,
- unsigned int num_coins,
- const struct TALER_MERCHANT_PayCoin *coins,
- const char *mode,
- TALER_MERCHANT_PayCallback pay_cb,
- void *pay_cb_cls,
- TALER_MERCHANT_PayRefundCallback abort_cb,
- void *abort_cb_cls)
+ const char *merchant_url,
+ const char *instance,
+ const struct GNUNET_HashCode *h_contract_terms,
+ const struct TALER_Amount *amount,
+ const struct TALER_Amount *max_fee,
+ const struct TALER_MerchantPublicKeyP *merchant_pub,
+ const struct TALER_MerchantSignatureP *merchant_sig,
+ struct GNUNET_TIME_Absolute timestamp,
+ struct GNUNET_TIME_Absolute refund_deadline,
+ struct GNUNET_TIME_Absolute pay_deadline,
+ const struct GNUNET_HashCode *h_wire,
+ const char *order_id,
+ unsigned int num_coins,
+ const struct TALER_MERCHANT_PayCoin *coins,
+ const char *mode,
+ TALER_MERCHANT_PayCallback pay_cb,
+ void *pay_cb_cls,
+ TALER_MERCHANT_PayRefundCallback abort_cb,
+ void *abort_cb_cls)
{
struct TALER_DepositRequestPS dr;
struct TALER_MERCHANT_PaidCoin pc[num_coins];
@@ -708,7 +710,7 @@ prepare_pay_generic (struct GNUNET_CURL_Context *ctx,
dr.refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline);
dr.merchant = *merchant_pub;
- for (unsigned int i=0;i<num_coins;i++)
+ for (unsigned int i = 0; i<num_coins; i++)
{
const struct TALER_MERCHANT_PayCoin *coin = &coins[i]; // coin priv.
struct TALER_MERCHANT_PaidCoin *p = &pc[i]; // coin pub.
@@ -716,21 +718,21 @@ prepare_pay_generic (struct GNUNET_CURL_Context *ctx,
/* prepare 'dr' for this coin to generate coin signature */
GNUNET_CRYPTO_eddsa_key_get_public (&coin->coin_priv.eddsa_priv,
- &dr.coin_pub.eddsa_pub);
+ &dr.coin_pub.eddsa_pub);
TALER_amount_hton (&dr.amount_with_fee,
- &coin->amount_with_fee);
+ &coin->amount_with_fee);
if (GNUNET_SYSERR ==
- TALER_amount_subtract (&fee,
- &coin->amount_with_fee,
- &coin->amount_without_fee))
+ TALER_amount_subtract (&fee,
+ &coin->amount_with_fee,
+ &coin->amount_without_fee))
{
/* Integer underflow, fee larger than total amount?
- This should not happen (client violated API!) */
+ This should not happen (client violated API!) */
GNUNET_break (0);
return NULL;
}
TALER_amount_hton (&dr.deposit_fee,
- &fee);
+ &fee);
{
TALER_LOG_DEBUG ("... amount_with_fee was %s\n",
TALER_amount2s (&coin->amount_with_fee));
@@ -739,8 +741,8 @@ prepare_pay_generic (struct GNUNET_CURL_Context *ctx,
}
GNUNET_CRYPTO_eddsa_sign (&coin->coin_priv.eddsa_priv,
- &dr.purpose,
- &p->coin_sig.eddsa_signature);
+ &dr.purpose,
+ &p->coin_sig.eddsa_signature);
p->denom_pub = coin->denom_pub;
p->denom_sig = coin->denom_sig;
p->denom_value = coin->denom_value;
@@ -751,16 +753,16 @@ prepare_pay_generic (struct GNUNET_CURL_Context *ctx,
p->exchange_url = coin->exchange_url;
}
return request_pay_generic (ctx,
- merchant_url,
- merchant_pub,
- order_id,
- num_coins,
- pc,
- mode,
- pay_cb,
- pay_cb_cls,
- abort_cb,
- abort_cb_cls);
+ merchant_url,
+ merchant_pub,
+ order_id,
+ num_coins,
+ pc,
+ mode,
+ pay_cb,
+ pay_cb_cls,
+ abort_cb,
+ abort_cb_cls);
}
@@ -791,11 +793,11 @@ prepare_pay_generic (struct GNUNET_CURL_Context *ctx,
*/
struct TALER_MERCHANT_Pay *
TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx,
- const char *merchant_url,
- const char *instance,
+ const char *merchant_url,
+ const char *instance,
const struct GNUNET_HashCode *h_contract_terms,
- const struct TALER_Amount *amount,
- const struct TALER_Amount *max_fee,
+ const struct TALER_Amount *amount,
+ const struct TALER_Amount *max_fee,
const struct TALER_MerchantPublicKeyP *merchant_pub,
const struct TALER_MerchantSignatureP *merchant_sig,
struct GNUNET_TIME_Absolute timestamp,
@@ -809,25 +811,25 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx,
void *pay_cb_cls)
{
return prepare_pay_generic (ctx,
- merchant_url,
- instance,
- h_contract_terms,
- amount,
- max_fee,
- merchant_pub,
- merchant_sig,
- timestamp,
- refund_deadline,
- pay_deadline,
- h_wire,
- order_id,
- num_coins,
- coins,
- "pay",
- pay_cb,
- pay_cb_cls,
- NULL,
- NULL);
+ merchant_url,
+ instance,
+ h_contract_terms,
+ amount,
+ max_fee,
+ merchant_pub,
+ merchant_sig,
+ timestamp,
+ refund_deadline,
+ pay_deadline,
+ h_wire,
+ order_id,
+ num_coins,
+ coins,
+ "pay",
+ pay_cb,
+ pay_cb_cls,
+ NULL,
+ NULL);
}
@@ -857,45 +859,45 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx,
*/
struct TALER_MERCHANT_Pay *
TALER_MERCHANT_pay_abort (struct GNUNET_CURL_Context *ctx,
- const char *merchant_url,
- const char *instance,
- const struct GNUNET_HashCode *h_contract,
- const struct TALER_Amount *amount,
- const struct TALER_Amount *max_fee,
- const struct TALER_MerchantPublicKeyP *merchant_pub,
- const struct TALER_MerchantSignatureP *merchant_sig,
- struct GNUNET_TIME_Absolute timestamp,
- struct GNUNET_TIME_Absolute refund_deadline,
- struct GNUNET_TIME_Absolute pay_deadline,
- const struct GNUNET_HashCode *h_wire,
- const char *order_id,
- unsigned int num_coins,
- const struct TALER_MERCHANT_PayCoin *coins,
- TALER_MERCHANT_PayRefundCallback payref_cb,
- void *payref_cb_cls)
+ const char *merchant_url,
+ const char *instance,
+ const struct GNUNET_HashCode *h_contract,
+ const struct TALER_Amount *amount,
+ const struct TALER_Amount *max_fee,
+ const struct TALER_MerchantPublicKeyP *merchant_pub,
+ const struct TALER_MerchantSignatureP *merchant_sig,
+ struct GNUNET_TIME_Absolute timestamp,
+ struct GNUNET_TIME_Absolute refund_deadline,
+ struct GNUNET_TIME_Absolute pay_deadline,
+ const struct GNUNET_HashCode *h_wire,
+ const char *order_id,
+ unsigned int num_coins,
+ const struct TALER_MERCHANT_PayCoin *coins,
+ TALER_MERCHANT_PayRefundCallback payref_cb,
+ void *payref_cb_cls)
{
struct TALER_MERCHANT_Pay *ph;
ph = prepare_pay_generic (ctx,
- merchant_url,
- instance,
- h_contract,
- amount,
- max_fee,
- merchant_pub,
- merchant_sig,
- timestamp,
- refund_deadline,
- pay_deadline,
- h_wire,
- order_id,
- num_coins,
- coins,
- "abort-refund",
- NULL,
- NULL,
- payref_cb,
- payref_cb_cls);
+ merchant_url,
+ instance,
+ h_contract,
+ amount,
+ max_fee,
+ merchant_pub,
+ merchant_sig,
+ timestamp,
+ refund_deadline,
+ pay_deadline,
+ h_wire,
+ order_id,
+ num_coins,
+ coins,
+ "abort-refund",
+ NULL,
+ NULL,
+ payref_cb,
+ payref_cb_cls);
ph->h_contract_terms = *h_contract;
return ph;
}
@@ -918,8 +920,9 @@ TALER_MERCHANT_pay_abort (struct GNUNET_CURL_Context *ctx,
*/
struct TALER_MERCHANT_Pay *
TALER_MERCHANT_pay_frontend (struct GNUNET_CURL_Context *ctx,
- const char *merchant_url,
- const struct TALER_MerchantPublicKeyP *merchant_pub,
+ const char *merchant_url,
+ const struct
+ TALER_MerchantPublicKeyP *merchant_pub,
const char *order_id,
unsigned int num_coins,
const struct TALER_MERCHANT_PaidCoin *coins,
@@ -927,16 +930,16 @@ TALER_MERCHANT_pay_frontend (struct GNUNET_CURL_Context *ctx,
void *pay_cb_cls)
{
return request_pay_generic (ctx,
- merchant_url,
- merchant_pub,
- order_id,
- num_coins,
- coins,
- "pay",
- pay_cb,
- pay_cb_cls,
- NULL,
- NULL);
+ merchant_url,
+ merchant_pub,
+ order_id,
+ num_coins,
+ coins,
+ "pay",
+ pay_cb,
+ pay_cb_cls,
+ NULL,
+ NULL);
}
diff --git a/src/lib/merchant_api_proposal.c b/src/lib/merchant_api_proposal.c
index 3b48c50c..25552bc0 100644
--- a/src/lib/merchant_api_proposal.c
+++ b/src/lib/merchant_api_proposal.c
@@ -135,7 +135,7 @@ handle_proposal_finished (void *cls,
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("order_id",
&order_id),
- GNUNET_JSON_spec_end()
+ GNUNET_JSON_spec_end ()
};
po->job = NULL;
@@ -163,9 +163,9 @@ handle_proposal_finished (void *cls,
}
break;
case MHD_HTTP_BAD_REQUEST:
- /* This should never happen, either us or
- the merchant is buggy (or API version conflict);
- just pass JSON reply to the application */
+ /* This should never happen, either us or
+ the merchant is buggy (or API version conflict);
+ just pass JSON reply to the application */
break;
case MHD_HTTP_FORBIDDEN:
break;
@@ -193,7 +193,7 @@ handle_proposal_finished (void *cls,
}
po->cb (po->cb_cls,
response_code,
- TALER_JSON_get_error_code (json),
+ TALER_JSON_get_error_code (json),
json,
order_id);
GNUNET_JSON_parse_free (spec);
@@ -216,10 +216,10 @@ handle_proposal_finished (void *cls,
struct TALER_MERCHANT_ProposalOperation *
TALER_MERCHANT_order_put
(struct GNUNET_CURL_Context *ctx,
- const char *backend_url,
- const json_t *order,
- TALER_MERCHANT_ProposalCallback proposal_cb,
- void *proposal_cb_cls)
+ const char *backend_url,
+ const json_t *order,
+ TALER_MERCHANT_ProposalCallback proposal_cb,
+ void *proposal_cb_cls)
{
struct TALER_MERCHANT_ProposalOperation *po;
json_t *req;
@@ -274,14 +274,14 @@ handle_proposal_lookup_finished (void *cls,
struct TALER_MerchantSignatureP sig;
struct GNUNET_HashCode hash;
const json_t *json = response;
-
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_json ("contract_terms",
&contract_terms),
GNUNET_JSON_spec_fixed_auto ("sig",
&sig),
- GNUNET_JSON_spec_end()
+ GNUNET_JSON_spec_end ()
};
+
plo->job = NULL;
if (MHD_HTTP_OK != response_code)
{
@@ -314,7 +314,6 @@ handle_proposal_lookup_finished (void *cls,
NULL,
NULL,
NULL);
-
TALER_MERCHANT_proposal_lookup_cancel (plo);
return;
}
@@ -368,8 +367,10 @@ TALER_MERCHANT_proposal_lookup (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
const char *order_id,
const char *instance,
- const struct GNUNET_CRYPTO_EddsaPublicKey *nonce,
- TALER_MERCHANT_ProposalLookupOperationCallback plo_cb,
+ const struct
+ GNUNET_CRYPTO_EddsaPublicKey *nonce,
+ TALER_MERCHANT_ProposalLookupOperationCallback
+ plo_cb,
void *plo_cb_cls)
{
struct TALER_MERCHANT_ProposalLookupOperation *plo;
@@ -386,7 +387,8 @@ TALER_MERCHANT_proposal_lookup (struct GNUNET_CURL_Context *ctx,
char *nonce_str;
plo->has_nonce = GNUNET_YES;
plo->nonce = *nonce;
- nonce_str = GNUNET_STRINGS_data_to_string_alloc (nonce, sizeof (struct GNUNET_CRYPTO_EddsaPublicKey));
+ nonce_str = GNUNET_STRINGS_data_to_string_alloc (nonce, sizeof (struct
+ GNUNET_CRYPTO_EddsaPublicKey));
GNUNET_assert (NULL != nonce_str);
GNUNET_asprintf (&plo->url,
"%s?order_id=%s&instance=%s&nonce=%s",
diff --git a/src/lib/merchant_api_tip_authorize.c b/src/lib/merchant_api_tip_authorize.c
index d77041c7..f79064a6 100644
--- a/src/lib/merchant_api_tip_authorize.c
+++ b/src/lib/merchant_api_tip_authorize.c
@@ -88,7 +88,7 @@ check_ok (struct TALER_MERCHANT_TipAuthorizeOperation *tao,
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("taler_tip_uri", &taler_tip_uri),
GNUNET_JSON_spec_fixed_auto ("tip_id", &tip_id),
- GNUNET_JSON_spec_end()
+ GNUNET_JSON_spec_end ()
};
if (GNUNET_OK !=
@@ -96,8 +96,12 @@ check_ok (struct TALER_MERCHANT_TipAuthorizeOperation *tao,
spec,
NULL, NULL))
{
+ char *log;
+
GNUNET_break_op (0);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "JSON %s\n", json_dumps (json, 0));
+ log = json_dumps (json, 0);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "JSON %s\n", log);
+ free (log);
return GNUNET_SYSERR;
}
tao->cb (tao->cb_cls,
@@ -132,7 +136,7 @@ handle_tip_authorize_finished (void *cls,
{
case MHD_HTTP_OK:
if (GNUNET_OK != check_ok (tao,
- json))
+ json))
{
GNUNET_break_op (0);
response_code = 0;
@@ -255,7 +259,8 @@ TALER_MERCHANT_tip_authorize (struct GNUNET_CURL_Context *ctx,
* @param tao handle to the tracking operation being cancelled
*/
void
-TALER_MERCHANT_tip_authorize_cancel (struct TALER_MERCHANT_TipAuthorizeOperation *tao)
+TALER_MERCHANT_tip_authorize_cancel (struct
+ TALER_MERCHANT_TipAuthorizeOperation *tao)
{
if (NULL != tao->job)
{
diff --git a/src/lib/merchant_api_tip_pickup.c b/src/lib/merchant_api_tip_pickup.c
index 99863cb3..e49151bc 100644
--- a/src/lib/merchant_api_tip_pickup.c
+++ b/src/lib/merchant_api_tip_pickup.c
@@ -93,7 +93,7 @@ check_ok (struct TALER_MERCHANT_TipPickupOperation *tpo,
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("reserve_pub", &reserve_pub),
GNUNET_JSON_spec_json ("reserve_sigs", &ja),
- GNUNET_JSON_spec_end()
+ GNUNET_JSON_spec_end ()
};
unsigned int ja_len;
@@ -109,18 +109,19 @@ check_ok (struct TALER_MERCHANT_TipPickupOperation *tpo,
if (ja_len != tpo->num_planchets)
{
GNUNET_break_op (0);
+ GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
{
struct TALER_ReserveSignatureP reserve_sigs[ja_len];
- for (unsigned int i=0;i<ja_len;i++)
+ for (unsigned int i = 0; i<ja_len; i++)
{
json_t *pj = json_array_get (ja, i);
struct GNUNET_JSON_Specification ispec[] = {
GNUNET_JSON_spec_fixed_auto ("reserve_sig", &reserve_sigs[i]),
- GNUNET_JSON_spec_end()
+ GNUNET_JSON_spec_end ()
};
if (GNUNET_OK !=
@@ -129,6 +130,7 @@ check_ok (struct TALER_MERCHANT_TipPickupOperation *tpo,
NULL, NULL))
{
GNUNET_break_op (0);
+ GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
}
@@ -240,7 +242,7 @@ TALER_MERCHANT_tip_pickup (struct GNUNET_CURL_Context *ctx,
return NULL;
}
pa = json_array ();
- for (unsigned int i=0;i<num_planchets;i++)
+ for (unsigned int i = 0; i<num_planchets; i++)
{
const struct TALER_PlanchetDetail *planchet = &planchets[i];
json_t *p;
@@ -249,7 +251,8 @@ TALER_MERCHANT_tip_pickup (struct GNUNET_CURL_Context *ctx,
" s:o," /* denom_pub_hash */
" s:o," /* coin_ev */
"}",
- "denom_pub_hash", GNUNET_JSON_from_data_auto (&planchet->denom_pub_hash),
+ "denom_pub_hash", GNUNET_JSON_from_data_auto (
+ &planchet->denom_pub_hash),
"coin_ev", GNUNET_JSON_from_data (planchet->coin_ev,
planchet->coin_ev_size));
if (NULL == p)
diff --git a/src/lib/merchant_api_track_transfer.c b/src/lib/merchant_api_track_transfer.c
index 8c8121a4..b5105c54 100644
--- a/src/lib/merchant_api_track_transfer.c
+++ b/src/lib/merchant_api_track_transfer.c
@@ -82,7 +82,8 @@ struct TALER_MERCHANT_TrackTransferHandle
* #GNUNET_SYSERR if the response was bogus
*/
static int
-check_track_transfer_response_ok (struct TALER_MERCHANT_TrackTransferHandle *wdh,
+check_track_transfer_response_ok (struct
+ TALER_MERCHANT_TrackTransferHandle *wdh,
const json_t *json)
{
json_t *deposits;
@@ -97,7 +98,7 @@ check_track_transfer_response_ok (struct TALER_MERCHANT_TrackTransferHandle *wdh
GNUNET_JSON_spec_fixed_auto ("H_wire", &h_wire),
GNUNET_JSON_spec_json ("deposits_sums", &deposits),
GNUNET_JSON_spec_fixed_auto ("exchange_pub", &exchange_pub),
- GNUNET_JSON_spec_end()
+ GNUNET_JSON_spec_end ()
};
if (GNUNET_OK !=
@@ -112,7 +113,7 @@ check_track_transfer_response_ok (struct TALER_MERCHANT_TrackTransferHandle *wdh
{
struct TALER_MERCHANT_TrackTransferDetails details[num_details];
- for (unsigned int i=0;i<num_details;i++)
+ for (unsigned int i = 0; i<num_details; i++)
{
struct TALER_MERCHANT_TrackTransferDetails *detail = &details[i];
json_t *deposit = json_array_get (deposits, i);
@@ -120,7 +121,7 @@ check_track_transfer_response_ok (struct TALER_MERCHANT_TrackTransferHandle *wdh
GNUNET_JSON_spec_string ("order_id", &detail->order_id),
TALER_JSON_spec_amount ("deposit_value", &detail->deposit_value),
TALER_JSON_spec_amount ("deposit_fee", &detail->deposit_fee),
- GNUNET_JSON_spec_end()
+ GNUNET_JSON_spec_end ()
};
if (GNUNET_OK !=
@@ -135,7 +136,7 @@ check_track_transfer_response_ok (struct TALER_MERCHANT_TrackTransferHandle *wdh
}
wdh->cb (wdh->cb_cls,
MHD_HTTP_OK,
- TALER_EC_NONE,
+ TALER_EC_NONE,
&exchange_pub,
json,
&h_wire,
@@ -181,7 +182,7 @@ handle_track_transfer_finished (void *cls,
response_code = 0;
break;
case MHD_HTTP_FAILED_DEPENDENCY:
- /* Not a reason to break execution. */
+ /* Not a reason to break execution. */
break;
case MHD_HTTP_NOT_FOUND:
/* Nothing really to verify, this should never
@@ -202,7 +203,7 @@ handle_track_transfer_finished (void *cls,
}
tdo->cb (tdo->cb_cls,
response_code,
- TALER_JSON_get_error_code (json),
+ TALER_JSON_get_error_code (json),
NULL,
json,
NULL,
@@ -230,10 +231,12 @@ struct TALER_MERCHANT_TrackTransferHandle *
TALER_MERCHANT_track_transfer (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
const char *instance,
- const char *wire_method,
- const struct TALER_WireTransferIdentifierRawP *wtid,
+ const char *wire_method,
+ const struct
+ TALER_WireTransferIdentifierRawP *wtid,
const char *exchange_url,
- TALER_MERCHANT_TrackTransferCallback track_transfer_cb,
+ TALER_MERCHANT_TrackTransferCallback
+ track_transfer_cb,
void *track_transfer_cb_cls)
{
struct TALER_MERCHANT_TrackTransferHandle *tdo;
@@ -241,7 +244,8 @@ TALER_MERCHANT_track_transfer (struct GNUNET_CURL_Context *ctx,
char *wtid_str;
wtid_str = GNUNET_STRINGS_data_to_string_alloc (wtid,
- sizeof (struct TALER_WireTransferIdentifierRawP));
+ sizeof (struct
+ TALER_WireTransferIdentifierRawP));
tdo = GNUNET_new (struct TALER_MERCHANT_TrackTransferHandle);
tdo->ctx = ctx;
tdo->cb = track_transfer_cb; // very last to be called
@@ -274,7 +278,8 @@ TALER_MERCHANT_track_transfer (struct GNUNET_CURL_Context *ctx,
* @param tdo handle to the tracking operation being cancelled
*/
void
-TALER_MERCHANT_track_transfer_cancel (struct TALER_MERCHANT_TrackTransferHandle *tdo)
+TALER_MERCHANT_track_transfer_cancel (struct
+ TALER_MERCHANT_TrackTransferHandle *tdo)
{
if (NULL != tdo->job)
{
diff --git a/src/lib/testing_api_cmd_pay.c b/src/lib/testing_api_cmd_pay.c
index e24105ee..7f1c82a7 100644
--- a/src/lib/testing_api_cmd_pay.c
+++ b/src/lib/testing_api_cmd_pay.c
@@ -376,7 +376,7 @@ check_payment_run (void *cls,
TALER_TESTING_FAIL (is);
if (GNUNET_OK != TALER_TESTING_get_trait_order_id (
- proposal_cmd, 0, &order_id))
+ proposal_cmd, 0, &order_id))
TALER_TESTING_FAIL (is);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -384,13 +384,13 @@ check_payment_run (void *cls,
order_id);
cps->cpo = TALER_MERCHANT_check_payment
- (is->ctx,
- cps->merchant_url,
- "default", // only default instance for now.
- order_id,
- NULL,
- check_payment_cb,
- cps);
+ (is->ctx,
+ cps->merchant_url,
+ "default", // only default instance for now.
+ order_id,
+ NULL,
+ check_payment_cb,
+ cps);
GNUNET_assert (NULL != cps->cpo);
}
@@ -479,8 +479,8 @@ build_coins (struct TALER_MERCHANT_PayCoin **pc,
*ctok = '\0';
ctok++;
if (1 != sscanf (ctok,
- "%u",
- &ci))
+ "%u",
+ &ci))
{
GNUNET_break (0);
return GNUNET_SYSERR;
@@ -488,7 +488,7 @@ build_coins (struct TALER_MERCHANT_PayCoin **pc,
}
coin_cmd = TALER_TESTING_interpreter_lookup_command
- (is, token);
+ (is, token);
if (NULL == coin_cmd)
{
@@ -500,7 +500,7 @@ build_coins (struct TALER_MERCHANT_PayCoin **pc,
*npc,
(*npc) + 1);
- icoin = &((*pc)[(*npc)-1]);
+ icoin = &((*pc)[(*npc) - 1]);
{
const struct TALER_CoinSpendPrivateKeyP *coin_priv;
@@ -510,19 +510,19 @@ build_coins (struct TALER_MERCHANT_PayCoin **pc,
GNUNET_assert
(GNUNET_OK == TALER_TESTING_get_trait_coin_priv
- (coin_cmd, 0, &coin_priv));
+ (coin_cmd, 0, &coin_priv));
GNUNET_assert
(GNUNET_OK == TALER_TESTING_get_trait_denom_pub
- (coin_cmd, 0, &denom_pub));
+ (coin_cmd, 0, &denom_pub));
GNUNET_assert
(GNUNET_OK == TALER_TESTING_get_trait_denom_sig
- (coin_cmd, 0, &denom_sig));
+ (coin_cmd, 0, &denom_sig));
GNUNET_assert
(GNUNET_OK == TALER_TESTING_get_trait_amount_obj
- (coin_cmd, 0, &denom_value));
+ (coin_cmd, 0, &denom_value));
icoin->coin_priv = *coin_priv;
icoin->denom_pub = denom_pub->key;
@@ -531,12 +531,12 @@ build_coins (struct TALER_MERCHANT_PayCoin **pc,
icoin->amount_with_fee = *denom_value;
}
GNUNET_assert (NULL != (dpk = TALER_TESTING_find_pk
- (is->keys, &icoin->denom_value)));
+ (is->keys, &icoin->denom_value)));
GNUNET_assert (GNUNET_SYSERR != TALER_amount_subtract
- (&icoin->amount_without_fee,
- &icoin->denom_value,
- &dpk->fee_deposit));
+ (&icoin->amount_without_fee,
+ &icoin->denom_value,
+ &dpk->fee_deposit));
GNUNET_assert
(GNUNET_OK == TALER_TESTING_get_trait_url
@@ -597,15 +597,15 @@ pay_cb (void *cls,
GNUNET_JSON_spec_fixed_auto ("sig",
&sig),
GNUNET_JSON_spec_fixed_auto ("h_contract_terms",
- &ps->h_contract_terms),
+ &ps->h_contract_terms),
GNUNET_JSON_spec_end ()
};
const struct TALER_TESTING_Command *proposal_cmd;
GNUNET_assert (GNUNET_OK == GNUNET_JSON_parse (
- obj, spec,
- &error_name,
- &error_line));
+ obj, spec,
+ &error_name,
+ &error_line));
mr.purpose.purpose = htonl (
TALER_SIGNATURE_MERCHANT_PAYMENT_OK);
@@ -614,18 +614,18 @@ pay_cb (void *cls,
/* proposal reference was used at least once, at this point */
GNUNET_assert
- ( NULL !=
- ( proposal_cmd = TALER_TESTING_interpreter_lookup_command
- (ps->is, ps->proposal_reference)));
+ (NULL !=
+ (proposal_cmd = TALER_TESTING_interpreter_lookup_command
+ (ps->is, ps->proposal_reference)));
if (GNUNET_OK != TALER_TESTING_get_trait_peer_key_pub
- (proposal_cmd, 0, &merchant_pub))
+ (proposal_cmd, 0, &merchant_pub))
TALER_TESTING_FAIL (ps->is);
if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify (
- TALER_SIGNATURE_MERCHANT_PAYMENT_OK,
- &mr.purpose, &sig,
- merchant_pub))
+ TALER_SIGNATURE_MERCHANT_PAYMENT_OK,
+ &mr.purpose, &sig,
+ merchant_pub))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Merchant signature given in response to /pay"
@@ -685,7 +685,7 @@ pay_abort_cb (void *cls,
pas->num_refunds = num_refunds;
pas->res = GNUNET_new_array
- (num_refunds, struct TALER_MERCHANT_RefundEntry);
+ (num_refunds, struct TALER_MERCHANT_RefundEntry);
memcpy (pas->res,
res,
@@ -733,8 +733,8 @@ _pay_run (const char *merchant_url,
const char *amount_with_fee,
const char *amount_without_fee,
const char *refund_fee,
- struct TALER_MERCHANT_Pay * (*api_func) (),
- void (*api_cb) (),
+ struct TALER_MERCHANT_Pay * (*api_func)(),
+ void (*api_cb)(),
void *cls)
{
const struct TALER_TESTING_Command *proposal_cmd;
@@ -757,7 +757,7 @@ _pay_run (const char *merchant_url,
struct TALER_MERCHANT_Pay *ret;
proposal_cmd = TALER_TESTING_interpreter_lookup_command (is,
- proposal_reference);
+ proposal_reference);
if (NULL == proposal_cmd)
{
@@ -767,8 +767,8 @@ _pay_run (const char *merchant_url,
if (GNUNET_OK !=
TALER_TESTING_get_trait_contract_terms (proposal_cmd,
- 0,
- &contract_terms))
+ 0,
+ &contract_terms))
{
GNUNET_break (0);
return NULL;
@@ -793,7 +793,7 @@ _pay_run (const char *merchant_url,
&total_amount),
TALER_JSON_spec_amount ("max_fee",
&max_fee),
- GNUNET_JSON_spec_end()
+ GNUNET_JSON_spec_end ()
};
if (GNUNET_OK !=
@@ -805,12 +805,12 @@ _pay_run (const char *merchant_url,
char *js;
js = json_dumps (contract_terms,
- JSON_INDENT (1));
+ JSON_INDENT (1));
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Parser failed on %s:%u for input `%s'\n",
error_name,
error_line,
- js);
+ js);
free (js);
GNUNET_break_op (0);
return NULL;
@@ -822,7 +822,7 @@ _pay_run (const char *merchant_url,
if (GNUNET_OK !=
build_coins (&pay_coins,
&npay_coins,
- cr,
+ cr,
is,
amount_with_fee,
amount_without_fee,
@@ -830,7 +830,7 @@ _pay_run (const char *merchant_url,
{
GNUNET_array_grow (pay_coins,
npay_coins,
- 0);
+ 0);
GNUNET_free (cr);
GNUNET_break (0);
return NULL;
@@ -838,7 +838,7 @@ _pay_run (const char *merchant_url,
GNUNET_free (cr);
if (GNUNET_OK != TALER_TESTING_get_trait_merchant_sig
- (proposal_cmd, 0, &merchant_sig))
+ (proposal_cmd, 0, &merchant_sig))
{
GNUNET_break (0);
return NULL;
@@ -846,7 +846,7 @@ _pay_run (const char *merchant_url,
if (GNUNET_OK != TALER_TESTING_get_trait_h_contract_terms
- (proposal_cmd, 0, &h_proposal))
+ (proposal_cmd, 0, &h_proposal))
{
GNUNET_break (0);
return NULL;
@@ -952,25 +952,25 @@ pay_traits (void *cls,
struct GNUNET_CRYPTO_EddsaPublicKey *merchant_pub;
if ( NULL ==
- ( proposal_cmd = TALER_TESTING_interpreter_lookup_command
- (ps->is, ps->proposal_reference)))
+ (proposal_cmd = TALER_TESTING_interpreter_lookup_command
+ (ps->is, ps->proposal_reference)))
{
GNUNET_break (0);
return GNUNET_SYSERR;
}
if (GNUNET_OK != TALER_TESTING_get_trait_order_id
- (proposal_cmd, 0, &order_id))
+ (proposal_cmd, 0, &order_id))
{
GNUNET_break (0);
return GNUNET_SYSERR;
}
if (GNUNET_OK != TALER_TESTING_get_trait_peer_key_pub
- (proposal_cmd,
- 0,
- (const struct GNUNET_CRYPTO_EddsaPublicKey **)
- &merchant_pub))
+ (proposal_cmd,
+ 0,
+ (const struct GNUNET_CRYPTO_EddsaPublicKey **)
+ &merchant_pub))
{
GNUNET_break (0);
return GNUNET_SYSERR;
@@ -1099,28 +1099,28 @@ pay_abort_run (void *cls,
pas->is = is;
pay_cmd = TALER_TESTING_interpreter_lookup_command
- (is, pas->pay_reference);
+ (is, pas->pay_reference);
if (NULL == pay_cmd)
TALER_TESTING_FAIL (is);
if (GNUNET_OK != TALER_TESTING_get_trait_proposal_reference
- (pay_cmd, 0, &proposal_reference))
+ (pay_cmd, 0, &proposal_reference))
TALER_TESTING_FAIL (is);
if (GNUNET_OK != TALER_TESTING_get_trait_coin_reference
- (pay_cmd, 0, &coin_reference))
+ (pay_cmd, 0, &coin_reference))
TALER_TESTING_FAIL (is);
if (GNUNET_OK != TALER_TESTING_get_trait_amount
- (pay_cmd, AMOUNT_WITH_FEE, &amount_with_fee))
+ (pay_cmd, AMOUNT_WITH_FEE, &amount_with_fee))
TALER_TESTING_FAIL (is);
if (GNUNET_OK != TALER_TESTING_get_trait_amount
- (pay_cmd, AMOUNT_WITHOUT_FEE, &amount_without_fee))
+ (pay_cmd, AMOUNT_WITHOUT_FEE, &amount_without_fee))
TALER_TESTING_FAIL (is);
if (GNUNET_OK != TALER_TESTING_get_trait_amount
- (pay_cmd, REFUND_FEE, &refund_fee))
+ (pay_cmd, REFUND_FEE, &refund_fee))
TALER_TESTING_FAIL (is);
if (NULL == (pas->pao = _pay_run (pas->merchant_url,
@@ -1220,9 +1220,9 @@ TALER_TESTING_cmd_pay_abort (const char *label,
*/
static void
pay_again_cb (void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
- const json_t *obj)
+ unsigned int http_status,
+ enum TALER_ErrorCode ec,
+ const json_t *obj)
{
struct PayAgainState *pas = cls;
struct GNUNET_CRYPTO_EddsaSignature sig;
@@ -1245,8 +1245,8 @@ pay_again_cb (void *cls,
}
if ( NULL ==
- ( pay_cmd = TALER_TESTING_interpreter_lookup_command
- (pas->is, pas->pay_reference)))
+ (pay_cmd = TALER_TESTING_interpreter_lookup_command
+ (pas->is, pas->pay_reference)))
TALER_TESTING_FAIL (pas->is);
if (MHD_HTTP_OK == http_status)
@@ -1255,9 +1255,9 @@ pay_again_cb (void *cls,
/* Check signature */
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("sig",
- &sig),
+ &sig),
GNUNET_JSON_spec_fixed_auto ("h_contract_terms",
- &mr.h_contract_terms),
+ &mr.h_contract_terms),
GNUNET_JSON_spec_end ()
};
@@ -1266,18 +1266,18 @@ pay_again_cb (void *cls,
&error_name,
&error_line));
mr.purpose.purpose = htonl
- (TALER_SIGNATURE_MERCHANT_PAYMENT_OK);
+ (TALER_SIGNATURE_MERCHANT_PAYMENT_OK);
mr.purpose.size = htonl (sizeof (mr));
if (GNUNET_OK != TALER_TESTING_get_trait_peer_key_pub
- (pay_cmd, 0, &merchant_pub))
+ (pay_cmd, 0, &merchant_pub))
TALER_TESTING_FAIL (pas->is);
if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify
- (TALER_SIGNATURE_MERCHANT_PAYMENT_OK,
- &mr.purpose,
- &sig,
- merchant_pub))
+ (TALER_SIGNATURE_MERCHANT_PAYMENT_OK,
+ &mr.purpose,
+ &sig,
+ merchant_pub))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Merchant signature given in"
@@ -1310,20 +1310,20 @@ pay_again_run (void *cls,
pas->is = is;
pay_cmd = TALER_TESTING_interpreter_lookup_command
- (is, pas->pay_reference);
+ (is, pas->pay_reference);
if (NULL == pay_cmd)
TALER_TESTING_FAIL (is);
if (GNUNET_OK != TALER_TESTING_get_trait_proposal_reference
- (pay_cmd, 0, &proposal_reference))
+ (pay_cmd, 0, &proposal_reference))
TALER_TESTING_FAIL (is);
if (GNUNET_OK != TALER_TESTING_get_trait_amount
- (pay_cmd, AMOUNT_WITH_FEE, &amount_with_fee))
+ (pay_cmd, AMOUNT_WITH_FEE, &amount_with_fee))
TALER_TESTING_FAIL (is);
if (GNUNET_OK != TALER_TESTING_get_trait_amount
- (pay_cmd, AMOUNT_WITHOUT_FEE, &amount_without_fee))
+ (pay_cmd, AMOUNT_WITHOUT_FEE, &amount_without_fee))
TALER_TESTING_FAIL (is);
if (NULL == (pas->pao = _pay_run (pas->merchant_url,
@@ -1422,10 +1422,10 @@ TALER_TESTING_cmd_pay_again (const char *label,
*/
static void
abort_refund_cb (void *cls,
- unsigned int http_status,
- enum TALER_ErrorCode ec,
- const struct TALER_ExchangePublicKeyP *sign_key,
- const json_t *obj)
+ unsigned int http_status,
+ enum TALER_ErrorCode ec,
+ const struct TALER_ExchangePublicKeyP *sign_key,
+ const json_t *obj)
{
struct PayAbortRefundState *pars = cls;
@@ -1492,45 +1492,45 @@ pay_abort_refund_run (void *cls,
pars->is = is;
if ( NULL ==
- ( abort_cmd = TALER_TESTING_interpreter_lookup_command
- (is, pars->abort_reference)) )
+ (abort_cmd = TALER_TESTING_interpreter_lookup_command
+ (is, pars->abort_reference)) )
TALER_TESTING_FAIL (is);
if (GNUNET_OK != TALER_TESTING_get_trait_uint
- (abort_cmd, 0, &num_refunds))
+ (abort_cmd, 0, &num_refunds))
TALER_TESTING_FAIL (is);
if (pars->num_coins >= *num_refunds)
TALER_TESTING_FAIL (is);
if (GNUNET_OK != TALER_TESTING_get_trait_h_contract_terms
- (abort_cmd, 0, &h_contract_terms))
+ (abort_cmd, 0, &h_contract_terms))
TALER_TESTING_FAIL (is);
if (GNUNET_OK != TALER_TESTING_get_trait_peer_key_pub
- (abort_cmd, 0, &merchant_pub))
+ (abort_cmd, 0, &merchant_pub))
TALER_TESTING_FAIL (is);
if (GNUNET_OK != TALER_TESTING_get_trait_refund_entry
- (abort_cmd, 0, &refund_entry))
+ (abort_cmd, 0, &refund_entry))
TALER_TESTING_FAIL (is);
GNUNET_assert (GNUNET_OK == TALER_string_to_amount
- (pars->refund_amount, &refund_amount));
+ (pars->refund_amount, &refund_amount));
GNUNET_assert (GNUNET_OK == TALER_string_to_amount
- (pars->refund_fee, &refund_fee));
+ (pars->refund_fee, &refund_fee));
pars->rh = TALER_EXCHANGE_refund2
- (is->exchange,
- &refund_amount,
- &refund_fee,
- h_contract_terms,
- &refund_entry->coin_pub,
- refund_entry->rtransaction_id,
- (const struct TALER_MerchantPublicKeyP *) merchant_pub,
- &refund_entry->merchant_sig,
- &abort_refund_cb,
- pars);
+ (is->exchange,
+ &refund_amount,
+ &refund_fee,
+ h_contract_terms,
+ &refund_entry->coin_pub,
+ refund_entry->rtransaction_id,
+ (const struct TALER_MerchantPublicKeyP *) merchant_pub,
+ &refund_entry->merchant_sig,
+ &abort_refund_cb,
+ pars);
GNUNET_assert (NULL != pars->rh);
}
@@ -1553,11 +1553,11 @@ pay_abort_refund_run (void *cls,
struct TALER_TESTING_Command
TALER_TESTING_cmd_pay_abort_refund
(const char *label,
- const char *abort_reference,
- unsigned int num_coins,
- const char *refund_amount,
- const char *refund_fee,
- unsigned int http_status)
+ const char *abort_reference,
+ unsigned int num_coins,
+ const char *refund_amount,
+ const char *refund_fee,
+ unsigned int http_status)
{
struct PayAbortRefundState *pars;
diff --git a/src/lib/testing_api_cmd_proposal.c b/src/lib/testing_api_cmd_proposal.c
index 9f2d6d8c..f095f38f 100644
--- a/src/lib/testing_api_cmd_proposal.c
+++ b/src/lib/testing_api_cmd_proposal.c
@@ -162,7 +162,7 @@ proposal_traits (void *cls,
struct ProposalState *ps = cls;
#define MAKE_TRAIT_NONCE(ptr) \
- TALER_TESTING_make_trait_peer_key_pub (1, ptr)
+ TALER_TESTING_make_trait_peer_key_pub (1, ptr)
struct TALER_TESTING_Trait traits[] = {
TALER_TESTING_make_trait_order_id (0, ps->order_id),
@@ -196,16 +196,21 @@ proposal_traits (void *cls,
static void
proposal_lookup_initial_cb
(void *cls,
- unsigned int http_status,
- const json_t *json,
- const json_t *contract_terms,
- const struct TALER_MerchantSignatureP *sig,
- const struct GNUNET_HashCode *hash)
+ unsigned int http_status,
+ const json_t *json,
+ const json_t *contract_terms,
+ const struct TALER_MerchantSignatureP *sig,
+ const struct GNUNET_HashCode *hash)
{
struct ProposalState *ps = cls;
struct TALER_MerchantPublicKeyP merchant_pub;
const char *error_name;
unsigned int error_line;
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_fixed_auto ("merchant_pub",
+ &merchant_pub),
+ GNUNET_JSON_spec_end ()
+ };
ps->plo = NULL;
if (ps->http_status != http_status)
@@ -215,27 +220,24 @@ proposal_lookup_initial_cb
ps->h_contract_terms = *hash;
ps->merchant_sig = *sig;
-
- struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_fixed_auto ("merchant_pub",
- &merchant_pub),
- GNUNET_JSON_spec_end()
- };
-
if (GNUNET_OK !=
GNUNET_JSON_parse (contract_terms,
spec,
&error_name,
&error_line))
{
+ char *log;
+
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Parser failed on %s:%u\n",
error_name,
error_line);
+ log = json_dumps (ps->contract_terms,
+ JSON_INDENT (1));
fprintf (stderr,
"%s\n",
- json_dumps (ps->contract_terms,
- JSON_INDENT (1)));
+ log);
+ free (log);
TALER_TESTING_FAIL (ps->is);
}
@@ -262,7 +264,7 @@ proposal_lookup_initial_cb
static void
proposal_cb (void *cls,
unsigned int http_status,
- enum TALER_ErrorCode ec,
+ enum TALER_ErrorCode ec,
const json_t *obj,
const char *order_id)
{
@@ -291,35 +293,35 @@ proposal_cb (void *cls,
ps->order_id = GNUNET_strdup (order_id);
break;
default:
- {
- char *s = json_dumps (obj, JSON_COMPACT);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected status code from /proposal:" \
- " %u (%d). Command %s, response: %s\n",
- http_status,
- ec,
- TALER_TESTING_interpreter_get_current_label (
- ps->is),
- s);
- GNUNET_free_non_null (s);
- /**
- * Not failing, as test cases are _supposed_
- * to create non 200 OK situations.
- */
- TALER_TESTING_interpreter_next (ps->is);
- }
- return;
+ {
+ char *s = json_dumps (obj, JSON_COMPACT);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unexpected status code from /proposal:" \
+ " %u (%d). Command %s, response: %s\n",
+ http_status,
+ ec,
+ TALER_TESTING_interpreter_get_current_label (
+ ps->is),
+ s);
+ GNUNET_free_non_null (s);
+ /**
+ * Not failing, as test cases are _supposed_
+ * to create non 200 OK situations.
+ */
+ TALER_TESTING_interpreter_next (ps->is);
+ }
+ return;
}
if (NULL ==
- (ps->plo = TALER_MERCHANT_proposal_lookup
- (ps->is->ctx,
- ps->merchant_url,
- ps->order_id,
- ps->instance,
- &ps->nonce,
- &proposal_lookup_initial_cb,
- ps)))
+ (ps->plo = TALER_MERCHANT_proposal_lookup
+ (ps->is->ctx,
+ ps->merchant_url,
+ ps->order_id,
+ ps->instance,
+ &ps->nonce,
+ &proposal_lookup_initial_cb,
+ ps)))
TALER_TESTING_FAIL (ps->is);
}
@@ -362,8 +364,8 @@ proposal_run (void *cls,
// FIXME: should probably use get_monotone() to ensure uniqueness!
now = GNUNET_TIME_absolute_get ();
order_id = GNUNET_STRINGS_data_to_string_alloc
- (&now.abs_value_us,
- sizeof (now.abs_value_us));
+ (&now.abs_value_us,
+ sizeof (now.abs_value_us));
json_object_set_new (order,
"order_id",
json_string (order_id));
@@ -372,8 +374,8 @@ proposal_run (void *cls,
GNUNET_CRYPTO_random_block
(GNUNET_CRYPTO_QUALITY_WEAK,
- &ps->nonce,
- sizeof (struct GNUNET_CRYPTO_EddsaPublicKey));
+ &ps->nonce,
+ sizeof (struct GNUNET_CRYPTO_EddsaPublicKey));
if (NULL != ps->instance)
{
json_t *merchant;
@@ -483,7 +485,7 @@ TALER_TESTING_cmd_proposal (const char *label,
ps->order = order;
ps->http_status = http_status;
ps->merchant_url = merchant_url;
- ps->instance = (NULL == instance) ? "default": instance;
+ ps->instance = (NULL == instance) ? "default" : instance;
struct TALER_TESTING_Command cmd = {
.cls = ps,
@@ -545,7 +547,7 @@ proposal_lookup_run (void *cls,
/* Only used if we do NOT use the nonce from traits. */
struct GNUNET_CRYPTO_EddsaPublicKey dummy_nonce;
#define GET_TRAIT_NONCE(cmd,ptr) \
- TALER_TESTING_get_trait_peer_key_pub (cmd, 1, ptr)
+ TALER_TESTING_get_trait_peer_key_pub (cmd, 1, ptr)
pls->is = is;
@@ -562,7 +564,7 @@ proposal_lookup_run (void *cls,
const struct TALER_TESTING_Command *proposal_cmd;
proposal_cmd = TALER_TESTING_interpreter_lookup_command
- (is, pls->proposal_reference);
+ (is, pls->proposal_reference);
if (NULL == proposal_cmd)
TALER_TESTING_FAIL (is);
@@ -572,7 +574,7 @@ proposal_lookup_run (void *cls,
TALER_TESTING_FAIL (is);
if (GNUNET_OK != TALER_TESTING_get_trait_order_id
- (proposal_cmd, 0, &order_id))
+ (proposal_cmd, 0, &order_id))
TALER_TESTING_FAIL (is);
}
pls->plo = TALER_MERCHANT_proposal_lookup (is->ctx,
@@ -601,10 +603,10 @@ proposal_lookup_run (void *cls,
struct TALER_TESTING_Command
TALER_TESTING_cmd_proposal_lookup
(const char *label,
- const char *merchant_url,
- unsigned int http_status,
- const char *proposal_reference,
- const char *order_id)
+ const char *merchant_url,
+ unsigned int http_status,
+ const char *proposal_reference,
+ const char *order_id)
{
struct ProposalLookupState *pls;