ftbfs
This commit is contained in:
parent
d822035216
commit
b37fff0d5b
@ -258,6 +258,17 @@ TALER_payto_xtalerbank_make (const char *bank_url,
|
|||||||
const char *account_name);
|
const char *account_name);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an x-taler-bank payto:// URL from an @a account_url.
|
||||||
|
*
|
||||||
|
* @param account_url the bank URL
|
||||||
|
* @param account_name the account name
|
||||||
|
* @return payto:// URL
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
TALER_payto_xtalerbank_make2 (const char *account_url);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given an x-taler-bank payto:// URL, compute
|
* Given an x-taler-bank payto:// URL, compute
|
||||||
* the HTTP(S) base URL of the account.
|
* the HTTP(S) base URL of the account.
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<http://www.gnu.org/licenses/>
|
<http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @file exchange-lib/testing_api_cmd_admin_add_incoming.c
|
* @file lib/testing_api_cmd_admin_add_incoming.c
|
||||||
* @brief implementation of a bank /admin/add-incoming command
|
* @brief implementation of a bank /admin/add-incoming command
|
||||||
* @author Christian Grothoff
|
* @author Christian Grothoff
|
||||||
* @author Marcello Stanisci
|
* @author Marcello Stanisci
|
||||||
@ -58,6 +58,11 @@ struct AdminAddIncomingState
|
|||||||
*/
|
*/
|
||||||
const char *payto_debit_account;
|
const char *payto_debit_account;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Money sender account URL.
|
||||||
|
*/
|
||||||
|
char *payto_credit_account;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Username to use for authentication.
|
* Username to use for authentication.
|
||||||
*/
|
*/
|
||||||
@ -376,6 +381,7 @@ admin_add_incoming_cleanup (void *cls,
|
|||||||
GNUNET_SCHEDULER_cancel (fts->retry_task);
|
GNUNET_SCHEDULER_cancel (fts->retry_task);
|
||||||
fts->retry_task = NULL;
|
fts->retry_task = NULL;
|
||||||
}
|
}
|
||||||
|
GNUNET_free (fts->payto_credit_account);
|
||||||
GNUNET_free (fts);
|
GNUNET_free (fts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,7 +408,8 @@ admin_add_incoming_traits (void *cls,
|
|||||||
TALER_TESTING_make_trait_payto (TALER_TESTING_PT_DEBIT,
|
TALER_TESTING_make_trait_payto (TALER_TESTING_PT_DEBIT,
|
||||||
fts->payto_debit_account),
|
fts->payto_debit_account),
|
||||||
TALER_TESTING_make_trait_payto (TALER_TESTING_PT_CREDIT,
|
TALER_TESTING_make_trait_payto (TALER_TESTING_PT_CREDIT,
|
||||||
fts->exchange_credit_url),
|
fts->payto_credit_account),
|
||||||
|
TALER_TESTING_make_trait_url (0, fts->exchange_credit_url),
|
||||||
TALER_TESTING_make_trait_amount_obj (0, &fts->amount),
|
TALER_TESTING_make_trait_amount_obj (0, &fts->amount),
|
||||||
TALER_TESTING_make_trait_absolute_time (0, &fts->timestamp),
|
TALER_TESTING_make_trait_absolute_time (0, &fts->timestamp),
|
||||||
TALER_TESTING_make_trait_reserve_priv (0,
|
TALER_TESTING_make_trait_reserve_priv (0,
|
||||||
@ -419,6 +426,65 @@ admin_add_incoming_traits (void *cls,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create internal state for "/admin/add-incoming" CMD.
|
||||||
|
*
|
||||||
|
* @param amount the amount to transfer.
|
||||||
|
* @param account_bank_url base URL of the exchange account receiving the money
|
||||||
|
* @param payto_debit_account which account sends money
|
||||||
|
* @param auth authentication data
|
||||||
|
* @return the internal state
|
||||||
|
*/
|
||||||
|
static struct AdminAddIncomingState *
|
||||||
|
make_fts (const char *amount,
|
||||||
|
const char *exchange_base_url,
|
||||||
|
const struct TALER_BANK_AuthenticationData *auth,
|
||||||
|
const char *payto_debit_account)
|
||||||
|
{
|
||||||
|
struct AdminAddIncomingState *fts;
|
||||||
|
|
||||||
|
fts = GNUNET_new (struct AdminAddIncomingState);
|
||||||
|
fts->exchange_credit_url = exchange_base_url;
|
||||||
|
fts->payto_debit_account = payto_debit_account;
|
||||||
|
fts->payto_credit_account
|
||||||
|
= TALER_payto_xtalerbank_make2 (exchange_base_url);
|
||||||
|
fts->auth = *auth;
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
TALER_string_to_amount (amount,
|
||||||
|
&fts->amount))
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"Failed to parse amount `%s'\n",
|
||||||
|
amount);
|
||||||
|
GNUNET_assert (0);
|
||||||
|
}
|
||||||
|
return fts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to create admin/add-incoming command.
|
||||||
|
*
|
||||||
|
* @param label command label.
|
||||||
|
* @param fts internal state to use
|
||||||
|
* @return the command.
|
||||||
|
*/
|
||||||
|
static struct TALER_TESTING_Command
|
||||||
|
make_command (const char *label,
|
||||||
|
struct AdminAddIncomingState *fts)
|
||||||
|
{
|
||||||
|
struct TALER_TESTING_Command cmd = {
|
||||||
|
.cls = fts,
|
||||||
|
.label = label,
|
||||||
|
.run = &admin_add_incoming_run,
|
||||||
|
.cleanup = &admin_add_incoming_cleanup,
|
||||||
|
.traits = &admin_add_incoming_traits
|
||||||
|
};
|
||||||
|
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create admin/add-incoming command.
|
* Create admin/add-incoming command.
|
||||||
*
|
*
|
||||||
@ -438,34 +504,11 @@ TALER_TESTING_cmd_admin_add_incoming
|
|||||||
const struct TALER_BANK_AuthenticationData *auth,
|
const struct TALER_BANK_AuthenticationData *auth,
|
||||||
const char *payto_debit_account)
|
const char *payto_debit_account)
|
||||||
{
|
{
|
||||||
struct AdminAddIncomingState *fts;
|
return make_command (label,
|
||||||
|
make_fts (amount,
|
||||||
fts = GNUNET_new (struct AdminAddIncomingState);
|
exchange_base_url,
|
||||||
fts->exchange_credit_url = exchange_base_url;
|
auth,
|
||||||
fts->payto_debit_account = payto_debit_account;
|
payto_debit_account));
|
||||||
fts->auth = *auth;
|
|
||||||
if (GNUNET_OK !=
|
|
||||||
TALER_string_to_amount (amount,
|
|
||||||
&fts->amount))
|
|
||||||
{
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"Failed to parse amount `%s' at %s\n",
|
|
||||||
amount,
|
|
||||||
label);
|
|
||||||
GNUNET_assert (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
struct TALER_TESTING_Command cmd = {
|
|
||||||
.cls = fts,
|
|
||||||
.label = label,
|
|
||||||
.run = &admin_add_incoming_run,
|
|
||||||
.cleanup = &admin_add_incoming_cleanup,
|
|
||||||
.traits = &admin_add_incoming_traits
|
|
||||||
};
|
|
||||||
|
|
||||||
return cmd;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -495,32 +538,13 @@ TALER_TESTING_cmd_admin_add_incoming_with_ref
|
|||||||
{
|
{
|
||||||
struct AdminAddIncomingState *fts;
|
struct AdminAddIncomingState *fts;
|
||||||
|
|
||||||
fts = GNUNET_new (struct AdminAddIncomingState);
|
fts = make_fts (amount,
|
||||||
fts->exchange_credit_url = account_base_url;
|
account_base_url,
|
||||||
fts->payto_debit_account = payto_debit_account;
|
auth,
|
||||||
fts->auth = *auth;
|
payto_debit_account);
|
||||||
fts->reserve_reference = ref;
|
fts->reserve_reference = ref;
|
||||||
if (GNUNET_OK !=
|
return make_command (label,
|
||||||
TALER_string_to_amount (amount,
|
fts);
|
||||||
&fts->amount))
|
|
||||||
{
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"Failed to parse amount `%s' at %s\n",
|
|
||||||
amount,
|
|
||||||
label);
|
|
||||||
GNUNET_assert (0);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
struct TALER_TESTING_Command cmd = {
|
|
||||||
.cls = fts,
|
|
||||||
.label = label,
|
|
||||||
.run = &admin_add_incoming_run,
|
|
||||||
.cleanup = &admin_add_incoming_cleanup,
|
|
||||||
.traits = &admin_add_incoming_traits
|
|
||||||
};
|
|
||||||
|
|
||||||
return cmd;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -557,33 +581,15 @@ TALER_TESTING_cmd_admin_add_incoming_with_instance
|
|||||||
{
|
{
|
||||||
struct AdminAddIncomingState *fts;
|
struct AdminAddIncomingState *fts;
|
||||||
|
|
||||||
fts = GNUNET_new (struct AdminAddIncomingState);
|
fts = make_fts (amount,
|
||||||
fts->exchange_credit_url = account_base_url;
|
account_base_url,
|
||||||
fts->payto_debit_account = payto_debit_account;
|
auth,
|
||||||
fts->auth = *auth;
|
payto_debit_account);
|
||||||
fts->instance = instance;
|
fts->instance = instance;
|
||||||
fts->config_filename = config_filename;
|
fts->config_filename = config_filename;
|
||||||
if (GNUNET_OK !=
|
|
||||||
TALER_string_to_amount (amount,
|
|
||||||
&fts->amount))
|
|
||||||
{
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"Failed to parse amount `%s' at %s\n",
|
|
||||||
amount,
|
|
||||||
label);
|
|
||||||
GNUNET_assert (0);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
struct TALER_TESTING_Command cmd = {
|
|
||||||
.cls = fts,
|
|
||||||
.label = label,
|
|
||||||
.run = &admin_add_incoming_run,
|
|
||||||
.cleanup = &admin_add_incoming_cleanup,
|
|
||||||
.traits = &admin_add_incoming_traits
|
|
||||||
};
|
|
||||||
|
|
||||||
return cmd;
|
return make_command (label,
|
||||||
}
|
fts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -607,4 +613,4 @@ TALER_TESTING_cmd_admin_add_incoming_retry (struct TALER_TESTING_Command cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* end of testing_api_cmd_admin_add_incoming.c */
|
/* end of testing_api_cmd_bank_admin_add_incoming.c */
|
||||||
|
@ -304,7 +304,6 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
|||||||
continue; /* skip until we find the marker */
|
continue; /* skip until we find the marker */
|
||||||
|
|
||||||
TALER_LOG_DEBUG ("Found first row\n");
|
TALER_LOG_DEBUG ("Found first row\n");
|
||||||
|
|
||||||
if (build_history_hit_limit (total,
|
if (build_history_hit_limit (total,
|
||||||
hs,
|
hs,
|
||||||
pos))
|
pos))
|
||||||
@ -312,16 +311,14 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
|||||||
TALER_LOG_DEBUG ("Hit history limit\n");
|
TALER_LOG_DEBUG ("Hit history limit\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
GNUNET_assert (GNUNET_OK ==
|
||||||
|
TALER_TESTING_get_trait_payto (pos,
|
||||||
GNUNET_assert
|
TALER_TESTING_PT_CREDIT,
|
||||||
(GNUNET_OK == TALER_TESTING_GET_TRAIT_CREDIT_ACCOUNT
|
&credit_account));
|
||||||
(pos, &credit_account));
|
GNUNET_assert (GNUNET_OK ==
|
||||||
|
TALER_TESTING_get_trait_payto (pos,
|
||||||
GNUNET_assert
|
TALER_TESTING_PT_DEBIT,
|
||||||
(GNUNET_OK == TALER_TESTING_GET_TRAIT_DEBIT_ACCOUNT
|
&debit_account));
|
||||||
(pos, &debit_account));
|
|
||||||
|
|
||||||
TALER_LOG_INFO ("Potential history element:"
|
TALER_LOG_INFO ("Potential history element:"
|
||||||
" %s->%s; my account: %s\n",
|
" %s->%s; my account: %s\n",
|
||||||
debit_account,
|
debit_account,
|
||||||
@ -365,8 +362,9 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
|||||||
const char *credit_account;
|
const char *credit_account;
|
||||||
const char *debit_account;
|
const char *debit_account;
|
||||||
|
|
||||||
if (GNUNET_OK != TALER_TESTING_GET_TRAIT_ROW_ID
|
if (GNUNET_OK !=
|
||||||
(pos, &row_id))
|
TALER_TESTING_GET_TRAIT_ROW_ID (pos,
|
||||||
|
&row_id))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (NULL != row_id_start)
|
if (NULL != row_id_start)
|
||||||
@ -401,14 +399,14 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
GNUNET_assert
|
GNUNET_assert (GNUNET_OK ==
|
||||||
(GNUNET_OK == TALER_TESTING_GET_TRAIT_CREDIT_ACCOUNT
|
TALER_TESTING_get_trait_payto (pos,
|
||||||
(pos, &credit_account));
|
TALER_TESTING_PT_CREDIT,
|
||||||
|
&credit_account));
|
||||||
GNUNET_assert
|
GNUNET_assert (GNUNET_OK ==
|
||||||
(GNUNET_OK == TALER_TESTING_GET_TRAIT_DEBIT_ACCOUNT
|
TALER_TESTING_get_trait_payto (pos,
|
||||||
(pos, &debit_account));
|
TALER_TESTING_PT_DEBIT,
|
||||||
|
&debit_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,
|
||||||
|
@ -48,6 +48,9 @@ main (int argc,
|
|||||||
r);
|
r);
|
||||||
r = TALER_payto_xtalerbank_make ("https://localhost",
|
r = TALER_payto_xtalerbank_make ("https://localhost",
|
||||||
"account");
|
"account");
|
||||||
|
CHECK ("payto://x-taler-bank/localhost/account",
|
||||||
|
r);
|
||||||
|
r = TALER_payto_xtalerbank_make2 ("https://localhost/account");
|
||||||
CHECK ("payto://x-taler-bank/localhost/account",
|
CHECK ("payto://x-taler-bank/localhost/account",
|
||||||
r);
|
r);
|
||||||
r = TALER_payto_xtalerbank_make ("http://localhost:80/",
|
r = TALER_payto_xtalerbank_make ("http://localhost:80/",
|
||||||
@ -60,6 +63,10 @@ main (int argc,
|
|||||||
r);
|
r);
|
||||||
r = TALER_payto_xtalerbank_make ("http://localhost/",
|
r = TALER_payto_xtalerbank_make ("http://localhost/",
|
||||||
"account");
|
"account");
|
||||||
|
r = TALER_payto_xtalerbank_make2 ("http://localhost:80/account");
|
||||||
|
CHECK ("payto://x-taler-bank/localhost:80/account",
|
||||||
|
r);
|
||||||
|
r = TALER_payto_xtalerbank_make2 ("http://localhost/account");
|
||||||
CHECK ("payto://x-taler-bank/localhost:80/account",
|
CHECK ("payto://x-taler-bank/localhost:80/account",
|
||||||
r);
|
r);
|
||||||
r = TALER_xtalerbank_base_url_from_payto (
|
r = TALER_xtalerbank_base_url_from_payto (
|
||||||
|
@ -623,6 +623,60 @@ TALER_payto_xtalerbank_make (const char *bank_url,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an x-taler-bank payto:// URL from an @a account_url.
|
||||||
|
*
|
||||||
|
* @param account_url the bank URL
|
||||||
|
* @param account_name the account name
|
||||||
|
* @return payto:// URL
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
TALER_payto_xtalerbank_make2 (const char *account_url)
|
||||||
|
{
|
||||||
|
char *payto;
|
||||||
|
int plaintext;
|
||||||
|
const char *port;
|
||||||
|
size_t slen;
|
||||||
|
const char *account;
|
||||||
|
|
||||||
|
if (0 == strncasecmp ("https://",
|
||||||
|
account_url,
|
||||||
|
strlen ("https://")))
|
||||||
|
{
|
||||||
|
account_url += strlen ("https://");
|
||||||
|
plaintext = GNUNET_NO;
|
||||||
|
}
|
||||||
|
else if (0 == strncasecmp ("http://",
|
||||||
|
account_url,
|
||||||
|
strlen ("http://")))
|
||||||
|
{
|
||||||
|
account_url += strlen ("http://");
|
||||||
|
plaintext = GNUNET_YES;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
account = strchr (account_url,
|
||||||
|
'/');
|
||||||
|
if (NULL == account)
|
||||||
|
return NULL;
|
||||||
|
slen = account - account_url;
|
||||||
|
port = memchr (account_url,
|
||||||
|
':',
|
||||||
|
slen);
|
||||||
|
if ( (0 < slen) &&
|
||||||
|
('/' == account_url[slen - 1]) )
|
||||||
|
slen--;
|
||||||
|
GNUNET_asprintf (&payto,
|
||||||
|
( (NULL == port) && (GNUNET_YES == plaintext) )
|
||||||
|
? "payto://x-taler-bank/%.*s:80/%s"
|
||||||
|
: "payto://x-taler-bank/%.*s/%s",
|
||||||
|
(int) slen,
|
||||||
|
account_url,
|
||||||
|
account + 1);
|
||||||
|
return payto;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given an x-taler-bank payto:// URL, compute
|
* Given an x-taler-bank payto:// URL, compute
|
||||||
* the HTTP(S) base URL of the account.
|
* the HTTP(S) base URL of the account.
|
||||||
|
Loading…
Reference in New Issue
Block a user