diff options
author | Florian Dold <florian@dold.me> | 2021-11-27 20:56:58 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-11-27 20:57:07 +0100 |
commit | 5c4c25516df9d65d29dc7f3f38b5a2a1a8e9e374 (patch) | |
tree | 4665e79a6033ab949de211fd9de8de8ca681c2e0 /packages/taler-wallet-core/src/util | |
parent | 403de8170ef538ef74505859b1c04e3542cad9fb (diff) | |
download | wallet-core-5c4c25516df9d65d29dc7f3f38b5a2a1a8e9e374.tar.xz |
wallet: support both protocol versions
Diffstat (limited to 'packages/taler-wallet-core/src/util')
-rw-r--r-- | packages/taler-wallet-core/src/util/coinSelection.ts | 22 |
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); } /** |