View Issue Details

IDProjectCategoryView StatusLast Update
0012273Talerexchangepublic2026-11-21 22:49
Reporterbot-oec [agent]  
ImplementerChristian Grothoff  
Estimated effort (hours)2 
PrioritynormalSeveritymajor 
Status implementing 
Target Version1.10 
Summary0012273: Coins offered to a reserve open request are charged although the exchange refuses it for too low a payment (402)
Description`post-reserves-RESERVE_PUB-open.rst` documents 402 "when the payment offered is insufficient for the requested operation"; such a refusal should charge nothing. `post-reserves-RESERVE_PUB-open.c` debits each coin's contribution (`insert_reserve_open_deposit`) before `exchange_do_reserve_open` computes the cost. When the payment is too low, the procedure returns without an error ("amount paid too low"); the handler commits the transaction and answers 402, so the coins' contributions are kept and nothing is bought. A retry with more is a new request (new `reserve_sig`), which does not count the earlier contributions.

The same holds, by reading the code, when nothing needs to change (the reserve is already open long enough, "no change required") and when the request is out of range: the coins are charged, the reserve payment is not.

**Steps to reproduce:**

1. A coin of EUR:5 offers EUR:0.015 to keep the reserve open for a year with five purses: 402.
2. Deposit EUR:5 from the coin: expected 200, gets 409 (insufficient residual value).

The test `src/testing/test_exchange_api_open_underpay.c` does this; it fails on master at step 2 (expects 200, gets 409). The test will be on branch `dev/oec/formalization-findings` on git.taler.net; a note here will name the commit.

**Proposed fix:** compute the cost before charging the coins, or roll the transaction back whenever `exchange_do_reserve_open` does not extend the reserve. A fix of the second kind in `post-reserves-RESERVE_PUB-open.c` (roll back when coins were offered and the reserve was not extended or nothing had to change) makes the test pass; the P2P tests still pass.

**Found by:** the formalization of the Taler protocols; the rule violated is (E0) in `spec/p2p.md` with the atomicity of handlers (`spec/notation.md`): a request whose payment is below the cost is refused with `PAYMENT_REQUIRED`, and nothing is charged.
TagsNo tags attached.

Required notifications

Address or linkRemarkAdded byNotifiedActions

Activities

bot-oec [agent]

2026-11-21 10:47

reporter   ~0030673

Test: branch `dev/oec/formalization-findings` of exchange.git (git.taler.net), commit f5170f90bce7 "testing: coins of a refused reserve open request (0012273)", on master 7b658d8da.

test_exchange_api_open_underpay_{cs,rsa}: a coin of EUR:5 offers EUR:0.015 to keep a reserve open for a year with five purses, which the exchange refuses (402); then EUR:5 are deposited from the coin: expected 200, gets 409 (insufficient residual value).

Fails on master at deposit-all.

bot-oec [agent]

2026-11-21 22:49

reporter   ~0030713

Proposed patch (exchange master ba48fdeac; with it test_exchange_api_open_underpay_{rsa,cs} from dev/oec/formalization-findings passes, and test_exchange_api_p2p_{rsa,cs} still pass). When coins were offered and the reserve was not extended (payment too low, request out of range, or the reserve already open long enough), the transaction is rolled back, so the coins' contributions are not kept; the reply is the same as before:

diff --git a/src/exchange/taler-exchange-httpd_post-reserves-RESERVE_PUB-open.c b/src/exchange/taler-exchange-httpd_post-reserves-RESERVE_PUB-open.c
index 0a76a5e45..07d5a6a21 100644
--- a/src/exchange/taler-exchange-httpd_post-reserves-RESERVE_PUB-open.c
+++ b/src/exchange/taler-exchange-httpd_post-reserves-RESERVE_PUB-open.c
@@ -309,6 +309,20 @@ reserve_open_transaction (void *cls,
           rsc->reserve_pub);
     return GNUNET_DB_STATUS_HARD_ERROR;
   }
+ if ( (rsc->payments_len > 0) &&
+ ( (GNUNET_TIME_timestamp_cmp (rsc->reserve_expiration,
+ <,
+ rsc->desired_expiration)) ||
+ (TALER_amount_is_zero (&rsc->open_cost)) ) )
+ {
+ /* Nothing was bought: the payment was too low, the request out of
+ range, or the reserve already open long enough. The coins'
+ contributions inserted above must not be kept. */
+ TALER_EXCHANGEDB_rollback (TEH_pg);
+ *mhd_ret = reply_reserve_open_success (connection,
+ rsc);
+ return GNUNET_DB_STATUS_HARD_ERROR;
+ }
   return qs;
 }

Issue History

Date ModifiedUsernameFieldChange
2026-11-21 10:28bot-oecNew Issue
2026-11-21 10:28bot-oecImplementer => oec
2026-11-21 10:28bot-oecReviewer => Christian Grothoff
2026-11-21 10:28bot-oecRelease signed by => Christian Grothoff
2026-11-21 10:28bot-oecDeployed by => Christian Grothoff
2026-11-21 10:28bot-oecVerifier => oec
2026-11-21 10:28bot-oecCommunicator => CM_7
2026-11-21 10:47bot-oecNote Added: 0030673
2026-11-21 16:15oecImplementeroec =>
2026-11-21 22:26Christian GrothoffLocked by => Christian Grothoff
2026-11-21 22:26Christian GrothoffStatusnew => planning
2026-11-21 22:27Christian GrothoffImplementer => Christian Grothoff
2026-11-21 22:27Christian GrothoffReviewerChristian Grothoff => oec
2026-11-21 22:27Christian GrothoffTarget Version => 1.10
2026-11-21 22:27Christian GrothoffStatusplanning => implementing
2026-11-21 22:27Christian GrothoffLocked byChristian Grothoff =>
2026-11-21 22:27Christian GrothoffEstimated effort (hours) => 2
2026-11-21 22:42Christian GrothoffView Statusprivate => public
2026-11-21 22:49bot-oecNote Added: 0030713