make fakebank and banklib match specifified new API
This commit is contained in:
parent
2d16cddfd9
commit
7b1909bc99
@ -1083,7 +1083,7 @@ wire_out_cb (void *cls,
|
|||||||
|
|
||||||
payto_url = TALER_JSON_wire_to_payto (wire);
|
payto_url = TALER_JSON_wire_to_payto (wire);
|
||||||
if (0 != strcasecmp (payto_url,
|
if (0 != strcasecmp (payto_url,
|
||||||
roi->details.account_url))
|
roi->details.credit_account_url))
|
||||||
{
|
{
|
||||||
/* Destination bank account is wrong in actual wire transfer, so
|
/* Destination bank account is wrong in actual wire transfer, so
|
||||||
we should count the wire transfer as entirely spurious, and
|
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,
|
if ( (0 == GNUNET_memcmp (&ctx->roi->details.wtid,
|
||||||
&rc->wtid)) &&
|
&rc->wtid)) &&
|
||||||
(0 == strcasecmp (rc->receiver_account,
|
(0 == strcasecmp (rc->receiver_account,
|
||||||
ctx->roi->details.account_url)) &&
|
ctx->roi->details.credit_account_url)) &&
|
||||||
(0 == TALER_amount_cmp (&rc->amount,
|
(0 == TALER_amount_cmp (&rc->amount,
|
||||||
&ctx->roi->details.amount)) )
|
&ctx->roi->details.amount)) )
|
||||||
{
|
{
|
||||||
@ -1254,7 +1254,7 @@ complain_out_not_found (void *cls,
|
|||||||
};
|
};
|
||||||
|
|
||||||
(void) wa; // FIXME: log which account is affected...
|
(void) wa; // FIXME: log which account is affected...
|
||||||
hash_rc (roi->details.account_url,
|
hash_rc (roi->details.credit_account_url,
|
||||||
&roi->details.wtid,
|
&roi->details.wtid,
|
||||||
&rkey);
|
&rkey);
|
||||||
GNUNET_CONTAINER_multihashmap_get_multiple (reserve_closures,
|
GNUNET_CONTAINER_multihashmap_get_multiple (reserve_closures,
|
||||||
@ -1382,7 +1382,7 @@ history_debit_cb (void *cls,
|
|||||||
roi->details.amount = details->amount;
|
roi->details.amount = details->amount;
|
||||||
roi->details.execution_date = details->execution_date;
|
roi->details.execution_date = details->execution_date;
|
||||||
roi->details.wtid = details->wtid;
|
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 !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CONTAINER_multihashmap_put (out_map,
|
GNUNET_CONTAINER_multihashmap_put (out_map,
|
||||||
&roi->subject_hash,
|
&roi->subject_hash,
|
||||||
@ -1528,7 +1528,7 @@ reserve_in_cb (void *cls,
|
|||||||
rii->details.amount = *credit;
|
rii->details.amount = *credit;
|
||||||
rii->details.execution_date = execution_date;
|
rii->details.execution_date = execution_date;
|
||||||
rii->details.reserve_pub = *reserve_pub;
|
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],
|
memcpy (&rii[1],
|
||||||
sender_account_details,
|
sender_account_details,
|
||||||
slen);
|
slen);
|
||||||
@ -1761,8 +1761,8 @@ history_credit_cb (void *cls,
|
|||||||
}
|
}
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (0 != strcasecmp (details->account_url,
|
if (0 != strcasecmp (details->debit_account_url,
|
||||||
rii->details.account_url))
|
rii->details.debit_account_url))
|
||||||
{
|
{
|
||||||
report (report_missattribution_in_inconsistencies,
|
report (report_missattribution_in_inconsistencies,
|
||||||
json_pack ("{s:o, s:I, s:I, s:o}",
|
json_pack ("{s:o, s:I, s:I, s:o}",
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief An admin/add/incoming Handle
|
* @brief An admin/add-incoming Handle
|
||||||
*/
|
*/
|
||||||
struct TALER_BANK_AdminAddIncomingHandle
|
struct TALER_BANK_AdminAddIncomingHandle
|
||||||
{
|
{
|
||||||
@ -62,7 +62,7 @@ struct TALER_BANK_AdminAddIncomingHandle
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Function called when we're done processing the
|
* 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 cls the `struct TALER_BANK_AdminAddIncomingHandle`
|
||||||
* @param response_code HTTP response code, 0 on error
|
* @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.
|
* to the operators of the bank.
|
||||||
*
|
*
|
||||||
* @param ctx curl context for the event loop
|
* @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 auth authentication data to send to the bank
|
||||||
* @param reserve_pub wire transfer subject for the transfer
|
* @param reserve_pub wire transfer subject for the transfer
|
||||||
* @param amount amount that was deposited
|
* @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 the callback to call when the final result for this request is available
|
||||||
* @param res_cb_cls closure for the above callback
|
* @param res_cb_cls closure for the above callback
|
||||||
* @return NULL
|
* @return NULL
|
||||||
@ -184,7 +184,7 @@ TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx,
|
|||||||
const struct
|
const struct
|
||||||
TALER_ReservePublicKeyP *reserve_pub,
|
TALER_ReservePublicKeyP *reserve_pub,
|
||||||
const struct TALER_Amount *amount,
|
const struct TALER_Amount *amount,
|
||||||
const char *credit_account,
|
const char *debit_account,
|
||||||
TALER_BANK_AdminAddIncomingResultCallback res_cb,
|
TALER_BANK_AdminAddIncomingResultCallback res_cb,
|
||||||
void *res_cb_cls)
|
void *res_cb_cls)
|
||||||
{
|
{
|
||||||
@ -193,9 +193,12 @@ TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx,
|
|||||||
CURL *eh;
|
CURL *eh;
|
||||||
|
|
||||||
admin_obj = json_pack ("{s:o, s:o, s:s}",
|
admin_obj = json_pack ("{s:o, s:o, s:s}",
|
||||||
"subject", GNUNET_JSON_from_data_auto (reserve_pub),
|
"reserve_pub",
|
||||||
"amount", TALER_JSON_from_amount (amount),
|
GNUNET_JSON_from_data_auto (reserve_pub),
|
||||||
"credit_account", credit_account);
|
"amount",
|
||||||
|
TALER_JSON_from_amount (amount),
|
||||||
|
"debit_account",
|
||||||
|
debit_account);
|
||||||
if (NULL == admin_obj)
|
if (NULL == admin_obj)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
@ -205,7 +208,10 @@ TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx,
|
|||||||
aai->cb = res_cb;
|
aai->cb = res_cb;
|
||||||
aai->cb_cls = res_cb_cls;
|
aai->cb_cls = res_cb_cls;
|
||||||
aai->request_url = TALER_BANK_path_to_url_ (account_base_url,
|
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 = curl_slist_append
|
||||||
(aai->post_ctx.headers,
|
(aai->post_ctx.headers,
|
||||||
"Content-Type: application/json");
|
"Content-Type: application/json");
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
see <http://www.gnu.org/licenses/>
|
see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @file bank-lib/bank_api_history.c
|
* @file bank-lib/bank_api_credit.c
|
||||||
* @brief Implementation of the /history[-range]
|
* @brief Implementation of the /history/incoming
|
||||||
* requests of the bank's HTTP API.
|
* requests of the bank's HTTP API.
|
||||||
* @author Christian Grothoff
|
* @author Christian Grothoff
|
||||||
* @author Marcello Stanisci
|
* @author Marcello Stanisci
|
||||||
@ -78,7 +78,7 @@ parse_account_history (struct TALER_BANK_CreditHistoryHandle *hh,
|
|||||||
json_t *history_array;
|
json_t *history_array;
|
||||||
|
|
||||||
if (NULL == (history_array = json_object_get (history,
|
if (NULL == (history_array = json_object_get (history,
|
||||||
"data")))
|
"incoming_transactions")))
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
@ -101,8 +101,10 @@ parse_account_history (struct TALER_BANK_CreditHistoryHandle *hh,
|
|||||||
&row_id),
|
&row_id),
|
||||||
GNUNET_JSON_spec_fixed_auto ("reserve_pub",
|
GNUNET_JSON_spec_fixed_auto ("reserve_pub",
|
||||||
&td.reserve_pub),
|
&td.reserve_pub),
|
||||||
GNUNET_JSON_spec_string ("counterpart",
|
GNUNET_JSON_spec_string ("debit_account",
|
||||||
&td.account_url),
|
&td.debit_account_url),
|
||||||
|
GNUNET_JSON_spec_string ("credit_account",
|
||||||
|
&td.credit_account_url),
|
||||||
GNUNET_JSON_spec_end ()
|
GNUNET_JSON_spec_end ()
|
||||||
};
|
};
|
||||||
json_t *transaction = json_array_get (history_array,
|
json_t *transaction = json_array_get (history_array,
|
||||||
@ -250,13 +252,16 @@ TALER_BANK_credit_history (struct GNUNET_CURL_Context *ctx,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UINT64_MAX == start_row)
|
if ( ( (UINT64_MAX == start_row) &&
|
||||||
|
(0 > num_results) ) ||
|
||||||
|
( (0 == start_row) &&
|
||||||
|
(0 < num_results) ) )
|
||||||
GNUNET_asprintf (&url,
|
GNUNET_asprintf (&url,
|
||||||
"/history&delta=%lld",
|
"/history/incoming?delta=%lld",
|
||||||
(long long) num_results);
|
(long long) num_results);
|
||||||
else
|
else
|
||||||
GNUNET_asprintf (&url,
|
GNUNET_asprintf (&url,
|
||||||
"/history&delta=%lld&start=%llu",
|
"/history/incoming?delta=%lld&start=%llu",
|
||||||
(long long) num_results,
|
(long long) num_results,
|
||||||
start_row);
|
start_row);
|
||||||
hh = GNUNET_new (struct TALER_BANK_CreditHistoryHandle);
|
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->bank_base_url = GNUNET_strdup (bank_base_url);
|
||||||
hh->request_url = TALER_BANK_path_to_url_ (bank_base_url,
|
hh->request_url = TALER_BANK_path_to_url_ (bank_base_url,
|
||||||
url);
|
url);
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
||||||
|
"Requesting history at `%s'\n",
|
||||||
|
hh->request_url);
|
||||||
eh = curl_easy_init ();
|
eh = curl_easy_init ();
|
||||||
if ( (GNUNET_OK !=
|
if ( (GNUNET_OK !=
|
||||||
TALER_BANK_setup_auth_ (eh,
|
TALER_BANK_setup_auth_ (eh,
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
see <http://www.gnu.org/licenses/>
|
see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @file bank-lib/bank_api_history.c
|
* @file bank-lib/bank_api_debit.c
|
||||||
* @brief Implementation of the /history[-range]
|
* @brief Implementation of the /history/outgoing
|
||||||
* requests of the bank's HTTP API.
|
* requests of the bank's HTTP API.
|
||||||
* @author Christian Grothoff
|
* @author Christian Grothoff
|
||||||
* @author Marcello Stanisci
|
* @author Marcello Stanisci
|
||||||
@ -78,7 +78,7 @@ parse_account_history (struct TALER_BANK_DebitHistoryHandle *hh,
|
|||||||
json_t *history_array;
|
json_t *history_array;
|
||||||
|
|
||||||
if (NULL == (history_array = json_object_get (history,
|
if (NULL == (history_array = json_object_get (history,
|
||||||
"data")))
|
"outgoing_transactions")))
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
@ -101,8 +101,10 @@ parse_account_history (struct TALER_BANK_DebitHistoryHandle *hh,
|
|||||||
&row_id),
|
&row_id),
|
||||||
GNUNET_JSON_spec_fixed_auto ("wtid",
|
GNUNET_JSON_spec_fixed_auto ("wtid",
|
||||||
&td.wtid),
|
&td.wtid),
|
||||||
GNUNET_JSON_spec_string ("counterpart",
|
GNUNET_JSON_spec_string ("credit_account",
|
||||||
&td.account_url),
|
&td.credit_account_url),
|
||||||
|
GNUNET_JSON_spec_string ("debit_account",
|
||||||
|
&td.debit_account_url),
|
||||||
GNUNET_JSON_spec_string ("exchange_base_url",
|
GNUNET_JSON_spec_string ("exchange_base_url",
|
||||||
&td.exchange_base_url),
|
&td.exchange_base_url),
|
||||||
GNUNET_JSON_spec_end ()
|
GNUNET_JSON_spec_end ()
|
||||||
@ -252,13 +254,16 @@ TALER_BANK_debit_history (struct GNUNET_CURL_Context *ctx,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UINT64_MAX == start_row)
|
if ( ( (UINT64_MAX == start_row) &&
|
||||||
|
(0 > num_results) ) ||
|
||||||
|
( (0 == start_row) &&
|
||||||
|
(0 < num_results) ) )
|
||||||
GNUNET_asprintf (&url,
|
GNUNET_asprintf (&url,
|
||||||
"/history&delta=%lld",
|
"/history/outgoing?delta=%lld",
|
||||||
(long long) num_results);
|
(long long) num_results);
|
||||||
else
|
else
|
||||||
GNUNET_asprintf (&url,
|
GNUNET_asprintf (&url,
|
||||||
"/history&delta=%lld&start=%llu",
|
"/history/outgoing?delta=%lld&start=%llu",
|
||||||
(long long) num_results,
|
(long long) num_results,
|
||||||
start_row);
|
start_row);
|
||||||
hh = GNUNET_new (struct TALER_BANK_DebitHistoryHandle);
|
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,
|
hh->request_url = TALER_BANK_path_to_url_ (bank_base_url,
|
||||||
url);
|
url);
|
||||||
|
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
||||||
|
"Requesting history at `%s'\n",
|
||||||
|
hh->request_url);
|
||||||
eh = curl_easy_init ();
|
eh = curl_easy_init ();
|
||||||
if ( (GNUNET_OK !=
|
if ( (GNUNET_OK !=
|
||||||
TALER_BANK_setup_auth_ (eh,
|
TALER_BANK_setup_auth_ (eh,
|
||||||
|
@ -168,6 +168,11 @@ struct TALER_FAKEBANK_Handle
|
|||||||
*/
|
*/
|
||||||
uint64_t serial_counter;
|
uint64_t serial_counter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BaseURL of the fakebank.
|
||||||
|
*/
|
||||||
|
char *my_baseurl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Our port number.
|
* Our port number.
|
||||||
*/
|
*/
|
||||||
@ -187,8 +192,31 @@ 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.
|
* Generate log messages for failed check operation.
|
||||||
|
*
|
||||||
|
* @param h handle to output transaction log for
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
check_log (struct TALER_FAKEBANK_Handle *h)
|
check_log (struct TALER_FAKEBANK_Handle *h)
|
||||||
@ -197,10 +225,10 @@ check_log (struct TALER_FAKEBANK_Handle *h)
|
|||||||
{
|
{
|
||||||
if (GNUNET_YES == t->checked)
|
if (GNUNET_YES == t->checked)
|
||||||
continue;
|
continue;
|
||||||
fprintf (stderr,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"%llu -> %llu (%s)\n",
|
"%s -> %s (%s)\n",
|
||||||
(unsigned long long) t->debit_account,
|
t->debit_account,
|
||||||
(unsigned long long) t->credit_account,
|
t->credit_account,
|
||||||
TALER_amount2s (&t->amount));
|
TALER_amount2s (&t->amount));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -247,10 +275,10 @@ TALER_FAKEBANK_check_debit (struct TALER_FAKEBANK_Handle *h,
|
|||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf (stderr,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Did not find matching transaction!\nI have:\n");
|
"Did not find matching transaction!\nI have:\n");
|
||||||
check_log (h);
|
check_log (h);
|
||||||
fprintf (stderr,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"I wanted:\n%s -> %s (%s) from %s\n",
|
"I wanted:\n%s -> %s (%s) from %s\n",
|
||||||
want_debit,
|
want_debit,
|
||||||
want_credit,
|
want_credit,
|
||||||
@ -296,10 +324,10 @@ TALER_FAKEBANK_check_credit (struct TALER_FAKEBANK_Handle *h,
|
|||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf (stderr,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Did not find matching transaction!\nI have:\n");
|
"Did not find matching transaction!\nI have:\n");
|
||||||
check_log (h);
|
check_log (h);
|
||||||
fprintf (stderr,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"I wanted:\n%llu -> %llu (%s) with subject %s\n",
|
"I wanted:\n%llu -> %llu (%s) with subject %s\n",
|
||||||
(unsigned long long) want_debit,
|
(unsigned long long) want_debit,
|
||||||
(unsigned long long) want_credit,
|
(unsigned long long) want_credit,
|
||||||
@ -419,7 +447,7 @@ TALER_FAKEBANK_check_empty (struct TALER_FAKEBANK_Handle *h)
|
|||||||
}
|
}
|
||||||
if (NULL == t)
|
if (NULL == t)
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
fprintf (stderr,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Expected empty transaction set, but I have:\n");
|
"Expected empty transaction set, but I have:\n");
|
||||||
check_log (h);
|
check_log (h);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
@ -460,6 +488,7 @@ TALER_FAKEBANK_stop (struct TALER_FAKEBANK_Handle *h)
|
|||||||
MHD_stop_daemon (h->mhd_bank);
|
MHD_stop_daemon (h->mhd_bank);
|
||||||
h->mhd_bank = NULL;
|
h->mhd_bank = NULL;
|
||||||
}
|
}
|
||||||
|
GNUNET_free (h->my_baseurl);
|
||||||
GNUNET_free (h);
|
GNUNET_free (h);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -498,6 +527,7 @@ handle_mhd_completion_callback (void *cls,
|
|||||||
*
|
*
|
||||||
* @param h the fakebank handle
|
* @param h the fakebank handle
|
||||||
* @param connection the connection
|
* @param connection the connection
|
||||||
|
* @param account account into which to deposit the funds (credit)
|
||||||
* @param upload_data request data
|
* @param upload_data request data
|
||||||
* @param upload_data_size size of @a upload_data in bytes
|
* @param upload_data_size size of @a upload_data in bytes
|
||||||
* @param con_cls closure for request (a `struct Buffer *`)
|
* @param con_cls closure for request (a `struct Buffer *`)
|
||||||
@ -506,6 +536,7 @@ handle_mhd_completion_callback (void *cls,
|
|||||||
static int
|
static int
|
||||||
handle_admin_add_incoming (struct TALER_FAKEBANK_Handle *h,
|
handle_admin_add_incoming (struct TALER_FAKEBANK_Handle *h,
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
|
const char *account,
|
||||||
const char *upload_data,
|
const char *upload_data,
|
||||||
size_t *upload_data_size,
|
size_t *upload_data_size,
|
||||||
void **con_cls)
|
void **con_cls)
|
||||||
@ -538,16 +569,16 @@ handle_admin_add_incoming (struct TALER_FAKEBANK_Handle *h,
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
const char *debit_account;
|
const char *debit_account;
|
||||||
const char *credit_account;
|
|
||||||
struct TALER_Amount amount;
|
struct TALER_Amount amount;
|
||||||
struct TALER_ReservePublicKeyP reserve_pub;
|
struct TALER_ReservePublicKeyP reserve_pub;
|
||||||
|
char *debit;
|
||||||
struct GNUNET_JSON_Specification spec[] = {
|
struct GNUNET_JSON_Specification spec[] = {
|
||||||
GNUNET_JSON_spec_fixed_auto ("reserve_pub", &reserve_pub),
|
GNUNET_JSON_spec_fixed_auto ("reserve_pub", &reserve_pub),
|
||||||
GNUNET_JSON_spec_string ("debit_account", &debit_account),
|
GNUNET_JSON_spec_string ("debit_account", &debit_account),
|
||||||
GNUNET_JSON_spec_string ("credit_account", &credit_account),
|
|
||||||
TALER_JSON_spec_amount ("amount", &amount),
|
TALER_JSON_spec_amount ("amount", &amount),
|
||||||
GNUNET_JSON_spec_end ()
|
GNUNET_JSON_spec_end ()
|
||||||
};
|
};
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_JSON_parse (json,
|
GNUNET_JSON_parse (json,
|
||||||
spec,
|
spec,
|
||||||
@ -557,17 +588,19 @@ handle_admin_add_incoming (struct TALER_FAKEBANK_Handle *h,
|
|||||||
json_decref (json);
|
json_decref (json);
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
|
debit = get_xtalerbank_payto_account (debit_account);
|
||||||
row_id = TALER_FAKEBANK_make_admin_transfer (h,
|
row_id = TALER_FAKEBANK_make_admin_transfer (h,
|
||||||
debit_account,
|
debit,
|
||||||
credit_account,
|
account,
|
||||||
&amount,
|
&amount,
|
||||||
&reserve_pub);
|
&reserve_pub);
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
"Receiving incoming wire transfer: %s->%s, subject: %s, amount: %s\n",
|
"Receiving incoming wire transfer: %s->%s, subject: %s, amount: %s\n",
|
||||||
debit_account,
|
debit,
|
||||||
credit_account,
|
account,
|
||||||
TALER_B2S (&reserve_pub),
|
TALER_B2S (&reserve_pub),
|
||||||
TALER_amount2s (&amount));
|
TALER_amount2s (&amount));
|
||||||
|
GNUNET_free (debit);
|
||||||
}
|
}
|
||||||
json_decref (json);
|
json_decref (json);
|
||||||
|
|
||||||
@ -882,15 +915,24 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
|
|||||||
account))
|
account))
|
||||||
{
|
{
|
||||||
json_t *trans;
|
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
|
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,
|
"row_id", (json_int_t) pos->row_id,
|
||||||
"date", GNUNET_JSON_from_time_abs (pos->date),
|
"date", GNUNET_JSON_from_time_abs (pos->date),
|
||||||
"amount", TALER_JSON_from_amount (&pos->amount),
|
"amount", TALER_JSON_from_amount (&pos->amount),
|
||||||
"credit_account", account,
|
"credit_account", credit_payto,
|
||||||
"debit_account", pos->debit_account,
|
"debit_account", debit_payto,
|
||||||
"wtid", pos->subject /* we "know" it is OK */);
|
"wtid", GNUNET_JSON_from_data_auto (
|
||||||
|
&pos->subject.debit.wtid));
|
||||||
|
GNUNET_free (credit_payto);
|
||||||
|
GNUNET_free (debit_payto);
|
||||||
GNUNET_assert (0 ==
|
GNUNET_assert (0 ==
|
||||||
json_array_append_new (history,
|
json_array_append_new (history,
|
||||||
trans));
|
trans));
|
||||||
@ -904,14 +946,16 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
|
|||||||
else
|
else
|
||||||
pos = pos->next;
|
pos = pos->next;
|
||||||
}
|
}
|
||||||
return TALER_MHD_reply_json (connection,
|
return TALER_MHD_reply_json_pack (connection,
|
||||||
history,
|
MHD_HTTP_OK,
|
||||||
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 h the fakebank handle
|
||||||
* @param connection the connection
|
* @param connection the connection
|
||||||
@ -974,15 +1018,23 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h,
|
|||||||
account))
|
account))
|
||||||
{
|
{
|
||||||
json_t *trans;
|
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
|
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:s}",
|
||||||
"row_id", (json_int_t) pos->row_id,
|
"row_id", (json_int_t) pos->row_id,
|
||||||
"date", GNUNET_JSON_from_time_abs (pos->date),
|
"date", GNUNET_JSON_from_time_abs (pos->date),
|
||||||
"amount", TALER_JSON_from_amount (&pos->amount),
|
"amount", TALER_JSON_from_amount (&pos->amount),
|
||||||
"credit_account", pos->credit_account,
|
"credit_account", credit_payto,
|
||||||
"debit_account", account,
|
"debit_account", debit_payto,
|
||||||
"reserve_pub", pos->subject /* we "know" it is OK */);
|
"reserve_pub", pos->subject /* we "know" it is OK */);
|
||||||
|
GNUNET_free (credit_payto);
|
||||||
|
GNUNET_free (debit_payto);
|
||||||
GNUNET_assert (0 ==
|
GNUNET_assert (0 ==
|
||||||
json_array_append_new (history,
|
json_array_append_new (history,
|
||||||
trans));
|
trans));
|
||||||
@ -996,9 +1048,11 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h,
|
|||||||
else
|
else
|
||||||
pos = pos->next;
|
pos = pos->next;
|
||||||
}
|
}
|
||||||
return TALER_MHD_reply_json (connection,
|
return TALER_MHD_reply_json_pack (connection,
|
||||||
history,
|
MHD_HTTP_OK,
|
||||||
MHD_HTTP_OK);
|
"{s:o}",
|
||||||
|
"outgoing_transactions",
|
||||||
|
history);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1026,8 +1080,9 @@ serve (struct TALER_FAKEBANK_Handle *h,
|
|||||||
void **con_cls)
|
void **con_cls)
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
||||||
"Fakebank, serving: %s\n",
|
"Fakebank, serving URL `%s' for account `%s'\n",
|
||||||
url);
|
url,
|
||||||
|
account);
|
||||||
if ( (0 == strcmp (url,
|
if ( (0 == strcmp (url,
|
||||||
"/")) &&
|
"/")) &&
|
||||||
(0 == strcasecmp (method,
|
(0 == strcasecmp (method,
|
||||||
@ -1036,11 +1091,12 @@ serve (struct TALER_FAKEBANK_Handle *h,
|
|||||||
connection,
|
connection,
|
||||||
con_cls);
|
con_cls);
|
||||||
if ( (0 == strcmp (url,
|
if ( (0 == strcmp (url,
|
||||||
"/admin/add/incoming")) &&
|
"/admin/add-incoming")) &&
|
||||||
(0 == strcasecmp (method,
|
(0 == strcasecmp (method,
|
||||||
MHD_HTTP_METHOD_POST)) )
|
MHD_HTTP_METHOD_POST)) )
|
||||||
return handle_admin_add_incoming (h,
|
return handle_admin_add_incoming (h,
|
||||||
connection,
|
connection,
|
||||||
|
account,
|
||||||
upload_data,
|
upload_data,
|
||||||
upload_data_size,
|
upload_data_size,
|
||||||
con_cls);
|
con_cls);
|
||||||
@ -1264,6 +1320,9 @@ TALER_FAKEBANK_start (uint16_t port)
|
|||||||
|
|
||||||
h = GNUNET_new (struct TALER_FAKEBANK_Handle);
|
h = GNUNET_new (struct TALER_FAKEBANK_Handle);
|
||||||
h->port = port;
|
h->port = port;
|
||||||
|
GNUNET_asprintf (&h->my_baseurl,
|
||||||
|
"http://localhost:%u/",
|
||||||
|
(unsigned int) port);
|
||||||
h->mhd_bank = MHD_start_daemon (MHD_USE_DEBUG
|
h->mhd_bank = MHD_start_daemon (MHD_USE_DEBUG
|
||||||
#if EPOLL_SUPPORT
|
#if EPOLL_SUPPORT
|
||||||
| MHD_USE_EPOLL_INTERNAL_THREAD
|
| MHD_USE_EPOLL_INTERNAL_THREAD
|
||||||
|
@ -440,7 +440,7 @@ history_cb (void *cls,
|
|||||||
&details->reserve_pub,
|
&details->reserve_pub,
|
||||||
&details->amount,
|
&details->amount,
|
||||||
details->execution_date,
|
details->execution_date,
|
||||||
details->account_url,
|
details->debit_account_url,
|
||||||
wa_pos->section_name,
|
wa_pos->section_name,
|
||||||
serial_id);
|
serial_id);
|
||||||
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
|
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
|
||||||
|
@ -199,11 +199,11 @@ typedef void
|
|||||||
* to the operators of the bank.
|
* to the operators of the bank.
|
||||||
*
|
*
|
||||||
* @param ctx curl context for the event loop
|
* @param ctx curl context for the event loop
|
||||||
* @param account_base_url URL of the account (used to execute this request)
|
* @param account_base_url URL of the bank (money flows into this account)
|
||||||
* @param auth authentication data to use
|
* @param auth authentication data to send to the bank
|
||||||
* @param reserve_pub wire transfer subject for the transfer
|
* @param reserve_pub wire transfer subject for the transfer
|
||||||
* @param amount amount that was deposited
|
* @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 the callback to call when the final result for this request is available
|
||||||
* @param res_cb_cls closure for the above callback
|
* @param res_cb_cls closure for the above callback
|
||||||
* @return NULL
|
* @return NULL
|
||||||
@ -350,7 +350,13 @@ struct TALER_BANK_CreditDetails
|
|||||||
* payto://-URL of the source account that
|
* payto://-URL of the source account that
|
||||||
* send the funds.
|
* 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
|
* payto://-URL of the source account that
|
||||||
* send the funds.
|
* 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;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,19 +73,6 @@
|
|||||||
TALER_TESTING_make_trait_string (5, data)
|
TALER_TESTING_make_trait_string (5, data)
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
* Allocate and return a piece of wire-details. Combines
|
||||||
* a @a payto -URL and adds some salt to create the JSON.
|
* a @a payto -URL and adds some salt to create the JSON.
|
||||||
|
@ -391,4 +391,16 @@ char *
|
|||||||
TALER_payto_get_method (const char *payto_url);
|
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
|
#endif
|
||||||
|
@ -398,7 +398,7 @@ admin_add_incoming_traits (void *cls,
|
|||||||
{
|
{
|
||||||
struct AdminAddIncomingState *fts = cls;
|
struct AdminAddIncomingState *fts = cls;
|
||||||
struct TALER_TESTING_Trait traits[] = {
|
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_ROW_ID (&fts->serial_id),
|
||||||
TALER_TESTING_MAKE_TRAIT_CREDIT_ACCOUNT (fts->exchange_credit_url),
|
TALER_TESTING_MAKE_TRAIT_CREDIT_ACCOUNT (fts->exchange_credit_url),
|
||||||
TALER_TESTING_make_trait_amount_obj (0, &fts->amount),
|
TALER_TESTING_make_trait_amount_obj (0, &fts->amount),
|
||||||
|
@ -170,7 +170,7 @@ print_expected (struct History *h,
|
|||||||
TALER_amount2s (&h[i].details.amount),
|
TALER_amount2s (&h[i].details.amount),
|
||||||
(unsigned long long) h[i].row_id,
|
(unsigned long long) h[i].row_id,
|
||||||
TALER_B2S (&h[i].details.reserve_pub),
|
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,
|
credit_account,
|
||||||
hs->account_url);
|
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, ':');
|
bank_hostname = strchr (hs->account_url, ':');
|
||||||
GNUNET_assert (NULL != bank_hostname);
|
GNUNET_assert (NULL != bank_hostname);
|
||||||
bank_hostname += 3;
|
bank_hostname += 3;
|
||||||
@ -435,15 +423,6 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
|||||||
* information. */
|
* information. */
|
||||||
|
|
||||||
/* Asked for credit, and account got the credit. */
|
/* Asked for credit, and account got the credit. */
|
||||||
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,
|
if (0 == strcasecmp (hs->account_url,
|
||||||
credit_account))
|
credit_account))
|
||||||
{
|
{
|
||||||
@ -461,10 +440,12 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
|||||||
TALER_TESTING_get_trait_url
|
TALER_TESTING_get_trait_url
|
||||||
(pos, 1,
|
(pos, 1,
|
||||||
&account_url));
|
&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].details.amount = *amount;
|
||||||
h[total].row_id = *row_id;
|
h[total].row_id = *row_id;
|
||||||
h[total].details.reserve_pub = *reserve_pub;
|
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");
|
TALER_LOG_INFO ("+1-bit of my history\n");
|
||||||
total++;
|
total++;
|
||||||
}
|
}
|
||||||
@ -530,8 +511,8 @@ check_result (struct TALER_TESTING_Interpreter *is,
|
|||||||
&details->reserve_pub)) ||
|
&details->reserve_pub)) ||
|
||||||
(0 != TALER_amount_cmp (&h[off].details.amount,
|
(0 != TALER_amount_cmp (&h[off].details.amount,
|
||||||
&details->amount)) ||
|
&details->amount)) ||
|
||||||
(0 != strcasecmp (h[off].details.account_url,
|
(0 != strcasecmp (h[off].details.debit_account_url,
|
||||||
details->account_url)) )
|
details->debit_account_url)) )
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
print_expected (h,
|
print_expected (h,
|
||||||
@ -582,20 +563,12 @@ history_cb (void *cls,
|
|||||||
struct HistoryState *hs = is->commands[is->ip].cls;
|
struct HistoryState *hs = is->commands[is->ip].cls;
|
||||||
|
|
||||||
(void) row_id;
|
(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)
|
if (NULL == details)
|
||||||
{
|
{
|
||||||
hs->hh = NULL;
|
hs->hh = NULL;
|
||||||
if ( (hs->results_obtained != compute_result_count (is)) ||
|
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;
|
uint64_t total;
|
||||||
struct History *h;
|
struct History *h;
|
||||||
@ -622,6 +595,15 @@ history_cb (void *cls,
|
|||||||
return GNUNET_OK;
|
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 */
|
/* check current element */
|
||||||
if (GNUNET_OK != check_result (is,
|
if (GNUNET_OK != check_result (is,
|
||||||
hs->results_obtained,
|
hs->results_obtained,
|
||||||
|
@ -170,7 +170,7 @@ print_expected (struct History *h,
|
|||||||
TALER_amount2s (&h[i].details.amount),
|
TALER_amount2s (&h[i].details.amount),
|
||||||
(unsigned long long) h[i].row_id,
|
(unsigned long long) h[i].row_id,
|
||||||
TALER_B2S (&h[i].details.wtid),
|
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;
|
int inc;
|
||||||
unsigned int start;
|
unsigned int start;
|
||||||
unsigned int end;
|
unsigned int end;
|
||||||
|
/* 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.
|
||||||
* @var turns GNUNET_YES whenever either no 'start' value was
|
*/
|
||||||
* given for the history query, or the given value is found
|
int ok;
|
||||||
* in the list of all the CMDs.
|
|
||||||
*/int ok;
|
|
||||||
const uint64_t *row_id_start = NULL;
|
const uint64_t *row_id_start = NULL;
|
||||||
|
|
||||||
if (NULL != hs->start_row_reference)
|
if (NULL != hs->start_row_reference)
|
||||||
@ -278,11 +276,11 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
|||||||
const char *debit_account;
|
const char *debit_account;
|
||||||
const char *credit_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
|
* that do not offer a "row_id" trait. Such skipped CMDs are
|
||||||
* not interesting for building a history.
|
* 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,
|
0,
|
||||||
&row_id))
|
&row_id))
|
||||||
continue;
|
continue;
|
||||||
@ -408,18 +406,16 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
|||||||
(GNUNET_OK == TALER_TESTING_GET_TRAIT_CREDIT_ACCOUNT
|
(GNUNET_OK == TALER_TESTING_GET_TRAIT_CREDIT_ACCOUNT
|
||||||
(pos, &credit_account));
|
(pos, &credit_account));
|
||||||
|
|
||||||
TALER_LOG_INFO ("Potential history bit:"
|
TALER_LOG_INFO ("Potential history bit: %s->%s; my account: %s\n",
|
||||||
" %s->%s; my account: %s\n",
|
|
||||||
debit_account,
|
debit_account,
|
||||||
credit_account,
|
credit_account,
|
||||||
hs->account_url);
|
hs->account_url);
|
||||||
|
|
||||||
/**
|
/* Discard transactions where the audited account played _both_ the debit
|
||||||
* Discard transactions where the audited account played
|
* and the debit roles, but _only if_ the audit goes on both directions..
|
||||||
* _both_ the debit and the debit roles, but _only if_
|
* This needs more explaination!
|
||||||
* the audit goes on both directions.. This needs more
|
*/
|
||||||
* explaination!
|
if (0 == strcasecmp (hs->account_url,
|
||||||
*/if (0 == strcasecmp (hs->account_url,
|
|
||||||
debit_account))
|
debit_account))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
@ -434,15 +430,6 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
|||||||
* information. */
|
* information. */
|
||||||
|
|
||||||
/* Asked for debit, and account got the debit. */
|
/* Asked for debit, and account got the debit. */
|
||||||
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,
|
if (0 == strcasecmp (hs->account_url,
|
||||||
debit_account))
|
debit_account))
|
||||||
{
|
{
|
||||||
@ -460,10 +447,12 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
|||||||
TALER_TESTING_get_trait_url
|
TALER_TESTING_get_trait_url
|
||||||
(pos, 1,
|
(pos, 1,
|
||||||
&account_url));
|
&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].details.amount = *amount;
|
||||||
h[total].row_id = *row_id;
|
h[total].row_id = *row_id;
|
||||||
h[total].details.wtid = *wtid;
|
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");
|
TALER_LOG_INFO ("+1-bit of my history\n");
|
||||||
total++;
|
total++;
|
||||||
}
|
}
|
||||||
@ -529,8 +518,8 @@ check_result (struct TALER_TESTING_Interpreter *is,
|
|||||||
&details->wtid)) ||
|
&details->wtid)) ||
|
||||||
(0 != TALER_amount_cmp (&h[off].details.amount,
|
(0 != TALER_amount_cmp (&h[off].details.amount,
|
||||||
&details->amount)) ||
|
&details->amount)) ||
|
||||||
(0 != strcasecmp (h[off].details.account_url,
|
(0 != strcasecmp (h[off].details.credit_account_url,
|
||||||
details->account_url)) )
|
details->credit_account_url)) )
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
print_expected (h,
|
print_expected (h,
|
||||||
@ -581,20 +570,12 @@ history_cb (void *cls,
|
|||||||
struct HistoryState *hs = is->commands[is->ip].cls;
|
struct HistoryState *hs = is->commands[is->ip].cls;
|
||||||
|
|
||||||
(void) row_id;
|
(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)
|
if (NULL == details)
|
||||||
{
|
{
|
||||||
hs->hh = NULL;
|
hs->hh = NULL;
|
||||||
if ( (hs->results_obtained != compute_result_count (is)) ||
|
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;
|
uint64_t total;
|
||||||
struct History *h;
|
struct History *h;
|
||||||
@ -621,6 +602,15 @@ history_cb (void *cls,
|
|||||||
return GNUNET_OK;
|
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 */
|
/* check current element */
|
||||||
if (GNUNET_OK != check_result (is,
|
if (GNUNET_OK != check_result (is,
|
||||||
hs->results_obtained,
|
hs->results_obtained,
|
||||||
|
@ -349,10 +349,10 @@ TALER_TESTING_prepare_bank (const char *config_filename,
|
|||||||
"%s%s",
|
"%s%s",
|
||||||
bc->bank_url,
|
bc->bank_url,
|
||||||
EXCHANGE_ACCOUNT_NAME);
|
EXCHANGE_ACCOUNT_NAME);
|
||||||
bc->exchange_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url,
|
bc->exchange_payto = TALER_payto_xtalerbank_make (bc->bank_url,
|
||||||
EXCHANGE_ACCOUNT_NAME);
|
EXCHANGE_ACCOUNT_NAME);
|
||||||
bc->user42_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "42");
|
bc->user42_payto = TALER_payto_xtalerbank_make (bc->bank_url, "42");
|
||||||
bc->user43_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "43");
|
bc->user43_payto = TALER_payto_xtalerbank_make (bc->bank_url, "43");
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -424,46 +424,17 @@ TALER_TESTING_prepare_fakebank (const char *config_filename,
|
|||||||
}
|
}
|
||||||
bc->bank_url = fakebank_url;
|
bc->bank_url = fakebank_url;
|
||||||
GNUNET_asprintf (&bc->exchange_account_url,
|
GNUNET_asprintf (&bc->exchange_account_url,
|
||||||
"%s%s",
|
"%s/%s",
|
||||||
bc->bank_url,
|
bc->bank_url,
|
||||||
EXCHANGE_ACCOUNT_NAME);
|
EXCHANGE_ACCOUNT_NAME);
|
||||||
bc->exchange_auth.method = TALER_BANK_AUTH_NONE;
|
bc->exchange_auth.method = TALER_BANK_AUTH_NONE;
|
||||||
bc->exchange_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "2");
|
bc->exchange_payto = TALER_payto_xtalerbank_make (bc->bank_url, "2");
|
||||||
bc->user42_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "42");
|
bc->user42_payto = TALER_payto_xtalerbank_make (bc->bank_url, "42");
|
||||||
bc->user43_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "43");
|
bc->user43_payto = TALER_payto_xtalerbank_make (bc->bank_url, "43");
|
||||||
return GNUNET_OK;
|
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
|
* Allocate and return a piece of wire-details. Combines
|
||||||
* a @a payto -URL and adds some salt to create the JSON.
|
* a @a payto -URL and adds some salt to create the JSON.
|
||||||
|
@ -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 */
|
/* end of util.c */
|
||||||
|
Loading…
Reference in New Issue
Block a user