aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/auditor/taler-wire-auditor.c14
-rw-r--r--src/bank-lib/bank_api_admin.c24
-rw-r--r--src/bank-lib/bank_api_credit.c25
-rw-r--r--src/bank-lib/bank_api_debit.c24
-rw-r--r--src/bank-lib/fakebank.c149
-rw-r--r--src/exchange/taler-exchange-httpd_refresh_reveal.c6
-rw-r--r--src/exchange/taler-exchange-wirewatch.c2
-rw-r--r--src/include/taler_bank_service.h23
-rw-r--r--src/include/taler_testing_lib.h13
-rw-r--r--src/include/taler_util.h12
-rw-r--r--src/lib/exchange_api_handle.c2
-rw-r--r--src/lib/testing_api_cmd_bank_admin_add_incoming.c2
-rw-r--r--src/lib/testing_api_cmd_bank_history_credit.c52
-rw-r--r--src/lib/testing_api_cmd_bank_history_debit.c70
-rw-r--r--src/lib/testing_api_helpers_bank.c45
-rw-r--r--src/util/util.c29
16 files changed, 278 insertions, 214 deletions
diff --git a/src/auditor/taler-wire-auditor.c b/src/auditor/taler-wire-auditor.c
index 22f3b2a4c..ffbbfd718 100644
--- a/src/auditor/taler-wire-auditor.c
+++ b/src/auditor/taler-wire-auditor.c
@@ -1083,7 +1083,7 @@ wire_out_cb (void *cls,
payto_url = TALER_JSON_wire_to_payto (wire);
if (0 != strcasecmp (payto_url,
- roi->details.account_url))
+ roi->details.credit_account_url))
{
/* Destination bank account is wrong in actual wire transfer, so
we should count the wire transfer as entirely spurious, and
@@ -1212,7 +1212,7 @@ check_rc_matches (void *cls,
if ( (0 == GNUNET_memcmp (&ctx->roi->details.wtid,
&rc->wtid)) &&
(0 == strcasecmp (rc->receiver_account,
- ctx->roi->details.account_url)) &&
+ ctx->roi->details.credit_account_url)) &&
(0 == TALER_amount_cmp (&rc->amount,
&ctx->roi->details.amount)) )
{
@@ -1254,7 +1254,7 @@ complain_out_not_found (void *cls,
};
(void) wa; // FIXME: log which account is affected...
- hash_rc (roi->details.account_url,
+ hash_rc (roi->details.credit_account_url,
&roi->details.wtid,
&rkey);
GNUNET_CONTAINER_multihashmap_get_multiple (reserve_closures,
@@ -1382,7 +1382,7 @@ history_debit_cb (void *cls,
roi->details.amount = details->amount;
roi->details.execution_date = details->execution_date;
roi->details.wtid = details->wtid;
- roi->details.account_url = GNUNET_strdup (details->account_url);
+ roi->details.credit_account_url = GNUNET_strdup (details->credit_account_url);
if (GNUNET_OK !=
GNUNET_CONTAINER_multihashmap_put (out_map,
&roi->subject_hash,
@@ -1528,7 +1528,7 @@ reserve_in_cb (void *cls,
rii->details.amount = *credit;
rii->details.execution_date = execution_date;
rii->details.reserve_pub = *reserve_pub;
- rii->details.account_url = (const char *) &rii[1];
+ rii->details.debit_account_url = (const char *) &rii[1];
memcpy (&rii[1],
sender_account_details,
slen);
@@ -1761,8 +1761,8 @@ history_credit_cb (void *cls,
}
goto cleanup;
}
- if (0 != strcasecmp (details->account_url,
- rii->details.account_url))
+ if (0 != strcasecmp (details->debit_account_url,
+ rii->details.debit_account_url))
{
report (report_missattribution_in_inconsistencies,
json_pack ("{s:o, s:I, s:I, s:o}",
diff --git a/src/bank-lib/bank_api_admin.c b/src/bank-lib/bank_api_admin.c
index 068fd0e0e..2b6e45f45 100644
--- a/src/bank-lib/bank_api_admin.c
+++ b/src/bank-lib/bank_api_admin.c
@@ -27,7 +27,7 @@
/**
- * @brief An admin/add/incoming Handle
+ * @brief An admin/add-incoming Handle
*/
struct TALER_BANK_AdminAddIncomingHandle
{
@@ -62,7 +62,7 @@ struct TALER_BANK_AdminAddIncomingHandle
/**
* Function called when we're done processing the
- * HTTP /admin/add/incoming request.
+ * HTTP /admin/add-incoming request.
*
* @param cls the `struct TALER_BANK_AdminAddIncomingHandle`
* @param response_code HTTP response code, 0 on error
@@ -166,11 +166,11 @@ handle_admin_add_incoming_finished (void *cls,
* to the operators of the bank.
*
* @param ctx curl context for the event loop
- * @param account_base_url URL of the bank (used to execute this request)
+ * @param account_base_url URL of the bank (money flows into this account)
* @param auth authentication data to send to the bank
* @param reserve_pub wire transfer subject for the transfer
* @param amount amount that was deposited
- * @param credit_account account to deposit into (payto)
+ * @param debit_account account to deposit from (payto URI, but used as 'payfrom')
* @param res_cb the callback to call when the final result for this request is available
* @param res_cb_cls closure for the above callback
* @return NULL
@@ -184,7 +184,7 @@ TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx,
const struct
TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_Amount *amount,
- const char *credit_account,
+ const char *debit_account,
TALER_BANK_AdminAddIncomingResultCallback res_cb,
void *res_cb_cls)
{
@@ -193,9 +193,12 @@ TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx,
CURL *eh;
admin_obj = json_pack ("{s:o, s:o, s:s}",
- "subject", GNUNET_JSON_from_data_auto (reserve_pub),
- "amount", TALER_JSON_from_amount (amount),
- "credit_account", credit_account);
+ "reserve_pub",
+ GNUNET_JSON_from_data_auto (reserve_pub),
+ "amount",
+ TALER_JSON_from_amount (amount),
+ "debit_account",
+ debit_account);
if (NULL == admin_obj)
{
GNUNET_break (0);
@@ -205,7 +208,10 @@ TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx,
aai->cb = res_cb;
aai->cb_cls = res_cb_cls;
aai->request_url = TALER_BANK_path_to_url_ (account_base_url,
- "/admin/add/incoming");
+ "/admin/add-incoming");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Requesting administrative transaction at `%s'\n",
+ aai->request_url);
aai->post_ctx.headers = curl_slist_append
(aai->post_ctx.headers,
"Content-Type: application/json");
diff --git a/src/bank-lib/bank_api_credit.c b/src/bank-lib/bank_api_credit.c
index ed0a1e2a7..4bb6e7cb2 100644
--- a/src/bank-lib/bank_api_credit.c
+++ b/src/bank-lib/bank_api_credit.c
@@ -17,8 +17,8 @@
see <http://www.gnu.org/licenses/>
*/
/**
- * @file bank-lib/bank_api_history.c
- * @brief Implementation of the /history[-range]
+ * @file bank-lib/bank_api_credit.c
+ * @brief Implementation of the /history/incoming
* requests of the bank's HTTP API.
* @author Christian Grothoff
* @author Marcello Stanisci
@@ -78,7 +78,7 @@ parse_account_history (struct TALER_BANK_CreditHistoryHandle *hh,
json_t *history_array;
if (NULL == (history_array = json_object_get (history,
- "data")))
+ "incoming_transactions")))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@@ -101,8 +101,10 @@ parse_account_history (struct TALER_BANK_CreditHistoryHandle *hh,
&row_id),
GNUNET_JSON_spec_fixed_auto ("reserve_pub",
&td.reserve_pub),
- GNUNET_JSON_spec_string ("counterpart",
- &td.account_url),
+ GNUNET_JSON_spec_string ("debit_account",
+ &td.debit_account_url),
+ GNUNET_JSON_spec_string ("credit_account",
+ &td.credit_account_url),
GNUNET_JSON_spec_end ()
};
json_t *transaction = json_array_get (history_array,
@@ -250,13 +252,16 @@ TALER_BANK_credit_history (struct GNUNET_CURL_Context *ctx,
return NULL;
}
- if (UINT64_MAX == start_row)
+ if ( ( (UINT64_MAX == start_row) &&
+ (0 > num_results) ) ||
+ ( (0 == start_row) &&
+ (0 < num_results) ) )
GNUNET_asprintf (&url,
- "/history&delta=%lld",
+ "/history/incoming?delta=%lld",
(long long) num_results);
else
GNUNET_asprintf (&url,
- "/history&delta=%lld&start=%llu",
+ "/history/incoming?delta=%lld&start=%llu",
(long long) num_results,
start_row);
hh = GNUNET_new (struct TALER_BANK_CreditHistoryHandle);
@@ -265,7 +270,9 @@ TALER_BANK_credit_history (struct GNUNET_CURL_Context *ctx,
hh->bank_base_url = GNUNET_strdup (bank_base_url);
hh->request_url = TALER_BANK_path_to_url_ (bank_base_url,
url);
-
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Requesting history at `%s'\n",
+ hh->request_url);
eh = curl_easy_init ();
if ( (GNUNET_OK !=
TALER_BANK_setup_auth_ (eh,
diff --git a/src/bank-lib/bank_api_debit.c b/src/bank-lib/bank_api_debit.c
index 848362438..1d5f6eaeb 100644
--- a/src/bank-lib/bank_api_debit.c
+++ b/src/bank-lib/bank_api_debit.c
@@ -17,8 +17,8 @@
see <http://www.gnu.org/licenses/>
*/
/**
- * @file bank-lib/bank_api_history.c
- * @brief Implementation of the /history[-range]
+ * @file bank-lib/bank_api_debit.c
+ * @brief Implementation of the /history/outgoing
* requests of the bank's HTTP API.
* @author Christian Grothoff
* @author Marcello Stanisci
@@ -78,7 +78,7 @@ parse_account_history (struct TALER_BANK_DebitHistoryHandle *hh,
json_t *history_array;
if (NULL == (history_array = json_object_get (history,
- "data")))
+ "outgoing_transactions")))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@@ -101,8 +101,10 @@ parse_account_history (struct TALER_BANK_DebitHistoryHandle *hh,
&row_id),
GNUNET_JSON_spec_fixed_auto ("wtid",
&td.wtid),
- GNUNET_JSON_spec_string ("counterpart",
- &td.account_url),
+ GNUNET_JSON_spec_string ("credit_account",
+ &td.credit_account_url),
+ GNUNET_JSON_spec_string ("debit_account",
+ &td.debit_account_url),
GNUNET_JSON_spec_string ("exchange_base_url",
&td.exchange_base_url),
GNUNET_JSON_spec_end ()
@@ -252,13 +254,16 @@ TALER_BANK_debit_history (struct GNUNET_CURL_Context *ctx,
return NULL;
}
- if (UINT64_MAX == start_row)
+ if ( ( (UINT64_MAX == start_row) &&
+ (0 > num_results) ) ||
+ ( (0 == start_row) &&
+ (0 < num_results) ) )
GNUNET_asprintf (&url,
- "/history&delta=%lld",
+ "/history/outgoing?delta=%lld",
(long long) num_results);
else
GNUNET_asprintf (&url,
- "/history&delta=%lld&start=%llu",
+ "/history/outgoing?delta=%lld&start=%llu",
(long long) num_results,
start_row);
hh = GNUNET_new (struct TALER_BANK_DebitHistoryHandle);
@@ -268,6 +273,9 @@ TALER_BANK_debit_history (struct GNUNET_CURL_Context *ctx,
hh->request_url = TALER_BANK_path_to_url_ (bank_base_url,
url);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Requesting history at `%s'\n",
+ hh->request_url);
eh = curl_easy_init ();
if ( (GNUNET_OK !=
TALER_BANK_setup_auth_ (eh,
diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c
index 79c022794..295c053f3 100644
--- a/src/bank-lib/fakebank.c
+++ b/src/bank-lib/fakebank.c
@@ -169,6 +169,11 @@ struct TALER_FAKEBANK_Handle
uint64_t serial_counter;
/**
+ * BaseURL of the fakebank.
+ */
+ char *my_baseurl;
+
+ /**
* Our port number.
*/
uint16_t port;
@@ -188,7 +193,30 @@ struct TALER_FAKEBANK_Handle
/**
+ * Return account string from an x-taler-bank payto:// URL.
+ *
+ * @param payto:// URL of method x-taler-bank
+ * @return account_name the account name
+ */
+char *
+get_xtalerbank_payto_account (const char *payto_url)
+{
+ const char *beg;
+
+ GNUNET_assert (0 == strncasecmp (payto_url,
+ "payto://x-taler-bank/",
+ strlen ("payto://x-taler-bank/")));
+ beg = strchr (&payto_url[strlen ("payto://x-taler-bank/")],
+ '/');
+ GNUNET_assert (NULL != beg);
+ return GNUNET_strdup (&beg[1]);
+}
+
+
+/**
* Generate log messages for failed check operation.
+ *
+ * @param h handle to output transaction log for
*/
static void
check_log (struct TALER_FAKEBANK_Handle *h)
@@ -197,11 +225,11 @@ check_log (struct TALER_FAKEBANK_Handle *h)
{
if (GNUNET_YES == t->checked)
continue;
- fprintf (stderr,
- "%llu -> %llu (%s)\n",
- (unsigned long long) t->debit_account,
- (unsigned long long) t->credit_account,
- TALER_amount2s (&t->amount));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "%s -> %s (%s)\n",
+ t->debit_account,
+ t->credit_account,
+ TALER_amount2s (&t->amount));
}
}
@@ -247,15 +275,15 @@ TALER_FAKEBANK_check_debit (struct TALER_FAKEBANK_Handle *h,
return GNUNET_OK;
}
}
- fprintf (stderr,
- "Did not find matching transaction!\nI have:\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Did not find matching transaction!\nI have:\n");
check_log (h);
- fprintf (stderr,
- "I wanted:\n%s -> %s (%s) from %s\n",
- want_debit,
- want_credit,
- TALER_amount2s (want_amount),
- exchange_base_url);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "I wanted:\n%s -> %s (%s) from %s\n",
+ want_debit,
+ want_credit,
+ TALER_amount2s (want_amount),
+ exchange_base_url);
return GNUNET_SYSERR;
}
@@ -296,15 +324,15 @@ TALER_FAKEBANK_check_credit (struct TALER_FAKEBANK_Handle *h,
return GNUNET_OK;
}
}
- fprintf (stderr,
- "Did not find matching transaction!\nI have:\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Did not find matching transaction!\nI have:\n");
check_log (h);
- fprintf (stderr,
- "I wanted:\n%llu -> %llu (%s) with subject %s\n",
- (unsigned long long) want_debit,
- (unsigned long long) want_credit,
- TALER_amount2s (want_amount),
- TALER_B2S (reserve_pub));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "I wanted:\n%llu -> %llu (%s) with subject %s\n",
+ (unsigned long long) want_debit,
+ (unsigned long long) want_credit,
+ TALER_amount2s (want_amount),
+ TALER_B2S (reserve_pub));
return GNUNET_SYSERR;
}
@@ -419,8 +447,8 @@ TALER_FAKEBANK_check_empty (struct TALER_FAKEBANK_Handle *h)
}
if (NULL == t)
return GNUNET_OK;
- fprintf (stderr,
- "Expected empty transaction set, but I have:\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Expected empty transaction set, but I have:\n");
check_log (h);
return GNUNET_SYSERR;
}
@@ -460,6 +488,7 @@ TALER_FAKEBANK_stop (struct TALER_FAKEBANK_Handle *h)
MHD_stop_daemon (h->mhd_bank);
h->mhd_bank = NULL;
}
+ GNUNET_free (h->my_baseurl);
GNUNET_free (h);
}
@@ -498,6 +527,7 @@ handle_mhd_completion_callback (void *cls,
*
* @param h the fakebank handle
* @param connection the connection
+ * @param account account into which to deposit the funds (credit)
* @param upload_data request data
* @param upload_data_size size of @a upload_data in bytes
* @param con_cls closure for request (a `struct Buffer *`)
@@ -506,6 +536,7 @@ handle_mhd_completion_callback (void *cls,
static int
handle_admin_add_incoming (struct TALER_FAKEBANK_Handle *h,
struct MHD_Connection *connection,
+ const char *account,
const char *upload_data,
size_t *upload_data_size,
void **con_cls)
@@ -538,16 +569,16 @@ handle_admin_add_incoming (struct TALER_FAKEBANK_Handle *h,
}
{
const char *debit_account;
- const char *credit_account;
struct TALER_Amount amount;
struct TALER_ReservePublicKeyP reserve_pub;
+ char *debit;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("reserve_pub", &reserve_pub),
GNUNET_JSON_spec_string ("debit_account", &debit_account),
- GNUNET_JSON_spec_string ("credit_account", &credit_account),
TALER_JSON_spec_amount ("amount", &amount),
GNUNET_JSON_spec_end ()
};
+
if (GNUNET_OK !=
GNUNET_JSON_parse (json,
spec,
@@ -557,17 +588,19 @@ handle_admin_add_incoming (struct TALER_FAKEBANK_Handle *h,
json_decref (json);
return MHD_NO;
}
+ debit = get_xtalerbank_payto_account (debit_account);
row_id = TALER_FAKEBANK_make_admin_transfer (h,
- debit_account,
- credit_account,
+ debit,
+ account,
&amount,
&reserve_pub);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Receiving incoming wire transfer: %s->%s, subject: %s, amount: %s\n",
- debit_account,
- credit_account,
+ debit,
+ account,
TALER_B2S (&reserve_pub),
TALER_amount2s (&amount));
+ GNUNET_free (debit);
}
json_decref (json);
@@ -882,15 +915,24 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
account))
{
json_t *trans;
+ char *credit_payto;
+ char *debit_payto;
+ credit_payto = TALER_payto_xtalerbank_make (h->my_baseurl,
+ account);
+ debit_payto = TALER_payto_xtalerbank_make (h->my_baseurl,
+ pos->debit_account);
trans = json_pack
- ("{s:I, s:o, s:o, s:s, s:s, s:s}",
+ ("{s:I, s:o, s:o, s:s, s:s, s:o}",
"row_id", (json_int_t) pos->row_id,
"date", GNUNET_JSON_from_time_abs (pos->date),
"amount", TALER_JSON_from_amount (&pos->amount),
- "credit_account", account,
- "debit_account", pos->debit_account,
- "wtid", pos->subject /* we "know" it is OK */);
+ "credit_account", credit_payto,
+ "debit_account", debit_payto,
+ "wtid", GNUNET_JSON_from_data_auto (
+ &pos->subject.debit.wtid));
+ GNUNET_free (credit_payto);
+ GNUNET_free (debit_payto);
GNUNET_assert (0 ==
json_array_append_new (history,
trans));
@@ -904,14 +946,16 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
else
pos = pos->next;
}
- return TALER_MHD_reply_json (connection,
- history,
- MHD_HTTP_OK);
+ return TALER_MHD_reply_json_pack (connection,
+ MHD_HTTP_OK,
+ "{s:o}",
+ "incoming_transactions",
+ history);
}
/**
- * Handle incoming HTTP request for /history/incoming
+ * Handle incoming HTTP request for /history/outgoing
*
* @param h the fakebank handle
* @param connection the connection
@@ -974,15 +1018,23 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h,
account))
{
json_t *trans;
+ char *credit_payto;
+ char *debit_payto;
+ credit_payto = TALER_payto_xtalerbank_make (h->my_baseurl,
+ pos->credit_account);
+ debit_payto = TALER_payto_xtalerbank_make (h->my_baseurl,
+ account);
trans = json_pack
("{s:I, s:o, s:o, s:s, s:s, s:s}",
"row_id", (json_int_t) pos->row_id,
"date", GNUNET_JSON_from_time_abs (pos->date),
"amount", TALER_JSON_from_amount (&pos->amount),
- "credit_account", pos->credit_account,
- "debit_account", account,
+ "credit_account", credit_payto,
+ "debit_account", debit_payto,
"reserve_pub", pos->subject /* we "know" it is OK */);
+ GNUNET_free (credit_payto);
+ GNUNET_free (debit_payto);
GNUNET_assert (0 ==
json_array_append_new (history,
trans));
@@ -996,9 +1048,11 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h,
else
pos = pos->next;
}
- return TALER_MHD_reply_json (connection,
- history,
- MHD_HTTP_OK);
+ return TALER_MHD_reply_json_pack (connection,
+ MHD_HTTP_OK,
+ "{s:o}",
+ "outgoing_transactions",
+ history);
}
@@ -1026,8 +1080,9 @@ serve (struct TALER_FAKEBANK_Handle *h,
void **con_cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Fakebank, serving: %s\n",
- url);
+ "Fakebank, serving URL `%s' for account `%s'\n",
+ url,
+ account);
if ( (0 == strcmp (url,
"/")) &&
(0 == strcasecmp (method,
@@ -1036,11 +1091,12 @@ serve (struct TALER_FAKEBANK_Handle *h,
connection,
con_cls);
if ( (0 == strcmp (url,
- "/admin/add/incoming")) &&
+ "/admin/add-incoming")) &&
(0 == strcasecmp (method,
MHD_HTTP_METHOD_POST)) )
return handle_admin_add_incoming (h,
connection,
+ account,
upload_data,
upload_data_size,
con_cls);
@@ -1264,6 +1320,9 @@ TALER_FAKEBANK_start (uint16_t port)
h = GNUNET_new (struct TALER_FAKEBANK_Handle);
h->port = port;
+ GNUNET_asprintf (&h->my_baseurl,
+ "http://localhost:%u/",
+ (unsigned int) port);
h->mhd_bank = MHD_start_daemon (MHD_USE_DEBUG
#if EPOLL_SUPPORT
| MHD_USE_EPOLL_INTERNAL_THREAD
diff --git a/src/exchange/taler-exchange-httpd_refresh_reveal.c b/src/exchange/taler-exchange-httpd_refresh_reveal.c
index 97e687ea9..fb2602c61 100644
--- a/src/exchange/taler-exchange-httpd_refresh_reveal.c
+++ b/src/exchange/taler-exchange-httpd_refresh_reveal.c
@@ -771,9 +771,9 @@ handle_refresh_reveal_json (struct MHD_Connection *connection,
{
rctx->ev_sigs[i].rsa_signature
= GNUNET_CRYPTO_rsa_sign_blinded (
- rctx->dkis[i]->denom_priv.rsa_private_key,
- rctx->rcds[i].coin_ev,
- rctx->rcds[i].coin_ev_size);
+ rctx->dkis[i]->denom_priv.rsa_private_key,
+ rctx->rcds[i].coin_ev,
+ rctx->rcds[i].coin_ev_size);
if (NULL == rctx->ev_sigs[i].rsa_signature)
{
GNUNET_break (0);
diff --git a/src/exchange/taler-exchange-wirewatch.c b/src/exchange/taler-exchange-wirewatch.c
index eda86e363..c328e73e2 100644
--- a/src/exchange/taler-exchange-wirewatch.c
+++ b/src/exchange/taler-exchange-wirewatch.c
@@ -440,7 +440,7 @@ history_cb (void *cls,
&details->reserve_pub,
&details->amount,
details->execution_date,
- details->account_url,
+ details->debit_account_url,
wa_pos->section_name,
serial_id);
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
diff --git a/src/include/taler_bank_service.h b/src/include/taler_bank_service.h
index 60fce8cb2..67961b820 100644
--- a/src/include/taler_bank_service.h
+++ b/src/include/taler_bank_service.h
@@ -199,11 +199,11 @@ typedef void
* to the operators of the bank.
*
* @param ctx curl context for the event loop
- * @param account_base_url URL of the account (used to execute this request)
- * @param auth authentication data to use
+ * @param account_base_url URL of the bank (money flows into this account)
+ * @param auth authentication data to send to the bank
* @param reserve_pub wire transfer subject for the transfer
* @param amount amount that was deposited
- * @param credit_account account to deposit into
+ * @param debit_account account to deposit from (payto URI, but used as 'payfrom')
* @param res_cb the callback to call when the final result for this request is available
* @param res_cb_cls closure for the above callback
* @return NULL
@@ -350,7 +350,13 @@ struct TALER_BANK_CreditDetails
* payto://-URL of the source account that
* send the funds.
*/
- const char *account_url;
+ const char *debit_account_url;
+
+ /**
+ * payto://-URL of the target account that
+ * received the funds.
+ */
+ const char *credit_account_url;
};
@@ -455,7 +461,14 @@ struct TALER_BANK_DebitDetails
* payto://-URL of the source account that
* send the funds.
*/
- const char *account_url;
+ const char *debit_account_url;
+
+ /**
+ * payto://-URL of the target account that
+ * received the funds.
+ */
+ const char *credit_account_url;
+
};
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h
index b43336952..9499526af 100644
--- a/src/include/taler_testing_lib.h
+++ b/src/include/taler_testing_lib.h
@@ -74,19 +74,6 @@
/**
- * Create an x-taler-bank payto:// URL from a @a bank_url
- * and an @a account_name.
- *
- * @param bank_url the bank URL
- * @param account_name the account name
- * @return payto:// URL
- */
-char *
-TALER_TESTING_make_xtalerbank_payto (const char *bank_url,
- const char *account_name);
-
-
-/**
* Allocate and return a piece of wire-details. Combines
* a @a payto -URL and adds some salt to create the JSON.
*
diff --git a/src/include/taler_util.h b/src/include/taler_util.h
index 105dba61a..b6fed3f12 100644
--- a/src/include/taler_util.h
+++ b/src/include/taler_util.h
@@ -391,4 +391,16 @@ char *
TALER_payto_get_method (const char *payto_url);
+/**
+ * Create an x-taler-bank payto:// URL from a @a bank_url
+ * and an @a account_name.
+ *
+ * @param bank_url the bank URL
+ * @param account_name the account name
+ * @return payto:// URL
+ */
+char *
+TALER_payto_xtalerbank_make (const char *bank_url,
+ const char *account_name);
+
#endif
diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c
index 6b51519fd..abb95816c 100644
--- a/src/lib/exchange_api_handle.c
+++ b/src/lib/exchange_api_handle.c
@@ -1262,7 +1262,7 @@ keys_completed_cb (void *cls,
for (unsigned int i = 0; i<kd_old.num_denom_keys; i++)
kd.denom_keys[i].key.rsa_public_key
= GNUNET_CRYPTO_rsa_public_key_dup (
- kd_old.denom_keys[i].key.rsa_public_key);
+ kd_old.denom_keys[i].key.rsa_public_key);
kd.num_auditors = kd_old.num_auditors;
kd.auditors = GNUNET_new_array (kd.num_auditors,
diff --git a/src/lib/testing_api_cmd_bank_admin_add_incoming.c b/src/lib/testing_api_cmd_bank_admin_add_incoming.c
index 690b78437..d2f6cd2c6 100644
--- a/src/lib/testing_api_cmd_bank_admin_add_incoming.c
+++ b/src/lib/testing_api_cmd_bank_admin_add_incoming.c
@@ -398,7 +398,7 @@ admin_add_incoming_traits (void *cls,
{
struct AdminAddIncomingState *fts = cls;
struct TALER_TESTING_Trait traits[] = {
- TALER_TESTING_make_trait_url (1, fts->payto_debit_account),
+ TALER_TESTING_make_trait_payto (1, fts->payto_debit_account),
TALER_TESTING_MAKE_TRAIT_ROW_ID (&fts->serial_id),
TALER_TESTING_MAKE_TRAIT_CREDIT_ACCOUNT (fts->exchange_credit_url),
TALER_TESTING_make_trait_amount_obj (0, &fts->amount),
diff --git a/src/lib/testing_api_cmd_bank_history_credit.c b/src/lib/testing_api_cmd_bank_history_credit.c
index 92a28c22f..40ec99162 100644
--- a/src/lib/testing_api_cmd_bank_history_credit.c
+++ b/src/lib/testing_api_cmd_bank_history_credit.c
@@ -170,7 +170,7 @@ print_expected (struct History *h,
TALER_amount2s (&h[i].details.amount),
(unsigned long long) h[i].row_id,
TALER_B2S (&h[i].details.reserve_pub),
- h[i].details.account_url);
+ h[i].details.debit_account_url);
}
}
@@ -415,18 +415,6 @@ build_history (struct TALER_TESTING_Interpreter *is,
credit_account,
hs->account_url);
- /**
- * Discard transactions where the audited account played
- * _both_ the credit and the debit roles, but _only if_
- * the audit goes on both directions.. This needs more
- * explaination!
- */if (0 == strcasecmp (hs->account_url,
- credit_account))
- {
- GNUNET_break (0);
- continue;
- }
-
bank_hostname = strchr (hs->account_url, ':');
GNUNET_assert (NULL != bank_hostname);
bank_hostname += 3;
@@ -438,15 +426,6 @@ build_history (struct TALER_TESTING_Interpreter *is,
if (0 == strcasecmp (hs->account_url,
credit_account))
{
- h[total].url = GNUNET_strdup (debit_account);
- h[total].details.account_url = h[total].url;
- }
-
- /* This block _completes_ the information of the current item,
- * with amount / subject / exchange URL. */
- if (0 == strcasecmp (hs->account_url,
- credit_account))
- {
const struct TALER_Amount *amount;
const struct TALER_ReservePublicKeyP *reserve_pub;
const char *account_url;
@@ -461,10 +440,12 @@ build_history (struct TALER_TESTING_Interpreter *is,
TALER_TESTING_get_trait_url
(pos, 1,
&account_url));
+ h[total].url = GNUNET_strdup (debit_account);
+ h[total].details.debit_account_url = h[total].url;
h[total].details.amount = *amount;
h[total].row_id = *row_id;
h[total].details.reserve_pub = *reserve_pub;
- h[total].details.account_url = account_url;
+ h[total].details.credit_account_url = account_url;
TALER_LOG_INFO ("+1-bit of my history\n");
total++;
}
@@ -530,8 +511,8 @@ check_result (struct TALER_TESTING_Interpreter *is,
&details->reserve_pub)) ||
(0 != TALER_amount_cmp (&h[off].details.amount,
&details->amount)) ||
- (0 != strcasecmp (h[off].details.account_url,
- details->account_url)) )
+ (0 != strcasecmp (h[off].details.debit_account_url,
+ details->debit_account_url)) )
{
GNUNET_break (0);
print_expected (h,
@@ -582,20 +563,12 @@ history_cb (void *cls,
struct HistoryState *hs = is->commands[is->ip].cls;
(void) row_id;
- if (MHD_HTTP_OK != http_status)
- {
- hs->hh = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unwanted response code from /history: %u\n",
- http_status);
- TALER_TESTING_interpreter_fail (is);
- return GNUNET_SYSERR;
- }
if (NULL == details)
{
hs->hh = NULL;
if ( (hs->results_obtained != compute_result_count (is)) ||
- (GNUNET_YES == hs->failed) )
+ (GNUNET_YES == hs->failed) ||
+ (MHD_HTTP_NO_CONTENT != http_status) )
{
uint64_t total;
struct History *h;
@@ -622,6 +595,15 @@ history_cb (void *cls,
return GNUNET_OK;
}
+ if (MHD_HTTP_OK != http_status)
+ {
+ hs->hh = NULL;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unwanted response code from /history: %u\n",
+ http_status);
+ TALER_TESTING_interpreter_fail (is);
+ return GNUNET_SYSERR;
+ }
/* check current element */
if (GNUNET_OK != check_result (is,
hs->results_obtained,
diff --git a/src/lib/testing_api_cmd_bank_history_debit.c b/src/lib/testing_api_cmd_bank_history_debit.c
index 0b0cc40e1..ec4a323e6 100644
--- a/src/lib/testing_api_cmd_bank_history_debit.c
+++ b/src/lib/testing_api_cmd_bank_history_debit.c
@@ -170,7 +170,7 @@ print_expected (struct History *h,
TALER_amount2s (&h[i].details.amount),
(unsigned long long) h[i].row_id,
TALER_B2S (&h[i].details.wtid),
- h[i].details.account_url);
+ h[i].details.credit_account_url);
}
}
@@ -219,12 +219,10 @@ build_history (struct TALER_TESTING_Interpreter *is,
int inc;
unsigned int start;
unsigned int end;
-
- /**
- * @var turns GNUNET_YES whenever either no 'start' value was
- * given for the history query, or the given value is found
- * in the list of all the CMDs.
- */int ok;
+ /* GNUNET_YES whenever either no 'start' value was given for the history
+ * query, or the given value is found in the list of all the CMDs.
+ */
+ int ok;
const uint64_t *row_id_start = NULL;
if (NULL != hs->start_row_reference)
@@ -278,11 +276,11 @@ build_history (struct TALER_TESTING_Interpreter *is,
const char *debit_account;
const char *credit_account;
- /**
- * The following command allows us to skip over those CMDs
+ /* The following command allows us to skip over those CMDs
* that do not offer a "row_id" trait. Such skipped CMDs are
* not interesting for building a history.
- */if (GNUNET_OK != TALER_TESTING_get_trait_uint64 (pos,
+ */
+ if (GNUNET_OK != TALER_TESTING_get_trait_uint64 (pos,
0,
&row_id))
continue;
@@ -408,18 +406,16 @@ build_history (struct TALER_TESTING_Interpreter *is,
(GNUNET_OK == TALER_TESTING_GET_TRAIT_CREDIT_ACCOUNT
(pos, &credit_account));
- TALER_LOG_INFO ("Potential history bit:"
- " %s->%s; my account: %s\n",
+ TALER_LOG_INFO ("Potential history bit: %s->%s; my account: %s\n",
debit_account,
credit_account,
hs->account_url);
- /**
- * Discard transactions where the audited account played
- * _both_ the debit and the debit roles, but _only if_
- * the audit goes on both directions.. This needs more
- * explaination!
- */if (0 == strcasecmp (hs->account_url,
+ /* Discard transactions where the audited account played _both_ the debit
+ * and the debit roles, but _only if_ the audit goes on both directions..
+ * This needs more explaination!
+ */
+ if (0 == strcasecmp (hs->account_url,
debit_account))
{
GNUNET_break (0);
@@ -437,15 +433,6 @@ build_history (struct TALER_TESTING_Interpreter *is,
if (0 == strcasecmp (hs->account_url,
debit_account))
{
- h[total].url = GNUNET_strdup (credit_account);
- h[total].details.account_url = h[total].url;
- }
-
- /* This block _completes_ the information of the current item,
- * with amount / subject / exchange URL. */
- if (0 == strcasecmp (hs->account_url,
- debit_account))
- {
const struct TALER_Amount *amount;
const struct TALER_WireTransferIdentifierRawP *wtid;
const char *account_url;
@@ -460,10 +447,12 @@ build_history (struct TALER_TESTING_Interpreter *is,
TALER_TESTING_get_trait_url
(pos, 1,
&account_url));
+ h[total].url = GNUNET_strdup (credit_account);
+ h[total].details.credit_account_url = h[total].url;
h[total].details.amount = *amount;
h[total].row_id = *row_id;
h[total].details.wtid = *wtid;
- h[total].details.account_url = account_url;
+ h[total].details.debit_account_url = account_url;
TALER_LOG_INFO ("+1-bit of my history\n");
total++;
}
@@ -529,8 +518,8 @@ check_result (struct TALER_TESTING_Interpreter *is,
&details->wtid)) ||
(0 != TALER_amount_cmp (&h[off].details.amount,
&details->amount)) ||
- (0 != strcasecmp (h[off].details.account_url,
- details->account_url)) )
+ (0 != strcasecmp (h[off].details.credit_account_url,
+ details->credit_account_url)) )
{
GNUNET_break (0);
print_expected (h,
@@ -581,20 +570,12 @@ history_cb (void *cls,
struct HistoryState *hs = is->commands[is->ip].cls;
(void) row_id;
- if (MHD_HTTP_OK != http_status)
- {
- hs->hh = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unwanted response code from /history: %u\n",
- http_status);
- TALER_TESTING_interpreter_fail (is);
- return GNUNET_SYSERR;
- }
if (NULL == details)
{
hs->hh = NULL;
if ( (hs->results_obtained != compute_result_count (is)) ||
- (GNUNET_YES == hs->failed) )
+ (GNUNET_YES == hs->failed) ||
+ (MHD_HTTP_NO_CONTENT != http_status) )
{
uint64_t total;
struct History *h;
@@ -621,6 +602,15 @@ history_cb (void *cls,
return GNUNET_OK;
}
+ if (MHD_HTTP_OK != http_status)
+ {
+ hs->hh = NULL;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unwanted response code from /history: %u\n",
+ http_status);
+ TALER_TESTING_interpreter_fail (is);
+ return GNUNET_SYSERR;
+ }
/* check current element */
if (GNUNET_OK != check_result (is,
hs->results_obtained,
diff --git a/src/lib/testing_api_helpers_bank.c b/src/lib/testing_api_helpers_bank.c
index 1f0617992..5147034af 100644
--- a/src/lib/testing_api_helpers_bank.c
+++ b/src/lib/testing_api_helpers_bank.c
@@ -349,10 +349,10 @@ TALER_TESTING_prepare_bank (const char *config_filename,
"%s%s",
bc->bank_url,
EXCHANGE_ACCOUNT_NAME);
- bc->exchange_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url,
- EXCHANGE_ACCOUNT_NAME);
- bc->user42_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "42");
- bc->user43_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "43");
+ bc->exchange_payto = TALER_payto_xtalerbank_make (bc->bank_url,
+ EXCHANGE_ACCOUNT_NAME);
+ bc->user42_payto = TALER_payto_xtalerbank_make (bc->bank_url, "42");
+ bc->user43_payto = TALER_payto_xtalerbank_make (bc->bank_url, "43");
return GNUNET_OK;
}
@@ -424,47 +424,18 @@ TALER_TESTING_prepare_fakebank (const char *config_filename,
}
bc->bank_url = fakebank_url;
GNUNET_asprintf (&bc->exchange_account_url,
- "%s%s",
+ "%s/%s",
bc->bank_url,
EXCHANGE_ACCOUNT_NAME);
bc->exchange_auth.method = TALER_BANK_AUTH_NONE;
- bc->exchange_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "2");
- bc->user42_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "42");
- bc->user43_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "43");
+ bc->exchange_payto = TALER_payto_xtalerbank_make (bc->bank_url, "2");
+ bc->user42_payto = TALER_payto_xtalerbank_make (bc->bank_url, "42");
+ bc->user43_payto = TALER_payto_xtalerbank_make (bc->bank_url, "43");
return GNUNET_OK;
}
/**
- * Create an x-taler-bank payto:// URL from a @a bank_url
- * and an @a account_name.
- *
- * @param bank_url the bank URL
- * @param account_name the account name
- * @return payto:// URL
- */
-char *
-TALER_TESTING_make_xtalerbank_payto (const char *bank_url,
- const char *account_name)
-{
- char *payto;
- int ends_slash;
-
- if (0 < strlen (bank_url))
- ends_slash = '/' == bank_url[strlen (bank_url) - 1];
- else
- ends_slash = 0;
- GNUNET_asprintf (&payto,
- (ends_slash)
- ? "payto://x-taler-bank/%s%s"
- : "payto://x-taler-bank/%s/%s",
- bank_url,
- account_name);
- return payto;
-}
-
-
-/**
* Allocate and return a piece of wire-details. Combines
* a @a payto -URL and adds some salt to create the JSON.
*
diff --git a/src/util/util.c b/src/util/util.c
index e312e345b..50ac5c1a7 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -776,4 +776,33 @@ TALER_payto_get_method (const char *payto_url)
}
+/**
+ * Create an x-taler-bank payto:// URL from a @a bank_url
+ * and an @a account_name.
+ *
+ * @param bank_url the bank URL
+ * @param account_name the account name
+ * @return payto:// URL
+ */
+char *
+TALER_payto_xtalerbank_make (const char *bank_url,
+ const char *account_name)
+{
+ char *payto;
+ int ends_slash;
+
+ if (0 < strlen (bank_url))
+ ends_slash = '/' == bank_url[strlen (bank_url) - 1];
+ else
+ ends_slash = 0;
+ GNUNET_asprintf (&payto,
+ (ends_slash)
+ ? "payto://x-taler-bank/%s%s"
+ : "payto://x-taler-bank/%s/%s",
+ bank_url,
+ account_name);
+ return payto;
+}
+
+
/* end of util.c */