aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/wallet/wallet.ts8
-rw-r--r--lib/wallet/wxMessaging.ts29
2 files changed, 30 insertions, 7 deletions
diff --git a/lib/wallet/wallet.ts b/lib/wallet/wallet.ts
index 367c9cbcd..32b85e7b0 100644
--- a/lib/wallet/wallet.ts
+++ b/lib/wallet/wallet.ts
@@ -720,6 +720,10 @@ export class Wallet {
return Query(this.db)
.get("reserves", req.reservePub)
.then((r) => {
+ if (!r) {
+ console.error("Unable to confirm reserve, not found in DB");
+ return;
+ }
r.confirmed = true;
return Query(this.db)
.put("reserves", r)
@@ -770,6 +774,7 @@ export class Wallet {
}
storeCoin(coin: Coin): Promise<void> {
+ console.log("storing coin", new Date());
let historyEntry = {
type: "withdraw",
timestamp: (new Date).getTime(),
@@ -813,6 +818,9 @@ export class Wallet {
let denomsForWithdraw = getWithdrawDenomList(reserve.current_amount,
denomsAvailable);
+ // Number of coins we try to withdraw at once
+ const concurrency = 1;
+
let ps = denomsForWithdraw.map((denom) => {
console.log("withdrawing", JSON.stringify(denom));
// Do the withdraw asynchronously, so crypto is interleaved
diff --git a/lib/wallet/wxMessaging.ts b/lib/wallet/wxMessaging.ts
index 9c08b20ca..514cdce13 100644
--- a/lib/wallet/wxMessaging.ts
+++ b/lib/wallet/wxMessaging.ts
@@ -193,24 +193,38 @@ function dispatch(handlers: any, req: any, sender: any, sendResponse: any) {
const p = handlers[req.type](req.detail, sender);
return p.then((r: any) => {
- sendResponse(r);
+ try {
+ sendResponse(r);
+ } catch (e) {
+ // might fail if tab disconnected
+ }
})
})
.catch((e) => {
console.log(`exception during wallet handler for '${req.type}'`);
console.log("request", req);
console.error(e);
- sendResponse({
- error: "exception",
- hint: e.message,
- stack: e.stack.toString()
- });
+ try {
+ sendResponse({
+ error: "exception",
+ hint: e.message,
+ stack: e.stack.toString()
+ });
+
+ } catch (e) {
+ // might fail if tab disconnected
+ }
});
// The sendResponse call is async
return true;
} else {
console.error(`Request type ${JSON.stringify(req)} unknown, req ${req.type}`);
- sendResponse({error: "request unknown"});
+ try {
+ sendResponse({error: "request unknown"});
+ } catch (e) {
+ // might fail if tab disconnected
+ }
+
// The sendResponse call is sync
return false;
}
@@ -300,6 +314,7 @@ export function wxMain() {
let uri = URI(tab.url);
if (uri.protocol() == "http" || uri.protocol() == "https") {
console.log("injecting into existing tab", tab.id);
+ chrome.tabs.executeScript(tab.id, {file: "lib/vendor/URI.js"});
chrome.tabs.executeScript(tab.id, {file: "content_scripts/notify.js"});
}
}