aborted-credit-shows-the-whole-amount-as-fee.md (4907B)
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 # An aborted withdrawal says the whole amount went to fees 18 19 Found in the notes of the `abort_then_retry` scenario: a withdrawal that was 20 aborted before the bank confirmed it reads 21 22 ``` 23 This transaction was aborted 24 Chosen amount €5.00 25 Fee -€5.00 26 Total amount €0.00 27 ``` 28 29 Nothing was withdrawn and no fee was charged — the exchange never saw the 30 money — but the screen says the whole €5.00 was consumed by fees. 31 32 **Severity: low-moderate.** Cosmetic in the sense that no money moved, but it 33 is alarming in exactly the situation where a user is already unsure what 34 happened, it is reachable in a release build by anyone who aborts a 35 withdrawal, and the same arithmetic is used on three further screens. 36 37 ## What happens 38 39 The fee row is derived from the difference between the two amounts: 40 41 ```kotlin 42 // wallet/src/main/java/net/taler/wallet/withdraw/TransactionWithdrawalComposable.kt:171 43 if (t.amountRaw > t.amountEffective) { 44 val fee = t.amountRaw - t.amountEffective 45 TransactionAmountComposable( 46 label = stringResource(id = R.string.amount_fee), 47 amount = fee.withSpec(spec), 48 amountType = AmountType.Negative, 49 ) 50 } 51 ``` 52 53 For a successful withdrawal that is right: `amountRaw` is what the bank sends, 54 `amountEffective` what lands in the wallet, and the difference is the 55 withdrawal fee. For an aborted one wallet-core reports `amountEffective` of 56 zero, and the difference becomes the entire amount. 57 58 The same expression appears on every *credit* screen, so each of them makes 59 the same claim once its transaction is aborted or fails: 60 61 - `withdraw/TransactionWithdrawalComposable.kt:171` 62 - `peer/TransactionPeerPushCredit.kt` 63 - `peer/TransactionPeerPullCredit.kt` 64 - `refund/TransactionRefundComposable.kt` 65 66 The debit screens (payment, deposit, peer-push-debit, peer-pull-debit) use the 67 difference the other way round (`amountEffective > amountRaw`), which goes to 68 zero instead of to the full amount — an expired purchase correctly shows 69 "Total €1.00 / Paid €0.00" with no fee row at all. 70 71 ### An abandoned deposit: the same oracle, but probably not the same defect 72 73 `abandon_aborting_deposit` trips the oracle on a *debit*, and it is recorded 74 here rather than as its own finding because it may well be correct. A deposit 75 submitted while offline, then aborted, then abandoned reads 76 77 ``` 78 This transaction has failed or been abandoned 79 Chosen amount €0.98 80 Fee -€0.02 81 Amount sent -€1.00 82 ``` 83 84 and the money is genuinely gone — the balance went from €9.87 to €8.87 across 85 the abandon, which is what the confirmation dialog promises ("Funds still in 86 transit WILL GET LOST"). So "Amount sent −€1.00" is true. 87 88 What is doubtful is the **fee row**: the exchange never completed the deposit, 89 so it earned no €0.02 deposit fee; the whole €1.00 was lost in transit, not 90 split between a fee and a transfer. If that reading is right the screen should 91 show the loss as a loss rather than as a fee and a payment. A maintainer can 92 judge that faster than this campaign can — it is recorded, with the balances 93 either side, rather than asserted. 94 95 ## Reproduce by hand 96 97 1. On the main screen tap **Withdraw**, or follow a bank's withdrawal URI. 98 2. Confirm the withdrawal, so the wallet is waiting for the bank. 99 3. Tap **Abort**, and confirm. 100 4. The transaction now reads "This transaction was aborted", with 101 "Fee −€5.00" and "Total amount €0.00" under a "Chosen amount" of €5.00. 102 103 ## Reproduce with the simulator 104 105 ```bash 106 ssh root@tripwire.taler.net 107 cd /opt/taler-sim/driver 108 python3 ../findings/repro_aborted_fee.py # worker 0 by default 109 SIM_WORKER=4 python3 suite.py withdraw_abort # the scenario notes it too 110 ``` 111 112 ## Suggested fix 113 114 Show the fee row only when the difference is a fee: either gate it on the 115 transaction's state (`txState.major` of `Pending` or `Done`, not `Aborted`, 116 `Failed` or `Expired`), or, better, take the fee from the withdrawal's own 117 details rather than inferring it — wallet-core reports the fee structure, and 118 inferring it from two amounts means every state where one of them is zeroed 119 produces a wrong number. The same change applies to the three other credit 120 screens.