@@ -23,13 +23,14 @@ protocol BDKSyncService {
2323
2424 func updateNetwork( network: Network )
2525 func updateEsploraURL( _ url: String )
26+
27+ func getTransactions( ) throws -> [ CanonicalTx ]
28+ func getBalance( ) throws -> Balance
2629}
2730
2831extension BDKSyncService {
2932 func buildWallet( params: String ? ) throws -> Wallet {
30- guard let newConnection = self . connection == nil ?
31- try Connection . createConnection ( ) :
32- self . connection else {
33+ guard let connection = self . connection else {
3334 throw WalletError . dbNotFound
3435 }
3536
@@ -45,7 +46,7 @@ extension BDKSyncService {
4546 descriptor: descriptor,
4647 changeDescriptor: changeDescriptor,
4748 network: network,
48- connection: newConnection
49+ connection: connection
4950 )
5051
5152 return wallet
@@ -151,18 +152,16 @@ extension BDKSyncService {
151152 }
152153
153154 func loadWalleFromBackup( ) throws -> Wallet {
155+ guard let connection = self . connection else {
156+ throw WalletError . dbNotFound
157+ }
158+
154159 let backupInfo = try keyClient. getBackupInfo ( )
155160 let descriptor = try Descriptor ( descriptor: backupInfo. descriptor, network: self . network)
156161 let changeDescriptor = try Descriptor (
157162 descriptor: backupInfo. changeDescriptor,
158163 network: self . network
159164 )
160-
161- try FileManager . default. ensureDirectoryExists ( at: URL . walletDataDirectoryURL)
162- try FileManager . default. removeOldFlatFileIfNeeded ( at: URL . defaultWalletDirectory)
163- let persistenceBackendPath = URL . persistenceBackendPath
164- let connection = try Connection ( path: persistenceBackendPath)
165-
166165 let wallet = try Wallet . load (
167166 descriptor: descriptor,
168167 changeDescriptor: changeDescriptor,
0 commit comments