summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/util/coinSelection.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-core/src/util/coinSelection.ts')
-rw-r--r--packages/taler-wallet-core/src/util/coinSelection.ts22
1 files changed, 19 insertions, 3 deletions
diff --git a/packages/taler-wallet-core/src/util/coinSelection.ts b/packages/taler-wallet-core/src/util/coinSelection.ts
index ba26c98fe..bfc481eaf 100644
--- a/packages/taler-wallet-core/src/util/coinSelection.ts
+++ b/packages/taler-wallet-core/src/util/coinSelection.ts
@@ -23,7 +23,12 @@
/**
* Imports.
*/
-import { AmountJson, Amounts, DenominationPubKey } from "@gnu-taler/taler-util";
+import {
+ AmountJson,
+ Amounts,
+ DenominationPubKey,
+ DenomKeyType,
+} from "@gnu-taler/taler-util";
import { strcmp, Logger } from "@gnu-taler/taler-util";
const logger = new Logger("coinSelection.ts");
@@ -215,10 +220,21 @@ function denomPubCmp(
} else if (p1.cipher > p2.cipher) {
return +1;
}
- if (p1.cipher !== 1 || p2.cipher !== 1) {
+ if (
+ p1.cipher === DenomKeyType.LegacyRsa &&
+ p2.cipher === DenomKeyType.LegacyRsa
+ ) {
+ return strcmp(p1.rsa_public_key, p2.rsa_public_key);
+ } else if (p1.cipher === DenomKeyType.Rsa && p2.cipher === DenomKeyType.Rsa) {
+ if ((p1.age_mask ?? 0) < (p2.age_mask ?? 0)) {
+ return -1;
+ } else if ((p1.age_mask ?? 0) > (p2.age_mask ?? 0)) {
+ return 1;
+ }
+ return strcmp(p1.rsa_public_key, p2.rsa_public_key);
+ } else {
throw Error("unsupported cipher");
}
- return strcmp(p1.rsa_public_key, p2.rsa_public_key);
}
/**