diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-03-12 00:44:28 +0530 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-03-12 00:44:28 +0530 |
commit | 2c52046f0bf358a5e07c53394b3b72d091356cce (patch) | |
tree | 8993c992b9c8240ee865671cdfbab380e61af96c /src/operations/withdraw.ts | |
parent | 6e2881fabf74a3c1da8e94dcbe3e68fce6080d9e (diff) | |
download | wallet-core-2c52046f0bf358a5e07c53394b3b72d091356cce.tar.gz wallet-core-2c52046f0bf358a5e07c53394b3b72d091356cce.tar.bz2 wallet-core-2c52046f0bf358a5e07c53394b3b72d091356cce.zip |
full recoup, untested/unfinished first attempt
Diffstat (limited to 'src/operations/withdraw.ts')
-rw-r--r-- | src/operations/withdraw.ts | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/operations/withdraw.ts b/src/operations/withdraw.ts index 0c58f5f2f..478aa4ceb 100644 --- a/src/operations/withdraw.ts +++ b/src/operations/withdraw.ts @@ -24,6 +24,7 @@ import { PlanchetRecord, initRetryInfo, updateRetryInfoTimeout, + CoinSourceType, } from "../types/dbTypes"; import * as Amounts from "../util/amounts"; import { @@ -48,6 +49,7 @@ import { timestampCmp, timestampSubtractDuraction, } from "../util/time"; +import { Store } from "../util/query"; const logger = new Logger("withdraw.ts"); @@ -229,10 +231,13 @@ async function processPlanchet( denomPubHash: planchet.denomPubHash, denomSig, exchangeBaseUrl: withdrawalSession.exchangeBaseUrl, - reservePub: planchet.reservePub, status: CoinStatus.Fresh, - coinIndex: coinIdx, - withdrawSessionId: withdrawalSessionId, + coinSource: { + type: CoinSourceType.Withdraw, + coinIndex: coinIdx, + reservePub: planchet.reservePub, + withdrawSessionId: withdrawalSessionId + } }; let withdrawSessionFinished = false; @@ -449,14 +454,15 @@ async function processWithdrawCoin( return; } - const coin = await ws.db.getIndexed(Stores.coins.byWithdrawalWithIdx, [ - withdrawalSessionId, - coinIndex, - ]); + const planchet = withdrawalSession.planchets[coinIndex]; - if (coin) { - console.log("coin already exists"); - return; + if (planchet) { + const coin = await ws.db.get(Stores.coins, planchet.coinPub); + + if (coin) { + console.log("coin already exists"); + return; + } } if (!withdrawalSession.planchets[coinIndex]) { |