Fix some payment bugs.
It still doesn't work, some of the emscripten interface stuff still needs to be finished.
This commit is contained in:
parent
38c947d771
commit
0d5c37a49e
@ -19,7 +19,7 @@ namespace Db {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Keys {
|
export interface Keys {
|
||||||
denoms: { [key: string]: Denomination };
|
denoms: Denomination[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Denomination {
|
export interface Denomination {
|
||||||
@ -47,6 +47,7 @@ namespace Db {
|
|||||||
denomPub: string;
|
denomPub: string;
|
||||||
denomSig: string;
|
denomSig: string;
|
||||||
currentAmount: AmountJson;
|
currentAmount: AmountJson;
|
||||||
|
mintBaseUrl: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ function signDeposit(db, offer, cds) {
|
|||||||
* @param db
|
* @param db
|
||||||
* @param paymentAmount
|
* @param paymentAmount
|
||||||
* @param depositFeeLimit
|
* @param depositFeeLimit
|
||||||
* @param mintKeys
|
* @param allowedMints
|
||||||
*/
|
*/
|
||||||
function getPossibleMintCoins(db, paymentAmount, depositFeeLimit, allowedMints) {
|
function getPossibleMintCoins(db, paymentAmount, depositFeeLimit, allowedMints) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -83,10 +83,14 @@ function getPossibleMintCoins(db, paymentAmount, depositFeeLimit, allowedMints)
|
|||||||
if (!cursor) {
|
if (!cursor) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let value = cursor.value;
|
||||||
let cd = {
|
let cd = {
|
||||||
coin: cursor.value,
|
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];
|
let x = m[mint.baseUrl];
|
||||||
if (!x) {
|
if (!x) {
|
||||||
m[mint.baseUrl] = [cd];
|
m[mint.baseUrl] = [cd];
|
||||||
@ -94,6 +98,7 @@ function getPossibleMintCoins(db, paymentAmount, depositFeeLimit, allowedMints)
|
|||||||
else {
|
else {
|
||||||
x.push(cd);
|
x.push(cd);
|
||||||
}
|
}
|
||||||
|
cursor.continue();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -278,7 +283,7 @@ function withdrawPrepare(db, denom, reserve) {
|
|||||||
coinPub: coinPub.toCrock(),
|
coinPub: coinPub.toCrock(),
|
||||||
coinPriv: coinPriv.toCrock(),
|
coinPriv: coinPriv.toCrock(),
|
||||||
denomPub: denomPub.encode().toCrock(),
|
denomPub: denomPub.encode().toCrock(),
|
||||||
mintBaseUrl: reserve.mintBaseUrl,
|
mintBaseUrl: reserve.mint_base_url,
|
||||||
withdrawSig: sig.toCrock(),
|
withdrawSig: sig.toCrock(),
|
||||||
coinEv: ev.toCrock(),
|
coinEv: ev.toCrock(),
|
||||||
coinValue: denom.value
|
coinValue: denom.value
|
||||||
@ -330,7 +335,8 @@ function withdrawExecute(db, pc) {
|
|||||||
coinPriv: pc.coinPriv,
|
coinPriv: pc.coinPriv,
|
||||||
denomPub: pc.denomPub,
|
denomPub: pc.denomPub,
|
||||||
denomSig: denomSig.encode().toCrock(),
|
denomSig: denomSig.encode().toCrock(),
|
||||||
currentAmount: pc.coinValue
|
currentAmount: pc.coinValue,
|
||||||
|
mintBaseUrl: pc.mintBaseUrl,
|
||||||
};
|
};
|
||||||
console.log("unblinded coin");
|
console.log("unblinded coin");
|
||||||
resolve(coin);
|
resolve(coin);
|
||||||
|
@ -131,7 +131,7 @@ interface MintInfo {
|
|||||||
* @param db
|
* @param db
|
||||||
* @param paymentAmount
|
* @param paymentAmount
|
||||||
* @param depositFeeLimit
|
* @param depositFeeLimit
|
||||||
* @param mintKeys
|
* @param allowedMints
|
||||||
*/
|
*/
|
||||||
function getPossibleMintCoins(db: IDBDatabase,
|
function getPossibleMintCoins(db: IDBDatabase,
|
||||||
paymentAmount: AmountJson,
|
paymentAmount: AmountJson,
|
||||||
@ -156,16 +156,21 @@ function getPossibleMintCoins(db: IDBDatabase,
|
|||||||
if (!cursor) {
|
if (!cursor) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let value: Db.Coin = cursor.value;
|
||||||
let cd = {
|
let cd = {
|
||||||
coin: cursor.value,
|
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];
|
let x = m[mint.baseUrl];
|
||||||
if (!x) {
|
if (!x) {
|
||||||
m[mint.baseUrl] = [cd];
|
m[mint.baseUrl] = [cd];
|
||||||
} else {
|
} else {
|
||||||
x.push(cd);
|
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,
|
function withdrawPrepare(db: IDBDatabase,
|
||||||
denom: Db.Denomination,
|
denom: Db.Denomination,
|
||||||
reserve): Promise<Db.PreCoin> {
|
reserve: Reserve): Promise<Db.PreCoin> {
|
||||||
let reservePriv = new EddsaPrivateKey();
|
let reservePriv = new EddsaPrivateKey();
|
||||||
reservePriv.loadCrock(reserve.reserve_priv);
|
reservePriv.loadCrock(reserve.reserve_priv);
|
||||||
let reservePub = new EddsaPublicKey();
|
let reservePub = new EddsaPublicKey();
|
||||||
@ -383,7 +395,7 @@ function withdrawPrepare(db: IDBDatabase,
|
|||||||
coinPub: coinPub.toCrock(),
|
coinPub: coinPub.toCrock(),
|
||||||
coinPriv: coinPriv.toCrock(),
|
coinPriv: coinPriv.toCrock(),
|
||||||
denomPub: denomPub.encode().toCrock(),
|
denomPub: denomPub.encode().toCrock(),
|
||||||
mintBaseUrl: reserve.mintBaseUrl,
|
mintBaseUrl: reserve.mint_base_url,
|
||||||
withdrawSig: sig.toCrock(),
|
withdrawSig: sig.toCrock(),
|
||||||
coinEv: ev.toCrock(),
|
coinEv: ev.toCrock(),
|
||||||
coinValue: denom.value
|
coinValue: denom.value
|
||||||
@ -444,7 +456,8 @@ function withdrawExecute(db, pc: Db.PreCoin): Promise<Db.Coin> {
|
|||||||
coinPriv: pc.coinPriv,
|
coinPriv: pc.coinPriv,
|
||||||
denomPub: pc.denomPub,
|
denomPub: pc.denomPub,
|
||||||
denomSig: denomSig.encode().toCrock(),
|
denomSig: denomSig.encode().toCrock(),
|
||||||
currentAmount: pc.coinValue
|
currentAmount: pc.coinValue,
|
||||||
|
mintBaseUrl: pc.mintBaseUrl,
|
||||||
};
|
};
|
||||||
console.log("unblinded coin");
|
console.log("unblinded coin");
|
||||||
resolve(coin);
|
resolve(coin);
|
||||||
|
@ -10,14 +10,12 @@
|
|||||||
<script src="balance-overview.js" type="text/javascript"></script>
|
<script src="balance-overview.js" type="text/javascript"></script>
|
||||||
|
|
||||||
<script id="balance-template" type="text/x-handlebars-template">
|
<script id="balance-template" type="text/x-handlebars-template">
|
||||||
{{#if this.length}}
|
|
||||||
{{#each this}}
|
{{#each this}}
|
||||||
<p>{{prettyAmountNoCurrency this}} <a>{{@key}}</a></p>
|
<p>{{prettyAmountNoCurrency this}} <a>{{@key}}</a></p>
|
||||||
{{/each}}
|
|
||||||
{{else}}
|
{{else}}
|
||||||
<p>Looks like your wallet is empty. Want to get some
|
<p>Looks like your wallet is empty. Want to get some
|
||||||
<a id="link-kudos" href="http://bank.demo.taler.net">KUDOS?</a>
|
<a id="link-kudos" href="http://bank.demo.taler.net">KUDOS?</a>
|
||||||
{{/if}}
|
{{/each}}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
@ -20,6 +20,7 @@ document.addEventListener('DOMContentLoaded', (e) => {
|
|||||||
let context = document.getElementById("balance-template").innerHTML;
|
let context = document.getElementById("balance-template").innerHTML;
|
||||||
let template = Handlebars.compile(context);
|
let template = Handlebars.compile(context);
|
||||||
document.getElementById("content").innerHTML = template(wallet);
|
document.getElementById("content").innerHTML = template(wallet);
|
||||||
|
console.log("got wallet", JSON.stringify(wallet));
|
||||||
let el = document.getElementById("link-kudos");
|
let el = document.getElementById("link-kudos");
|
||||||
if (el) {
|
if (el) {
|
||||||
el.onclick = (e) => {
|
el.onclick = (e) => {
|
||||||
@ -37,5 +38,6 @@ document.addEventListener('DOMContentLoaded', (e) => {
|
|||||||
});
|
});
|
||||||
document.getElementById("reset").addEventListener("click", (e) => {
|
document.getElementById("reset").addEventListener("click", (e) => {
|
||||||
chrome.runtime.sendMessage({ type: "reset" });
|
chrome.runtime.sendMessage({ type: "reset" });
|
||||||
|
window.close();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -14,7 +14,7 @@ let React = {
|
|||||||
}
|
}
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', (e) => {
|
document.addEventListener('DOMContentLoaded', (e) => {
|
||||||
@ -23,6 +23,7 @@ document.addEventListener('DOMContentLoaded', (e) => {
|
|||||||
let context = document.getElementById("balance-template").innerHTML;
|
let context = document.getElementById("balance-template").innerHTML;
|
||||||
let template = Handlebars.compile(context);
|
let template = Handlebars.compile(context);
|
||||||
document.getElementById("content").innerHTML = template(wallet);
|
document.getElementById("content").innerHTML = template(wallet);
|
||||||
|
console.log("got wallet", JSON.stringify(wallet));
|
||||||
let el = document.getElementById("link-kudos");
|
let el = document.getElementById("link-kudos");
|
||||||
if (el) {
|
if (el) {
|
||||||
el.onclick = (e) => {
|
el.onclick = (e) => {
|
||||||
@ -41,5 +42,6 @@ document.addEventListener('DOMContentLoaded', (e) => {
|
|||||||
});
|
});
|
||||||
document.getElementById("reset").addEventListener("click", (e) => {
|
document.getElementById("reset").addEventListener("click", (e) => {
|
||||||
chrome.runtime.sendMessage({type: "reset"});
|
chrome.runtime.sendMessage({type: "reset"});
|
||||||
|
window.close();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user