Skip to content

Commit db1a908

Browse files
committed
added Kyoto stop service
1 parent c13fc74 commit db1a908

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

BDKSwiftExampleWallet/Service/BDK Service/BDKService.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ private class BDKService {
134134
func sentAndReceived(tx: Transaction) throws -> SentAndReceivedValues {
135135
try service.sentAndReceived(tx: tx)
136136
}
137+
138+
func stop() async throws {
139+
try await service.stopService()
140+
}
137141
}
138142

139143
extension BDKService {
@@ -170,6 +174,7 @@ struct BDKClient {
170174
let getEsploraURL: () -> String
171175
let updateNetwork: (Network) -> Void
172176
let updateEsploraURL: (String) -> Void
177+
let stop: () async throws -> Void
173178
}
174179

175180
extension BDKClient {
@@ -222,6 +227,9 @@ extension BDKClient {
222227
},
223228
updateEsploraURL: { newURL in
224229
BDKService.shared.updateEsploraURL(newURL)
230+
},
231+
stop: {
232+
try await BDKService.shared.stop()
225233
}
226234
)
227235
}
@@ -278,7 +286,8 @@ extension BDKClient {
278286
getNetwork: { .signet },
279287
getEsploraURL: { Constants.Config.EsploraServerURLNetwork.Signet.mutiny },
280288
updateNetwork: { _ in },
281-
updateEsploraURL: { _ in }
289+
updateEsploraURL: { _ in },
290+
stop: { }
282291
)
283292
}
284293
#endif

BDKSwiftExampleWallet/Service/BDKSyncService/BDKSyncService.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ protocol BDKSyncService {
3535
func send(address: String, amount: UInt64, feeRate: UInt64) async throws
3636
func listUnspent() throws -> [LocalOutput]
3737
func getAddress() throws -> String
38+
func stopService() async throws
3839
}
3940

4041
extension BDKSyncService {
@@ -264,13 +265,11 @@ extension BDKSyncService {
264265

265266
// MARK: - Optionals methods
266267

267-
func updateEsploraURL(_ url: String) {
268-
// Optional implementation
269-
}
268+
func updateEsploraURL(_ url: String) { }
270269

271-
func updateNetwork(network: Network) {
272-
// Optional implementation
273-
}
270+
func updateNetwork(network: Network) { }
271+
272+
func stopService() async throws { }
274273

275274
// MARK: - Private
276275

BDKSwiftExampleWallet/Service/BDKSyncService/KyotoService.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import BitcoinDevKit
99
import Foundation
1010

1111
final class KyotoService: BDKSyncService {
12-
12+
1313
private static let nodeHeight: UInt32 = 253_000
1414

1515
static let shared = KyotoService()
@@ -77,6 +77,10 @@ final class KyotoService: BDKSyncService {
7777

7878
}
7979

80+
func stopService() async throws {
81+
try await client?.shutdown()
82+
}
83+
8084
// MARK: - Private
8185

8286
private func buildNode(from wallet: Wallet, scanType: ScanType) throws -> CbfComponents {

0 commit comments

Comments
 (0)