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);
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
* the HTTP(S) base URL of the account.
|
||||
|
@ -17,7 +17,7 @@
|
||||
<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
|
||||
* @author Christian Grothoff
|
||||
* @author Marcello Stanisci
|
||||
@ -58,6 +58,11 @@ struct AdminAddIncomingState
|
||||
*/
|
||||
const char *payto_debit_account;
|
||||
|
||||
/**
|
||||
* Money sender account URL.
|
||||
*/
|
||||
char *payto_credit_account;
|
||||
|
||||
/**
|
||||
* Username to use for authentication.
|
||||
*/
|
||||
@ -376,6 +381,7 @@ admin_add_incoming_cleanup (void *cls,
|
||||
GNUNET_SCHEDULER_cancel (fts->retry_task);
|
||||
fts->retry_task = NULL;
|
||||
}
|
||||
GNUNET_free (fts->payto_credit_account);
|
||||
GNUNET_free (fts);
|
||||
}
|
||||
|
||||
@ -402,7 +408,8 @@ admin_add_incoming_traits (void *cls,
|
||||
TALER_TESTING_make_trait_payto (TALER_TESTING_PT_DEBIT,
|
||||
fts->payto_debit_account),
|
||||
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_absolute_time (0, &fts->timestamp),
|
||||
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.
|
||||
*
|
||||
@ -438,34 +504,11 @@ TALER_TESTING_cmd_admin_add_incoming
|
||||
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->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;
|
||||
}
|
||||
return make_command (label,
|
||||
make_fts (amount,
|
||||
exchange_base_url,
|
||||
auth,
|
||||
payto_debit_account));
|
||||
}
|
||||
|
||||
|
||||
@ -495,32 +538,13 @@ TALER_TESTING_cmd_admin_add_incoming_with_ref
|
||||
{
|
||||
struct AdminAddIncomingState *fts;
|
||||
|
||||
fts = GNUNET_new (struct AdminAddIncomingState);
|
||||
fts->exchange_credit_url = account_base_url;
|
||||
fts->payto_debit_account = payto_debit_account;
|
||||
fts->auth = *auth;
|
||||
fts = make_fts (amount,
|
||||
account_base_url,
|
||||
auth,
|
||||
payto_debit_account);
|
||||
fts->reserve_reference = ref;
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@ -557,33 +581,15 @@ TALER_TESTING_cmd_admin_add_incoming_with_instance
|
||||
{
|
||||
struct AdminAddIncomingState *fts;
|
||||
|
||||
fts = GNUNET_new (struct AdminAddIncomingState);
|
||||
fts->exchange_credit_url = account_base_url;
|
||||
fts->payto_debit_account = payto_debit_account;
|
||||
fts->auth = *auth;
|
||||
fts = make_fts (amount,
|
||||
account_base_url,
|
||||
auth,
|
||||
payto_debit_account);
|
||||
fts->instance = instance;
|
||||
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 */
|
||||
|
||||
TALER_LOG_DEBUG ("Found first row\n");
|
||||
|
||||
if (build_history_hit_limit (total,
|
||||
hs,
|
||||
pos))
|
||||
@ -312,16 +311,14 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
||||
TALER_LOG_DEBUG ("Hit history limit\n");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
GNUNET_assert
|
||||
(GNUNET_OK == TALER_TESTING_GET_TRAIT_CREDIT_ACCOUNT
|
||||
(pos, &credit_account));
|
||||
|
||||
GNUNET_assert
|
||||
(GNUNET_OK == TALER_TESTING_GET_TRAIT_DEBIT_ACCOUNT
|
||||
(pos, &debit_account));
|
||||
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_payto (pos,
|
||||
TALER_TESTING_PT_CREDIT,
|
||||
&credit_account));
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_payto (pos,
|
||||
TALER_TESTING_PT_DEBIT,
|
||||
&debit_account));
|
||||
TALER_LOG_INFO ("Potential history element:"
|
||||
" %s->%s; my account: %s\n",
|
||||
debit_account,
|
||||
@ -365,8 +362,9 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
||||
const char *credit_account;
|
||||
const char *debit_account;
|
||||
|
||||
if (GNUNET_OK != TALER_TESTING_GET_TRAIT_ROW_ID
|
||||
(pos, &row_id))
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_GET_TRAIT_ROW_ID (pos,
|
||||
&row_id))
|
||||
continue;
|
||||
|
||||
if (NULL != row_id_start)
|
||||
@ -401,14 +399,14 @@ build_history (struct TALER_TESTING_Interpreter *is,
|
||||
break;
|
||||
}
|
||||
|
||||
GNUNET_assert
|
||||
(GNUNET_OK == TALER_TESTING_GET_TRAIT_CREDIT_ACCOUNT
|
||||
(pos, &credit_account));
|
||||
|
||||
GNUNET_assert
|
||||
(GNUNET_OK == TALER_TESTING_GET_TRAIT_DEBIT_ACCOUNT
|
||||
(pos, &debit_account));
|
||||
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_payto (pos,
|
||||
TALER_TESTING_PT_CREDIT,
|
||||
&credit_account));
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_TESTING_get_trait_payto (pos,
|
||||
TALER_TESTING_PT_DEBIT,
|
||||
&debit_account));
|
||||
TALER_LOG_INFO ("Potential history bit:"
|
||||
" %s->%s; my account: %s\n",
|
||||
debit_account,
|
||||
|
@ -48,6 +48,9 @@ main (int argc,
|
||||
r);
|
||||
r = TALER_payto_xtalerbank_make ("https://localhost",
|
||||
"account");
|
||||
CHECK ("payto://x-taler-bank/localhost/account",
|
||||
r);
|
||||
r = TALER_payto_xtalerbank_make2 ("https://localhost/account");
|
||||
CHECK ("payto://x-taler-bank/localhost/account",
|
||||
r);
|
||||
r = TALER_payto_xtalerbank_make ("http://localhost:80/",
|
||||
@ -60,6 +63,10 @@ main (int argc,
|
||||
r);
|
||||
r = TALER_payto_xtalerbank_make ("http://localhost/",
|
||||
"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",
|
||||
r);
|
||||
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
|
||||
* the HTTP(S) base URL of the account.
|
||||
|
Loading…
Reference in New Issue
Block a user