You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
platform-wallet: make Rust the single source of Core transaction accounting (drop Swift re-derivation) #5226
The same wallet can therefore show different history on DET (SQLite) and iOS (SwiftData), and every checker or contact-ownership change must be made twice. packages/swift-sdk/CLAUDE.md already states that Rust owns this logic.
Follow-up: after the load-time replay, fold per-account slices into wallet-level records, diff them against the stored values, and emit only corrected records through the normal persist callbacks. Never downgrade a stored spend when prevout history is missing.
Delete the Swift re-derivation: reconcileTransactionAccounting, accountingDirty, reconciledAccounting, the preserveLockAccounting special case, and the related tests.
Add a parity test between the fold and SQLite repair_record.
Open decisions
Cross-wallet rows: a SwiftData PersistentTransaction is keyed by txid across all local wallets, while Rust emits per-wallet values. Proposal: add a spends_wallet_funds flag to TransactionRecordFFI and keep one precedence rule in Swift.
Live gap: if a spender is already chain-locked and pruned when its funding transaction is discovered later in the same session, Rust corrects the record only at the next load.
Summary
Make Rust the single source of Core transaction accounting (
net_amount,direction, ownership). Remove the independent re-derivation in the Swift SDK.Problem
Two implementations compute the same values with different rules:
reconcileTransactionAccountinginPlatformWalletPersistenceHandler.swift, run on load and at the end of each persistence round.core_history::repair_recordand the live wallet projection.Where they differ:
allOutputsOwned = false, and re-encodes contact exclusion from a raw account-type tag.The same wallet can therefore show different history on DET (SQLite) and iOS (SwiftData), and every checker or contact-ownership change must be made twice.
packages/swift-sdk/CLAUDE.mdalready states that Rust owns this logic.Plan
net_amountanddirection.reconcileTransactionAccounting,accountingDirty,reconciledAccounting, thepreserveLockAccountingspecial case, and the related tests.repair_record.Open decisions
PersistentTransactionis keyed by txid across all local wallets, while Rust emits per-wallet values. Proposal: add aspends_wallet_fundsflag toTransactionRecordFFIand keep one precedence rule in Swift.References
TODO(persist-accounting-backfill-marker),TODO(test-round-accounting-failure)(Swift).🤖 Generated with Claude Code