check trust by key, not by URL

This commit is contained in:
Florian Dold 2017-06-04 20:25:28 +02:00
parent 2cf33705c8
commit 00b25fa66a
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
2 changed files with 4 additions and 9 deletions

View File

@ -154,14 +154,9 @@ export interface AuditorRecord {
*/ */
export interface ExchangeForCurrencyRecord { export interface ExchangeForCurrencyRecord {
/** /**
* Priority for automatic selection when withdrawing.
* FIXME: unused? * FIXME: unused?
*/ */
priority: number; exchangePub: string;
/**
* FIXME: unused?
*/
pinnedPub?: string;
/** /**
* Base URL of the exchange. * Base URL of the exchange.
*/ */

View File

@ -1158,7 +1158,7 @@ export class Wallet {
} }
if (!isAudited && !isTrusted) { if (!isAudited && !isTrusted) {
currencyRecord.exchanges.push({baseUrl: req.exchange, priority: 0}); currencyRecord.exchanges.push({baseUrl: req.exchange, exchangePub: exchangeInfo.masterPublicKey});
} }
await this.q() await this.q()
@ -1445,14 +1445,14 @@ export class Wallet {
const currencyRecord = await this.q().get(Stores.currencies, exchangeInfo.currency); const currencyRecord = await this.q().get(Stores.currencies, exchangeInfo.currency);
if (currencyRecord) { if (currencyRecord) {
for (const trustedExchange of currencyRecord.exchanges) { for (const trustedExchange of currencyRecord.exchanges) {
if (trustedExchange.baseUrl === exchangeInfo.baseUrl) { if (trustedExchange.exchangePub === exchangeInfo.masterPublicKey) {
isTrusted = true; isTrusted = true;
break; break;
} }
} }
for (const trustedAuditor of currencyRecord.auditors) { for (const trustedAuditor of currencyRecord.auditors) {
for (const exchangeAuditor of exchangeInfo.auditors) { for (const exchangeAuditor of exchangeInfo.auditors) {
if (trustedAuditor.baseUrl === exchangeAuditor.auditor_url) { if (trustedAuditor.auditorPub === exchangeAuditor.auditor_pub) {
isAudited = true; isAudited = true;
break; break;
} }