store exchange public key with signature on denomination
This commit is contained in:
parent
7d15ce3d88
commit
af2ad00d84
@ -513,6 +513,12 @@ export interface DenominationRecord {
|
||||
* Base URL of the exchange.
|
||||
*/
|
||||
exchangeBaseUrl: string;
|
||||
|
||||
/**
|
||||
* Master public key of the exchange that made the signature
|
||||
* on the denomination.
|
||||
*/
|
||||
exchangeMasterPub: string;
|
||||
}
|
||||
|
||||
export interface ExchangeBankAccount {
|
||||
|
@ -337,6 +337,7 @@ export async function importBackup(
|
||||
denomPub: backupDenomination.denom_pub,
|
||||
denomPubHash: denomPubHash,
|
||||
exchangeBaseUrl: backupExchangeDetails.base_url,
|
||||
exchangeMasterPub: backupExchangeDetails.master_public_key,
|
||||
feeDeposit: Amounts.parseOrThrow(backupDenomination.fee_deposit),
|
||||
feeRefresh: Amounts.parseOrThrow(backupDenomination.fee_refresh),
|
||||
feeRefund: Amounts.parseOrThrow(backupDenomination.fee_refund),
|
||||
|
@ -77,6 +77,7 @@ const logger = new Logger("exchanges.ts");
|
||||
|
||||
function denominationRecordFromKeys(
|
||||
exchangeBaseUrl: string,
|
||||
exchangeMasterPub: string,
|
||||
denomIn: Denomination,
|
||||
): DenominationRecord {
|
||||
const denomPubHash = encodeCrock(hash(decodeCrock(denomIn.denom_pub)));
|
||||
@ -84,6 +85,7 @@ function denominationRecordFromKeys(
|
||||
denomPub: denomIn.denom_pub,
|
||||
denomPubHash,
|
||||
exchangeBaseUrl,
|
||||
exchangeMasterPub,
|
||||
feeDeposit: Amounts.parseOrThrow(denomIn.fee_deposit),
|
||||
feeRefresh: Amounts.parseOrThrow(denomIn.fee_refresh),
|
||||
feeRefund: Amounts.parseOrThrow(denomIn.fee_refund),
|
||||
@ -378,7 +380,11 @@ async function downloadKeysInfo(
|
||||
currency,
|
||||
auditors: exchangeKeysJson.auditors,
|
||||
currentDenominations: exchangeKeysJson.denoms.map((d) =>
|
||||
denominationRecordFromKeys(baseUrl, d),
|
||||
denominationRecordFromKeys(
|
||||
baseUrl,
|
||||
exchangeKeysJson.master_public_key,
|
||||
d,
|
||||
),
|
||||
),
|
||||
protocolVersion: exchangeKeysJson.version,
|
||||
signingKeys: exchangeKeysJson.signkeys,
|
||||
@ -410,20 +416,22 @@ async function updateExchangeFromUrlImpl(
|
||||
const r = await provideExchangeRecord(ws, baseUrl, now);
|
||||
|
||||
if (!forceNow && r && !isTimestampExpired(r.nextUpdate)) {
|
||||
const res = await ws.db.mktx((x) => ({
|
||||
exchanges: x.exchanges,
|
||||
exchangeDetails: x.exchangeDetails,
|
||||
})).runReadOnly(async (tx) => {
|
||||
const exchange = await tx.exchanges.get(baseUrl);
|
||||
if (!exchange) {
|
||||
return;
|
||||
}
|
||||
const exchangeDetails = await getExchangeDetails(tx, baseUrl);
|
||||
if (!exchangeDetails) {
|
||||
return;
|
||||
}
|
||||
return { exchange, exchangeDetails };
|
||||
});
|
||||
const res = await ws.db
|
||||
.mktx((x) => ({
|
||||
exchanges: x.exchanges,
|
||||
exchangeDetails: x.exchangeDetails,
|
||||
}))
|
||||
.runReadOnly(async (tx) => {
|
||||
const exchange = await tx.exchanges.get(baseUrl);
|
||||
if (!exchange) {
|
||||
return;
|
||||
}
|
||||
const exchangeDetails = await getExchangeDetails(tx, baseUrl);
|
||||
if (!exchangeDetails) {
|
||||
return;
|
||||
}
|
||||
return { exchange, exchangeDetails };
|
||||
});
|
||||
if (res) {
|
||||
logger.info("using existing exchange info");
|
||||
return res;
|
||||
@ -493,9 +501,9 @@ async function updateExchangeFromUrlImpl(
|
||||
r.lastError = undefined;
|
||||
r.retryInfo = initRetryInfo(false);
|
||||
r.lastUpdate = getTimestampNow();
|
||||
r.nextUpdate = keysInfo.expiry,
|
||||
// New denominations might be available.
|
||||
r.nextRefreshCheck = getTimestampNow();
|
||||
(r.nextUpdate = keysInfo.expiry),
|
||||
// New denominations might be available.
|
||||
(r.nextRefreshCheck = getTimestampNow());
|
||||
r.detailsPointer = {
|
||||
currency: details.currency,
|
||||
masterPublicKey: details.masterPublicKey,
|
||||
|
@ -33,6 +33,7 @@ test("withdrawal selection bug repro", (t) => {
|
||||
denomPubHash:
|
||||
"Q21FQSSG4FXNT96Z14CHXM8N1RZAG9GPHAV8PRWS0PZAAVWH7PBW6R97M2CH19KKP65NNSWXY7B6S53PT3CBM342E357ZXDDJ8RDVW8",
|
||||
exchangeBaseUrl: "https://exchange.demo.taler.net/",
|
||||
exchangeMasterPub: "",
|
||||
feeDeposit: {
|
||||
currency: "KUDOS",
|
||||
fraction: 1000000,
|
||||
@ -82,6 +83,7 @@ test("withdrawal selection bug repro", (t) => {
|
||||
denomPubHash:
|
||||
"447WA23SCBATMABHA0793F92MYTBYVPYMMQHCPKMKVY5P7RZRFMQ6VRW0Y8HRA7177GTBT0TBT08R21DZD129AJ995H9G09XBFE55G8",
|
||||
exchangeBaseUrl: "https://exchange.demo.taler.net/",
|
||||
exchangeMasterPub: "",
|
||||
feeDeposit: {
|
||||
currency: "KUDOS",
|
||||
fraction: 1000000,
|
||||
@ -131,6 +133,7 @@ test("withdrawal selection bug repro", (t) => {
|
||||
denomPubHash:
|
||||
"JS61DTKAFM0BX8Q4XV3ZSKB921SM8QK745Z2AFXTKFMBHHFNBD8TQ5ETJHFNDGBGX22FFN2A2ERNYG1SGSDQWNQHQQ2B14DBVJYJG8R",
|
||||
exchangeBaseUrl: "https://exchange.demo.taler.net/",
|
||||
exchangeMasterPub: "",
|
||||
feeDeposit: {
|
||||
currency: "KUDOS",
|
||||
fraction: 1000000,
|
||||
@ -180,6 +183,7 @@ test("withdrawal selection bug repro", (t) => {
|
||||
denomPubHash:
|
||||
"8T51NEY81VMPQ180EQ5WR0YH7GMNNT90W55Q0514KZM18AZT71FHJGJHQXGK0WTA7ACN1X2SD0S53XPBQ1A9KH960R48VCVVM6E3TH8",
|
||||
exchangeBaseUrl: "https://exchange.demo.taler.net/",
|
||||
exchangeMasterPub: "",
|
||||
feeDeposit: {
|
||||
currency: "KUDOS",
|
||||
fraction: 1000000,
|
||||
@ -229,6 +233,7 @@ test("withdrawal selection bug repro", (t) => {
|
||||
denomPubHash:
|
||||
"A41HW0Q2H9PCNMEWW0C0N45QAYVXZ8SBVRRAHE4W6X24SV1TH38ANTWDT80JXEBW9Z8PVPGT9GFV2EYZWJ5JW5W1N34NFNKHQSZ1PFR",
|
||||
exchangeBaseUrl: "https://exchange.demo.taler.net/",
|
||||
exchangeMasterPub: "",
|
||||
feeDeposit: {
|
||||
currency: "KUDOS",
|
||||
fraction: 1000000,
|
||||
@ -278,6 +283,7 @@ test("withdrawal selection bug repro", (t) => {
|
||||
denomPubHash:
|
||||
"F5NGBX33DTV4595XZZVK0S2MA1VMXFEJQERE5EBP5DS4QQ9EFRANN7YHWC1TKSHT2K6CQWDBRES8D3DWR0KZF5RET40B4AZXZ0RW1ZG",
|
||||
exchangeBaseUrl: "https://exchange.demo.taler.net/",
|
||||
exchangeMasterPub: "",
|
||||
feeDeposit: {
|
||||
currency: "KUDOS",
|
||||
fraction: 1000000,
|
||||
|
Loading…
Reference in New Issue
Block a user