diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-12-06 02:52:16 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-12-06 02:52:16 +0100 |
commit | 4159367d8c04b96a05da8a5ded043f8296a83174 (patch) | |
tree | 5587538fb13aead06d639a03e96cc09adcd99dd7 /src/wallet-impl/withdraw.ts | |
parent | d8170c815913b4395febc4ce3402fe45ba0d2e87 (diff) |
pending ops / history / notification tweaks
Diffstat (limited to 'src/wallet-impl/withdraw.ts')
-rw-r--r-- | src/wallet-impl/withdraw.ts | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/wallet-impl/withdraw.ts b/src/wallet-impl/withdraw.ts index 3122a463c..5d89f64a9 100644 --- a/src/wallet-impl/withdraw.ts +++ b/src/wallet-impl/withdraw.ts @@ -260,17 +260,17 @@ async function processPlanchet( let withdrawSessionFinished = false; let reserveDepleted = false; - await runWithWriteTransaction( + const success = await runWithWriteTransaction( ws.db, [Stores.coins, Stores.withdrawalSession, Stores.reserves], async tx => { const ws = await tx.get(Stores.withdrawalSession, withdrawalSessionId); if (!ws) { - return; + return false; } if (ws.withdrawn[coinIdx]) { // Already withdrawn - return; + return false; } ws.withdrawn[coinIdx] = true; ws.lastCoinErrors[coinIdx] = undefined; @@ -301,9 +301,16 @@ async function processPlanchet( } } await tx.add(Stores.coins, coin); + return true; }, ); + if (success) { + ws.notify( { + type: NotificationType.CoinWithdrawn, + } ); + } + if (withdrawSessionFinished) { ws.notify({ type: NotificationType.WithdrawSessionFinished, @@ -503,6 +510,7 @@ async function incrementWithdrawalRetry( wsr.lastError = err; await tx.put(Stores.withdrawalSession, wsr); }); + ws.notify({ type: NotificationType.WithdrawOperationError }); } export async function processWithdrawSession( |