@@ -96,7 +96,7 @@ public class WalletService: ObservableObject {
9696 let candidate = filtered. filter { !$0. isImported } . sorted { $0. createdAt < $1. createdAt } . first
9797 if let cand = candidate {
9898 let ts = UInt32 ( cand. createdAt. timeIntervalSince1970)
99- if let h = client. getCheckpointHeight ( beforeTimestamp: ts) {
99+ if let h = await client. getCheckpointHeight ( beforeTimestamp: ts) {
100100 startHeight = h
101101 }
102102 } else {
@@ -116,14 +116,14 @@ public class WalletService: ObservableObject {
116116 }
117117 }
118118
119- try clientLocal. initialize ( dataDir: dataDir, masternodesEnabled: mnEnabled, startHeight: startHeight)
119+ try await clientLocal. initialize ( dataDir: dataDir, masternodesEnabled: mnEnabled, startHeight: startHeight)
120120
121121 // Start the SPV client
122- try clientLocal. start ( )
122+ try await clientLocal. start ( )
123123 print ( " ✅ SPV Client initialized and started successfully for \( net. rawValue) " )
124124
125125 // Seed UI with latest checkpoint height if we don't have a header yet
126- let seedHeight = clientLocal. getLatestCheckpointHeight ( )
126+ let seedHeight = await clientLocal. getLatestCheckpointHeight ( )
127127 await MainActor . run {
128128 if WalletService . shared. latestHeaderHeight == 0 , let cp = seedHeight {
129129 WalletService . shared. latestHeaderHeight = Int ( cp)
@@ -467,7 +467,7 @@ extension WalletService {
467467 Task . detached ( priority: . utility) {
468468 let clientBox = await MainActor . run { WalletService . shared [ keyPath: \WalletService . spvClient] . map ( SendableBox . init) }
469469 guard let client = clientBox? . value else { return }
470- guard let stats = client. getStats ( ) else { return }
470+ guard let stats = await client. getStats ( ) else { return }
471471 await MainActor . run {
472472 // Only overwrite with positive values; keep seeded values otherwise
473473 if stats. headerHeight > 0 {
@@ -529,21 +529,21 @@ extension WalletService: SPVClientDelegate {
529529 let denom = max ( 1.0 , Double ( targetHeight) - base)
530530 let headerPct = min ( 1.0 , max ( 0.0 , numer / denom) )
531531
532- let txPctFinal : Double = {
533- if let snap = client? . getSyncSnapshot ( ) , snap. headerHeight > 0 {
534- return min ( 1.0 , max ( 0.0 , Double ( snap. lastSyncedFilterHeight) / Double( snap. headerHeight) ) )
535- } else if let stats = client? . getStats ( ) , stats. headerHeight > 0 {
536- return min ( 1.0 , max ( 0.0 , Double ( stats. filterHeight) / Double( stats. headerHeight) ) )
537- }
538- return prevTx
539- } ( )
532+ let txPctFinal : Double
533+ if let snap = await client? . getSyncSnapshot ( ) , snap. headerHeight > 0 {
534+ txPctFinal = min ( 1.0 , max ( 0.0 , Double ( snap. lastSyncedFilterHeight) / Double( snap. headerHeight) ) )
535+ } else if let stats = await client? . getStats ( ) , stats. headerHeight > 0 {
536+ txPctFinal = min ( 1.0 , max ( 0.0 , Double ( stats. filterHeight) / Double( stats. headerHeight) ) )
537+ } else {
538+ txPctFinal = prevTx
539+ }
540540
541- let mnPctFinal : Double = {
542- if let snap = client? . getSyncSnapshot ( ) {
543- return snap. masternodesSynced ? 1.0 : 0.0
544- }
545- return prevMn
546- } ( )
541+ let mnPctFinal : Double
542+ if let snap = await client? . getSyncSnapshot ( ) {
543+ mnPctFinal = snap. masternodesSynced ? 1.0 : 0.0
544+ } else {
545+ mnPctFinal = prevMn
546+ }
547547
548548 await MainActor . run {
549549 WalletService . shared. headerProgress = headerPct
0 commit comments