taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 5ab3e5ab92b7e2d24656315133b03cd739d423c9
parent 5ce1e53ef652bd991a5c790f95177dc4fe2f64db
Author: Florian Dold <dold@taler.net>
Date:   Wed, 22 Jul 2026 10:40:45 +0200

wallet: let a breached hard limit decide the limit check

Among the breached rules the one with the smallest threshold was picked and
classified on its own soft_limit flag, so a soft rule below a breached hard
rule reported the operation as merely requiring KYC.

Diffstat:
Mpackages/taler-wallet-core/src/kyc.ts | 19+++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/packages/taler-wallet-core/src/kyc.ts b/packages/taler-wallet-core/src/kyc.ts @@ -291,13 +291,20 @@ export async function checkLimit( ): Promise<LimitCheckResult> { let applicableLimit: AccountLimit | undefined; for (const rule of rules) { - // Check if a rule applies and is more specific - // (smaller threshold) - // than the previously handled rule (if any). if ( - rule.operation_type === operation && - Amounts.cmp(amount, rule.threshold) > 0 && - (applicableLimit == null || + rule.operation_type !== operation || + Amounts.cmp(amount, rule.threshold) <= 0 + ) { + continue; + } + // A rule that cannot be raised by passing KYC decides the outcome even + // when a soft rule with a smaller threshold is violated as well. + // Among rules of the same kind the more specific (smaller threshold) one + // applies. + if ( + applicableLimit == null || + (!!applicableLimit.soft_limit && !rule.soft_limit) || + (!!applicableLimit.soft_limit === !!rule.soft_limit && Amounts.cmp(rule.threshold, applicableLimit.threshold) < 0) ) { applicableLimit = rule;