payto fixes WIP
This commit is contained in:
parent
c677720e7b
commit
6faf6fc732
@ -1 +1 @@
|
||||
Subproject commit 934a6a18301e81c4fd1b3a8cda2dc13dca4741cc
|
||||
Subproject commit ca53235ccfa0458ebf11c204888ca370e20ec3f5
|
@ -1842,8 +1842,7 @@ process_credits (void *cls)
|
||||
"Starting bank CREDIT history of account `%s'\n",
|
||||
wa->section_name);
|
||||
wa->chh = TALER_BANK_credit_history (ctx,
|
||||
wa->account.details.x_taler_bank.
|
||||
account_base_url,
|
||||
wa->auth.wire_gateway_url,
|
||||
&wa->auth,
|
||||
wa->in_wire_off,
|
||||
INT64_MAX,
|
||||
|
@ -98,16 +98,50 @@ TALER_BANK_auth_parse_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
||||
{ NULL, TALER_BANK_AUTH_NONE }
|
||||
};
|
||||
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 !=
|
||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
||||
section,
|
||||
"TALER_BANK_AUTH_METHOD",
|
||||
"WIRE_GATEWAY_URL",
|
||||
&auth->wire_gateway_url))
|
||||
{
|
||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
||||
section,
|
||||
"WIRE_GATEWAY_URL");
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
|
||||
if (GNUNET_OK !=
|
||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
||||
section,
|
||||
"WIRE_GATEWAY_AUTH_METHOD",
|
||||
&method))
|
||||
{
|
||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
||||
section,
|
||||
"TALER_BANK_AUTH_METHOD");
|
||||
"WIRE_GATEWAY_AUTH_METHOD");
|
||||
GNUNET_free (auth->wire_gateway_url);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
for (unsigned int i = 0; NULL != methods[i].m; i++)
|
||||
@ -132,6 +166,7 @@ TALER_BANK_auth_parse_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
||||
section,
|
||||
"USERNAME");
|
||||
GNUNET_free (method);
|
||||
GNUNET_free (auth->wire_gateway_url);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
if (GNUNET_OK !=
|
||||
@ -146,11 +181,14 @@ TALER_BANK_auth_parse_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
||||
section,
|
||||
"PASSWORD");
|
||||
GNUNET_free (method);
|
||||
GNUNET_free (auth->wire_gateway_url);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
auth->method = TALER_BANK_AUTH_BASIC;
|
||||
GNUNET_free (method);
|
||||
return GNUNET_OK;
|
||||
case TALER_BANK_AUTH_FAKEBANK:
|
||||
GNUNET_assert (0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -184,7 +222,10 @@ TALER_BANK_auth_free (struct TALER_BANK_AuthenticationData *auth)
|
||||
auth->details.basic.password = NULL;
|
||||
}
|
||||
break;
|
||||
case TALER_BANK_AUTH_FAKEBANK:
|
||||
break;
|
||||
}
|
||||
GNUNET_free (auth->wire_gateway_url);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1783,8 +1783,7 @@ wire_prepare_cb (void *cls,
|
||||
}
|
||||
wa = wpd->wa;
|
||||
wpd->eh = TALER_BANK_execute_wire_transfer (ctx,
|
||||
wa->account.details.x_taler_bank.
|
||||
account_base_url,
|
||||
wa->auth.wire_gateway_url,
|
||||
&wa->auth,
|
||||
buf,
|
||||
buf_size,
|
||||
|
@ -537,8 +537,7 @@ find_transfers (void *cls)
|
||||
current_batch_size = 0;
|
||||
|
||||
hh = TALER_BANK_credit_history (ctx,
|
||||
wa_pos->account.details.x_taler_bank.
|
||||
account_base_url,
|
||||
wa_pos->auth.wire_gateway_url,
|
||||
&wa_pos->auth,
|
||||
last_row_off,
|
||||
batch_size,
|
||||
|
@ -42,7 +42,12 @@ enum TALER_BANK_AuthenticationMethod
|
||||
/**
|
||||
* 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,
|
||||
};
|
||||
|
||||
|
||||
@ -52,6 +57,12 @@ enum TALER_BANK_AuthenticationMethod
|
||||
struct TALER_BANK_AuthenticationData
|
||||
{
|
||||
|
||||
/**
|
||||
* Base URL we use to talk to the wire gateway,
|
||||
* which talks to the bank for us.
|
||||
*/
|
||||
char *wire_gateway_url;
|
||||
|
||||
/**
|
||||
* Which authentication method should we use?
|
||||
*/
|
||||
@ -79,6 +90,14 @@ struct TALER_BANK_AuthenticationData
|
||||
char *password;
|
||||
} basic;
|
||||
|
||||
struct
|
||||
{
|
||||
/**
|
||||
* Port that the fakebank runs on.
|
||||
*/
|
||||
uint16_t fb_port;
|
||||
} fakebank;
|
||||
|
||||
} details;
|
||||
|
||||
};
|
||||
|
@ -71,6 +71,7 @@ METHOD = x-taler-bank
|
||||
[account-2]
|
||||
# What is the bank account (with the "Taler Bank" demo system)?
|
||||
URL = "payto://x-taler-bank/localhost:8082/2"
|
||||
FAKEBANK_PORT = 8082
|
||||
|
||||
# This is the response we give out for the /wire request. It provides
|
||||
# wallets with the bank information for transfers to the exchange.
|
||||
|
@ -140,7 +140,7 @@ main (int argc,
|
||||
TALER_LOG_DEBUG ("Running against the Fakebank.\n");
|
||||
if (GNUNET_OK !=
|
||||
TALER_TESTING_prepare_fakebank (CONFIG_FILE,
|
||||
"account-1",
|
||||
"account-2",
|
||||
&bc))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
|
@ -1,8 +1,9 @@
|
||||
[taler]
|
||||
currency = KUDOS
|
||||
|
||||
[account-1]
|
||||
URL = payto://x-taler-bank/localhost:8081/1
|
||||
[account-2]
|
||||
URL = payto://x-taler-bank/localhost:8081/2
|
||||
FAKEBANK_PORT = 8081
|
||||
|
||||
[bank]
|
||||
SERVE = http
|
||||
|
@ -380,11 +380,30 @@ TALER_TESTING_prepare_fakebank (const char *config_filename,
|
||||
{
|
||||
struct GNUNET_CONFIGURATION_Handle *cfg;
|
||||
char *payto_url;
|
||||
uint16_t fakebank_port;
|
||||
|
||||
cfg = GNUNET_CONFIGURATION_create ();
|
||||
if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg,
|
||||
config_filename))
|
||||
return GNUNET_SYSERR;
|
||||
|
||||
if (GNUNET_OK !=
|
||||
TALER_BANK_auth_parse_cfg (cfg,
|
||||
"account-" EXCHANGE_ACCOUNT_NAME,
|
||||
&bc->exchange_auth))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
GNUNET_CONFIGURATION_destroy (cfg);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
|
||||
GNUNET_assert (TALER_BANK_AUTH_FAKEBANK == bc->exchange_auth.method);
|
||||
|
||||
fakebank_port = bc->exchange_auth.details.fakebank.fb_port;
|
||||
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Fakebank port from config: %u\n",
|
||||
(unsigned int) fakebank_port);
|
||||
|
||||
if (GNUNET_OK !=
|
||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
||||
config_section,
|
||||
@ -418,10 +437,16 @@ TALER_TESTING_prepare_fakebank (const char *config_filename,
|
||||
GNUNET_free (payto_url);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
bc->exchange_account_url
|
||||
= TALER_xtalerbank_account_url_from_payto (payto_url);
|
||||
GNUNET_asprintf (&bc->exchange_account_url,
|
||||
"http://localhost:%u/%s/",
|
||||
fakebank_port,
|
||||
EXCHANGE_ACCOUNT_NAME);
|
||||
GNUNET_assert (NULL != bc->exchange_account_url);
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "fakebank account URL: %s\n",
|
||||
bc->exchange_account_url);
|
||||
GNUNET_free (payto_url);
|
||||
/* Now we know it's the fake bank, for purpose of authentication, we
|
||||
* don't have any auth. */
|
||||
bc->exchange_auth.method = TALER_BANK_AUTH_NONE;
|
||||
bc->exchange_payto = TALER_payto_xtalerbank_make (bc->bank_url, "2");
|
||||
bc->user42_payto = TALER_payto_xtalerbank_make (bc->bank_url, "42");
|
||||
|
Loading…
Reference in New Issue
Block a user