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
bug: spark exit funding is not watched after a restore #1296
After the wallet is restored from its recovery phrase on a new device, exit funding sent to a funding address at index 1 or above isn't watched. A user who restores after a failed salvage can leave that funding unrecovered, with no automatic way back.
Why
The next funding index is a counter in UserDefaults.standard, under sparkExitNextFundingIndex-<network>-<walletIndex> (Bitkit/Managers/SparkExitManager.swift:1174-1179, set at :964, given back at :545-546).
The only other input is the exit record stored on the device (SparkExitMath.nextFundingIndex, Bitkit/Services/SparkExit/SparkExitFunding.swift:585-588).
Bitkit's settings backup doesn't include the counter (Bitkit/Models/SettingsBackupConfig.swift).
The Spark exit backup holds only each leaf with its ancestor chain, with no funding data (unilateral_exit_backup.rs#L29-L34 at Spark SDK 0.28.0).
So after a restore from the phrase, the counter reads 0 and no record exists.
Unlike Android, an iCloud or Finder device backup restored onto a new iPhone can bring UserDefaults back. A restore from the phrase alone can't.
Raised by @pwltr in review 5850248225 on the Android twin, and checked against the SDK source.
Fix options
Scan funding addresses 0..N at start, up to a gap limit.
Or back up the counter with the exit backup or the settings backup.
Test
Set the counter to 3, clear UserDefaults and the exit record, restore from the seed, and assert that the next exit finds a UTXO at index 2.
Fixed in synonymdev/bitkit-ios#1217 (7622b77..31be1fe), which now closes this issue. The funding counter and the earlier exit addresses are in the VSS METADATA backup. A restore keeps the higher counter. Without a backed-up counter, the funding addresses are scanned (gap of 20, at most 1,000). Every funding address that still holds coins is watched again after a restore.
Activity
ovitrif commentedon Nov 11, 2026
Fixed in synonymdev/bitkit-ios#1217 (7622b77..31be1fe), which now closes this issue. The funding counter and the earlier exit addresses are in the VSS METADATA backup. A restore keeps the higher counter. Without a backed-up counter, the funding addresses are scanned (gap of 20, at most 1,000). Every funding address that still holds coins is watched again after a restore.
ovitrif commentedon Nov 12, 2026
Closed: fixed by #1217 on the Spark branch, which reached master through #1128 at 96225a1.