payto fixes WIP

This commit is contained in:
Florian Dold 2020-01-17 02:23:38 +01:00
parent 8ea2af444f
commit cc862fb279
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
10 changed files with 57 additions and 82 deletions

View File

@ -1438,8 +1438,7 @@ process_debits (void *cls)
wa->section_name); wa->section_name);
GNUNET_assert (NULL == wa->dhh); GNUNET_assert (NULL == wa->dhh);
wa->dhh = TALER_BANK_debit_history (ctx, wa->dhh = TALER_BANK_debit_history (ctx,
wa->account.details.x_taler_bank. wa->auth.wire_gateway_url,
account_base_url,
&wa->auth, &wa->auth,
wa->out_wire_off, wa->out_wire_off,
INT64_MAX, INT64_MAX,

View File

@ -98,27 +98,6 @@ TALER_BANK_auth_parse_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg,
{ NULL, TALER_BANK_AUTH_NONE } { NULL, TALER_BANK_AUTH_NONE }
}; };
char *method; char *method;
unsigned long long fakebank_port;
if (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_number (cfg,
section,
"FAKEBANK_PORT",
&fakebank_port))
{
auth->method = TALER_BANK_AUTH_FAKEBANK;
auth->details.fakebank.fb_port = (uint16_t) fakebank_port;
// FIXME: we should not hardcode exchange account number "2"
GNUNET_asprintf (&auth->wire_gateway_url,
"http://localhost:%u/2/",
(unsigned int) fakebank_port);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Using fakebank %s on port %u\n",
auth->wire_gateway_url,
(unsigned int) fakebank_port);
return GNUNET_OK;
}
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg, GNUNET_CONFIGURATION_get_value_string (cfg,
@ -187,8 +166,6 @@ TALER_BANK_auth_parse_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg,
auth->method = TALER_BANK_AUTH_BASIC; auth->method = TALER_BANK_AUTH_BASIC;
GNUNET_free (method); GNUNET_free (method);
return GNUNET_OK; return GNUNET_OK;
case TALER_BANK_AUTH_FAKEBANK:
GNUNET_assert (0);
} }
} }
} }
@ -222,8 +199,6 @@ TALER_BANK_auth_free (struct TALER_BANK_AuthenticationData *auth)
auth->details.basic.password = NULL; auth->details.basic.password = NULL;
} }
break; break;
case TALER_BANK_AUTH_FAKEBANK:
break;
} }
GNUNET_free (auth->wire_gateway_url); GNUNET_free (auth->wire_gateway_url);
} }

View File

@ -315,9 +315,9 @@ TALER_FAKEBANK_check_credit (struct TALER_FAKEBANK_Handle *h,
"Did not find matching transaction!\nI have:\n"); "Did not find matching transaction!\nI have:\n");
check_log (h); check_log (h);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"I wanted:\n%llu -> %llu (%s) with subject %s (CREDIT)\n", "I wanted:\n%s -> %s (%s) with subject %s (CREDIT)\n",
(unsigned long long) want_debit, want_debit,
(unsigned long long) want_credit, want_credit,
TALER_amount2s (want_amount), TALER_amount2s (want_amount),
TALER_B2S (reserve_pub)); TALER_B2S (reserve_pub));
return GNUNET_SYSERR; return GNUNET_SYSERR;

View File

@ -114,8 +114,10 @@ load_account (void *cls,
ai->payto_url)) ai->payto_url))
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"URL in Wire response file `%s' does not match URL in configuration!\n", "URL in Wire response file `%s' does not match URL in configuration (%s vs %s)!\n",
ai->wire_response_filename); ai->wire_response_filename,
url,
ai->payto_url);
json_decref (wire_s); json_decref (wire_s);
GNUNET_free (url); GNUNET_free (url);
*ret = GNUNET_SYSERR; *ret = GNUNET_SYSERR;

View File

@ -43,11 +43,6 @@ enum TALER_BANK_AuthenticationMethod
* Basic authentication with cleartext username and password. * Basic authentication with cleartext username and password.
*/ */
TALER_BANK_AUTH_BASIC, TALER_BANK_AUTH_BASIC,
/**
* The authentication data refers to a fakebank.
*/
TALER_BANK_AUTH_FAKEBANK,
}; };

View File

