From 6f579eb833be396b56903ff7252c3023ef46a92d Mon Sep 17 00:00:00 2001 From: Marcello Stanisci Date: Tue, 12 Jun 2018 19:16:43 +0200 Subject: From payto:// to base url. The conversion prepends http// or https:// depending on the port given beside the hostname. If port is 433, then prepends https://, otherwise prepends http://. For now, the conversion was only necessary at the /history bank lib. --- src/wire-plugins/plugin_wire_taler-bank.c | 37 ++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'src/wire-plugins') diff --git a/src/wire-plugins/plugin_wire_taler-bank.c b/src/wire-plugins/plugin_wire_taler-bank.c index 4d2d9be0f..0954fd882 100644 --- a/src/wire-plugins/plugin_wire_taler-bank.c +++ b/src/wire-plugins/plugin_wire_taler-bank.c @@ -978,6 +978,9 @@ taler_bank_get_history (void *cls, const uint64_t *start_off_b64; uint64_t start_row; struct Account account; + char *bank_base_url; + char *p; + long long unsigned port; if (0 == num_results) { @@ -1029,8 +1032,40 @@ taler_bank_get_history (void *cls, whh->hres_cb = hres_cb; whh->hres_cb_cls = hres_cb_cls; + + if (NULL != (p = strchr (account.hostname, + (unsigned char) ':'))) + { + p++; + if (1 != sscanf (p, + "%llu", + &port)) + { + GNUNET_break (0); + TALER_LOG_ERROR ("Malformed host from payto:// URI\n"); + return NULL; + } + } + + if (443 != port) + { + GNUNET_assert + (GNUNET_SYSERR != GNUNET_asprintf + (&bank_base_url, + "http://%s", + account.hostname)); + } + else + { + GNUNET_assert + (GNUNET_SYSERR != GNUNET_asprintf + (&bank_base_url, + "https://%s", + account.hostname)); + } + whh->hh = TALER_BANK_history (tc->ctx, - account.hostname, + bank_base_url, &whh->auth, (uint64_t) account.no, direction, -- cgit v1.2.3