implement new, optimized refresh protocol
This commit is contained in:
parent
2e48d83b2b
commit
3e6bd6351f
@ -433,6 +433,7 @@ namespace RpcFunctions {
|
|||||||
finished: false,
|
finished: false,
|
||||||
hash: sessionHash.toCrock(),
|
hash: sessionHash.toCrock(),
|
||||||
meltCoinPub: meltCoin.coinPub,
|
meltCoinPub: meltCoin.coinPub,
|
||||||
|
newDenomHashes: newCoinDenoms.map((d) => d.denomPubHash),
|
||||||
newDenoms: newCoinDenoms.map((d) => d.denomPub),
|
newDenoms: newCoinDenoms.map((d) => d.denomPub),
|
||||||
norevealIndex: undefined,
|
norevealIndex: undefined,
|
||||||
preCoinsForGammas,
|
preCoinsForGammas,
|
||||||
|
@ -748,7 +748,12 @@ export interface RefreshSessionRecord {
|
|||||||
confirmSig: string;
|
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[];
|
newDenoms: string[];
|
||||||
|
|
||||||
|
@ -75,6 +75,7 @@ import {
|
|||||||
ProposalRecord,
|
ProposalRecord,
|
||||||
PurchaseRecord,
|
PurchaseRecord,
|
||||||
QueryPaymentResult,
|
QueryPaymentResult,
|
||||||
|
RefreshPreCoinRecord,
|
||||||
RefreshSessionRecord,
|
RefreshSessionRecord,
|
||||||
RefundPermission,
|
RefundPermission,
|
||||||
ReserveCreationInfo,
|
ReserveCreationInfo,
|
||||||
@ -320,7 +321,7 @@ export interface CoinsReturnRecord {
|
|||||||
*
|
*
|
||||||
* Uses libtool's current:revision:age versioning.
|
* 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
|
* Current database version, should be incremented
|
||||||
@ -2134,24 +2135,17 @@ export class Wallet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const reqUrl = new URI("refresh/melt").absoluteTo(refreshSession.exchangeBaseUrl);
|
const reqUrl = new URI("refresh/melt").absoluteTo(refreshSession.exchangeBaseUrl);
|
||||||
const meltCoin = {
|
const meltReq = {
|
||||||
coin_pub: coin.coinPub,
|
coin_pub: coin.coinPub,
|
||||||
confirm_sig: refreshSession.confirmSig,
|
confirm_sig: refreshSession.confirmSig,
|
||||||
denom_pub: coin.denomPub,
|
denom_pub: coin.denomPub,
|
||||||
denom_sig: coin.denomSig,
|
denom_sig: coin.denomSig,
|
||||||
|
rc: refreshSession.hash,
|
||||||
value_with_fee: refreshSession.valueWithFee,
|
value_with_fee: refreshSession.valueWithFee,
|
||||||
};
|
};
|
||||||
const coinEvs = refreshSession.preCoinsForGammas.map((x) => x.map((y) => y.coinEv));
|
console.log("melt request:", meltReq);
|
||||||
const req = {
|
const resp = await this.http.postJson(reqUrl.href(), meltReq);
|
||||||
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:", req);
|
|
||||||
console.log("melt response:", resp.responseText);
|
console.log("melt response:", resp.responseText);
|
||||||
|
|
||||||
if (resp.status !== 200) {
|
if (resp.status !== 200) {
|
||||||
@ -2186,9 +2180,19 @@ export class Wallet {
|
|||||||
const privs = Array.from(refreshSession.transferPrivs);
|
const privs = Array.from(refreshSession.transferPrivs);
|
||||||
privs.splice(norevealIndex, 1);
|
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 = {
|
const req = {
|
||||||
session_hash: refreshSession.hash,
|
coin_evs: evs,
|
||||||
|
new_denoms_h: refreshSession.newDenomHashes,
|
||||||
|
rc: refreshSession.hash,
|
||||||
transfer_privs: privs,
|
transfer_privs: privs,
|
||||||
|
transfer_pub: refreshSession.transferPubs[norevealIndex],
|
||||||
};
|
};
|
||||||
|
|
||||||
const reqUrl = new URI("refresh/reveal") .absoluteTo(refreshSession.exchangeBaseUrl);
|
const reqUrl = new URI("refresh/reveal") .absoluteTo(refreshSession.exchangeBaseUrl);
|
||||||
|
Loading…
Reference in New Issue
Block a user