@ -59,19 +59,24 @@ CONFIG = "postgres:///talercheck"
# advertised in /wire. # advertised in /wire.
[account-1] [account-1]
# What is the URL of our account? # What is the URL of our account?
URL = "payto://x-taler-bank/localhost:8082/42" URL = "payto://x-taler-bank/localhost/42"
WIRE_GATEWAY_URL = "http://localhost:8082/42/"
# This is the response we give out for the /wire request. It provides # This is the response we give out for the /wire request. It provides
# wallets with the bank information for transfers to the exchange. # wallets with the bank information for transfers to the exchange.
WIRE_RESPONSE = ${TALER_CONFIG_HOME}/account-1.json WIRE_RESPONSE = ${TALER_CONFIG_HOME}/account-1.json
# Which wire plugin should we used to access the account? # Which wire plugin should we used to access the account?
METHOD = x-taler-bank METHOD = x-taler-bank
[bank]
HTTP_PORT = 8082
# ENABLE_CREDIT = YES # ENABLE_CREDIT = YES
[account-2] [account-2]
# What is the bank account (with the "Taler Bank" demo system)? # What is the bank account (with the "Taler Bank" demo system)?
URL = "payto://x-taler-bank/localhost:8082/2" WIRE_GATEWAY_URL = "http://localhost:8082/2/"
FAKEBANK_PORT = 8082 URL = "payto://x-taler-bank/localhost/2"
# This is the response we give out for the /wire request. It provides # This is the response we give out for the /wire request. It provides
# wallets with the bank information for transfers to the exchange. # wallets with the bank information for transfers to the exchange.
@ -81,7 +86,7 @@ WIRE_RESPONSE = ${TALER_CONFIG_HOME}/account-2.json
METHOD = x-taler-bank METHOD = x-taler-bank
# Authentication information for basic authentication # Authentication information for basic authentication
TALER_BANK_AUTH_METHOD = "basic" WIRE_GATEWAY_AUTH_METHOD = "basic"
USERNAME = user USERNAME = user
PASSWORD = pass PASSWORD = pass

View File

@ -1,5 +1,4 @@
{ {
"url": "payto://x-taler-bank/localhost:8082/2", "url": "payto://x-taler-bank/localhost/2",
"master_sig": "2MNAYBN0Q5VEJKFBGH2SRJQSV3QXA81FPXMFF5Y5YQQW1MRTDGJTZX35XHMCZFZ9SN9Q4TQ6MNM8EX7GPPD2MP8Q528A1D8RK7N9J38", "master_sig": "HEWC1XDS0QZ53YQR451VRKD4N968NXWGZXS30HJ59MJ0PESACK1ZYPYCAT15P08WD58C7D7F6EVN26D59JKA75XEBDQCM8VYFETK82R"
"master_pub": "98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG"
} }

View File

