summaryrefslogtreecommitdiff
path: root/src/operations/reserves.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-07-16 14:44:59 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-07-16 14:44:59 +0530
commit75c5c59316a428fbebe2448d9d79a70689565657 (patch)
tree9dbc53b428011a8e24273f6c6e1fe70121e8d3d2 /src/operations/reserves.ts
parentc6d80b01281a6af578fb3468698419ddd5c172f8 (diff)
downloadwallet-core-75c5c59316a428fbebe2448d9d79a70689565657.tar.gz
wallet-core-75c5c59316a428fbebe2448d9d79a70689565657.tar.bz2
wallet-core-75c5c59316a428fbebe2448d9d79a70689565657.zip
report manual withdrawals properly in transaction list
Diffstat (limited to 'src/operations/reserves.ts')
-rw-r--r--src/operations/reserves.ts31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/operations/reserves.ts b/src/operations/reserves.ts
index 2761dfaf9..ff20ce9ba 100644
--- a/src/operations/reserves.ts
+++ b/src/operations/reserves.ts
@@ -53,7 +53,6 @@ import {
processWithdrawGroup,
getBankWithdrawalInfo,
denomSelectionInfoToState,
- getWithdrawDenomList,
} from "./withdraw";
import {
guardOperationException,
@@ -106,22 +105,25 @@ export async function createReserve(
let bankInfo: ReserveBankInfo | undefined;
if (req.bankWithdrawStatusUrl) {
- const denomSelInfo = await selectWithdrawalDenoms(
- ws,
- canonExchange,
- req.amount,
- );
- const denomSel = denomSelectionInfoToState(denomSelInfo);
bankInfo = {
statusUrl: req.bankWithdrawStatusUrl,
- amount: req.amount,
- bankWithdrawalGroupId: encodeCrock(getRandomBytes(32)),
- withdrawalStarted: false,
- denomSel,
};
}
+ const initialWithdrawalGroupId = encodeCrock(getRandomBytes(32));
+
+ const denomSelInfo = await selectWithdrawalDenoms(
+ ws,
+ canonExchange,
+ req.amount,
+ );
+ const initialDenomSel = denomSelectionInfoToState(denomSelInfo);
+
const reserveRecord: ReserveRecord = {
+ instructedAmount: req.amount,
+ initialWithdrawalGroupId,
+ initialDenomSel,
+ initialWithdrawalStarted: false,
timestampCreated: now,
exchangeBaseUrl: canonExchange,
reservePriv: keypair.priv,
@@ -750,10 +752,9 @@ async function depleteReserve(
let withdrawalGroupId: string;
- const bankInfo = newReserve.bankInfo;
- if (bankInfo && !bankInfo.withdrawalStarted) {
- withdrawalGroupId = bankInfo.bankWithdrawalGroupId;
- bankInfo.withdrawalStarted = true;
+ if (!newReserve.initialWithdrawalStarted) {
+ withdrawalGroupId = newReserve.initialWithdrawalGroupId;
+ newReserve.initialWithdrawalStarted = true;
} else {
withdrawalGroupId = encodeCrock(randomBytes(32));
}