From ec43b6a5bf4f8064aaad7fc303a10c7f585a110e Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 1 Sep 2022 22:26:22 +0200 Subject: wallet-core: fix issue with crock encoding of age restrictions --- .../taler-wallet-core/src/crypto/cryptoImplementation.ts | 6 ++---- packages/taler-wallet-core/src/operations/withdraw.ts | 10 ++++++---- packages/taler-wallet-core/src/util/coinSelection.ts | 13 ++++++++----- 3 files changed, 16 insertions(+), 13 deletions(-) (limited to 'packages/taler-wallet-core') diff --git a/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts b/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts index 2f39f7806..f0a5cba2b 100644 --- a/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts +++ b/packages/taler-wallet-core/src/crypto/cryptoImplementation.ts @@ -1084,7 +1084,7 @@ export const nativeCryptoR: TalerCryptoInterfaceR = { s.age_commitment = depositInfo.ageCommitmentProof?.commitment.publicKeys; } else if (depositInfo.ageCommitmentProof) { - (s as any).h_age_commitment = hAgeCommitment; + (s as any).h_age_commitment = encodeCrock(hAgeCommitment); } return s; @@ -1518,9 +1518,7 @@ export const nativeCryptoR: TalerCryptoInterfaceR = { }); logger.info(`payto URI: ${req.reservePayto}`); - logger.info( - `signing WALLET_PURSE_MERGE over ${encodeCrock(mergeSigBlob)}`, - ); + logger.info(`signing WALLET_PURSE_MERGE over ${encodeCrock(mergeSigBlob)}`); const reserveSigBlob = buildSigPS( TalerSignaturePurpose.WALLET_ACCOUNT_MERGE, diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts index 1a73dc01c..9678258f0 100644 --- a/packages/taler-wallet-core/src/operations/withdraw.ts +++ b/packages/taler-wallet-core/src/operations/withdraw.ts @@ -242,7 +242,7 @@ export function selectWithdrawalDenominations( for (const d of denoms) { let count = 0; const cost = Amounts.add(d.value, d.feeWithdraw).amount; - for (; ;) { + for (;;) { if (Amounts.cmp(remaining, cost) < 0) { break; } @@ -903,7 +903,8 @@ export async function updateWithdrawalDenoms( denom.verificationStatus === DenominationVerificationStatus.Unverified ) { logger.trace( - `Validating denomination (${current + 1}/${denominations.length + `Validating denomination (${current + 1}/${ + denominations.length }) signature of ${denom.denomPubHash}`, ); let valid = false; @@ -1030,7 +1031,7 @@ async function queryReserve( if ( resp.status === 404 && result.talerErrorResponse.code === - TalerErrorCode.EXCHANGE_RESERVES_STATUS_UNKNOWN + TalerErrorCode.EXCHANGE_RESERVES_STATUS_UNKNOWN ) { ws.notify({ type: NotificationType.ReserveNotYetFound, @@ -1336,7 +1337,7 @@ export async function getExchangeWithdrawalInfo( ) { logger.warn( `wallet's support for exchange protocol version ${WALLET_EXCHANGE_PROTOCOL_VERSION} might be outdated ` + - `(exchange has ${exchangeDetails.protocolVersion}), checking for updates`, + `(exchange has ${exchangeDetails.protocolVersion}), checking for updates`, ); } } @@ -1869,6 +1870,7 @@ export async function acceptWithdrawalFromUri( confirmUrl: withdrawInfo.confirmTransferUrl, }, }, + restrictAge: req.restrictAge, forcedDenomSel: req.forcedDenomSel, reserveStatus: ReserveRecordStatus.RegisteringBank, }); diff --git a/packages/taler-wallet-core/src/util/coinSelection.ts b/packages/taler-wallet-core/src/util/coinSelection.ts index b3439067e..97e25abd3 100644 --- a/packages/taler-wallet-core/src/util/coinSelection.ts +++ b/packages/taler-wallet-core/src/util/coinSelection.ts @@ -291,11 +291,14 @@ export function selectPayCoins( aci.denomPub.age_mask, req.requiredMinimumAge, ); - if (!aci.ageCommitmentProof) { - // No age restriction, can't use for this payment - continue; - } - if (aci.ageCommitmentProof.proof.privateKeys.length < index) { + // if (!aci.ageCommitmentProof) { + // // No age restriction, can't use for this payment + // continue; + // } + if ( + aci.ageCommitmentProof && + aci.ageCommitmentProof.proof.privateKeys.length < index + ) { // Available age proofs to low, can't use for this payment continue; } -- cgit v1.2.3