This commit is contained in:
Christian Grothoff 2020-01-13 22:15:43 +01:00
parent 7b1909bc99
commit 07b799b21f
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
2 changed files with 38 additions and 34 deletions

View File

@ -293,11 +293,11 @@ TALER_BANK_execute_wire_transfer (struct GNUNET_CURL_Context *ctx,
} }
TALER_amount_ntoh (&amount, TALER_amount_ntoh (&amount,
&wp->amount); &wp->amount);
transfer_obj = json_pack ("{s:o, s:o, s:s, s:o, s:o, s:s}", transfer_obj = json_pack ("{s:o, s:o, s:s, s:o, s:s}",
"request_uid", GNUNET_JSON_from_data_auto ( "request_uid", GNUNET_JSON_from_data_auto (
&wp->request_uid), &wp->request_uid),
"amount", TALER_JSON_from_amount (&amount), "amount", TALER_JSON_from_amount (&amount),
"exchange_url", exchange_base_url, "exchange_base_url", exchange_base_url,
"wtid", GNUNET_JSON_from_data_auto (&wp->wtid), "wtid", GNUNET_JSON_from_data_auto (&wp->wtid),
"credit_account", destination_account_url); "credit_account", destination_account_url);
if (NULL == transfer_obj) if (NULL == transfer_obj)

View File

@ -616,23 +616,23 @@ handle_admin_add_incoming (struct TALER_FAKEBANK_Handle *h,
/** /**
* Handle incoming HTTP request for /transaction. * Handle incoming HTTP request for /transfer.
* *
* @param h the fakebank handle * @param h the fakebank handle
* @param connection the connection * @param connection the connection
* @param account account making the transaction * @param account account making the transfer
* @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 *`)
* @return MHD result code * @return MHD result code
*/ */
static int static int
handle_transaction (struct TALER_FAKEBANK_Handle *h, handle_transfer (struct TALER_FAKEBANK_Handle *h,
struct MHD_Connection *connection, struct MHD_Connection *connection,
const char *account, 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)
{ {
enum GNUNET_JSON_PostResult pr; enum GNUNET_JSON_PostResult pr;
json_t *json; json_t *json;
@ -852,7 +852,7 @@ parse_history_common_args (struct MHD_Connection *connection,
/** /**
* 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
@ -911,8 +911,9 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
while ( (0 != ha.delta) && while ( (0 != ha.delta) &&
(NULL != pos) ) (NULL != pos) )
{ {
if (0 == strcasecmp (pos->credit_account, if ( (0 == strcasecmp (pos->credit_account,
account)) account)) &&
(T_DEBIT == pos->type) )
{ {
json_t *trans; json_t *trans;
char *credit_payto; char *credit_payto;
@ -923,12 +924,14 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
debit_payto = TALER_payto_xtalerbank_make (h->my_baseurl, debit_payto = TALER_payto_xtalerbank_make (h->my_baseurl,
pos->debit_account); pos->debit_account);
trans = json_pack trans = json_pack
("{s:I, s:o, s:o, s:s, s:s, s:o}", ("{s:I, s:o, s:o, s:s, 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", credit_payto, "credit_account", credit_payto,
"debit_account", debit_payto, "debit_account", debit_payto,
"exchange_base_url",
pos->subject.debit.exchange_base_url,
"wtid", GNUNET_JSON_from_data_auto ( "wtid", GNUNET_JSON_from_data_auto (
&pos->subject.debit.wtid)); &pos->subject.debit.wtid));
GNUNET_free (credit_payto); GNUNET_free (credit_payto);
@ -949,13 +952,13 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
return TALER_MHD_reply_json_pack (connection, return TALER_MHD_reply_json_pack (connection,
MHD_HTTP_OK, MHD_HTTP_OK,
"{s:o}", "{s:o}",
"incoming_transactions", "outgoing_transactions",
history); history);
} }
/** /**
* Handle incoming HTTP request for /history/outgoing * Handle incoming HTTP request for /history/incoming
* *
* @param h the fakebank handle * @param h the fakebank handle
* @param connection the connection * @param connection the connection
@ -1014,8 +1017,9 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h,
while ( (0 != ha.delta) && while ( (0 != ha.delta) &&
(NULL != pos) ) (NULL != pos) )
{ {
if (0 == strcasecmp (pos->debit_account, if ( (0 == strcasecmp (pos->debit_account,
account)) account)) &&
(T_CREDIT == pos->type) )
{ {
json_t *trans; json_t *trans;
char *credit_payto; char *credit_payto;
@ -1051,7 +1055,7 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h,
return TALER_MHD_reply_json_pack (connection, return TALER_MHD_reply_json_pack (connection,
MHD_HTTP_OK, MHD_HTTP_OK,
"{s:o}", "{s:o}",
"outgoing_transactions", "incoming_transactions",
history); history);
} }
@ -1101,32 +1105,32 @@ serve (struct TALER_FAKEBANK_Handle *h,
upload_data_size, upload_data_size,
con_cls); con_cls);
if ( (0 == strcmp (url, if ( (0 == strcmp (url,
"/transaction")) && "/transfer")) &&
(NULL != account) && (NULL != account) &&
(0 == strcasecmp (method, (0 == strcasecmp (method,
MHD_HTTP_METHOD_POST)) ) MHD_HTTP_METHOD_POST)) )
return handle_transaction (h, return handle_transfer (h,
connection, connection,
account, account,
upload_data, upload_data,
upload_data_size, upload_data_size,
con_cls); con_cls);
if ( (0 == strcmp (url, if ( (0 == strcmp (url,
"/history/incoming")) && "/history/incoming")) &&
(NULL != account) && (NULL != account) &&
(0 == strcasecmp (method, (0 == strcasecmp (method,
MHD_HTTP_METHOD_GET)) ) MHD_HTTP_METHOD_GET)) )
return handle_credit_history (h,
connection,
account);
if ( (0 == strcmp (url,
"/history/outgoing")) &&
(NULL != account) &&
(0 == strcasecmp (method,
MHD_HTTP_METHOD_GET)) )
return handle_debit_history (h, return handle_debit_history (h,
connection, connection,
account); account);
if ( (0 == strcmp (url,
"/history/outgoing")) &&
(NULL != account) &&
(0 == strcasecmp (method,
MHD_HTTP_METHOD_GET)) )
return handle_credit_history (h,
connection,
account);
/* Unexpected URL path, just close the connection. */ /* Unexpected URL path, just close the connection. */
/* we're rather impolite here, but it's a testcase. */ /* we're rather impolite here, but it's a testcase. */