aboutsummaryrefslogtreecommitdiff
path: root/src/util/payto.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/payto.c')
-rw-r--r--src/util/payto.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/util/payto.c b/src/util/payto.c
index d0f3a994b..83a1a7e1d 100644
--- a/src/util/payto.c
+++ b/src/util/payto.c
@@ -312,4 +312,48 @@ TALER_payto_from_reserve (const char *exchange_base_url,
}
+char *
+TALER_reserve_make_payto (const char *exchange_url,
+ const struct TALER_ReservePublicKeyP *reserve_pub)
+{
+ char pub_str[sizeof (*reserve_pub) * 2];
+ char *end;
+ bool is_http;
+ char *reserve_url;
+
+ end = GNUNET_STRINGS_data_to_string (
+ reserve_pub,
+ sizeof (*reserve_pub),
+ pub_str,
+ sizeof (pub_str));
+ *end = '\0';
+ if (0 == strncmp (exchange_url,
+ "http://",
+ strlen ("http://")))
+ {
+ is_http = true;
+ exchange_url = &exchange_url[strlen ("http://")];
+ }
+ else if (0 == strncmp (exchange_url,
+ "https://",
+ strlen ("https://")))
+ {
+ is_http = false;
+ exchange_url = &exchange_url[strlen ("https://")];
+ }
+ else
+ {
+ GNUNET_break (0);
+ return NULL;
+ }
+ /* exchange_url includes trailing '/' */
+ GNUNET_asprintf (&reserve_url,
+ "payto://%s/%s%s",
+ is_http ? "taler+http" : "taler",
+ exchange_url,
+ pub_str);
+ return reserve_url;
+}
+
+
/* end of payto.c */