add chaintip height to success message in wallet info and connection status screen when testing Electrum connection. Also add network chain check in these tests as well.
This commit is contained in:
parent
c3af212863
commit
ffdb2c237a
@ -105,7 +105,7 @@ struct ConnectionStatusView: View {
|
||||
if let result = testResult {
|
||||
Text(result)
|
||||
.font(.hbBody(13))
|
||||
.foregroundStyle(result.starts(with: "Success") ? Color.hbSuccess : Color.hbError)
|
||||
.foregroundStyle(result.starts(with: "Success") ? Color.hbSuccess : result.starts(with: "Warning") ? Color.hbBitcoinOrange : Color.hbError)
|
||||
}
|
||||
}
|
||||
.hbCard()
|
||||
@ -343,7 +343,17 @@ struct ConnectionStatusView: View {
|
||||
let config = wallet.electrumConfig
|
||||
do {
|
||||
let height = try await service.testElectrumConnection(config: config)
|
||||
testResult = "Success — chain tip at block \(height)"
|
||||
let network = wallet.bitcoinNetwork
|
||||
if network != .signet {
|
||||
if let detected = try? await service.detectElectrumNetwork(config: config),
|
||||
detected != network
|
||||
{
|
||||
testResult = "Warning: Server is \(detected.displayName), expected \(network.displayName)"
|
||||
isTesting = false
|
||||
return
|
||||
}
|
||||
}
|
||||
testResult = "Success — \(network.displayName) Chain Tip Height \(height)"
|
||||
} catch {
|
||||
testResult = "Failed: \(BitcoinService.friendlyElectrumError(error))"
|
||||
}
|
||||
|
||||
@ -235,7 +235,7 @@ struct WalletInfoView: View {
|
||||
if let result = connectionTestResult {
|
||||
Text(result)
|
||||
.font(.hbBody(13))
|
||||
.foregroundStyle(result.starts(with: "Success") ? Color.hbSuccess : Color.hbError)
|
||||
.foregroundStyle(result.starts(with: "Success") ? Color.hbSuccess : result.starts(with: "Warning") ? Color.hbBitcoinOrange : Color.hbError)
|
||||
}
|
||||
|
||||
HStack(spacing: 12) {
|
||||
@ -476,9 +476,19 @@ struct WalletInfoView: View {
|
||||
logger.info("Testing Electrum connection to \(config.url, privacy: .public)")
|
||||
Task {
|
||||
do {
|
||||
try await BitcoinService.shared.testElectrumConnection(config: config)
|
||||
let height = try await BitcoinService.shared.testElectrumConnection(config: config)
|
||||
logger.info("Electrum connection test succeeded")
|
||||
connectionTestResult = "Success — server responded to ping"
|
||||
let network = wallet.bitcoinNetwork
|
||||
if network != .signet {
|
||||
if let detected = try? await BitcoinService.shared.detectElectrumNetwork(config: config),
|
||||
detected != network
|
||||
{
|
||||
connectionTestResult = "Warning: Server is \(detected.displayName), expected \(network.displayName)"
|
||||
isTestingConnection = false
|
||||
return
|
||||
}
|
||||
}
|
||||
connectionTestResult = "Success — \(network.displayName) Chain Tip Height \(height)"
|
||||
} catch {
|
||||
logger.error("Electrum connection test failed: \(error)")
|
||||
connectionTestResult = "Failed: \(error.localizedDescription)"
|
||||
|
||||
@ -177,8 +177,9 @@ struct ElectrumServerSetupSection: View {
|
||||
let height = try await BitcoinService.shared.testElectrumConnection(config: config)
|
||||
// Verify network for mainnet, testnet3, testnet4 (skip signet)
|
||||
if expectedNetwork != .signet {
|
||||
let detected = try await BitcoinService.shared.detectElectrumNetwork(config: config)
|
||||
if let detected, detected != expectedNetwork {
|
||||
if let detected = try? await BitcoinService.shared.detectElectrumNetwork(config: config),
|
||||
detected != expectedNetwork
|
||||
{
|
||||
connectionTestResult = "Warning: Server is \(detected.displayName), expected \(expectedNetwork.displayName)"
|
||||
isTestingConnection = false
|
||||
return
|
||||
|
||||
Loading…
Reference in New Issue
Block a user