diff options
author | Florian Dold <florian@dold.me> | 2021-05-12 16:18:32 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-05-12 16:18:32 +0200 |
commit | f4ec5b1a32193744e439c04faca0b3d31f49c2bc (patch) | |
tree | 4f1573d1a7db68c68d9732654c80130e81a2e709 /packages/taler-wallet-core/src | |
parent | 4da4380480ec7026a1ef8f10589d60669a462497 (diff) | |
download | wallet-core-f4ec5b1a32193744e439c04faca0b3d31f49c2bc.tar.xz |
implement currencies subcommand
Diffstat (limited to 'packages/taler-wallet-core/src')
-rw-r--r-- | packages/taler-wallet-core/src/db.ts | 41 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/operations/reserves.ts | 1 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/wallet.ts | 11 |
3 files changed, 40 insertions, 13 deletions
diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts index 7a7c36561..2c009b4c5 100644 --- a/packages/taler-wallet-core/src/db.ts +++ b/packages/taler-wallet-core/src/db.ts @@ -357,20 +357,41 @@ export interface AuditorRecord { expirationStamp: number; } -/** - * Exchange for currencies as stored in the wallet's currency - * information database. - */ -export interface ExchangeForCurrencyRecord { + +export interface AuditorTrustInfo { /** - * FIXME: unused? + * Base URL of the auditor. */ - exchangeMasterPub: string; + auditorBaseUrl: string; /** - * Base URL of the exchange. + * Public key of the auditor. + */ + auditorPub: string; + + /** + * UIDs for the operation of adding this auditor + * as a trusted auditor. + */ + uids: string[]; +} + +export interface ExchangeTrustInfo { + /** + * Canonicalized exchange base URL. */ exchangeBaseUrl: string; + + /** + * Master public key of the exchange. + */ + exchangeMasterPub: string; + + /** + * UIDs for the operation of adding this exchange + * as trusted. + */ + uids: string[]; } /** @@ -390,12 +411,12 @@ export interface CurrencyRecord { /** * Auditors that the wallet trusts for this currency. */ - auditors: AuditorRecord[]; + auditors: AuditorTrustInfo[]; /** * Exchanges that the wallet trusts for this currency. */ - exchanges: ExchangeForCurrencyRecord[]; + exchanges: ExchangeTrustInfo[]; } /** diff --git a/packages/taler-wallet-core/src/operations/reserves.ts b/packages/taler-wallet-core/src/operations/reserves.ts index 855ee82ee..9a479427e 100644 --- a/packages/taler-wallet-core/src/operations/reserves.ts +++ b/packages/taler-wallet-core/src/operations/reserves.ts @@ -175,6 +175,7 @@ export async function createReserve( currencyRecord.exchanges.push({ exchangeBaseUrl: req.exchange, exchangeMasterPub: exchangeDetails.masterPublicKey, + uids: [encodeCrock(getRandomBytes(32))], }); } diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index bf277659e..f69d26e84 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -22,7 +22,11 @@ /** * Imports. */ -import { BackupRecovery, codecForAny, TalerErrorCode } from "@gnu-taler/taler-util"; +import { + BackupRecovery, + codecForAny, + TalerErrorCode, +} from "@gnu-taler/taler-util"; import { CryptoWorkerFactory } from "./crypto/workers/cryptoApi"; import { addBackupProvider, @@ -181,8 +185,8 @@ const builtinCurrencies: CurrencyRecord[] = [ auditors: [ { auditorPub: "BW9DC48PHQY4NH011SHHX36DZZ3Q22Y6X7FZ1VD1CMZ2PTFZ6PN0", - baseUrl: "https://auditor.demo.taler.net/", - expirationStamp: new Date(2027, 1).getTime(), + auditorBaseUrl: "https://auditor.demo.taler.net/", + uids: ["5P25XF8TVQP9AW6VYGY2KV47WT5Y3ZXFSJAA570GJPX5SVJXKBVG"], }, ], exchanges: [], @@ -672,6 +676,7 @@ export class Wallet { return await this.db.iter(Stores.exchanges).toArray(); } + async getExchanges(): Promise<ExchangesListRespose> { const exchanges: (ExchangeListItem | undefined)[] = await this.db .iter(Stores.exchanges) |