aboutsummaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-06-21 18:42:59 +0200
committerFlorian Dold <florian@dold.me>2024-06-21 18:42:59 +0200
commitfab9a1176a1f5f42c9b9385c09f0d1571ad7e3e3 (patch)
tree870c94aaac7732b725c85c2437f7fb85caa23712 /packages
parent043b7aefa91234f73209e810c85cf0d1ee7ca8d0 (diff)
downloadwallet-core-fab9a1176a1f5f42c9b9385c09f0d1571ad7e3e3.tar.xz
wallet-core: use correct wallet-selected amount in withdrawal
Diffstat (limited to 'packages')
-rw-r--r--packages/taler-wallet-cli/src/index.ts17
-rw-r--r--packages/taler-wallet-core/src/withdraw.ts16
2 files changed, 26 insertions, 7 deletions
diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts
index 252390733..d4c742008 100644
--- a/packages/taler-wallet-cli/src/index.ts
+++ b/packages/taler-wallet-cli/src/index.ts
@@ -21,6 +21,7 @@ import {
AbsoluteTime,
addPaytoQueryParams,
AgeRestriction,
+ Amounts,
AmountString,
codecForList,
codecForString,
@@ -75,7 +76,7 @@ import * as fs from "node:fs";
// thread worker, and thus must expose these two handlers.
export {
handleWorkerError,
- handleWorkerMessage,
+ handleWorkerMessage
} from "@gnu-taler/taler-wallet-core";
const logger = new Logger("taler-wallet-cli.ts");
@@ -722,6 +723,16 @@ walletCli
},
);
console.log("withdrawInfo", withdrawInfo);
+ let amount: AmountString | undefined = undefined;
+ if (withdrawInfo.editableAmount) {
+ if (withdrawInfo.amount) {
+ console.log(`Default amount: ${withdrawInfo.amount}`);
+ }
+ const res = await readlinePrompt(
+ `Amount (in ${withdrawInfo.currency}): `,
+ );
+ amount = Amounts.stringify(Amounts.parseOrThrow(res));
+ }
const selectedExchange =
args.handleUri.withdrawalExchange ??
withdrawInfo.defaultExchangeBaseUrl;
@@ -732,6 +743,10 @@ walletCli
processExit(1);
return;
}
+ // FIXME: Maybe prompt for this?
+ await wallet.client.call(WalletApiOperation.SetExchangeTosAccepted, {
+ exchangeBaseUrl: selectedExchange,
+ });
const res = await wallet.client.call(
WalletApiOperation.AcceptBankIntegratedWithdrawal,
{
diff --git a/packages/taler-wallet-core/src/withdraw.ts b/packages/taler-wallet-core/src/withdraw.ts
index b10c454f0..981c85ba4 100644
--- a/packages/taler-wallet-core/src/withdraw.ts
+++ b/packages/taler-wallet-core/src/withdraw.ts
@@ -3303,14 +3303,18 @@ export async function acceptWithdrawalFromUri(
"amount required, as withdrawal operation has flexible amount",
);
}
- amount = req.amount as AmountString;
+ amount = Amounts.stringify(req.amount);
} else {
- if (req.amount != null && !p.info.editableAmount) {
- throw Error(
- `mismatched amount, amount is fixed by bank (${p.info.amount}) but client provided different amount (${req.amount})`,
- );
+ if (req.amount == null) {
+ amount = p.info.amount;
+ } else {
+ if (!p.info.editableAmount) {
+ throw Error(
+ `mismatched amount, amount is fixed by bank (${p.info.amount}) but client provided different amount (${req.amount})`,
+ );
+ }
+ amount = Amounts.stringify(req.amount);
}
- amount = p.info.amount;
}
logger.info(`confirming withdrawal with tx ${p.transactionId}`);