invoice_paid_for_storage overwrites account.storage instead of adding to it #11

Open
opened 2026-10-09 17:11:46 +00:00 by padreug · 0 comments
Owner

tasks.py:83-99 handles a settled storage purchase. For an existing account:

tasks.py:97    account.storage = storage_to_buy
tasks.py:98    account.sats += amount

sats accumulates, storage is assigned. A user who already bought storage and buys again ends up with only the new amount; the ledger says they paid twice. _validate_storage (relay/event_validator.py:96-98) gates writes on account.storage + free_storage_bytes_value, so the user's writable quota shrinks after paying for more.

Impact: money in, purchased capacity lost. Settlement-path defect.

Fix direction: account.storage += storage_to_buy. Add a test on the FakeWallet fast loop: buy twice, assert the sum. Note the new-account branch at :88-90 is correct.

Found during reforge run #1 (sandbox nostrrelay#5).

`tasks.py:83-99` handles a settled storage purchase. For an existing account: ``` tasks.py:97 account.storage = storage_to_buy tasks.py:98 account.sats += amount ``` `sats` accumulates, `storage` is assigned. A user who already bought storage and buys again ends up with only the new amount; the ledger says they paid twice. `_validate_storage` (`relay/event_validator.py:96-98`) gates writes on `account.storage + free_storage_bytes_value`, so the user's writable quota shrinks after paying for more. Impact: money in, purchased capacity lost. Settlement-path defect. Fix direction: `account.storage += storage_to_buy`. Add a test on the FakeWallet fast loop: buy twice, assert the sum. Note the new-account branch at `:88-90` is correct. Found during reforge run #1 (sandbox nostrrelay#5).
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
aiolabs/nostrrelay#11
No description provided.