[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] branch master updated: wallet-core: report supported
From: |
gnunet |
Subject: |
[taler-wallet-core] branch master updated: wallet-core: report supportedAgeGroups |
Date: |
Tue, 01 Nov 2022 15:31:51 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-core.
The following commit(s) were added to refs/heads/master by this push:
new d63a773bf wallet-core: report supportedAgeGroups
d63a773bf is described below
commit d63a773bf5f3b74040e094a94afb732be7218106
Author: Florian Dold <florian@dold.me>
AuthorDate: Tue Nov 1 15:31:48 2022 +0100
wallet-core: report supportedAgeGroups
---
packages/taler-util/src/taler-crypto.ts | 17 +++++++++++++++++
packages/taler-util/src/wallet-types.ts | 2 ++
packages/taler-wallet-core/src/db.ts | 5 +++++
packages/taler-wallet-core/src/operations/common.ts | 5 +++++
packages/taler-wallet-core/src/operations/exchanges.ts | 10 ++++++++++
5 files changed, 39 insertions(+)
diff --git a/packages/taler-util/src/taler-crypto.ts
b/packages/taler-util/src/taler-crypto.ts
index d7e9a0c06..b4b96afbc 100644
--- a/packages/taler-util/src/taler-crypto.ts
+++ b/packages/taler-util/src/taler-crypto.ts
@@ -1025,6 +1025,23 @@ export namespace AgeRestriction {
return count;
}
+ /**
+ * Get the starting points for age groups in the mask.
+ */
+ export function getAgeGroupsFromMask(mask: number): number[] {
+ const groups: number[] = [];
+ let age = 1;
+ let m = mask >> 1;
+ while (m > 0) {
+ if (m & 1) {
+ groups.push(age);
+ }
+ m = m >> 1;
+ age++;
+ }
+ return groups;
+ }
+
export function getAgeGroupIndex(mask: number, age: number): number {
invariant((mask & 1) === 1);
let i = 0;
diff --git a/packages/taler-util/src/wallet-types.ts
b/packages/taler-util/src/wallet-types.ts
index f6bc13d65..3eafe7522 100644
--- a/packages/taler-util/src/wallet-types.ts
+++ b/packages/taler-util/src/wallet-types.ts
@@ -919,6 +919,7 @@ export interface ExchangeListItem {
paytoUris: string[];
tosStatus: ExchangeTosStatus;
exchangeStatus: ExchangeEntryStatus;
+ supportedAgeGroups: number[];
/**
* Permanently added to the wallet, as opposed to just
* temporarily queried.
@@ -998,6 +999,7 @@ export const codecForExchangeListItem = ():
Codec<ExchangeListItem> =>
.property("tosStatus", codecForAny())
.property("exchangeStatus", codecForAny())
.property("permanent", codecForBoolean())
+ .property("supportedAgeGroups", codecForList(codecForNumber()))
.build("ExchangeListItem");
export const codecForExchangesListResponse = (): Codec<ExchangesListResponse>
=>
diff --git a/packages/taler-wallet-core/src/db.ts
b/packages/taler-wallet-core/src/db.ts
index ce0070e69..b68da8333 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -473,6 +473,11 @@ export interface ExchangeDetailsRecord {
| undefined;
wireInfo: WireInfo;
+
+ /**
+ * Age restrictions supported by the exchange (bitmask).
+ */
+ ageMask?: number;
}
export interface ExchangeTosRecord {
diff --git a/packages/taler-wallet-core/src/operations/common.ts
b/packages/taler-wallet-core/src/operations/common.ts
index 59d2b8ec3..3ac003da3 100644
--- a/packages/taler-wallet-core/src/operations/common.ts
+++ b/packages/taler-wallet-core/src/operations/common.ts
@@ -18,6 +18,7 @@
* Imports.
*/
import {
+ AgeRestriction,
AmountJson,
Amounts,
CoinRefreshRequest,
@@ -365,6 +366,7 @@ export function makeExchangeListItem(
paytoUris: [],
exchangeStatus: ExchangeEntryStatus.Unknown,
permanent: r.permanent,
+ supportedAgeGroups: [],
};
}
let exchangeStatus;
@@ -376,5 +378,8 @@ export function makeExchangeListItem(
paytoUris: exchangeDetails.wireInfo.accounts.map((x) => x.payto_uri),
exchangeStatus,
permanent: r.permanent,
+ supportedAgeGroups: exchangeDetails.ageMask
+ ? AgeRestriction.getAgeGroupsFromMask(exchangeDetails.ageMask)
+ : [],
};
}
diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts
b/packages/taler-wallet-core/src/operations/exchanges.ts
index a8c4fec10..63e71c36c 100644
--- a/packages/taler-wallet-core/src/operations/exchanges.ts
+++ b/packages/taler-wallet-core/src/operations/exchanges.ts
@@ -76,6 +76,7 @@ import {
runOperationHandlerForResult,
} from "../util/retries.js";
import { WALLET_EXCHANGE_PROTOCOL_VERSION } from "../versions.js";
+import { isWithdrawableDenom } from "./withdraw.js";
const logger = new Logger("exchanges.ts");
@@ -657,6 +658,14 @@ export async function updateExchangeFromUrlHandler(
let detailsPointerChanged = false;
+ let ageMask = 0;
+ for (const x of keysInfo.currentDenominations) {
+ if (isWithdrawableDenom(x) && x.denomPub.age_mask != 0) {
+ ageMask = x.denomPub.age_mask;
+ break;
+ }
+ }
+
const updated = await ws.db
.mktx((x) => [
x.exchanges,
@@ -699,6 +708,7 @@ export async function updateExchangeFromUrlHandler(
wireInfo,
tosCurrentEtag: tosDownload.tosEtag,
tosAccepted: existingTosAccepted,
+ ageMask,
};
if (existingDetails?.rowId) {
newDetails.rowId = existingDetails.rowId;
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-wallet-core] branch master updated: wallet-core: report supportedAgeGroups,
gnunet <=