@ -119,6 +119,10 @@ check_bank_admin_transfer_run (void *cls,
} }
debit_account = TALER_xtalerbank_account_from_payto (debit_payto); debit_account = TALER_xtalerbank_account_from_payto (debit_payto);
credit_account = TALER_xtalerbank_account_from_payto (credit_payto); credit_account = TALER_xtalerbank_account_from_payto (credit_payto);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"converted debit_payto (%s) to debit_account (%s)\n",
debit_payto,
debit_account);
if (GNUNET_OK != if (GNUNET_OK !=
TALER_FAKEBANK_check_credit (is->fakebank, TALER_FAKEBANK_check_credit (is->fakebank,
&amount, &amount,

View File

@ -149,8 +149,15 @@ check_bank_transfer_run (void *cls,
&exchange_base_url)); &exchange_base_url));
} }
debit_account = TALER_xtalerbank_account_from_payto (debit_payto); debit_account = TALER_xtalerbank_account_from_payto (debit_payto);
credit_account = TALER_xtalerbank_account_from_payto (credit_payto); credit_account = TALER_xtalerbank_account_from_payto (credit_payto);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"converted debit_payto (%s) to debit_account (%s)\n",
debit_payto,
debit_account);
if (GNUNET_OK != if (GNUNET_OK !=
TALER_FAKEBANK_check_debit (is->fakebank, TALER_FAKEBANK_check_debit (is->fakebank,
&amount, &amount,

View File

@ -379,8 +379,7 @@ TALER_TESTING_prepare_fakebank (const char *config_filename,
struct TALER_TESTING_BankConfiguration *bc) struct TALER_TESTING_BankConfiguration *bc)
{ {
struct GNUNET_CONFIGURATION_Handle *cfg; struct GNUNET_CONFIGURATION_Handle *cfg;
char *payto_url; unsigned long long fakebank_port;
uint16_t fakebank_port;
cfg = GNUNET_CONFIGURATION_create (); cfg = GNUNET_CONFIGURATION_create ();
if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg,
@ -388,53 +387,38 @@ TALER_TESTING_prepare_fakebank (const char *config_filename,
return GNUNET_SYSERR; return GNUNET_SYSERR;
if (GNUNET_OK != if (GNUNET_OK !=
TALER_BANK_auth_parse_cfg (cfg, GNUNET_CONFIGURATION_get_value_number (cfg,
"account-" EXCHANGE_ACCOUNT_NAME, "BANK",
&bc->exchange_auth)) "HTTP_PORT",
&fakebank_port))
{ {
GNUNET_break (0); GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
"BANK",
"HTTP_PORT");
GNUNET_CONFIGURATION_destroy (cfg); GNUNET_CONFIGURATION_destroy (cfg);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
bc->exchange_auth.method = TALER_BANK_AUTH_NONE;
// FIXME: we should not hardcode exchange account number "2"
GNUNET_asprintf (&bc->exchange_auth.wire_gateway_url,
"http://localhost:%u/2/",
(unsigned int) fakebank_port);
GNUNET_assert (TALER_BANK_AUTH_FAKEBANK == bc->exchange_auth.method); GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Using fakebank %s on port %u\n",
fakebank_port = bc->exchange_auth.details.fakebank.fb_port; bc->exchange_auth.wire_gateway_url,
(unsigned int) fakebank_port);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Fakebank port from config: %u\n", GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Fakebank port from config: %u\n",
(unsigned int) fakebank_port); (unsigned int) fakebank_port);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
config_section,
"URL",
&payto_url))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
config_section,
"URL");
GNUNET_CONFIGURATION_destroy (cfg);
return GNUNET_SYSERR;
}
GNUNET_CONFIGURATION_destroy (cfg); GNUNET_CONFIGURATION_destroy (cfg);
bc->bank_url bc->bank_url = bc->exchange_auth.wire_gateway_url;
= TALER_xtalerbank_base_url_from_payto (payto_url);
if (NULL == bc->bank_url)
{
GNUNET_log_config_invalid
(GNUNET_ERROR_TYPE_WARNING,
config_section,
"URL",
"expected `x-taler-bank' payto://-URL");
GNUNET_free (payto_url);
return GNUNET_SYSERR;
}
if (GNUNET_OK != if (GNUNET_OK !=
TALER_TESTING_url_port_free (bc->bank_url)) TALER_TESTING_url_port_free (bc->bank_url))
{ {
GNUNET_free (bc->bank_url); GNUNET_free (bc->bank_url);
bc->bank_url = NULL; bc->bank_url = NULL;
GNUNET_free (payto_url);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
GNUNET_asprintf (&bc->exchange_account_url, GNUNET_asprintf (&bc->exchange_account_url,
@ -444,13 +428,18 @@ TALER_TESTING_prepare_fakebank (const char *config_filename,
GNUNET_assert (NULL != bc->exchange_account_url); GNUNET_assert (NULL != bc->exchange_account_url);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "fakebank account URL: %s\n", GNUNET_log (GNUNET_ERROR_TYPE_INFO, "fakebank account URL: %s\n",
bc->exchange_account_url); bc->exchange_account_url);
GNUNET_free (payto_url);
/* Now we know it's the fake bank, for purpose of authentication, we /* Now we know it's the fake bank, for purpose of authentication, we
* don't have any auth. */ * don't have any auth. */
bc->exchange_auth.method = TALER_BANK_AUTH_NONE; bc->exchange_auth.method = TALER_BANK_AUTH_NONE;
bc->exchange_payto = TALER_payto_xtalerbank_make (bc->bank_url, "2"); bc->exchange_payto = "payto://x-taler-bank/localhost/2";
bc->user42_payto = TALER_payto_xtalerbank_make (bc->bank_url, "42"); bc->user42_payto = "payto://x-taler-bank/localhost/42";
bc->user43_payto = TALER_payto_xtalerbank_make (bc->bank_url, "43"); bc->user43_payto = "payto://x-taler-bank/localhost/43";
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "exchange payto: %s\n",
bc->exchange_payto);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "user42_payto: %s\n",
bc->user42_payto);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "user42_payto: %s\n",
bc->user43_payto);
return GNUNET_OK; return GNUNET_OK;
} }