aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-util/src/payto.ts
diff options
context:
space:
mode:
authorÖzgür Kesim <oec-taler@kesim.org>2023-08-29 19:39:09 +0200
committerÖzgür Kesim <oec-taler@kesim.org>2023-08-29 19:39:09 +0200
commitd42a06607b90c540fa3eb87daa3b4aacbfdd19a7 (patch)
treeccc225e39f420a6bacbd82500f039fd4f5d74ad3 /packages/taler-util/src/payto.ts
parentdd4b96e1e62f20c9881d532e40531df8c932a379 (diff)
parenta386de8a9c1aa3fff76b4cb37fb3287213981387 (diff)
Merge branch 'master' into age-withdraw
Diffstat (limited to 'packages/taler-util/src/payto.ts')
-rw-r--r--packages/taler-util/src/payto.ts22
1 files changed, 22 insertions, 0 deletions
diff --git a/packages/taler-util/src/payto.ts b/packages/taler-util/src/payto.ts
index dd35b44be..2b0af4cc2 100644
--- a/packages/taler-util/src/payto.ts
+++ b/packages/taler-util/src/payto.ts
@@ -239,3 +239,25 @@ export function parsePaytoUri(s: string): PaytoUri | undefined {
isKnown: false,
};
}
+
+export function talerPaytoFromExchangeReserve(
+ exchangeBaseUrl: string,
+ reservePub: string,
+): string {
+ const url = new URL(exchangeBaseUrl);
+ let proto: string;
+ if (url.protocol === "http:") {
+ proto = "taler-reserve-http";
+ } else if (url.protocol === "https:") {
+ proto = "taler-reserve";
+ } else {
+ throw Error(`unsupported exchange base URL protocol (${url.protocol})`);
+ }
+
+ let path = url.pathname;
+ if (!path.endsWith("/")) {
+ path = path + "/";
+ }
+
+ return `payto://${proto}/${url.host}${url.pathname}${reservePub}`;
+}