taler-android

Android apps for GNU Taler (wallet, PoS, cashier)
Log | Files | Refs | README | LICENSE

refresh-fails-on-mixed-age-denominations.md (5300B)


      1 <!--
      2   This file is part of GNU Taler
      3   (C) 2026 Taler Systems S.A.
      4 
      5   GNU Taler is free software; you can redistribute it and/or modify it under the
      6   terms of the GNU General Public License as published by the Free Software
      7   Foundation; either version 3, or (at your option) any later version.
      8 
      9   GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
     10   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     11   A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     12 
     13   You should have received a copy of the GNU General Public License along with
     14   GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     15 -->
     16 
     17 # Change is lost when a denomination family mixes age-restricted and ordinary coins
     18 
     19 Found by the `refund` scenario in round 7, once the simulator's exchange was
     20 given age-restricted denominations alongside the ordinary ones.
     21 
     22 **Severity: moderate, and it applies to the shipped app.** What is certain is
     23 that the exchange refuses the melt and wallet-core retries the refresh group
     24 indefinitely — a permanent background failure on an ordinary spend. What is
     25 *not* established is money loss: in the run measured here the displayed balance
     26 after withdraw / pay / refund was exactly what the arithmetic predicts
     27 (EUR:8.75), with nothing shown as pending, so the user may see nothing wrong
     28 while a refresh churns underneath. Whether the affected coins remain spendable
     29 over a longer horizon was not determined.
     30 
     31 It only shows on an exchange that offers both kinds of denomination for the
     32 same value — which is exactly what an exchange supporting age restriction
     33 looks like.
     34 
     35 **Already fixed upstream**: wallet-core commit `efb714f76`, "wallet-core:
     36 preserve denomination age masks during refresh" (2026-09-14). The app ships
     37 `net.taler:qtart:1.6.42`, which is wallet-core `c2e11ad42` of 2026-09-01 —
     38 thirteen days older. Bumping `qtart_version` in `wallet/build.gradle` to a
     39 build that contains that commit is the fix here.
     40 
     41 ## What happens
     42 
     43 Withdraw, spend part of a coin, take a refund. The exchange rejects the melt
     44 that the refresh needs:
     45 
     46 ```json
     47 {"code":1365,
     48  "hint":"The client provided invalid age commitment data: missing, not an
     49          array, or array of invalid size.",
     50  "detail":"old_age_commitment_h"}
     51 ```
     52 
     53 `EXCHANGE_REFRESHES_REVEAL_AGE_RESTRICTION_COMMITMENT_INVALID`. wallet-core
     54 then reports the group as incomplete and keeps retrying:
     55 
     56 ```
     57 refresh:54W1D6A47J8PPS8EE681YRWCD5S2QACVM5GEK1MEGEQTGFFJ70CG:
     58   code 7029: Error (WALLET_REFRESH_GROUP_INCOMPLETE)
     59 refresh:54W1D6A47J8PPS8EE681YRWCD5S2QACVM5GEK1MEGEQTGFFJ70CG: retried 5 times
     60 ```
     61 
     62 In that one episode: 8 rejections from the exchange, 22 refresh-incomplete
     63 errors. The retry counter keeps climbing (5, then 8, …) for as long as the
     64 wallet is watched.
     65 
     66 Which member of the denomination family the wallet picks for the new coins
     67 decides whether the age mask matches, so it is not certain on every spend —
     68 but it is common: the reproducer below hit it on its **first** withdraw /
     69 spend / refund cycle (six rejections), while one earlier run of the `refund`
     70 scenario on the same stack produced none.
     71 
     72 ## Reproduce by hand
     73 
     74 1. Run an exchange that offers age-restricted *and* ordinary denominations for
     75    the same values. In the simulator's `backend/sim.conf` that is
     76    `AGE_RESTRICTION_ENABLED = YES` in `[exchange]` plus the `coin_eur_*` and
     77    `coin_eur_*_age_restricted` sections; `/keys` then advertises group age
     78    masks of both `0` and `2446593`.
     79 2. Install the wallet, enable **Developer mode**, and withdraw from that
     80    exchange (no age restriction needed).
     81 3. Pay for something that costs less than one coin — the remainder has to be
     82    refreshed into change.
     83 4. Take a refund for part of it.
     84 5. Watch `adb logcat | grep -E '"code":1365|REFRESH_GROUP_INCOMPLETE'`. When
     85    the wallet picks an incompatible family member, the rejection appears and
     86    repeats as the refresh is retried.
     87 
     88 Nothing is shown in the UI — no error, nothing pending — which is what makes
     89 this worth fixing even where the balance ends up right: a user has no way to
     90 know their wallet is retrying a request the exchange will always refuse.
     91 
     92 ## Reproduce with the simulator
     93 
     94 ```bash
     95 ssh root@tripwire.taler.net
     96 cd /opt/taler-sim/driver
     97 python3 ../findings/repro_age_restricted_refresh_fails.py        # three cycles
     98 python3 ../findings/repro_age_restricted_refresh_fails.py emulator-5562 5
     99 ```
    100 
    101 ## Why
    102 
    103 `refresh.ts` sends `old_age_commitment_h` with the melt, and the new coins
    104 have to be chosen with an age mask compatible with the old one. Before
    105 `efb714f76`, the denomination selected for the new coins could come from a
    106 different member of the same family — one with a different age mask — and the
    107 exchange rejects the reveal as inconsistent. The commit's own words: "Select a
    108 compatible member of each denomination family and use the same age-mask
    109 constraint for refresh cost estimates. Families can contain both restricted
    110 and unrestricted denominations."
    111 
    112 ## Suggested fix
    113 
    114 Bump `qtart_version` in `wallet/build.gradle` past wallet-core `efb714f76`,
    115 and keep an age-restriction-enabled exchange in whatever integration testing
    116 the app does — the defect is invisible without one, which is why it survived
    117 to a release.