File tree Expand file tree Collapse file tree 3 files changed +20
-8
lines changed
BDKSwiftExampleWallet/Service Expand file tree Collapse file tree 3 files changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -134,6 +134,10 @@ private class BDKService {
134
134
func sentAndReceived( tx: Transaction ) throws -> SentAndReceivedValues {
135
135
try service. sentAndReceived ( tx: tx)
136
136
}
137
+
138
+ func stop( ) async throws {
139
+ try await service. stopService ( )
140
+ }
137
141
}
138
142
139
143
extension BDKService {
@@ -170,6 +174,7 @@ struct BDKClient {
170
174
let getEsploraURL : ( ) -> String
171
175
let updateNetwork : ( Network ) -> Void
172
176
let updateEsploraURL : ( String ) -> Void
177
+ let stop : ( ) async throws -> Void
173
178
}
174
179
175
180
extension BDKClient {
@@ -222,6 +227,9 @@ extension BDKClient {
222
227
} ,
223
228
updateEsploraURL: { newURL in
224
229
BDKService . shared. updateEsploraURL ( newURL)
230
+ } ,
231
+ stop: {
232
+ try await BDKService . shared. stop ( )
225
233
}
226
234
)
227
235
}
@@ -278,7 +286,8 @@ extension BDKClient {
278
286
getNetwork: { . signet } ,
279
287
getEsploraURL: { Constants . Config. EsploraServerURLNetwork. Signet. mutiny } ,
280
288
updateNetwork: { _ in } ,
281
- updateEsploraURL: { _ in }
289
+ updateEsploraURL: { _ in } ,
290
+ stop: { }
282
291
)
283
292
}
284
293
#endif
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ protocol BDKSyncService {
35
35
func send( address: String , amount: UInt64 , feeRate: UInt64 ) async throws
36
36
func listUnspent( ) throws -> [ LocalOutput ]
37
37
func getAddress( ) throws -> String
38
+ func stopService( ) async throws
38
39
}
39
40
40
41
extension BDKSyncService {
@@ -264,13 +265,11 @@ extension BDKSyncService {
264
265
265
266
// MARK: - Optionals methods
266
267
267
- func updateEsploraURL( _ url: String ) {
268
- // Optional implementation
269
- }
268
+ func updateEsploraURL( _ url: String ) { }
270
269
271
- func updateNetwork( network: Network ) {
272
- // Optional implementation
273
- }
270
+ func updateNetwork( network: Network ) { }
271
+
272
+ func stopService ( ) async throws { }
274
273
275
274
// MARK: - Private
276
275
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import BitcoinDevKit
9
9
import Foundation
10
10
11
11
final class KyotoService: BDKSyncService {
12
-
12
+
13
13
private static let nodeHeight : UInt32 = 253_000
14
14
15
15
static let shared = KyotoService ( )
@@ -77,6 +77,10 @@ final class KyotoService: BDKSyncService {
77
77
78
78
}
79
79
80
+ func stopService( ) async throws {
81
+ try await client? . shutdown ( )
82
+ }
83
+
80
84
// MARK: - Private
81
85
82
86
private func buildNode( from wallet: Wallet , scanType: ScanType ) throws -> CbfComponents {
You can’t perform that action at this time.
0 commit comments