From f45ef767016a425d04cce7755b27aceff292603c Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Thu, 24 Mar 2022 16:02:38 -0300
Subject: esbuild configuration

---
 .../src/wallet/ManualWithdrawPage.tsx                      | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

(limited to 'packages/taler-wallet-webextension/src/wallet/ManualWithdrawPage.tsx')

diff --git a/packages/taler-wallet-webextension/src/wallet/ManualWithdrawPage.tsx b/packages/taler-wallet-webextension/src/wallet/ManualWithdrawPage.tsx
index 05c518508..bea8f0029 100644
--- a/packages/taler-wallet-webextension/src/wallet/ManualWithdrawPage.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/ManualWithdrawPage.tsx
@@ -19,6 +19,8 @@ import {
   AmountJson,
   Amounts,
   NotificationType,
+  parsePaytoUri,
+  PaytoUri,
 } from "@gnu-taler/taler-util";
 import { h, VNode } from "preact";
 import { useState } from "preact/hooks";
@@ -41,6 +43,8 @@ export function ManualWithdrawPage({ currency, onCancel }: Props): VNode {
         response: AcceptManualWithdrawalResult;
         exchangeBaseUrl: string;
         amount: AmountJson;
+        paytoURI: PaytoUri | undefined;
+        payto: string;
       }
     | undefined
   >(undefined);
@@ -60,7 +64,12 @@ export function ManualWithdrawPage({ currency, onCancel }: Props): VNode {
         exchangeBaseUrl,
         Amounts.stringify(amount),
       );
-      setSuccess({ exchangeBaseUrl, response, amount });
+      const payto = response.exchangePaytoUris[0];
+      const paytoURI = parsePaytoUri(payto);
+      if (paytoURI && paytoURI.isKnown && paytoURI.targetType === "bitcoin") {
+        paytoURI.generateSegwitAddress(response.reservePub);
+      }
+      setSuccess({ exchangeBaseUrl, response, amount, paytoURI, payto });
     } catch (e) {
       if (e instanceof Error) {
         setError(e.message);
@@ -75,7 +84,8 @@ export function ManualWithdrawPage({ currency, onCancel }: Props): VNode {
     return (
       <ReserveCreated
         reservePub={success.response.reservePub}
-        payto={success.response.exchangePaytoUris[0]}
+        paytoURI={success.paytoURI}
+        payto={success.payto}
         exchangeBaseUrl={success.exchangeBaseUrl}
         amount={success.amount}
         onCancel={onCancel}
-- 
cgit v1.2.3

