Repository navigation
Description
TL;DR
Wallet record accounting should reject values that cannot be represented, without partially changing wallet state. Platform currently needs a temporary defensive restoration path to retain conflict information safely.
User story
As a wallet application developer, I want malformed or oversized stored transaction amounts to produce a typed error or an explicit unavailable-accounting result, while preserving spend/conflict protection.
Scenario
Restore a transaction record with owned output or attributed input values above i64::MAX, or values whose aggregate exceeds the supported range, then attribute a late funding transaction.
Actual: at aca020263990a86a15cc1d97ae2cbf965d488db5, TransactionRecord::recompute_net_and_direction casts u64 amounts with as i64, sums unchecked and subtracts unchecked. Its late-funding caller mutates input/output details before recomputing. Casts can produce incorrect amounts; arithmetic overflow can panic in checked builds or wrap when overflow checks are disabled.
Expected: checked accounting and an explicit failure/unavailable result before committing mutations; preserve transaction identity, input topology and finality needed for conflict handling.
Detailed discussion
Code inspection, not a new runtime reproduction:
Scope:
- Validate conversions, accumulation and net calculation with typed failure handling before mutation. Keep native callers safe too.
- Provide a supported restoration path that preserves conflict topology without fabricating representable accounting values or requiring hosts to edit record details directly.
- Cover individual and aggregate bounds, late attribution, no partial mutation on failure, and retained conflict protection in debug/release behavior.
Platform's restore_unreplayed_records temporarily sanitizes the in-memory accounting details while preserving stored details; it does not fix the owner-side late-attribution arithmetic. Wallet-wide spent claims in #1112 and shared downstream replay in dashpay/platform#5220 do not address this arithmetic contract. Once the owner API is available, replace the downstream sanitization.
🤖 Co-authored by Claudius the Magnificent AI Agent
Activity