wallet-core: fix withdrawal of age-restricted denoms without age restriction

This commit is contained in:
Florian Dold 2022-09-01 22:43:57 +02:00
parent ec43b6a5bf
commit 9fe0e74256
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B

View File

@ -674,16 +674,17 @@ export const nativeCryptoR: TalerCryptoInterfaceR = {
let maybeAcp: AgeCommitmentProof | undefined = undefined;
let maybeAgeCommitmentHash: string | undefined = undefined;
if (req.restrictAge) {
if (denomPub.age_mask === 0) {
if (req.restrictAge || denomPub.age_mask) {
if (req.restrictAge && denomPub.age_mask === 0) {
throw Error(
"requested age restriction for a denomination that does not support age restriction",
);
}
logger.info("creating age-restricted planchet");
const age = req.restrictAge || 32;
logger.info(`creating age-restricted planchet (age ${age})`);
maybeAcp = await AgeRestriction.restrictionCommit(
denomPub.age_mask,
req.restrictAge,
age,
);
maybeAgeCommitmentHash = AgeRestriction.hashCommitment(
maybeAcp.commitment,