aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/deposits.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-01-05 18:45:49 +0100
committerFlorian Dold <florian@dold.me>2023-01-05 18:45:54 +0100
commit92f1b5928c764b3af12a29b97bbc3e434a82b1b0 (patch)
tree040f88aa54aec8fedb99ba57ad18218715d19e25 /packages/taler-wallet-core/src/operations/deposits.ts
parent44aaa7a636ba25b37c1c26a306e64e0db75a2747 (diff)
downloadwallet-core-92f1b5928c764b3af12a29b97bbc3e434a82b1b0.tar.xz
wallet-core: implement insufficient balance details
For now, only for merchant payments
Diffstat (limited to 'packages/taler-wallet-core/src/operations/deposits.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/deposits.ts24
1 files changed, 12 insertions, 12 deletions
diff --git a/packages/taler-wallet-core/src/operations/deposits.ts b/packages/taler-wallet-core/src/operations/deposits.ts
index 406d658af..1cb051365 100644
--- a/packages/taler-wallet-core/src/operations/deposits.ts
+++ b/packages/taler-wallet-core/src/operations/deposits.ts
@@ -268,7 +268,7 @@ export async function getFeeForDeposit(
prevPayCoins: [],
});
- if (!payCoinSel) {
+ if (payCoinSel.type !== "success") {
throw Error("insufficient funds");
}
@@ -276,7 +276,7 @@ export async function getFeeForDeposit(
ws,
p.targetType,
amount,
- payCoinSel,
+ payCoinSel.coinSel,
);
}
@@ -355,16 +355,16 @@ export async function prepareDepositGroup(
prevPayCoins: [],
});
- if (!payCoinSel) {
+ if (payCoinSel.type !== "success") {
throw Error("insufficient funds");
}
- const totalDepositCost = await getTotalPaymentCost(ws, payCoinSel);
+ const totalDepositCost = await getTotalPaymentCost(ws, payCoinSel.coinSel);
const effectiveDepositAmount = await getEffectiveDepositAmount(
ws,
p.targetType,
- payCoinSel,
+ payCoinSel.coinSel,
);
return {
@@ -452,18 +452,18 @@ export async function createDepositGroup(
prevPayCoins: [],
});
- if (!payCoinSel) {
+ if (payCoinSel.type !== "success") {
throw Error("insufficient funds");
}
- const totalDepositCost = await getTotalPaymentCost(ws, payCoinSel);
+ const totalDepositCost = await getTotalPaymentCost(ws, payCoinSel.coinSel);
const depositGroupId = encodeCrock(getRandomBytes(32));
const effectiveDepositAmount = await getEffectiveDepositAmount(
ws,
p.targetType,
- payCoinSel,
+ payCoinSel.coinSel,
);
const depositGroup: DepositGroupRecord = {
@@ -474,9 +474,9 @@ export async function createDepositGroup(
noncePub: noncePair.pub,
timestampCreated: AbsoluteTime.toTimestamp(now),
timestampFinished: undefined,
- payCoinSelection: payCoinSel,
+ payCoinSelection: payCoinSel.coinSel,
payCoinSelectionUid: encodeCrock(getRandomBytes(32)),
- depositedPerCoin: payCoinSel.coinPubs.map(() => false),
+ depositedPerCoin: payCoinSel.coinSel.coinPubs.map(() => false),
merchantPriv: merchantPair.priv,
merchantPub: merchantPair.pub,
totalPayCost: Amounts.stringify(totalDepositCost),
@@ -500,8 +500,8 @@ export async function createDepositGroup(
.runReadWrite(async (tx) => {
await spendCoins(ws, tx, {
allocationId: `txn:deposit:${depositGroup.depositGroupId}`,
- coinPubs: payCoinSel.coinPubs,
- contributions: payCoinSel.coinContributions.map((x) =>
+ coinPubs: payCoinSel.coinSel.coinPubs,
+ contributions: payCoinSel.coinSel.coinContributions.map((x) =>
Amounts.parseOrThrow(x),
),
refreshReason: RefreshReason.PayDeposit,