diff --git a/DashWallet/Sources/Infrastructure/SwiftDashSDK/Contacts/ContactItem.swift b/DashWallet/Sources/Infrastructure/SwiftDashSDK/Contacts/ContactItem.swift index b2665511e..dac0a4690 100644 --- a/DashWallet/Sources/Infrastructure/SwiftDashSDK/Contacts/ContactItem.swift +++ b/DashWallet/Sources/Infrastructure/SwiftDashSDK/Contacts/ContactItem.swift @@ -119,12 +119,12 @@ struct ContactItem: Identifiable, Equatable { if let username, !username.isEmpty { return username.withoutDashSuffix } - return String(contactIdentityId.map { String(format: "%02x", $0) }.joined().prefix(8)) + "…" + return String(identityIdBase58.prefix(8)) + "…" } /// The identity id as users see it elsewhere — Platform explorers, the /// wallet's own identity list and the `dashpay://user` QR payload all read - /// base58, so a contact's id is shown the same way rather than as the hex - /// `displayTitle`'s fallback happens to use. + /// base58. `displayTitle`'s last-resort fallback truncates this same + /// string, so a contact reads the same way everywhere. var identityIdBase58: String { contactIdentityId.toBase58String() } } diff --git a/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/DWCurrentUserIdentityInfo.swift b/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/DWCurrentUserIdentityInfo.swift index 1e1a0c008..f9d6facef 100644 --- a/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/DWCurrentUserIdentityInfo.swift +++ b/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/DWCurrentUserIdentityInfo.swift @@ -113,7 +113,6 @@ public final class DWCurrentUserIdentityInfo: NSObject { /// on the next property access after `currentRevision` advances. private struct Snapshot { let identityId: Data? - let identityIdHex: String? let username: String? let usernames: [String] let displayName: String? @@ -122,7 +121,6 @@ public final class DWCurrentUserIdentityInfo: NSObject { static let empty = Snapshot( identityId: nil, - identityIdHex: nil, username: nil, usernames: [], displayName: nil, @@ -239,18 +237,11 @@ public final class DWCurrentUserIdentityInfo: NSObject { snapshot.publicMessage } - /// 32-byte identity ID rendered as lowercase hex (64 chars), or - /// nil when no identity is registered. Mirrors the format used - /// by `SDKIdentityProfileSheet` and the coordinator logs. - @objc public var identityIdHex: String? { - snapshot.identityIdHex - } - /// Raw 32-byte identity ID, or nil when no identity is registered. - /// Swift-only (SDK APIs take `Identifier` = `Data`); Obj-C callers - /// use `identityIdHex`. Added for the contacts service (Row #18), - /// which passes it as `ownerIdentityId` into the SwiftData - /// predicates and `ManagedPlatformWallet` contact calls. + /// Swift-only (SDK APIs take `Identifier` = `Data`). Added for the + /// contacts service (Row #18), which passes it as `ownerIdentityId` + /// into the SwiftData predicates and `ManagedPlatformWallet` contact + /// calls; the marketplace, invitation and send paths read it too. public var identityId: Data? { snapshot.identityId } @@ -575,7 +566,6 @@ public final class DWCurrentUserIdentityInfo: NSObject { return Snapshot( identityId: identityId, - identityIdHex: hex, username: username, usernames: usernames, displayName: displayName, diff --git a/DashWallet/Sources/UI/DashPay/Profile/SDKIdentityProfileSheet.swift b/DashWallet/Sources/UI/DashPay/Profile/SDKIdentityProfileSheet.swift index c9f993caf..71416e6a9 100644 --- a/DashWallet/Sources/UI/DashPay/Profile/SDKIdentityProfileSheet.swift +++ b/DashWallet/Sources/UI/DashPay/Profile/SDKIdentityProfileSheet.swift @@ -14,7 +14,7 @@ import DashUIKit struct SDKIdentityProfileSheet: View { @Environment(\.dismiss) private var dismiss - @State private var identityIdHex: String? = nil + @State private var identityIdBase58: String? = nil /// Owner's profile picture, read from the same identity snapshot the rest /// of the app renders from. nil → the deterministic initials placeholder. @State private var avatarURL: String? @@ -165,9 +165,9 @@ struct SDKIdentityProfileSheet: View { VStack(alignment: .leading, spacing: 16) { infoRow( title: NSLocalizedString("Identity ID", comment: "SDK identity profile sheet"), - value: identityIdHex ?? NSLocalizedString("Loading…", comment: ""), + value: identityIdBase58 ?? NSLocalizedString("Loading…", comment: ""), monospaced: true, - copyable: identityIdHex != nil + copyable: identityIdBase58 != nil ) identityBalanceRow } @@ -336,8 +336,9 @@ struct SDKIdentityProfileSheet: View { /// Look up the persisted identity ID from SwiftData. Mirrors the /// fetch pattern in `DWIdentityRegistrationCoordinator.lookupExistingIdentityId` /// (PersistentIdentity scoped to the active wallet); we render the - /// 32-byte id as lowercase hex matching the existing coordinator - /// logs (`identityId.map { String(format: "%02x", $0) }.joined()`). + /// 32-byte id as base58, the form Platform explorers, the contacts + /// list (`ContactItem.identityIdBase58`) and the `dashpay://user` QR + /// payload all use. Coordinator logs still print hex. private func loadIdentityId() { guard let walletId = SwiftDashSDKHost.shared.wallet?.walletId, @@ -352,7 +353,7 @@ struct SDKIdentityProfileSheet: View { ) descriptor.fetchLimit = 1 if let identity = try? context.fetch(descriptor).first { - identityIdHex = identity.identityId.map { String(format: "%02x", $0) }.joined() + identityIdBase58 = identity.identityId.toBase58String() identitySeed = identity.identityId identityIdData = identity.identityId // Stored as the Int64 bit-pattern of the UInt64 credits (see diff --git a/DashWallet/Sources/UI/Home/Views/ShieldedActivityHistory.swift b/DashWallet/Sources/UI/Home/Views/ShieldedActivityHistory.swift index 6f25c2657..a6b986064 100644 --- a/DashWallet/Sources/UI/Home/Views/ShieldedActivityHistory.swift +++ b/DashWallet/Sources/UI/Home/Views/ShieldedActivityHistory.swift @@ -94,8 +94,8 @@ struct ShieldedActivityItem: Identifiable { let minNotePosition: UInt64? /// Decoded UTF-8 text memo, when the 36-byte Dash memo is kind-1 text. let memoText: String? - /// Created identity id (hex) for `identityCreate` entries. - let createdIdentityIdHex: String? + /// Created identity id (base58) for `identityCreate` entries. + let createdIdentityIdBase58: String? /// Decoded destination, when the entry's counterparty names one: /// the Base58Check Core address for a withdrawal, the bech32m /// Platform address for an unshield. Nil for other kinds and for @@ -144,8 +144,8 @@ struct ShieldedActivityItem: Identifiable { : .distantPast minNotePosition = row.hasMinNotePosition ? row.minNotePosition : nil memoText = Self.decodeTextMemo(row.memo) - createdIdentityIdHex = effectiveKind == .identityCreate && row.identityId.count == 32 - ? row.identityId.map { String(format: "%02x", $0) }.joined() + createdIdentityIdBase58 = effectiveKind == .identityCreate && row.identityId.count == 32 + ? row.identityId.toBase58String() : nil } @@ -393,7 +393,7 @@ struct ShieldedActivityDetailsView: View { } .padding(.vertical, 10) } - if let identityId = item.createdIdentityIdHex { + if let identityId = item.createdIdentityIdBase58 { copyableRow(NSLocalizedString("Identity ID", comment: "Identities"), identityId) } infoRow( diff --git a/DashWallet/Sources/UI/Menu/Security/Wallets/IdentitiesViewModel.swift b/DashWallet/Sources/UI/Menu/Security/Wallets/IdentitiesViewModel.swift index 9171d5636..0718b0c44 100644 --- a/DashWallet/Sources/UI/Menu/Security/Wallets/IdentitiesViewModel.swift +++ b/DashWallet/Sources/UI/Menu/Security/Wallets/IdentitiesViewModel.swift @@ -356,7 +356,7 @@ final class IdentitiesViewModel: ObservableObject { let title = alias ?? displayedName ?? (pendingBelongsToIdentity ? pendingLabel : nil) - ?? (String(identity.identityIdString.prefix(12)) + "...") + ?? (String(identity.identityIdBase58.prefix(12)) + "...") let hasName = alias != nil || mainName != nil || preferredName != nil || !ownedNames.isEmpty // Balance is stored as Int64 bit-pattern of the UInt64 credits. let credits = UInt64(bitPattern: identity.balance)