DCE: only keep x-taler-wire processing functions we actually use/need
This commit is contained in:
parent
c805e9cf20
commit
d2d7791c69
@ -245,41 +245,6 @@ 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);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @param payto the payto URL
|
|
||||||
* @return bank URL of the account, NULL if not x-taler-bak payto URL
|
|
||||||
*/
|
|
||||||
char *
|
|
||||||
TALER_xtalerbank_base_url_from_payto (const char *payto);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain the account name from a payto URL.
|
* Obtain the account name from a payto URL.
|
||||||
*
|
*
|
||||||
|
@ -58,11 +58,6 @@ struct AdminAddIncomingState
|
|||||||
*/
|
*/
|
||||||
const char *payto_debit_account;
|
const char *payto_debit_account;
|
||||||
|
|
||||||
/**
|
|
||||||
* Money receiver payto URL.
|
|
||||||
*/
|
|
||||||
char *payto_credit_account;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Username to use for authentication.
|
* Username to use for authentication.
|
||||||
*/
|
*/
|
||||||
@ -381,7 +376,6 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,8 +401,9 @@ admin_add_incoming_traits (void *cls,
|
|||||||
TALER_TESTING_make_trait_bank_row (&fts->serial_id),
|
TALER_TESTING_make_trait_bank_row (&fts->serial_id),
|
||||||
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),
|
||||||
|
/* Used as a marker, content does not matter */
|
||||||
TALER_TESTING_make_trait_payto (TALER_TESTING_PT_CREDIT,
|
TALER_TESTING_make_trait_payto (TALER_TESTING_PT_CREDIT,
|
||||||
fts->payto_credit_account),
|
"payto://void/the-exchange"),
|
||||||
TALER_TESTING_make_trait_url (TALER_TESTING_UT_EXCHANGE_BANK_ACCOUNT_URL,
|
TALER_TESTING_make_trait_url (TALER_TESTING_UT_EXCHANGE_BANK_ACCOUNT_URL,
|
||||||
fts->exchange_credit_url),
|
fts->exchange_credit_url),
|
||||||
TALER_TESTING_make_trait_amount_obj (0, &fts->amount),
|
TALER_TESTING_make_trait_amount_obj (0, &fts->amount),
|
||||||
@ -447,8 +442,6 @@ make_fts (const char *amount,
|
|||||||
fts = GNUNET_new (struct AdminAddIncomingState);
|
fts = GNUNET_new (struct AdminAddIncomingState);
|
||||||
fts->exchange_credit_url = exchange_base_url;
|
fts->exchange_credit_url = exchange_base_url;
|
||||||
fts->payto_debit_account = payto_debit_account;
|
fts->payto_debit_account = payto_debit_account;
|
||||||
fts->payto_credit_account
|
|
||||||
= TALER_payto_xtalerbank_make2 (exchange_base_url);
|
|
||||||
fts->auth = *auth;
|
fts->auth = *auth;
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_string_to_amount (amount,
|
TALER_string_to_amount (amount,
|
||||||
|
@ -42,41 +42,6 @@ main (int argc,
|
|||||||
GNUNET_log_setup ("test-payto",
|
GNUNET_log_setup ("test-payto",
|
||||||
"WARNING",
|
"WARNING",
|
||||||
NULL);
|
NULL);
|
||||||
r = TALER_payto_xtalerbank_make ("https://localhost/",
|
|
||||||
"account");
|
|
||||||
CHECK ("payto://x-taler-bank/localhost/account",
|
|
||||||
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/",
|
|
||||||
"account");
|
|
||||||
CHECK ("payto://x-taler-bank/localhost:80/account",
|
|
||||||
r);
|
|
||||||
r = TALER_payto_xtalerbank_make ("http://localhost:80",
|
|
||||||
"account");
|
|
||||||
CHECK ("payto://x-taler-bank/localhost:80/account",
|
|
||||||
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 (
|
|
||||||
"payto://x-taler-bank/localhost/bob");
|
|
||||||
CHECK ("https://localhost/",
|
|
||||||
r);
|
|
||||||
r = TALER_xtalerbank_base_url_from_payto (
|
|
||||||
"payto://x-taler-bank/localhost:1080/bob");
|
|
||||||
CHECK ("http://localhost:1080/",
|
|
||||||
r);
|
|
||||||
r = TALER_xtalerbank_account_from_payto (
|
r = TALER_xtalerbank_account_from_payto (
|
||||||
"payto://x-taler-bank/localhost:1080/alice");
|
"payto://x-taler-bank/localhost:1080/alice");
|
||||||
CHECK ("alice",
|
CHECK ("alice",
|
||||||
|
149
src/util/util.c
149
src/util/util.c
@ -570,155 +570,6 @@ 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 plaintext;
|
|
||||||
const char *port;
|
|
||||||
size_t slen;
|
|
||||||
|
|
||||||
if (0 == strncasecmp ("https://",
|
|
||||||
bank_url,
|
|
||||||
strlen ("https://")))
|
|
||||||
{
|
|
||||||
bank_url += strlen ("https://");
|
|
||||||
plaintext = GNUNET_NO;
|
|
||||||
}
|
|
||||||
else if (0 == strncasecmp ("http://",
|
|
||||||
bank_url,
|
|
||||||
strlen ("http://")))
|
|
||||||
{
|
|
||||||
bank_url += strlen ("http://");
|
|
||||||
plaintext = GNUNET_YES;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
slen = strlen (bank_url);
|
|
||||||
port = memchr (bank_url,
|
|
||||||
':',
|
|
||||||
slen);
|
|
||||||
if ( (0 < slen) &&
|
|
||||||
('/' == bank_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,
|
|
||||||
bank_url,
|
|
||||||
account_name);
|
|
||||||
return payto;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @param payto the payto URL
|
|
||||||
* @return bank URL of the account, NULL if not x-taler-bak payto URL
|
|
||||||
*/
|
|
||||||
char *
|
|
||||||
TALER_xtalerbank_base_url_from_payto (const char *payto)
|
|
||||||
{
|
|
||||||
const char *start;
|
|
||||||
const char *end;
|
|
||||||
char *ret;
|
|
||||||
int https;
|
|
||||||
const char *colon;
|
|
||||||
unsigned int port;
|
|
||||||
|
|
||||||
if (0 != strncasecmp (payto,
|
|
||||||
"payto://x-taler-bank/",
|
|
||||||
strlen ("payto://x-taler-bank/")))
|
|
||||||
return NULL;
|
|
||||||
start = &payto[strlen ("payto://x-taler-bank/")];
|
|
||||||
end = strchr (start,
|
|
||||||
'/');
|
|
||||||
if (NULL == end)
|
|
||||||
end = &start[strlen (start)];
|
|
||||||
colon = strrchr (start,
|
|
||||||
':');
|
|
||||||
https = GNUNET_YES;
|
|
||||||
if ( (NULL != colon) &&
|
|
||||||
(1 == sscanf (colon + 1,
|
|
||||||
"%u",
|
|
||||||
&port)) &&
|
|
||||||
(443 != port) )
|
|
||||||
https = GNUNET_NO;
|
|
||||||
GNUNET_asprintf (&ret,
|
|
||||||
"%s://%.*s/",
|
|
||||||
(https ? "https" : "http"),
|
|
||||||
(int) (end - start),
|
|
||||||
start);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain the account name from a payto URL.
|
* Obtain the account name from a payto URL.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user