summaryrefslogtreecommitdiff
path: root/src/operations/reserves.ts
diff options
context:
space:
mode:
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));
}