aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2015-12-17 23:34:39 +0100
committerFlorian Dold <florian.dold@gmail.com>2015-12-17 23:34:39 +0100
commit0d5c37a49e688503dc2933d379c68541dd432248 (patch)
treeb2218c700c7856286f64aab6827bc1a82c052e68
parent38c947d7712d77070ca521b4718032fb31c0f108 (diff)
downloadwallet-core-0d5c37a49e688503dc2933d379c68541dd432248.tar.xz
Fix some payment bugs.
It still doesn't work, some of the emscripten interface stuff still needs to be finished.
-rw-r--r--extension/background/db.ts3
-rw-r--r--extension/background/wallet.js14
-rw-r--r--extension/background/wallet.ts23
-rw-r--r--extension/popup/balance-overview.html58
-rw-r--r--extension/popup/balance-overview.js2
-rw-r--r--extension/popup/balance-overview.tsx4
6 files changed, 63 insertions, 41 deletions
diff --git a/extension/background/db.ts b/extension/background/db.ts
index 12d944a83..40c1cdaca 100644
--- a/extension/background/db.ts
+++ b/extension/background/db.ts
@@ -19,7 +19,7 @@ namespace Db {
}
export interface Keys {
- denoms: { [key: string]: Denomination };
+ denoms: Denomination[];
}
export interface Denomination {
@@ -47,6 +47,7 @@ namespace Db {
denomPub: string;
denomSig: string;
currentAmount: AmountJson;
+ mintBaseUrl: string;
}
diff --git a/extension/background/wallet.js b/extension/background/wallet.js
index f915187ab..422e60ca5 100644
--- a/extension/background/wallet.js
+++ b/extension/background/wallet.js
@@ -61,7 +61,7 @@ function signDeposit(db, offer, cds) {
* @param db
* @param paymentAmount
* @param depositFeeLimit
- * @param mintKeys
+ * @param allowedMints
*/
function getPossibleMintCoins(db, paymentAmount, depositFeeLimit, allowedMints) {
return new Promise((resolve, reject) => {
@@ -83,10 +83,14 @@ function getPossibleMintCoins(db, paymentAmount, depositFeeLimit, allowedMints)
if (!cursor) {
return;
}
+ let value = cursor.value;
let cd = {
coin: cursor.value,
- denom: mint.keys.denoms[cursor.value.denomPub]
+ denom: mint.keys.denoms.find((e) => e.denom_pub === value.denomPub)
};
+ if (!cd.denom) {
+ throw Error("denom not found");
+ }
let x = m[mint.baseUrl];
if (!x) {
m[mint.baseUrl] = [cd];
@@ -94,6 +98,7 @@ function getPossibleMintCoins(db, paymentAmount, depositFeeLimit, allowedMints)
else {
x.push(cd);
}
+ cursor.continue();
};
};
}
@@ -278,7 +283,7 @@ function withdrawPrepare(db, denom, reserve) {
coinPub: coinPub.toCrock(),
coinPriv: coinPriv.toCrock(),
denomPub: denomPub.encode().toCrock(),
- mintBaseUrl: reserve.mintBaseUrl,
+ mintBaseUrl: reserve.mint_base_url,
withdrawSig: sig.toCrock(),
coinEv: ev.toCrock(),
coinValue: denom.value
@@ -330,7 +335,8 @@ function withdrawExecute(db, pc) {
coinPriv: pc.coinPriv,
denomPub: pc.denomPub,
denomSig: denomSig.encode().toCrock(),
- currentAmount: pc.coinValue
+ currentAmount: pc.coinValue,
+ mintBaseUrl: pc.mintBaseUrl,
};
console.log("unblinded coin");
resolve(coin);
diff --git a/extension/background/wallet.ts b/extension/background/wallet.ts
index 281a24c6e..a2ac45dfa 100644
--- a/extension/background/wallet.ts
+++ b/extension/background/wallet.ts
@@ -131,7 +131,7 @@ interface MintInfo {
* @param db
* @param paymentAmount
* @param depositFeeLimit
- * @param mintKeys
+ * @param allowedMints
*/
function getPossibleMintCoins(db: IDBDatabase,
paymentAmount: AmountJson,
@@ -156,16 +156,21 @@ function getPossibleMintCoins(db: IDBDatabase,
if (!cursor) {
return;
}
+ let value: Db.Coin = cursor.value;
let cd = {
coin: cursor.value,
- denom: mint.keys.denoms[cursor.value.denomPub]
+ denom: mint.keys.denoms.find((e) => e.denom_pub === value.denomPub)
};
+ if (!cd.denom) {
+ throw Error("denom not found");
+ }
let x = m[mint.baseUrl];
if (!x) {
m[mint.baseUrl] = [cd];
} else {
x.push(cd);
}
+ cursor.continue();
}
}
}
@@ -340,9 +345,16 @@ function rankDenom(denom1: any, denom2: any) {
}
+interface Reserve {
+ mint_base_url: string
+ reserve_priv: string;
+ reserve_pub: string;
+}
+
+
function withdrawPrepare(db: IDBDatabase,
denom: Db.Denomination,
- reserve): Promise<Db.PreCoin> {
+ reserve: Reserve): Promise<Db.PreCoin> {
let reservePriv = new EddsaPrivateKey();
reservePriv.loadCrock(reserve.reserve_priv);
let reservePub = new EddsaPublicKey();
@@ -383,7 +395,7 @@ function withdrawPrepare(db: IDBDatabase,
coinPub: coinPub.toCrock(),
coinPriv: coinPriv.toCrock(),
denomPub: denomPub.encode().toCrock(),
- mintBaseUrl: reserve.mintBaseUrl,
+ mintBaseUrl: reserve.mint_base_url,
withdrawSig: sig.toCrock(),
coinEv: ev.toCrock(),
coinValue: denom.value
@@ -444,7 +456,8 @@ function withdrawExecute(db, pc: Db.PreCoin): Promise<Db.Coin> {
coinPriv: pc.coinPriv,
denomPub: pc.denomPub,
denomSig: denomSig.encode().toCrock(),
- currentAmount: pc.coinValue
+ currentAmount: pc.coinValue,
+ mintBaseUrl: pc.mintBaseUrl,
};
console.log("unblinded coin");
resolve(coin);
diff --git a/extension/popup/balance-overview.html b/extension/popup/balance-overview.html
index a3aeae697..bb9726ab2 100644
--- a/extension/popup/balance-overview.html
+++ b/extension/popup/balance-overview.html
@@ -1,37 +1,35 @@
<!DOCTYPE html>
<html>
- <head>
- <meta charset="utf-8">
- <link rel="stylesheet" href="popup.css" type="text/css">
- <script src="../lib/util.js" type="text/javascript"></script>
- <script src="../lib/handlebars-v4.0.5.js"></script>
- <script src="../lib/commonHelpers.js"></script>
- <script src="balance-overview.js" type="text/javascript"></script>
-
- <script id="balance-template" type="text/x-handlebars-template">
- {{#if this.length}}
- {{#each this}}
- <p>{{prettyAmountNoCurrency this}} <a>{{@key}}</a></p>
- {{/each}}
- {{else}}
- <p>Looks like your wallet is empty. Want to get some
- <a id="link-kudos" href="http://bank.demo.taler.net">KUDOS?</a>
- {{/if}}
- </script>
+<head>
+ <meta charset="utf-8">
+ <link rel="stylesheet" href="popup.css" type="text/css">
+ <script src="../lib/util.js" type="text/javascript"></script>
+ <script src="../lib/handlebars-v4.0.5.js"></script>
+ <script src="../lib/commonHelpers.js"></script>
+ <script src="balance-overview.js" type="text/javascript"></script>
- </head>
- <body>
- <div id="header" class="nav">
- <a href="wallet.html" class="active">Wallet</a>
- <a href="transactions.html">Transactions</a>
- <a href="reserves.html">Reserves</a>
- <button id="debug">Debug!</button>
- <button id="reset">Reset!</button>
- </div>
+ <script id="balance-template" type="text/x-handlebars-template">
+ {{#each this}}
+ <p>{{prettyAmountNoCurrency this}} <a>{{@key}}</a></p>
+ {{else}}
+ <p>Looks like your wallet is empty. Want to get some
+ <a id="link-kudos" href="http://bank.demo.taler.net">KUDOS?</a>
+ {{/each}}
+ </script>
- <div id="content">
- </div>
+</head>
+<body>
+<div id="header" class="nav">
+ <a href="wallet.html" class="active">Wallet</a>
+ <a href="transactions.html">Transactions</a>
+ <a href="reserves.html">Reserves</a>
+ <button id="debug">Debug!</button>
+ <button id="reset">Reset!</button>
+</div>
- </body>
+<div id="content">
+</div>
+
+</body>
</html>
diff --git a/extension/popup/balance-overview.js b/extension/popup/balance-overview.js
index b2c5e0837..946ddc6b3 100644
--- a/extension/popup/balance-overview.js
+++ b/extension/popup/balance-overview.js
@@ -20,6 +20,7 @@ document.addEventListener('DOMContentLoaded', (e) => {
let context = document.getElementById("balance-template").innerHTML;
let template = Handlebars.compile(context);
document.getElementById("content").innerHTML = template(wallet);
+ console.log("got wallet", JSON.stringify(wallet));
let el = document.getElementById("link-kudos");
if (el) {
el.onclick = (e) => {
@@ -37,5 +38,6 @@ document.addEventListener('DOMContentLoaded', (e) => {
});
document.getElementById("reset").addEventListener("click", (e) => {
chrome.runtime.sendMessage({ type: "reset" });
+ window.close();
});
});
diff --git a/extension/popup/balance-overview.tsx b/extension/popup/balance-overview.tsx
index 38be50375..bc0e80ee6 100644
--- a/extension/popup/balance-overview.tsx
+++ b/extension/popup/balance-overview.tsx
@@ -14,7 +14,7 @@ let React = {
}
return e;
}
-}
+};
document.addEventListener('DOMContentLoaded', (e) => {
@@ -23,6 +23,7 @@ document.addEventListener('DOMContentLoaded', (e) => {
let context = document.getElementById("balance-template").innerHTML;
let template = Handlebars.compile(context);
document.getElementById("content").innerHTML = template(wallet);
+ console.log("got wallet", JSON.stringify(wallet));
let el = document.getElementById("link-kudos");
if (el) {
el.onclick = (e) => {
@@ -41,5 +42,6 @@ document.addEventListener('DOMContentLoaded', (e) => {
});
document.getElementById("reset").addEventListener("click", (e) => {
chrome.runtime.sendMessage({type: "reset"});
+ window.close();
});
});