aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-12-09 03:37:21 +0100
committerFlorian Dold <florian.dold@gmail.com>2017-12-09 03:37:21 +0100
commit3e6bd6351f5a581175a72200a876fb6c00ab879f (patch)
treeaa0bc4deecc8e884f4b81e68cc4f0788f604c55b /src
parent2e48d83b2bf01a79c882178976080dd6b75e4a30 (diff)
downloadwallet-core-3e6bd6351f5a581175a72200a876fb6c00ab879f.tar.xz
implement new, optimized refresh protocol
Diffstat (limited to 'src')
-rw-r--r--src/crypto/cryptoWorker.ts1
-rw-r--r--src/types.ts7
-rw-r--r--src/wallet.ts30
3 files changed, 24 insertions, 14 deletions
diff --git a/src/crypto/cryptoWorker.ts b/src/crypto/cryptoWorker.ts
index 5ec7c18e5..92947d039 100644
--- a/src/crypto/cryptoWorker.ts
+++ b/src/crypto/cryptoWorker.ts
@@ -433,6 +433,7 @@ namespace RpcFunctions {
finished: false,
hash: sessionHash.toCrock(),
meltCoinPub: meltCoin.coinPub,
+ newDenomHashes: newCoinDenoms.map((d) => d.denomPubHash),
newDenoms: newCoinDenoms.map((d) => d.denomPub),
norevealIndex: undefined,
preCoinsForGammas,
diff --git a/src/types.ts b/src/types.ts
index 767474e4a..39f0a850d 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -748,7 +748,12 @@ export interface RefreshSessionRecord {
confirmSig: string;
/**
- * Denominations of the newly requested coins
+ * Hased denominations of the newly requested coins.
+ */
+ newDenomHashes: string[];
+
+ /**
+ * Denominations of the newly requested coins.
*/
newDenoms: string[];
diff --git a/src/wallet.ts b/src/wallet.ts
index 56120638d..bd31d3217 100644
--- a/src/wallet.ts
+++ b/src/wallet.ts
@@ -75,6 +75,7 @@ import {
ProposalRecord,
PurchaseRecord,
QueryPaymentResult,
+ RefreshPreCoinRecord,
RefreshSessionRecord,
RefundPermission,
ReserveCreationInfo,
@@ -320,7 +321,7 @@ export interface CoinsReturnRecord {
*
* Uses libtool's current:revision:age versioning.
*/
-export const WALLET_PROTOCOL_VERSION = "0:0:0";
+export const WALLET_PROTOCOL_VERSION = "2:0:0";
/**
* Current database version, should be incremented
@@ -2134,24 +2135,17 @@ export class Wallet {
}
const reqUrl = new URI("refresh/melt").absoluteTo(refreshSession.exchangeBaseUrl);
- const meltCoin = {
+ const meltReq = {
coin_pub: coin.coinPub,
confirm_sig: refreshSession.confirmSig,
denom_pub: coin.denomPub,
denom_sig: coin.denomSig,
+ rc: refreshSession.hash,
value_with_fee: refreshSession.valueWithFee,
};
- const coinEvs = refreshSession.preCoinsForGammas.map((x) => x.map((y) => y.coinEv));
- const req = {
- coin_evs: coinEvs,
- melt_coin: meltCoin,
- new_denoms: refreshSession.newDenoms,
- transfer_pubs: refreshSession.transferPubs,
- };
- console.log("melt request:", req);
- const resp = await this.http.postJson(reqUrl.href(), req);
+ console.log("melt request:", meltReq);
+ const resp = await this.http.postJson(reqUrl.href(), meltReq);
- console.log("melt request:", req);
console.log("melt response:", resp.responseText);
if (resp.status !== 200) {
@@ -2186,9 +2180,19 @@ export class Wallet {
const privs = Array.from(refreshSession.transferPrivs);
privs.splice(norevealIndex, 1);
+ const preCoins = refreshSession.preCoinsForGammas[norevealIndex];
+ if (!preCoins) {
+ throw Error("refresh index error");
+ }
+
+ const evs = preCoins.map((x: RefreshPreCoinRecord) => x.coinEv);
+
const req = {
- session_hash: refreshSession.hash,
+ coin_evs: evs,
+ new_denoms_h: refreshSession.newDenomHashes,
+ rc: refreshSession.hash,
transfer_privs: privs,
+ transfer_pub: refreshSession.transferPubs[norevealIndex],
};
const reqUrl = new URI("refresh/reveal") .absoluteTo(refreshSession.exchangeBaseUrl);