summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-05-11 21:05:00 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-05-11 21:05:00 +0530
commit277a513a8f9c46392446514e7a37e77e4f4b5327 (patch)
tree3c129b67cce58fd94512ba63bbdc5b2124540693
parentd7ee78669d4ab25f5f883cc3858ccba4e409c354 (diff)
downloadwallet-core-277a513a8f9c46392446514e7a37e77e4f4b5327.tar.gz
wallet-core-277a513a8f9c46392446514e7a37e77e4f4b5327.tar.bz2
wallet-core-277a513a8f9c46392446514e7a37e77e4f4b5327.zip
directly withdraw after creating planchet
-rw-r--r--src/operations/withdraw.ts13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/operations/withdraw.ts b/src/operations/withdraw.ts
index 91e4ff1d8..36b9f1c0f 100644
--- a/src/operations/withdraw.ts
+++ b/src/operations/withdraw.ts
@@ -189,7 +189,7 @@ async function processPlanchet(
if (!withdrawalGroup) {
return;
}
- const planchet = await ws.db.getIndexed(Stores.planchets.byGroupAndIndex, [
+ let planchet = await ws.db.getIndexed(Stores.planchets.byGroupAndIndex, [
withdrawalGroupId,
coinIdx,
]);
@@ -247,12 +247,15 @@ async function processPlanchet(
coinIdx,
]);
if (p) {
+ planchet = p;
return;
}
await tx.put(Stores.planchets, newPlanchet);
+ planchet = newPlanchet;
});
- console.log("processPlanchet: planchet not found");
- return;
+ }
+ if (!planchet) {
+ throw Error("invariant violated");
}
if (planchet.withdrawalDone) {
console.log("processPlanchet: planchet already withdrawn");
@@ -332,6 +335,8 @@ async function processPlanchet(
let withdrawalGroupFinished = false;
+ const planchetCoinPub = planchet.coinPub;
+
const success = await ws.db.runWithWriteTransaction(
[Stores.coins, Stores.withdrawalGroups, Stores.reserves, Stores.planchets],
async (tx) => {
@@ -339,7 +344,7 @@ async function processPlanchet(
if (!ws) {
return false;
}
- const p = await tx.get(Stores.planchets, planchet.coinPub);
+ const p = await tx.get(Stores.planchets, planchetCoinPub);
if (!p) {
return false;
}