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
swift-sdk: shielded spend wrappers on v5.1-dev run without native-operation admission, so Clear, wallet deletion or shutdown can overlap a payment #6060
clearShielded() also does not check ensureSyncNativeOpAllowed. So while one of these payments runs (its proof alone takes tens of seconds):
clearShielded() or deleteWallet(...) from another scene sharing the manager can run, and Clear can purge a signed retry record or note reservation the payment has just saved, while the payment still goes on to broadcast;
shutdown() does not wait for the payment before destroying the handle.
Rust's shield_guard serializes payments against each other, but these paths do not hold the guards teardown uses.
Where it showed up
Review of #6051, which adds app screens for shieldedShieldFromIdentity and shieldedIdentityTopUpFromPool (thread: #6051). The gap is in the wrappers and applies to every shielded payment the app already exposes, so it is tracked here.
Existing fix to follow
#5863 on v5.2-dev (commit aba2e7bb4a) does this for shieldedShieldFromIdentityToRecipient: the call is admitted from before the detached task until the result is delivered, clearShielded() calls ensureSyncNativeOpAllowed, and an injectable native-call seam lets tests pause a payment in flight. The same pattern should cover every wrapper listed above, with tests for Clear, deletion and shutdown during a paused payment.
One more item for the same wrapper follow-up, from the #6051 review: shieldedIdentityDebitRecoveryRecords runs its FFI call from Task.detached, and the export's block_on_worker parks that thread while the coordinator waits for the store lock with no deadline (a scan holds the write lock across its network batches). Reopening or refreshing a screen that reads the records during a slow scan can therefore stack parked threads. localShieldedBalanceSnapshot already bounds its native lock wait (100 ms) and admits as a native operation; the recovery read should do the same. SwiftExampleApp now coalesces these reads (#6051), which limits but does not remove it.
One more consequence to cover here, from the review of #6183.
A shielded Clear that runs while an identity top-up (type 22) or a private document create (type 29) waits for its result purges the spend's activity row. When the result then arrives, the handler finds no stored row, falls back to the Pending row it captured before the broadcast, writes it back as Confirmed and returns success (write_activity_status in rs-platform-wallet/src/wallet/shielded/operations.rs, the stored.as_ref().unwrap_or(entry) fallback). If the note scan had failed that row on proof before the Clear (#6151), that proof is gone with the row, so the protection #6183 adds does not apply.
The fallback is shared by every note spend's result handler and predates #6183. The fix belongs with the admission work: hold shared operation admission in the Rust entry points (shielded_identity_top_up_from_pool, create_private_document_entry, the private contact payment) through settlement, as the token transfer does, so Clear waits for the result. A test should run Clear between the scan failing the row and the snapshot settling.
#6179 admits the payment wrappers listed here except one, and closes this issue when it merges. What it leaves open, and where each item is tracked:
shieldedFundFromAssetLock (plus shieldedFundFromCoinJoinDrain and seedShieldedPoolNotes): not admitted. On v5.1-dev the fundings wait for a ChainLock with no deadline and shutdown() cannot cancel a native call, so admitting them let shutdown hang once the host had stopped SPV. Let shutdown cancel long-running shielded wallet operations #6003 (cancellation) has to land first.
Activity
QuantumExplorer commentedon Nov 22, 2026
One more item for the same wrapper follow-up, from the #6051 review:
shieldedIdentityDebitRecoveryRecordsruns its FFI call fromTask.detached, and the export'sblock_on_workerparks that thread while the coordinator waits for the store lock with no deadline (a scan holds the write lock across its network batches). Reopening or refreshing a screen that reads the records during a slow scan can therefore stack parked threads.localShieldedBalanceSnapshotalready bounds its native lock wait (100 ms) and admits as a native operation; the recovery read should do the same. SwiftExampleApp now coalesces these reads (#6051), which limits but does not remove it.QuantumExplorer commentedon Nov 23, 2026
One more consequence to cover here, from the review of #6183.
A shielded Clear that runs while an identity top-up (type 22) or a private document create (type 29) waits for its result purges the spend's activity row. When the result then arrives, the handler finds no stored row, falls back to the Pending row it captured before the broadcast, writes it back as Confirmed and returns success (
write_activity_statusinrs-platform-wallet/src/wallet/shielded/operations.rs, thestored.as_ref().unwrap_or(entry)fallback). If the note scan had failed that row on proof before the Clear (#6151), that proof is gone with the row, so the protection #6183 adds does not apply.The fallback is shared by every note spend's result handler and predates #6183. The fix belongs with the admission work: hold shared operation admission in the Rust entry points (
shielded_identity_top_up_from_pool,create_private_document_entry, the private contact payment) through settlement, as the token transfer does, so Clear waits for the result. A test should run Clear between the scan failing the row and the snapshot settling.QuantumExplorer commentedon Nov 24, 2026
#6179 admits the payment wrappers listed here except one, and closes this issue when it merges. What it leaves open, and where each item is tracked:
shieldedFundFromAssetLock(plusshieldedFundFromCoinJoinDrainandseedShieldedPoolNotes): not admitted. Onv5.1-devthe fundings wait for a ChainLock with no deadline andshutdown()cannot cancel a native call, so admitting them let shutdown hang once the host had stopped SPV. Let shutdown cancel long-running shielded wallet operations #6003 (cancellation) has to land first.clearShielded()is not gated in Swift. The decision is made in Rust instead: fix(platform-wallet): refuse a shielded Clear while a shielded operation runs #6182 makes the native Clear refuse while a shielded operation runs, and fix(platform-wallet): hold the lifecycle gate and Clear admission across credit pool spends #6178 makes the credit pool payments hold the admission it reads.shieldedIdentityDebitRecoveryRecords(the comment above): swift-sdk: shieldedIdentityDebitRecoveryRecords parks a thread with no deadline, and token pool watch/unwatch are not admitted #6177.