implementing #4921: add base URL to wire transfers
This commit is contained in:
parent
4d8942b818
commit
397c718809
@ -162,8 +162,9 @@ 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 bank_base_url URL of the bank
|
* @param bank_base_url URL of the bank (used to execute this request)
|
||||||
* @param reserve_pub public key of the reserve
|
* @param exchange_base_url base URL of the exchange (for tracking)
|
||||||
|
* @param wtid wire transfer identifier for the transfer
|
||||||
* @param amount amount that was deposited
|
* @param amount amount that was deposited
|
||||||
* @param execution_date when did we receive the amount
|
* @param execution_date when did we receive the amount
|
||||||
* @param debit_account_no account number to withdraw from (53 bits at most)
|
* @param debit_account_no account number to withdraw from (53 bits at most)
|
||||||
@ -177,6 +178,7 @@ handle_admin_add_incoming_finished (void *cls,
|
|||||||
struct TALER_BANK_AdminAddIncomingHandle *
|
struct TALER_BANK_AdminAddIncomingHandle *
|
||||||
TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx,
|
TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx,
|
||||||
const char *bank_base_url,
|
const char *bank_base_url,
|
||||||
|
const char *exchange_base_url,
|
||||||
const struct TALER_WireTransferIdentifierRawP *wtid,
|
const struct TALER_WireTransferIdentifierRawP *wtid,
|
||||||
const struct TALER_Amount *amount,
|
const struct TALER_Amount *amount,
|
||||||
uint64_t debit_account_no,
|
uint64_t debit_account_no,
|
||||||
@ -188,9 +190,9 @@ TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx,
|
|||||||
json_t *admin_obj;
|
json_t *admin_obj;
|
||||||
CURL *eh;
|
CURL *eh;
|
||||||
|
|
||||||
admin_obj = json_pack ("{s:o, s:o,"
|
admin_obj = json_pack ("{s:s, s:o, s:o, s:I, s:I}",
|
||||||
" s:I, s:I}",
|
"exchange_url", exchange_base_url,
|
||||||
"wtid", GNUNET_JSON_from_data_auto (wtid), /* #4340 */
|
"wtid", GNUNET_JSON_from_data_auto (wtid),
|
||||||
"amount", TALER_JSON_from_amount (amount),
|
"amount", TALER_JSON_from_amount (amount),
|
||||||
"debit_account", (json_int_t) debit_account_no,
|
"debit_account", (json_int_t) debit_account_no,
|
||||||
"credit_account", (json_int_t) credit_account_no);
|
"credit_account", (json_int_t) credit_account_no);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
This file is part of TALER
|
This file is part of TALER
|
||||||
(C) 2016 Inria and GNUnet e.V.
|
(C) 2016, 2017 Inria and GNUnet e.V.
|
||||||
|
|
||||||
TALER is free software; you can redistribute it and/or modify it under the
|
TALER is free software; you can redistribute it and/or modify it under the
|
||||||
terms of the GNU General Public License as published by the Free Software
|
terms of the GNU General Public License as published by the Free Software
|
||||||
@ -65,6 +65,11 @@ struct Transaction
|
|||||||
* Subject of the transfer.
|
* Subject of the transfer.
|
||||||
*/
|
*/
|
||||||
struct TALER_WireTransferIdentifierRawP wtid;
|
struct TALER_WireTransferIdentifierRawP wtid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base URL of the exchange.
|
||||||
|
*/
|
||||||
|
char *exchange_base_url;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -105,6 +110,8 @@ struct TALER_FAKEBANK_Handle
|
|||||||
* @param want_amount transfer amount desired
|
* @param want_amount transfer amount desired
|
||||||
* @param want_debit account that should have been debited
|
* @param want_debit account that should have been debited
|
||||||
* @param want_debit account that should have been credited
|
* @param want_debit account that should have been credited
|
||||||
|
* @param exchange_base_url expected base URL of the exchange
|
||||||
|
* i.e. "https://example.com/"; may include a port
|
||||||
* @param[out] wtid set to the wire transfer identifier
|
* @param[out] wtid set to the wire transfer identifier
|
||||||
* @return #GNUNET_OK on success
|
* @return #GNUNET_OK on success
|
||||||
*/
|
*/
|
||||||
@ -113,6 +120,7 @@ TALER_FAKEBANK_check (struct TALER_FAKEBANK_Handle *h,
|
|||||||
const struct TALER_Amount *want_amount,
|
const struct TALER_Amount *want_amount,
|
||||||
uint64_t want_debit,
|
uint64_t want_debit,
|
||||||
uint64_t want_credit,
|
uint64_t want_credit,
|
||||||
|
const char *exchange_base_url,
|
||||||
struct TALER_WireTransferIdentifierRawP *wtid)
|
struct TALER_WireTransferIdentifierRawP *wtid)
|
||||||
{
|
{
|
||||||
struct Transaction *t;
|
struct Transaction *t;
|
||||||
@ -122,12 +130,15 @@ TALER_FAKEBANK_check (struct TALER_FAKEBANK_Handle *h,
|
|||||||
if ( (want_debit == t->debit_account) &&
|
if ( (want_debit == t->debit_account) &&
|
||||||
(want_credit == t->credit_account) &&
|
(want_credit == t->credit_account) &&
|
||||||
(0 == TALER_amount_cmp (want_amount,
|
(0 == TALER_amount_cmp (want_amount,
|
||||||
&t->amount)) )
|
&t->amount)) &&
|
||||||
|
(0 == strcasecmp (exchange_base_url,
|
||||||
|
t->exchange_base_url)) )
|
||||||
{
|
{
|
||||||
GNUNET_CONTAINER_DLL_remove (h->transactions_head,
|
GNUNET_CONTAINER_DLL_remove (h->transactions_head,
|
||||||
h->transactions_tail,
|
h->transactions_tail,
|
||||||
t);
|
t);
|
||||||
*wtid = t->wtid;
|
*wtid = t->wtid;
|
||||||
|
GNUNET_free (t->exchange_base_url);
|
||||||
GNUNET_free (t);
|
GNUNET_free (t);
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
}
|
}
|
||||||
@ -140,10 +151,11 @@ TALER_FAKEBANK_check (struct TALER_FAKEBANK_Handle *h,
|
|||||||
|
|
||||||
s = TALER_amount_to_string (&t->amount);
|
s = TALER_amount_to_string (&t->amount);
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"%llu -> %llu (%s)\n",
|
"%llu -> %llu (%s) from %s\n",
|
||||||
(unsigned long long) t->debit_account,
|
(unsigned long long) t->debit_account,
|
||||||
(unsigned long long) t->credit_account,
|
(unsigned long long) t->credit_account,
|
||||||
s);
|
s,
|
||||||
|
t->exchange_base_url);
|
||||||
GNUNET_free (s);
|
GNUNET_free (s);
|
||||||
}
|
}
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
@ -174,10 +186,11 @@ TALER_FAKEBANK_check_empty (struct TALER_FAKEBANK_Handle *h)
|
|||||||
|
|
||||||
s = TALER_amount_to_string (&t->amount);
|
s = TALER_amount_to_string (&t->amount);
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"%llu -> %llu (%s)\n",
|
"%llu -> %llu (%s) from %s\n",
|
||||||
(unsigned long long) t->debit_account,
|
(unsigned long long) t->debit_account,
|
||||||
(unsigned long long) t->credit_account,
|
(unsigned long long) t->credit_account,
|
||||||
s);
|
s,
|
||||||
|
t->exchange_base_url);
|
||||||
GNUNET_free (s);
|
GNUNET_free (s);
|
||||||
}
|
}
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
@ -199,6 +212,7 @@ TALER_FAKEBANK_stop (struct TALER_FAKEBANK_Handle *h)
|
|||||||
GNUNET_CONTAINER_DLL_remove (h->transactions_head,
|
GNUNET_CONTAINER_DLL_remove (h->transactions_head,
|
||||||
h->transactions_tail,
|
h->transactions_tail,
|
||||||
t);
|
t);
|
||||||
|
GNUNET_free (t->exchange_base_url);
|
||||||
GNUNET_free (t);
|
GNUNET_free (t);
|
||||||
}
|
}
|
||||||
if (NULL != h->mhd_task)
|
if (NULL != h->mhd_task)
|
||||||
@ -303,11 +317,13 @@ handle_mhd_request (void *cls,
|
|||||||
}
|
}
|
||||||
t = GNUNET_new (struct Transaction);
|
t = GNUNET_new (struct Transaction);
|
||||||
{
|
{
|
||||||
|
const char *base_url;
|
||||||
struct GNUNET_JSON_Specification spec[] = {
|
struct GNUNET_JSON_Specification spec[] = {
|
||||||
GNUNET_JSON_spec_fixed_auto ("wtid", &t->wtid),
|
GNUNET_JSON_spec_fixed_auto ("wtid", &t->wtid),
|
||||||
GNUNET_JSON_spec_uint64 ("debit_account", &t->debit_account),
|
GNUNET_JSON_spec_uint64 ("debit_account", &t->debit_account),
|
||||||
GNUNET_JSON_spec_uint64 ("credit_account", &t->credit_account),
|
GNUNET_JSON_spec_uint64 ("credit_account", &t->credit_account),
|
||||||
TALER_JSON_spec_amount ("amount", &t->amount),
|
TALER_JSON_spec_amount ("amount", &t->amount),
|
||||||
|
GNUNET_JSON_spec_string ("exchange_url", &base_url),
|
||||||
GNUNET_JSON_spec_end ()
|
GNUNET_JSON_spec_end ()
|
||||||
};
|
};
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
@ -319,14 +335,16 @@ handle_mhd_request (void *cls,
|
|||||||
json_decref (json);
|
json_decref (json);
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
|
t->exchange_base_url = GNUNET_strdup (base_url);
|
||||||
GNUNET_CONTAINER_DLL_insert (h->transactions_head,
|
GNUNET_CONTAINER_DLL_insert (h->transactions_head,
|
||||||
h->transactions_tail,
|
h->transactions_tail,
|
||||||
t);
|
t);
|
||||||
}
|
}
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
"Receiving incoming wire transfer: %llu->%llu\n",
|
"Receiving incoming wire transfer: %llu->%llu from %s\n",
|
||||||
(unsigned long long) t->debit_account,
|
(unsigned long long) t->debit_account,
|
||||||
(unsigned long long) t->credit_account);
|
(unsigned long long) t->credit_account,
|
||||||
|
t->exchange_base_url);
|
||||||
json_decref (json);
|
json_decref (json);
|
||||||
resp = MHD_create_response_from_buffer (0, "", MHD_RESPMEM_PERSISTENT);
|
resp = MHD_create_response_from_buffer (0, "", MHD_RESPMEM_PERSISTENT);
|
||||||
ret = MHD_queue_response (connection,
|
ret = MHD_queue_response (connection,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
This file is part of TALER
|
This file is part of TALER
|
||||||
Copyright (C) 2016 GNUnet e.V.
|
Copyright (C) 2016, 2017 GNUnet e.V.
|
||||||
|
|
||||||
TALER is free software; you can redistribute it and/or modify it under the
|
TALER is free software; you can redistribute it and/or modify it under the
|
||||||
terms of the GNU General Public License as published by the Free Software
|
terms of the GNU General Public License as published by the Free Software
|
||||||
@ -45,6 +45,7 @@ run (void *cls)
|
|||||||
.details.admin_add_incoming.expected_response_code = MHD_HTTP_OK,
|
.details.admin_add_incoming.expected_response_code = MHD_HTTP_OK,
|
||||||
.details.admin_add_incoming.credit_account_no = 1,
|
.details.admin_add_incoming.credit_account_no = 1,
|
||||||
.details.admin_add_incoming.debit_account_no = 2,
|
.details.admin_add_incoming.debit_account_no = 2,
|
||||||
|
.details.admin_add_incoming.exchange_base_url = "https://exchange.net/",
|
||||||
.details.admin_add_incoming.amount = "PUDOS:5.01" },
|
.details.admin_add_incoming.amount = "PUDOS:5.01" },
|
||||||
/* Add EUR:3.21 to account 3 */
|
/* Add EUR:3.21 to account 3 */
|
||||||
{ .oc = TBI_OC_ADMIN_ADD_INCOMING,
|
{ .oc = TBI_OC_ADMIN_ADD_INCOMING,
|
||||||
@ -52,6 +53,7 @@ run (void *cls)
|
|||||||
.details.admin_add_incoming.expected_response_code = MHD_HTTP_OK,
|
.details.admin_add_incoming.expected_response_code = MHD_HTTP_OK,
|
||||||
.details.admin_add_incoming.credit_account_no = 3,
|
.details.admin_add_incoming.credit_account_no = 3,
|
||||||
.details.admin_add_incoming.debit_account_no = 2,
|
.details.admin_add_incoming.debit_account_no = 2,
|
||||||
|
.details.admin_add_incoming.exchange_base_url = "https://exchange.org/",
|
||||||
.details.admin_add_incoming.amount = "PUDOS:3.21" },
|
.details.admin_add_incoming.amount = "PUDOS:3.21" },
|
||||||
/* check transfers arrived at fakebank */
|
/* check transfers arrived at fakebank */
|
||||||
{ .oc = TBI_OC_EXPECT_TRANSFER,
|
{ .oc = TBI_OC_EXPECT_TRANSFER,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
This file is part of TALER
|
This file is part of TALER
|
||||||
Copyright (C) 2016 GNUnet e.V.
|
Copyright (C) 2016, 2017 GNUnet e.V.
|
||||||
|
|
||||||
TALER is free software; you can redistribute it and/or modify it under the
|
TALER is free software; you can redistribute it and/or modify it under the
|
||||||
terms of the GNU General Public License as published by the Free Software
|
terms of the GNU General Public License as published by the Free Software
|
||||||
@ -222,6 +222,7 @@ interpreter_run (void *cls)
|
|||||||
cmd->details.admin_add_incoming.aih
|
cmd->details.admin_add_incoming.aih
|
||||||
= TALER_BANK_admin_add_incoming (is->ctx,
|
= TALER_BANK_admin_add_incoming (is->ctx,
|
||||||
"http://localhost:8081",
|
"http://localhost:8081",
|
||||||
|
cmd->details.admin_add_incoming.exchange_base_url,
|
||||||
&cmd->details.admin_add_incoming.wtid,
|
&cmd->details.admin_add_incoming.wtid,
|
||||||
&amount,
|
&amount,
|
||||||
cmd->details.admin_add_incoming.debit_account_no,
|
cmd->details.admin_add_incoming.debit_account_no,
|
||||||
@ -243,10 +244,11 @@ interpreter_run (void *cls)
|
|||||||
&amount));
|
&amount));
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_FAKEBANK_check (is->fakebank,
|
TALER_FAKEBANK_check (is->fakebank,
|
||||||
&amount,
|
&amount,
|
||||||
ref->details.admin_add_incoming.debit_account_no,
|
ref->details.admin_add_incoming.debit_account_no,
|
||||||
ref->details.admin_add_incoming.credit_account_no,
|
ref->details.admin_add_incoming.credit_account_no,
|
||||||
&wtid))
|
ref->details.admin_add_incoming.exchange_base_url,
|
||||||
|
&wtid))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
fail (is);
|
fail (is);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
This file is part of TALER
|
This file is part of TALER
|
||||||
Copyright (C) 2016 GNUnet e.V.
|
Copyright (C) 2016, 2017 GNUnet e.V.
|
||||||
|
|
||||||
TALER is free software; you can redistribute it and/or modify it under the
|
TALER is free software; you can redistribute it and/or modify it under the
|
||||||
terms of the GNU General Public License as published by the Free Software
|
terms of the GNU General Public License as published by the Free Software
|
||||||
@ -99,6 +99,11 @@ struct TBI_Command
|
|||||||
*/
|
*/
|
||||||
uint64_t debit_account_no;
|
uint64_t debit_account_no;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exchange base URL to use.
|
||||||
|
*/
|
||||||
|
const char *exchange_base_url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wire transfer identifier to use. Initialized to
|
* Wire transfer identifier to use. Initialized to
|
||||||
* a random value.
|
* a random value.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
This file is part of TALER
|
This file is part of TALER
|
||||||
Copyright (C) 2014, 2015, 2016 GNUnet e.V. and Inria
|
Copyright (C) 2014-2017 GNUnet e.V. and Inria
|
||||||
|
|
||||||
TALER is free software; you can redistribute it and/or modify it under the
|
TALER is free software; you can redistribute it and/or modify it under the
|
||||||
terms of the GNU General Public License as published by the Free Software
|
terms of the GNU General Public License as published by the Free Software
|
||||||
@ -604,6 +604,11 @@ struct Command
|
|||||||
*/
|
*/
|
||||||
uint64_t account_credit;
|
uint64_t account_credit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Which exchange base URL is expected?
|
||||||
|
*/
|
||||||
|
const char *exchange_base_url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set (!) to the wire transfer identifier observed.
|
* Set (!) to the wire transfer identifier observed.
|
||||||
*/
|
*/
|
||||||
@ -906,9 +911,10 @@ reserve_status_cb (void *cls,
|
|||||||
(0 == strcmp (cmd->details.reserve_status.reserve_reference,
|
(0 == strcmp (cmd->details.reserve_status.reserve_reference,
|
||||||
rel->details.admin_add_incoming.reserve_reference) ) ) )
|
rel->details.admin_add_incoming.reserve_reference) ) ) )
|
||||||
{
|
{
|
||||||
if (GNUNET_OK !=
|
if ( (j >= history_length) ||
|
||||||
compare_admin_add_incoming_history (&history[j],
|
(GNUNET_OK !=
|
||||||
rel))
|
compare_admin_add_incoming_history (&history[j],
|
||||||
|
rel)) )
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
fail (is);
|
fail (is);
|
||||||
@ -921,9 +927,10 @@ reserve_status_cb (void *cls,
|
|||||||
if (0 == strcmp (cmd->details.reserve_status.reserve_reference,
|
if (0 == strcmp (cmd->details.reserve_status.reserve_reference,
|
||||||
rel->details.reserve_withdraw.reserve_reference))
|
rel->details.reserve_withdraw.reserve_reference))
|
||||||
{
|
{
|
||||||
if (GNUNET_OK !=
|
if ( (j >= history_length) ||
|
||||||
compare_reserve_withdraw_history (&history[j],
|
(GNUNET_OK !=
|
||||||
rel))
|
compare_reserve_withdraw_history (&history[j],
|
||||||
|
rel)) )
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
fail (is);
|
fail (is);
|
||||||
@ -2280,10 +2287,11 @@ interpreter_run (void *cls)
|
|||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_FAKEBANK_check (fakebank,
|
TALER_FAKEBANK_check (fakebank,
|
||||||
&amount,
|
&amount,
|
||||||
cmd->details.check_bank_transfer.account_debit,
|
cmd->details.check_bank_transfer.account_debit,
|
||||||
cmd->details.check_bank_transfer.account_credit,
|
cmd->details.check_bank_transfer.account_credit,
|
||||||
&cmd->details.check_bank_transfer.wtid))
|
cmd->details.check_bank_transfer.exchange_base_url,
|
||||||
|
&cmd->details.check_bank_transfer.wtid))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
fail (is);
|
fail (is);
|
||||||
@ -2914,24 +2922,28 @@ run (void *cls)
|
|||||||
|
|
||||||
{ .oc = OC_CHECK_BANK_TRANSFER,
|
{ .oc = OC_CHECK_BANK_TRANSFER,
|
||||||
.label = "check_bank_transfer-499c",
|
.label = "check_bank_transfer-499c",
|
||||||
|
.details.check_bank_transfer.exchange_base_url = "https://exchange.com/",
|
||||||
.details.check_bank_transfer.amount = "EUR:4.99",
|
.details.check_bank_transfer.amount = "EUR:4.99",
|
||||||
.details.check_bank_transfer.account_debit = 2,
|
.details.check_bank_transfer.account_debit = 2,
|
||||||
.details.check_bank_transfer.account_credit = 42
|
.details.check_bank_transfer.account_credit = 42
|
||||||
},
|
},
|
||||||
{ .oc = OC_CHECK_BANK_TRANSFER,
|
{ .oc = OC_CHECK_BANK_TRANSFER,
|
||||||
.label = "check_bank_transfer-99c1",
|
.label = "check_bank_transfer-99c1",
|
||||||
|
.details.check_bank_transfer.exchange_base_url = "https://exchange.com/",
|
||||||
.details.check_bank_transfer.amount = "EUR:0.99",
|
.details.check_bank_transfer.amount = "EUR:0.99",
|
||||||
.details.check_bank_transfer.account_debit = 2,
|
.details.check_bank_transfer.account_debit = 2,
|
||||||
.details.check_bank_transfer.account_credit = 42
|
.details.check_bank_transfer.account_credit = 42
|
||||||
},
|
},
|
||||||
{ .oc = OC_CHECK_BANK_TRANSFER,
|
{ .oc = OC_CHECK_BANK_TRANSFER,
|
||||||
.label = "check_bank_transfer-99c2",
|
.label = "check_bank_transfer-99c2",
|
||||||
|
.details.check_bank_transfer.exchange_base_url = "https://exchange.com/",
|
||||||
.details.check_bank_transfer.amount = "EUR:0.99",
|
.details.check_bank_transfer.amount = "EUR:0.99",
|
||||||
.details.check_bank_transfer.account_debit = 2,
|
.details.check_bank_transfer.account_debit = 2,
|
||||||
.details.check_bank_transfer.account_credit = 42
|
.details.check_bank_transfer.account_credit = 42
|
||||||
},
|
},
|
||||||
{ .oc = OC_CHECK_BANK_TRANSFER,
|
{ .oc = OC_CHECK_BANK_TRANSFER,
|
||||||
.label = "check_bank_transfer-9c",
|
.label = "check_bank_transfer-9c",
|
||||||
|
.details.check_bank_transfer.exchange_base_url = "https://exchange.com/",
|
||||||
.details.check_bank_transfer.amount = "EUR:0.09",
|
.details.check_bank_transfer.amount = "EUR:0.09",
|
||||||
.details.check_bank_transfer.account_debit = 2,
|
.details.check_bank_transfer.account_debit = 2,
|
||||||
.details.check_bank_transfer.account_credit = 43
|
.details.check_bank_transfer.account_credit = 43
|
||||||
@ -3017,6 +3029,7 @@ run (void *cls)
|
|||||||
/* Check that deposit did run */
|
/* Check that deposit did run */
|
||||||
{ .oc = OC_CHECK_BANK_TRANSFER,
|
{ .oc = OC_CHECK_BANK_TRANSFER,
|
||||||
.label = "check_bank_transfer-pre-refund",
|
.label = "check_bank_transfer-pre-refund",
|
||||||
|
.details.check_bank_transfer.exchange_base_url = "https://exchange.com/",
|
||||||
.details.check_bank_transfer.amount = "EUR:4.98",
|
.details.check_bank_transfer.amount = "EUR:4.98",
|
||||||
.details.check_bank_transfer.account_debit = 2,
|
.details.check_bank_transfer.account_debit = 2,
|
||||||
.details.check_bank_transfer.account_credit = 42
|
.details.check_bank_transfer.account_credit = 42
|
||||||
|
@ -24,6 +24,10 @@ MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
|
|||||||
# How to access our database
|
# How to access our database
|
||||||
DB = postgres
|
DB = postgres
|
||||||
|
|
||||||
|
# Base URL of the exchange. Note that the test expects exactly this
|
||||||
|
# value in the wire transfers.
|
||||||
|
BASE_URL = "https://exchange.com/"
|
||||||
|
|
||||||
[exchangedb-postgres]
|
[exchangedb-postgres]
|
||||||
DB_CONN_STR = "postgres:///talercheck"
|
DB_CONN_STR = "postgres:///talercheck"
|
||||||
|
|
||||||
|
@ -33,6 +33,14 @@ UNIXPATH_MODE = 660
|
|||||||
# HTTP port the exchange listens to
|
# HTTP port the exchange listens to
|
||||||
PORT = 8081
|
PORT = 8081
|
||||||
|
|
||||||
|
# Base URL of the exchange (public-facing). Due to reverse proxies,
|
||||||
|
# this may or may not match our port or hostname at all and can thus
|
||||||
|
# not be determined automatically. Note that a globally reachable name
|
||||||
|
# is required, so 'localhost' will not work except for testing.
|
||||||
|
# Required for wire transfers as we need to include it in the wire
|
||||||
|
# transfers to enable tracking.
|
||||||
|
BASE_URL = http://localhost:8081/
|
||||||
|
|
||||||
|
|
||||||
[exchange-admin]
|
[exchange-admin]
|
||||||
# Network configuration for the /admin HTTP server
|
# Network configuration for the /admin HTTP server
|
||||||
|
@ -29,8 +29,6 @@
|
|||||||
#include "taler_wire_lib.h"
|
#include "taler_wire_lib.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information we keep for each loaded wire plugin.
|
* Information we keep for each loaded wire plugin.
|
||||||
*/
|
*/
|
||||||
@ -168,6 +166,11 @@ struct AggregationUnit
|
|||||||
*/
|
*/
|
||||||
static char *exchange_currency_string;
|
static char *exchange_currency_string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What is the base URL of this exchange?
|
||||||
|
*/
|
||||||
|
static char *exchange_base_url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The exchange's configuration (global)
|
* The exchange's configuration (global)
|
||||||
*/
|
*/
|
||||||
@ -763,6 +766,7 @@ run_aggregation (void *cls)
|
|||||||
au->ph = wp->wire_plugin->prepare_wire_transfer (wp->wire_plugin->cls,
|
au->ph = wp->wire_plugin->prepare_wire_transfer (wp->wire_plugin->cls,
|
||||||
au->wire,
|
au->wire,
|
||||||
&au->total_amount,
|
&au->total_amount,
|
||||||
|
exchange_base_url,
|
||||||
&au->wtid,
|
&au->wtid,
|
||||||
&prepare_cb,
|
&prepare_cb,
|
||||||
au);
|
au);
|
||||||
@ -1061,6 +1065,18 @@ run (void *cls,
|
|||||||
const char *cfgfile,
|
const char *cfgfile,
|
||||||
const struct GNUNET_CONFIGURATION_Handle *c)
|
const struct GNUNET_CONFIGURATION_Handle *c)
|
||||||
{
|
{
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
GNUNET_CONFIGURATION_get_value_string (c,
|
||||||
|
"exchange",
|
||||||
|
"BASE_URL",
|
||||||
|
&exchange_base_url))
|
||||||
|
{
|
||||||
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"exchange",
|
||||||
|
"BASE_URL");
|
||||||
|
global_ret = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
cfg = GNUNET_CONFIGURATION_dup (c);
|
cfg = GNUNET_CONFIGURATION_dup (c);
|
||||||
if (GNUNET_OK != exchange_serve_process_config ())
|
if (GNUNET_OK != exchange_serve_process_config ())
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,40 @@
|
|||||||
|
[PATHS]
|
||||||
|
# Persistant data storage for the testcase
|
||||||
|
TALER_TEST_HOME = test_taler_exchange_httpd_home/
|
||||||
|
|
||||||
|
[taler]
|
||||||
|
# Currency supported by the exchange (can only be one)
|
||||||
|
CURRENCY = EUR
|
||||||
|
|
||||||
[exchange]
|
[exchange]
|
||||||
#The DB plugin to use
|
# The DB plugin to use
|
||||||
DB = postgres
|
DB = postgres
|
||||||
|
|
||||||
|
# Wire format supported by the exchange
|
||||||
|
# We use 'test' for testing of the actual
|
||||||
|
# coin operations.
|
||||||
|
WIREFORMAT = test
|
||||||
|
|
||||||
|
# HTTP port the exchange listens to
|
||||||
|
PORT = 8081
|
||||||
|
|
||||||
|
# Master public key used to sign the exchange's various keys
|
||||||
|
MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
|
||||||
|
|
||||||
|
# Expected base URL of the exchange.
|
||||||
|
BASE_URL = "https://exchange.taler.net/"
|
||||||
|
|
||||||
[exchangedb-postgres]
|
[exchangedb-postgres]
|
||||||
|
|
||||||
#The connection string the plugin has to use for connecting to the database
|
#The connection string the plugin has to use for connecting to the database
|
||||||
DB_CONN_STR = postgres:///talercheck
|
DB_CONN_STR = postgres:///talercheck
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[exchange-wire-outgoing-test]
|
||||||
|
# What is the main website of the bank?
|
||||||
|
BANK_URI = "http://localhost:8082/"
|
||||||
|
|
||||||
|
# From which account at the 'bank' should outgoing
|
||||||
|
# wire transfers be made?
|
||||||
|
EXCHANGE_ACCOUNT_NUMBER = 3
|
||||||
|
@ -110,6 +110,11 @@ struct Command
|
|||||||
*/
|
*/
|
||||||
uint64_t credit_account;
|
uint64_t credit_account;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base URL of the exchange.
|
||||||
|
*/
|
||||||
|
const char *exchange_base_url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subject of the transfer, set by the command.
|
* Subject of the transfer, set by the command.
|
||||||
*/
|
*/
|
||||||
@ -512,7 +517,7 @@ interpreter (void *cls)
|
|||||||
NULL, NULL, NULL,
|
NULL, NULL, NULL,
|
||||||
"taler-exchange-aggregator",
|
"taler-exchange-aggregator",
|
||||||
"taler-exchange-aggregator",
|
"taler-exchange-aggregator",
|
||||||
"-c", "test_taler_exchange_httpd.conf",
|
"-c", config_filename,
|
||||||
"-t", /* enable temporary tables */
|
"-t", /* enable temporary tables */
|
||||||
NULL);
|
NULL);
|
||||||
if (NULL == aggregator_proc)
|
if (NULL == aggregator_proc)
|
||||||
@ -556,10 +561,11 @@ interpreter (void *cls)
|
|||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_FAKEBANK_check (fb,
|
TALER_FAKEBANK_check (fb,
|
||||||
&want_amount,
|
&want_amount,
|
||||||
cmd->details.expect_transaction.debit_account,
|
cmd->details.expect_transaction.debit_account,
|
||||||
cmd->details.expect_transaction.credit_account,
|
cmd->details.expect_transaction.credit_account,
|
||||||
&cmd->details.expect_transaction.wtid))
|
cmd->details.expect_transaction.exchange_base_url,
|
||||||
|
&cmd->details.expect_transaction.wtid))
|
||||||
{
|
{
|
||||||
fail (cmd);
|
fail (cmd);
|
||||||
return;
|
return;
|
||||||
@ -614,6 +620,7 @@ run_test ()
|
|||||||
.label = "expect-deposit-1",
|
.label = "expect-deposit-1",
|
||||||
.details.expect_transaction.debit_account = 3,
|
.details.expect_transaction.debit_account = 3,
|
||||||
.details.expect_transaction.credit_account = 4,
|
.details.expect_transaction.credit_account = 4,
|
||||||
|
.details.expect_transaction.exchange_base_url = "https://exchange.taler.net/",
|
||||||
.details.expect_transaction.amount = "EUR:0.9"
|
.details.expect_transaction.amount = "EUR:0.9"
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -660,6 +667,7 @@ run_test ()
|
|||||||
.label = "expect-deposit-2",
|
.label = "expect-deposit-2",
|
||||||
.details.expect_transaction.debit_account = 3,
|
.details.expect_transaction.debit_account = 3,
|
||||||
.details.expect_transaction.credit_account = 4,
|
.details.expect_transaction.credit_account = 4,
|
||||||
|
.details.expect_transaction.exchange_base_url = "https://exchange.taler.net/",
|
||||||
.details.expect_transaction.amount = "EUR:1.8"
|
.details.expect_transaction.amount = "EUR:1.8"
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -705,6 +713,7 @@ run_test ()
|
|||||||
.label = "expect-deposit-3a",
|
.label = "expect-deposit-3a",
|
||||||
.details.expect_transaction.debit_account = 3,
|
.details.expect_transaction.debit_account = 3,
|
||||||
.details.expect_transaction.credit_account = 4,
|
.details.expect_transaction.credit_account = 4,
|
||||||
|
.details.expect_transaction.exchange_base_url = "https://exchange.taler.net/",
|
||||||
.details.expect_transaction.amount = "EUR:0.9"
|
.details.expect_transaction.amount = "EUR:0.9"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -712,6 +721,7 @@ run_test ()
|
|||||||
.label = "expect-deposit-3b",
|
.label = "expect-deposit-3b",
|
||||||
.details.expect_transaction.debit_account = 3,
|
.details.expect_transaction.debit_account = 3,
|
||||||
.details.expect_transaction.credit_account = 4,
|
.details.expect_transaction.credit_account = 4,
|
||||||
|
.details.expect_transaction.exchange_base_url = "https://exchange.taler.net/",
|
||||||
.details.expect_transaction.amount = "EUR:0.9"
|
.details.expect_transaction.amount = "EUR:0.9"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -719,6 +729,7 @@ run_test ()
|
|||||||
.label = "expect-deposit-3c",
|
.label = "expect-deposit-3c",
|
||||||
.details.expect_transaction.debit_account = 3,
|
.details.expect_transaction.debit_account = 3,
|
||||||
.details.expect_transaction.credit_account = 5,
|
.details.expect_transaction.credit_account = 5,
|
||||||
|
.details.expect_transaction.exchange_base_url = "https://exchange.taler.net/",
|
||||||
.details.expect_transaction.amount = "EUR:0.9"
|
.details.expect_transaction.amount = "EUR:0.9"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -767,6 +778,7 @@ run_test ()
|
|||||||
.label = "expect-deposit-4",
|
.label = "expect-deposit-4",
|
||||||
.details.expect_transaction.debit_account = 3,
|
.details.expect_transaction.debit_account = 3,
|
||||||
.details.expect_transaction.credit_account = 4,
|
.details.expect_transaction.credit_account = 4,
|
||||||
|
.details.expect_transaction.exchange_base_url = "https://exchange.taler.net/",
|
||||||
.details.expect_transaction.amount = "EUR:0.2"
|
.details.expect_transaction.amount = "EUR:0.2"
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -811,6 +823,7 @@ run_test ()
|
|||||||
.label = "expect-deposit-5",
|
.label = "expect-deposit-5",
|
||||||
.details.expect_transaction.debit_account = 3,
|
.details.expect_transaction.debit_account = 3,
|
||||||
.details.expect_transaction.credit_account = 4,
|
.details.expect_transaction.credit_account = 4,
|
||||||
|
.details.expect_transaction.exchange_base_url = "https://exchange.taler.net/",
|
||||||
.details.expect_transaction.amount = "EUR:0.2"
|
.details.expect_transaction.amount = "EUR:0.2"
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -893,6 +906,7 @@ run_test ()
|
|||||||
.label = "expect-deposit-6",
|
.label = "expect-deposit-6",
|
||||||
.details.expect_transaction.debit_account = 3,
|
.details.expect_transaction.debit_account = 3,
|
||||||
.details.expect_transaction.credit_account = 4,
|
.details.expect_transaction.credit_account = 4,
|
||||||
|
.details.expect_transaction.exchange_base_url = "https://exchange.taler.net/",
|
||||||
.details.expect_transaction.amount = "EUR:0.01"
|
.details.expect_transaction.amount = "EUR:0.01"
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -932,6 +946,7 @@ run_test ()
|
|||||||
.label = "expect-deposit-7",
|
.label = "expect-deposit-7",
|
||||||
.details.expect_transaction.debit_account = 3,
|
.details.expect_transaction.debit_account = 3,
|
||||||
.details.expect_transaction.credit_account = 4,
|
.details.expect_transaction.credit_account = 4,
|
||||||
|
.details.expect_transaction.exchange_base_url = "https://exchange.taler.net/",
|
||||||
.details.expect_transaction.amount = "EUR:0.01"
|
.details.expect_transaction.amount = "EUR:0.01"
|
||||||
},
|
},
|
||||||
/* Now check profit was actually taken */
|
/* Now check profit was actually taken */
|
||||||
@ -953,6 +968,7 @@ run_test ()
|
|||||||
.label = "expect-deposit-7",
|
.label = "expect-deposit-7",
|
||||||
.details.expect_transaction.debit_account = 3,
|
.details.expect_transaction.debit_account = 3,
|
||||||
.details.expect_transaction.credit_account = 4,
|
.details.expect_transaction.credit_account = 4,
|
||||||
|
.details.expect_transaction.exchange_base_url = "https://exchange.taler.net/",
|
||||||
.details.expect_transaction.amount = "EUR:0.02"
|
.details.expect_transaction.amount = "EUR:0.02"
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1010,6 +1026,7 @@ run_test ()
|
|||||||
.label = "expect-deposit-8",
|
.label = "expect-deposit-8",
|
||||||
.details.expect_transaction.debit_account = 3,
|
.details.expect_transaction.debit_account = 3,
|
||||||
.details.expect_transaction.credit_account = 4,
|
.details.expect_transaction.credit_account = 4,
|
||||||
|
.details.expect_transaction.exchange_base_url = "https://exchange.taler.net/",
|
||||||
.details.expect_transaction.amount = "EUR:0.04"
|
.details.expect_transaction.amount = "EUR:0.04"
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1069,6 +1086,7 @@ run_test ()
|
|||||||
.label = "expect-deposit-9",
|
.label = "expect-deposit-9",
|
||||||
.details.expect_transaction.debit_account = 3,
|
.details.expect_transaction.debit_account = 3,
|
||||||
.details.expect_transaction.credit_account = 4,
|
.details.expect_transaction.credit_account = 4,
|
||||||
|
.details.expect_transaction.exchange_base_url = "https://exchange.taler.net/",
|
||||||
.details.expect_transaction.amount = "EUR:0.02"
|
.details.expect_transaction.amount = "EUR:0.02"
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1142,7 +1160,8 @@ run (void *cls)
|
|||||||
GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
|
GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
|
||||||
GNUNET_DISK_pipe_handle (sigpipe,
|
GNUNET_DISK_pipe_handle (sigpipe,
|
||||||
GNUNET_DISK_PIPE_END_READ),
|
GNUNET_DISK_PIPE_END_READ),
|
||||||
&maint_child_death, NULL);
|
&maint_child_death,
|
||||||
|
NULL);
|
||||||
GNUNET_SCHEDULER_add_shutdown (&shutdown_action,
|
GNUNET_SCHEDULER_add_shutdown (&shutdown_action,
|
||||||
NULL);
|
NULL);
|
||||||
timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
|
timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
|
||||||
@ -1195,9 +1214,11 @@ main (int argc,
|
|||||||
}
|
}
|
||||||
plugin_name++;
|
plugin_name++;
|
||||||
(void) GNUNET_asprintf (&testname,
|
(void) GNUNET_asprintf (&testname,
|
||||||
"test-taler-exchange-aggregator-%s", plugin_name);
|
"test-taler-exchange-aggregator-%s",
|
||||||
|
plugin_name);
|
||||||
(void) GNUNET_asprintf (&config_filename,
|
(void) GNUNET_asprintf (&config_filename,
|
||||||
"%s.conf", testname);
|
"%s.conf",
|
||||||
|
testname);
|
||||||
/* these might get in the way */
|
/* these might get in the way */
|
||||||
unsetenv ("XDG_DATA_HOME");
|
unsetenv ("XDG_DATA_HOME");
|
||||||
unsetenv ("XDG_CONFIG_HOME");
|
unsetenv ("XDG_CONFIG_HOME");
|
||||||
@ -1214,13 +1235,16 @@ main (int argc,
|
|||||||
GNUNET_free (testname);
|
GNUNET_free (testname);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
sigpipe = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO, GNUNET_NO, GNUNET_NO);
|
sigpipe = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO,
|
||||||
|
GNUNET_NO, GNUNET_NO);
|
||||||
GNUNET_assert (NULL != sigpipe);
|
GNUNET_assert (NULL != sigpipe);
|
||||||
shc_chld =
|
shc_chld =
|
||||||
GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, &sighandler_child_death);
|
GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD,
|
||||||
|
&sighandler_child_death);
|
||||||
coin_pk = GNUNET_CRYPTO_rsa_private_key_create (1024);
|
coin_pk = GNUNET_CRYPTO_rsa_private_key_create (1024);
|
||||||
coin_pub = GNUNET_CRYPTO_rsa_private_key_get_public (coin_pk);
|
coin_pub = GNUNET_CRYPTO_rsa_private_key_get_public (coin_pk);
|
||||||
GNUNET_SCHEDULER_run (&run, cfg);
|
GNUNET_SCHEDULER_run (&run,
|
||||||
|
cfg);
|
||||||
GNUNET_CRYPTO_rsa_private_key_free (coin_pk);
|
GNUNET_CRYPTO_rsa_private_key_free (coin_pk);
|
||||||
GNUNET_CRYPTO_rsa_public_key_free (coin_pub);
|
GNUNET_CRYPTO_rsa_public_key_free (coin_pub);
|
||||||
GNUNET_SIGNAL_handler_uninstall (shc_chld);
|
GNUNET_SIGNAL_handler_uninstall (shc_chld);
|
||||||
|
@ -57,8 +57,9 @@ 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 bank_base_url URL of the bank
|
* @param bank_base_url URL of the bank (used to execute this request)
|
||||||
* @param reserve_pub public key of the reserve
|
* @param exchange_base_url base URL of the exchange (for tracking)
|
||||||
|
* @param wtid wire transfer identifier for the transfer
|
||||||
* @param amount amount that was deposited
|
* @param amount amount that was deposited
|
||||||
* @param execution_date when did we receive the amount
|
* @param execution_date when did we receive the amount
|
||||||
* @param debit_account_no account number to withdraw from (53 bits at most)
|
* @param debit_account_no account number to withdraw from (53 bits at most)
|
||||||
@ -72,6 +73,7 @@ typedef void
|
|||||||
struct TALER_BANK_AdminAddIncomingHandle *
|
struct TALER_BANK_AdminAddIncomingHandle *
|
||||||
TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx,
|
TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx,
|
||||||
const char *bank_base_url,
|
const char *bank_base_url,
|
||||||
|
const char *exchange_base_url,
|
||||||
const struct TALER_WireTransferIdentifierRawP *wtid,
|
const struct TALER_WireTransferIdentifierRawP *wtid,
|
||||||
const struct TALER_Amount *amount,
|
const struct TALER_Amount *amount,
|
||||||
uint64_t debit_account_no,
|
uint64_t debit_account_no,
|
||||||
|
@ -71,15 +71,18 @@ TALER_FAKEBANK_check_empty (struct TALER_FAKEBANK_Handle *h);
|
|||||||
* @param want_amount transfer amount desired
|
* @param want_amount transfer amount desired
|
||||||
* @param want_debit account that should have been debited
|
* @param want_debit account that should have been debited
|
||||||
* @param want_debit account that should have been credited
|
* @param want_debit account that should have been credited
|
||||||
|
* @param exchange_base_url expected base URL of the exchange,
|
||||||
|
* i.e. "https://example.com/"; may include a port
|
||||||
* @param[out] wtid set to the wire transfer identifier
|
* @param[out] wtid set to the wire transfer identifier
|
||||||
* @return #GNUNET_OK on success
|
* @return #GNUNET_OK on success
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_FAKEBANK_check (struct TALER_FAKEBANK_Handle *h,
|
TALER_FAKEBANK_check (struct TALER_FAKEBANK_Handle *h,
|
||||||
const struct TALER_Amount *want_amount,
|
const struct TALER_Amount *want_amount,
|
||||||
uint64_t want_debit,
|
uint64_t want_debit,
|
||||||
uint64_t want_credit,
|
uint64_t want_credit,
|
||||||
struct TALER_WireTransferIdentifierRawP *wtid);
|
const char *exchange_base_url,
|
||||||
|
struct TALER_WireTransferIdentifierRawP *wtid);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,6 +155,7 @@ struct TALER_WIRE_Plugin
|
|||||||
* @param cls the @e cls of this struct with the plugin-specific state
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
* @param wire valid wire account information
|
* @param wire valid wire account information
|
||||||
* @param amount amount to transfer, already rounded
|
* @param amount amount to transfer, already rounded
|
||||||
|
* @param exchange_base_url base URL of this exchange
|
||||||
* @param wtid wire transfer identifier to use
|
* @param wtid wire transfer identifier to use
|
||||||
* @param ptc function to call with the prepared data to persist
|
* @param ptc function to call with the prepared data to persist
|
||||||
* @param ptc_cls closure for @a ptc
|
* @param ptc_cls closure for @a ptc
|
||||||
@ -164,6 +165,7 @@ struct TALER_WIRE_Plugin
|
|||||||
(*prepare_wire_transfer) (void *cls,
|
(*prepare_wire_transfer) (void *cls,
|
||||||
const json_t *wire,
|
const json_t *wire,
|
||||||
const struct TALER_Amount *amount,
|
const struct TALER_Amount *amount,
|
||||||
|
const char *exchange_base_url,
|
||||||
const struct TALER_WireTransferIdentifierRawP *wtid,
|
const struct TALER_WireTransferIdentifierRawP *wtid,
|
||||||
TALER_WIRE_PrepareTransactionCallback ptc,
|
TALER_WIRE_PrepareTransactionCallback ptc,
|
||||||
void *ptc_cls);
|
void *ptc_cls);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
This file is part of TALER
|
This file is part of TALER
|
||||||
Copyright (C) 2016 GNUnet e.V. & Inria
|
Copyright (C) 2016, 2017 GNUnet e.V. & Inria
|
||||||
|
|
||||||
TALER is free software; you can redistribute it and/or modify it under the
|
TALER is free software; you can redistribute it and/or modify it under the
|
||||||
terms of the GNU General Public License as published by the Free Software
|
terms of the GNU General Public License as published by the Free Software
|
||||||
@ -658,6 +658,7 @@ sepa_sign_wire_details (void *cls,
|
|||||||
* @param cls the @e cls of this struct with the plugin-specific state
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
* @param wire valid wire account information
|
* @param wire valid wire account information
|
||||||
* @param amount amount to transfer, already rounded
|
* @param amount amount to transfer, already rounded
|
||||||
|
* @param exchange_base_url base URL of the exchange (for tracking)
|
||||||
* @param wtid wire transfer identifier to use
|
* @param wtid wire transfer identifier to use
|
||||||
* @param psc function to call with the prepared data to persist
|
* @param psc function to call with the prepared data to persist
|
||||||
* @param psc_cls closure for @a psc
|
* @param psc_cls closure for @a psc
|
||||||
@ -667,6 +668,7 @@ static struct TALER_WIRE_PrepareHandle *
|
|||||||
sepa_prepare_wire_transfer (void *cls,
|
sepa_prepare_wire_transfer (void *cls,
|
||||||
const json_t *wire,
|
const json_t *wire,
|
||||||
const struct TALER_Amount *amount,
|
const struct TALER_Amount *amount,
|
||||||
|
const char *exchange_base_url,
|
||||||
const struct TALER_WireTransferIdentifierRawP *wtid,
|
const struct TALER_WireTransferIdentifierRawP *wtid,
|
||||||
TALER_WIRE_PrepareTransactionCallback psc,
|
TALER_WIRE_PrepareTransactionCallback psc,
|
||||||
void *psc_cls)
|
void *psc_cls)
|
||||||
|
@ -120,6 +120,7 @@ template_wire_validate (void *cls,
|
|||||||
* @param cls the @e cls of this struct with the plugin-specific state
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
* @param wire valid wire account information
|
* @param wire valid wire account information
|
||||||
* @param amount amount to transfer, already rounded
|
* @param amount amount to transfer, already rounded
|
||||||
|
* @param exchange_base_url base URL of the exchange (for tracking)
|
||||||
* @param wtid wire transfer identifier to use
|
* @param wtid wire transfer identifier to use
|
||||||
* @param ptc function to call with the prepared data to persist
|
* @param ptc function to call with the prepared data to persist
|
||||||
* @param ptc_cls closure for @a ptc
|
* @param ptc_cls closure for @a ptc
|
||||||
@ -129,6 +130,7 @@ static struct TALER_WIRE_PrepareHandle *
|
|||||||
template_prepare_wire_transfer (void *cls,
|
template_prepare_wire_transfer (void *cls,
|
||||||
const json_t *wire,
|
const json_t *wire,
|
||||||
const struct TALER_Amount *amount,
|
const struct TALER_Amount *amount,
|
||||||
|
const char *exchange_base_url,
|
||||||
const struct TALER_WireTransferIdentifierRawP *wtid,
|
const struct TALER_WireTransferIdentifierRawP *wtid,
|
||||||
TALER_WIRE_PrepareTransactionCallback ptc,
|
TALER_WIRE_PrepareTransactionCallback ptc,
|
||||||
void *ptc_cls)
|
void *ptc_cls)
|
||||||
|
@ -85,6 +85,11 @@ struct TALER_WIRE_PrepareHandle
|
|||||||
*/
|
*/
|
||||||
json_t *wire;
|
json_t *wire;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base URL to use for the exchange.
|
||||||
|
*/
|
||||||
|
char *exchange_base_url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to call with the serialized data.
|
* Function to call with the serialized data.
|
||||||
*/
|
*/
|
||||||
@ -397,7 +402,9 @@ struct BufFormatP
|
|||||||
*/
|
*/
|
||||||
struct TALER_AmountNBO amount;
|
struct TALER_AmountNBO amount;
|
||||||
|
|
||||||
/* followed by serialized 'wire' JSON data */
|
/* followed by serialized 'wire' JSON data (0-terminated) */
|
||||||
|
|
||||||
|
/* followed by 0-terminated base URL */
|
||||||
|
|
||||||
};
|
};
|
||||||
GNUNET_NETWORK_STRUCT_END
|
GNUNET_NETWORK_STRUCT_END
|
||||||
@ -417,6 +424,7 @@ test_prepare_wire_transfer_cancel (void *cls,
|
|||||||
if (NULL != pth->task)
|
if (NULL != pth->task)
|
||||||
GNUNET_SCHEDULER_cancel (pth->task);
|
GNUNET_SCHEDULER_cancel (pth->task);
|
||||||
json_decref (pth->wire);
|
json_decref (pth->wire);
|
||||||
|
GNUNET_free (pth->exchange_base_url);
|
||||||
GNUNET_free (pth);
|
GNUNET_free (pth);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,7 +440,8 @@ do_prepare (void *cls)
|
|||||||
{
|
{
|
||||||
struct TALER_WIRE_PrepareHandle *pth = cls;
|
struct TALER_WIRE_PrepareHandle *pth = cls;
|
||||||
char *wire_enc;
|
char *wire_enc;
|
||||||
size_t len;
|
size_t len_w;
|
||||||
|
size_t len_b;
|
||||||
struct BufFormatP bf;
|
struct BufFormatP bf;
|
||||||
|
|
||||||
pth->task = NULL;
|
pth->task = NULL;
|
||||||
@ -449,19 +458,23 @@ do_prepare (void *cls)
|
|||||||
pth);
|
pth);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
len = strlen (wire_enc) + 1;
|
len_w = strlen (wire_enc) + 1;
|
||||||
|
len_b = strlen (pth->exchange_base_url) + 1;
|
||||||
bf.wtid = pth->wtid;
|
bf.wtid = pth->wtid;
|
||||||
TALER_amount_hton (&bf.amount,
|
TALER_amount_hton (&bf.amount,
|
||||||
&pth->amount);
|
&pth->amount);
|
||||||
{
|
{
|
||||||
char buf[sizeof (struct BufFormatP) + len];
|
char buf[sizeof (struct BufFormatP) + len_w + len_b];
|
||||||
|
|
||||||
memcpy (buf,
|
memcpy (buf,
|
||||||
&bf,
|
&bf,
|
||||||
sizeof (struct BufFormatP));
|
sizeof (struct BufFormatP));
|
||||||
memcpy (&buf[sizeof (struct BufFormatP)],
|
memcpy (&buf[sizeof (struct BufFormatP)],
|
||||||
wire_enc,
|
wire_enc,
|
||||||
len);
|
len_w);
|
||||||
|
memcpy (&buf[sizeof (struct BufFormatP) + len_w],
|
||||||
|
pth->exchange_base_url,
|
||||||
|
len_b);
|
||||||
|
|
||||||
/* finally give the state back */
|
/* finally give the state back */
|
||||||
pth->ptc (pth->ptc_cls,
|
pth->ptc (pth->ptc_cls,
|
||||||
@ -485,6 +498,7 @@ do_prepare (void *cls)
|
|||||||
* @param cls the @e cls of this struct with the plugin-specific state
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
* @param wire valid wire account information
|
* @param wire valid wire account information
|
||||||
* @param amount amount to transfer, already rounded
|
* @param amount amount to transfer, already rounded
|
||||||
|
* @param exchange_base_url base URL of this exchange
|
||||||
* @param wtid wire transfer identifier to use
|
* @param wtid wire transfer identifier to use
|
||||||
* @param ptc function to call with the prepared data to persist
|
* @param ptc function to call with the prepared data to persist
|
||||||
* @param ptc_cls closure for @a ptc
|
* @param ptc_cls closure for @a ptc
|
||||||
@ -494,6 +508,7 @@ static struct TALER_WIRE_PrepareHandle *
|
|||||||
test_prepare_wire_transfer (void *cls,
|
test_prepare_wire_transfer (void *cls,
|
||||||
const json_t *wire,
|
const json_t *wire,
|
||||||
const struct TALER_Amount *amount,
|
const struct TALER_Amount *amount,
|
||||||
|
const char *exchange_base_url,
|
||||||
const struct TALER_WireTransferIdentifierRawP *wtid,
|
const struct TALER_WireTransferIdentifierRawP *wtid,
|
||||||
TALER_WIRE_PrepareTransactionCallback ptc,
|
TALER_WIRE_PrepareTransactionCallback ptc,
|
||||||
void *ptc_cls)
|
void *ptc_cls)
|
||||||
@ -515,6 +530,7 @@ test_prepare_wire_transfer (void *cls,
|
|||||||
pth = GNUNET_new (struct TALER_WIRE_PrepareHandle);
|
pth = GNUNET_new (struct TALER_WIRE_PrepareHandle);
|
||||||
pth->tc = tc;
|
pth->tc = tc;
|
||||||
pth->wire = json_incref ((json_t *) wire);
|
pth->wire = json_incref ((json_t *) wire);
|
||||||
|
pth->exchange_base_url = GNUNET_strdup (exchange_base_url);
|
||||||
pth->wtid = *wtid;
|
pth->wtid = *wtid;
|
||||||
pth->ptc = ptc;
|
pth->ptc = ptc;
|
||||||
pth->ptc_cls = ptc_cls;
|
pth->ptc_cls = ptc_cls;
|
||||||
@ -650,6 +666,8 @@ test_execute_wire_transfer (void *cls,
|
|||||||
json_int_t account_no;
|
json_int_t account_no;
|
||||||
struct BufFormatP bf;
|
struct BufFormatP bf;
|
||||||
char *emsg;
|
char *emsg;
|
||||||
|
const char *json_s;
|
||||||
|
const char *exchange_base_url;
|
||||||
|
|
||||||
if (NULL == tc->ctx)
|
if (NULL == tc->ctx)
|
||||||
{
|
{
|
||||||
@ -658,7 +676,14 @@ test_execute_wire_transfer (void *cls,
|
|||||||
return NULL; /* not initialized with configuration, cannot do transfers */
|
return NULL; /* not initialized with configuration, cannot do transfers */
|
||||||
}
|
}
|
||||||
if ( (buf_size <= sizeof (struct BufFormatP)) ||
|
if ( (buf_size <= sizeof (struct BufFormatP)) ||
|
||||||
('\0' != buf[buf_size -1]) )
|
('\0' != buf[buf_size - 1]) )
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
json_s = &buf[sizeof (struct BufFormatP)];
|
||||||
|
exchange_base_url = &json_s[strlen (json_s) + 1];
|
||||||
|
if (exchange_base_url > &buf[buf_size - 1])
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -668,7 +693,7 @@ test_execute_wire_transfer (void *cls,
|
|||||||
sizeof (bf));
|
sizeof (bf));
|
||||||
TALER_amount_ntoh (&amount,
|
TALER_amount_ntoh (&amount,
|
||||||
&bf.amount);
|
&bf.amount);
|
||||||
wire = json_loads (&buf[sizeof (struct BufFormatP)],
|
wire = json_loads (json_s,
|
||||||
JSON_REJECT_DUPLICATES,
|
JSON_REJECT_DUPLICATES,
|
||||||
NULL);
|
NULL);
|
||||||
if (NULL == wire)
|
if (NULL == wire)
|
||||||
@ -697,6 +722,7 @@ test_execute_wire_transfer (void *cls,
|
|||||||
eh->cc_cls = cc_cls;
|
eh->cc_cls = cc_cls;
|
||||||
eh->aaih = TALER_BANK_admin_add_incoming (tc->ctx,
|
eh->aaih = TALER_BANK_admin_add_incoming (tc->ctx,
|
||||||
tc->bank_uri,
|
tc->bank_uri,
|
||||||
|
exchange_base_url,
|
||||||
&bf.wtid,
|
&bf.wtid,
|
||||||
&amount,
|
&amount,
|
||||||
(uint64_t) tc->exchange_account_outgoing_no,
|
(uint64_t) tc->exchange_account_outgoing_no,
|
||||||
|
Loading…
Reference in New Issue
Block a user