Skip to content

Commit 1c2fd54

Browse files
committed
fix: add persist to replace takestaged+write
1 parent 725a3e5 commit 1c2fd54

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

BDKSwiftExampleWallet/Service/BDK Service/BDKService.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ private class BDKService {
3535
guard let wallet = self.wallet else {
3636
throw WalletError.walletNotFound
3737
}
38+
guard let connection = self.connection else {
39+
throw WalletError.dbNotFound
40+
}
3841
let addressInfo = wallet.revealNextAddress(keychain: .external)
42+
let _ = try wallet.persist(connection: connection)
3943
return addressInfo.address.description
4044
}
4145

@@ -213,6 +217,10 @@ private class BDKService {
213217
parallelRequests: UInt64(5)
214218
)
215219
let _ = try wallet.applyUpdate(update: update)
220+
guard let connection = self.connection else {
221+
throw WalletError.dbNotFound
222+
}
223+
let _ = try wallet.persist(connection: connection)
216224
}
217225

218226
func fullScanWithInspector(inspector: FullScanScriptInspector) async throws {
@@ -227,6 +235,10 @@ private class BDKService {
227235
parallelRequests: UInt64(5) // should we default value this for folks?
228236
)
229237
let _ = try wallet.applyUpdate(update: update)
238+
guard let connection = self.connection else {
239+
throw WalletError.dbNotFound
240+
}
241+
let _ = try wallet.persist(connection: connection)
230242
}
231243

232244
func calculateFee(tx: Transaction) throws -> Amount {

0 commit comments

Comments
 (0)