diff --git a/DashWallet.xcodeproj/project.pbxproj b/DashWallet.xcodeproj/project.pbxproj index a8ddafaa7d..63fcb4586c 100644 --- a/DashWallet.xcodeproj/project.pbxproj +++ b/DashWallet.xcodeproj/project.pbxproj @@ -84,6 +84,8 @@ 11E47BAB28EB38510097CFA0 /* SendCoinsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11E47BAA28EB38510097CFA0 /* SendCoinsService.swift */; }; 12BD10DCCEFF4142EA3BA0CA /* SwiftDashSDKWalletSending.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4BAA92B00D4109567DF870F /* SwiftDashSDKWalletSending.swift */; }; 12DE15416F9F7A0B8749CAF1 /* PaymentsLandingViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE64C10DA9C338D408982EBE /* PaymentsLandingViewModel.swift */; }; + 8820AD0A74800EDA9BBE4481 /* IdentityCreditsWatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06171096D5D5ACB796FB3D68 /* IdentityCreditsWatcher.swift */; }; + DAE070BBE395099DE28F91E4 /* ReceiveOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5686334C0BC09D6EC6968F6A /* ReceiveOption.swift */; }; 15F9C3B621487500E2919619 /* SendViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E6FAA6524ACE5F315B57AC3 /* SendViewModel.swift */; }; 16AA1B384A9758C1DA97676A /* SwiftDashSDKHost.swift in Sources */ = {isa = PBXBuildFile; fileRef = E181EB71C8803101EA789AA4 /* SwiftDashSDKHost.swift */; }; 17ED79A8B56522CD03A8CD5E /* ShieldedTransferCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D2C8F8102C5C603DB63569F /* ShieldedTransferCoordinator.swift */; }; @@ -1101,6 +1103,10 @@ AA0003032CA0F58E00B1B401 /* EnterAddressViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA0003012CA0F58E00B1B401 /* EnterAddressViewModel.swift */; }; AA0003042CA0F58E00A1B402 /* SwapAddressValidatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA0003032CA0F58E00A1B402 /* SwapAddressValidatorTests.swift */; }; 5A7E0C1D2E3F405162738495 /* VotingKeyFormatTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A7E0C1D2E3F405162738496 /* VotingKeyFormatTests.swift */; }; + BD63CE371BCBDC6C6C2B3E89 /* IdentityCreditsWatcherTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40915328799E60EFF1DED4BF /* IdentityCreditsWatcherTests.swift */; }; + 28B18F23C7ECDF7E68211209 /* PaymentsLandingIdentityOptionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC7EB895CF26FDCD2F8F324F /* PaymentsLandingIdentityOptionTests.swift */; }; + 5E423E4BDA2BBE9C7B3803BE /* IdentityTopUpEventTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3DE67DD53D3C7DB015A5F93 /* IdentityTopUpEventTests.swift */; }; + C36C1205E79FC632A5DE3F4D /* ReceiveOptionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20DFEF115C5EB3AFFC86490A /* ReceiveOptionTests.swift */; }; 5A7E0C1D2E3F405162738497 /* VotingKeyImportTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A7E0C1D2E3F405162738498 /* VotingKeyImportTests.swift */; }; AA0003052CA0F58E00B1B402 /* EnterAddressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA0003042CA0F58E00B1B402 /* EnterAddressView.swift */; }; AA0003062CA0F58E00B1B402 /* EnterAddressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA0003042CA0F58E00B1B402 /* EnterAddressView.swift */; }; @@ -1275,6 +1281,8 @@ C5745FA476F615D2C1E378F3 /* SwiftDashSDKReceiveAddressReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = A876A874736D422F781F797F /* SwiftDashSDKReceiveAddressReader.swift */; }; C5906424C3D379AF0CB83370 /* SendScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D1F21A7592E99814A800518 /* SendScreen.swift */; }; C6138156317BAF449AA76861 /* PaymentsLandingViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE64C10DA9C338D408982EBE /* PaymentsLandingViewModel.swift */; }; + 7DB78A53395396AAFA0395F1 /* IdentityCreditsWatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06171096D5D5ACB796FB3D68 /* IdentityCreditsWatcher.swift */; }; + 6EC85D43A6748BD1D7497C6F /* ReceiveOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5686334C0BC09D6EC6968F6A /* ReceiveOption.swift */; }; C017200000000000000CA2 /* ShieldedRecoverySheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = C017200000000000000CA1 /* ShieldedRecoverySheet.swift */; }; C017200000000000000CA3 /* ShieldedRecoverySheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = C017200000000000000CA1 /* ShieldedRecoverySheet.swift */; }; C017200000000000000DA2 /* ShieldedTransferStepList.swift in Sources */ = {isa = PBXBuildFile; fileRef = C017200000000000000DA1 /* ShieldedTransferStepList.swift */; }; @@ -2025,6 +2033,9 @@ 553696A24F315D361BC86231 /* VoteHistoryDAO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AFB72236D79932EAE7A38E2 /* VoteHistoryDAO.swift */; }; 7843C0A14DF4CBD4FFA605CD /* DWUsernameRegistrationRecovery.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF36BF1A7ACD652EDDA7D25D /* DWUsernameRegistrationRecovery.swift */; }; BABA10000000000000000002 /* DWIdentityBalanceRefresh.swift in Sources */ = {isa = PBXBuildFile; fileRef = BABA10000000000000000001 /* DWIdentityBalanceRefresh.swift */; }; + BABA10000000000000000102 /* IdentityTopUpDidComplete.swift in Sources */ = {isa = PBXBuildFile; fileRef = BABA10000000000000000101 /* IdentityTopUpDidComplete.swift */; }; + BABA10000000000000000202 /* IdentityTopUpsInFlight.swift in Sources */ = {isa = PBXBuildFile; fileRef = BABA10000000000000000201 /* IdentityTopUpsInFlight.swift */; }; + BABA10000000000000000203 /* IdentityTopUpsInFlight.swift in Sources */ = {isa = PBXBuildFile; fileRef = BABA10000000000000000201 /* IdentityTopUpsInFlight.swift */; }; F44028CBF49F4A2FE6268874 /* UsernameRegistrationRecoveryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 701E95B66E2409DD2F80D7AB /* UsernameRegistrationRecoveryTests.swift */; }; C0F1E5ED0A14B2C3D4E5F603 /* ContestedUsernameFeeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0F1E5ED0A14B2C3D4E5F604 /* ContestedUsernameFeeTests.swift */; }; 4046F707D79B443DF65A4A1B /* CreateUsernameShieldedCostTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D352A3186395D1462939197 /* CreateUsernameShieldedCostTests.swift */; }; @@ -3231,6 +3242,10 @@ AA0003012CA0F58E00B1B401 /* EnterAddressViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnterAddressViewModel.swift; sourceTree = ""; }; AA0003032CA0F58E00A1B402 /* SwapAddressValidatorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwapAddressValidatorTests.swift; sourceTree = ""; }; 5A7E0C1D2E3F405162738496 /* VotingKeyFormatTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VotingKeyFormatTests.swift; sourceTree = ""; }; + 40915328799E60EFF1DED4BF /* IdentityCreditsWatcherTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IdentityCreditsWatcherTests.swift; sourceTree = ""; }; + EC7EB895CF26FDCD2F8F324F /* PaymentsLandingIdentityOptionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentsLandingIdentityOptionTests.swift; sourceTree = ""; }; + A3DE67DD53D3C7DB015A5F93 /* IdentityTopUpEventTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IdentityTopUpEventTests.swift; sourceTree = ""; }; + 20DFEF115C5EB3AFFC86490A /* ReceiveOptionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReceiveOptionTests.swift; sourceTree = ""; }; 5A7E0C1D2E3F405162738498 /* VotingKeyImportTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VotingKeyImportTests.swift; sourceTree = ""; }; AA0003042CA0F58E00B1B402 /* EnterAddressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnterAddressView.swift; sourceTree = ""; }; AA0003072CA0F58E00B1B403 /* EnterAddressHostingController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnterAddressHostingController.swift; sourceTree = ""; }; @@ -3845,6 +3860,8 @@ FBF3F4301E42B02800C7248E /* ImageIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ImageIO.framework; path = System/Library/Frameworks/ImageIO.framework; sourceTree = SDKROOT; }; FE0000000000000000000061 /* ExtendedPublicKeysView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ExtendedPublicKeysView.swift; path = DashWallet/Sources/UI/Menu/Tools/ExtendedKeys/ExtendedPublicKeysView.swift; sourceTree = SOURCE_ROOT; }; FE64C10DA9C338D408982EBE /* PaymentsLandingViewModel.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = PaymentsLandingViewModel.swift; sourceTree = ""; }; + 06171096D5D5ACB796FB3D68 /* IdentityCreditsWatcher.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = IdentityCreditsWatcher.swift; sourceTree = ""; }; + 5686334C0BC09D6EC6968F6A /* ReceiveOption.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ReceiveOption.swift; sourceTree = ""; }; FF0000042DUMMYID001234567 /* DashSpend/PiggyCardsConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashSpend/PiggyCardsConstants.swift; sourceTree = ""; }; FF0000062DUMMYID001234567 /* PiggyCardsModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PiggyCardsModels.swift; sourceTree = ""; }; FF0000092DUMMYID001234567 /* BarcodeScanner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BarcodeScanner.swift; sourceTree = ""; }; @@ -3872,6 +3889,8 @@ 0AFB72236D79932EAE7A38E2 /* VoteHistoryDAO.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = VoteHistoryDAO.swift; sourceTree = ""; }; CF36BF1A7ACD652EDDA7D25D /* DWUsernameRegistrationRecovery.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DWUsernameRegistrationRecovery.swift; sourceTree = ""; }; BABA10000000000000000001 /* DWIdentityBalanceRefresh.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DWIdentityBalanceRefresh.swift; sourceTree = ""; }; + BABA10000000000000000101 /* IdentityTopUpDidComplete.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IdentityTopUpDidComplete.swift; sourceTree = ""; }; + BABA10000000000000000201 /* IdentityTopUpsInFlight.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IdentityTopUpsInFlight.swift; sourceTree = ""; }; 701E95B66E2409DD2F80D7AB /* UsernameRegistrationRecoveryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UsernameRegistrationRecoveryTests.swift; sourceTree = ""; }; C0F1E5ED0A14B2C3D4E5F604 /* ContestedUsernameFeeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContestedUsernameFeeTests.swift; sourceTree = ""; }; 4D352A3186395D1462939197 /* CreateUsernameShieldedCostTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateUsernameShieldedCostTests.swift; sourceTree = ""; }; @@ -6930,6 +6949,8 @@ E735446F9E918618E97EDD38 /* PaymentsLandingScreen.swift */, C0172000000000000003A1 /* PaymentsTabRootController.swift */, FE64C10DA9C338D408982EBE /* PaymentsLandingViewModel.swift */, + 06171096D5D5ACB796FB3D68 /* IdentityCreditsWatcher.swift */, + 5686334C0BC09D6EC6968F6A /* ReceiveOption.swift */, B401E660599FEF6B18087F91 /* PaymentsLandingHostingController.swift */, ); path = Landing; @@ -7365,6 +7386,10 @@ C5A11E0000000000000000F6 /* SelectCoinViewModelTests.swift */, C5A11E0000000000000000F4 /* SwapKitFailureDetailTests.swift */, 5A7E0C1D2E3F405162738496 /* VotingKeyFormatTests.swift */, + 40915328799E60EFF1DED4BF /* IdentityCreditsWatcherTests.swift */, + EC7EB895CF26FDCD2F8F324F /* PaymentsLandingIdentityOptionTests.swift */, + A3DE67DD53D3C7DB015A5F93 /* IdentityTopUpEventTests.swift */, + 20DFEF115C5EB3AFFC86490A /* ReceiveOptionTests.swift */, 5A7E0C1D2E3F405162738498 /* VotingKeyImportTests.swift */, AA00F1002FF0A10000A1B402 /* ExchangeAddressLookupContextTests.swift */, AA00100D2CA0B10001A0B10D /* SwapKitQuoteDecodingTests.swift */, @@ -7468,6 +7493,8 @@ D826C39F49D5CD6EC19C8C8E /* DWIdentityRegistrationCoordinator.swift */, CF36BF1A7ACD652EDDA7D25D /* DWUsernameRegistrationRecovery.swift */, BABA10000000000000000001 /* DWIdentityBalanceRefresh.swift */, + BABA10000000000000000101 /* IdentityTopUpDidComplete.swift */, + BABA10000000000000000201 /* IdentityTopUpsInFlight.swift */, D54F8E662513F09BA840FB94 /* DWIdentityRegistrationBridge.swift */, 5B30DA60B985C3CC3ED05B64 /* DWCurrentUserIdentityInfo.swift */, 82926C69F3BB675BEF1A1FFD /* DWProfileUpdateCoordinator.swift */, @@ -10505,6 +10532,9 @@ 15F9C3B621487500E2919619 /* SendViewModel.swift in Sources */, 8B8898971DC24152E171DABC /* PaymentsLandingScreen.swift in Sources */, 12DE15416F9F7A0B8749CAF1 /* PaymentsLandingViewModel.swift in Sources */, + 8820AD0A74800EDA9BBE4481 /* IdentityCreditsWatcher.swift in Sources */, + BABA10000000000000000203 /* IdentityTopUpsInFlight.swift in Sources */, + DAE070BBE395099DE28F91E4 /* ReceiveOption.swift in Sources */, 908AB7EFCC69D3828BBD70A8 /* PaymentsLandingHostingController.swift in Sources */, C029D3337FF6DAD231B33C4B /* SendToContactScreen.swift in Sources */, 1F2E9228002A59F638346E1F /* SendToContactViewController.swift in Sources */, @@ -10696,6 +10726,10 @@ C5A11E0000000000000000F7 /* SelectCoinViewModelTests.swift in Sources */, C5A11E0000000000000000F5 /* SwapKitFailureDetailTests.swift in Sources */, 5A7E0C1D2E3F405162738495 /* VotingKeyFormatTests.swift in Sources */, + BD63CE371BCBDC6C6C2B3E89 /* IdentityCreditsWatcherTests.swift in Sources */, + 28B18F23C7ECDF7E68211209 /* PaymentsLandingIdentityOptionTests.swift in Sources */, + 5E423E4BDA2BBE9C7B3803BE /* IdentityTopUpEventTests.swift in Sources */, + C36C1205E79FC632A5DE3F4D /* ReceiveOptionTests.swift in Sources */, 5A7E0C1D2E3F405162738497 /* VotingKeyImportTests.swift in Sources */, AA00F1012FF0A10000A1B402 /* ExchangeAddressLookupContextTests.swift in Sources */, AA00100E2CA0B10001A0B10E /* SwapKitQuoteDecodingTests.swift in Sources */, @@ -11563,6 +11597,8 @@ F4202BDB27E7066201C23A58 /* DWIdentityRegistrationCoordinator.swift in Sources */, 7843C0A14DF4CBD4FFA605CD /* DWUsernameRegistrationRecovery.swift in Sources */, BABA10000000000000000002 /* DWIdentityBalanceRefresh.swift in Sources */, + BABA10000000000000000102 /* IdentityTopUpDidComplete.swift in Sources */, + BABA10000000000000000202 /* IdentityTopUpsInFlight.swift in Sources */, A11E57A70006C0DE0006B006 /* DWInvitationLinkNormalizer.swift in Sources */, A11E57A70007C0DE0007B007 /* DWInvitationService.swift in Sources */, C85067CBF3243AC0B42E9A2C /* InvitationValidation.swift in Sources */, @@ -11619,6 +11655,8 @@ E932B50D2C8449B6C2A8A6E0 /* SendToContactViewModel.swift in Sources */, 6D5D6EFD5F40D11B2FB6E8A1 /* PaymentsLandingScreen.swift in Sources */, C6138156317BAF449AA76861 /* PaymentsLandingViewModel.swift in Sources */, + 7DB78A53395396AAFA0395F1 /* IdentityCreditsWatcher.swift in Sources */, + 6EC85D43A6748BD1D7497C6F /* ReceiveOption.swift in Sources */, 72F0556F329AE232966A8B4A /* PaymentsLandingHostingController.swift in Sources */, 1C2999FF1FC854E7DB138250 /* TransferTimingSheet.swift in Sources */, FF4A426923D0CF755AE981FB /* InternalTransferViewModel.swift in Sources */, diff --git a/DashWallet/Sources/Infrastructure/SwiftDashSDK/AssetLockRecoveryService.swift b/DashWallet/Sources/Infrastructure/SwiftDashSDK/AssetLockRecoveryService.swift index ba5afa565e..7eb894acc0 100644 --- a/DashWallet/Sources/Infrastructure/SwiftDashSDK/AssetLockRecoveryService.swift +++ b/DashWallet/Sources/Infrastructure/SwiftDashSDK/AssetLockRecoveryService.swift @@ -641,10 +641,27 @@ struct AssetLockRecoveryService { txidWire: txidWire, vout: vout, walletIdHex: walletIdHex, retryUnverifiedConsumption: retryUnverifiedConsumption ) { - _ = try await wallet.resumeTopUpWithAssetLock( - identityId: identityId, - outPointTxid: txidWire, - outPointVout: vout) + let resume = { + try await wallet.resumeTopUpWithAssetLock( + identityId: identityId, + outPointTxid: txidWire, + outPointVout: vout) + } + // Announced like every other own top-up (ADR-0034), so the watched + // Identity card raises no Receipt for it. The lock's value is the + // most it can add; without the lock row or a network it is not + // announced, as nothing true can be said about the credits. + if let network = SwiftDashSDKHost.shared.runningNetwork, + let container = SwiftDashSDKHost.shared.modelContainer, + let lock = try? Self.persistedLock(txidWire: txidWire, vout: vout, in: container.mainContext), + lock.amountDuffs > 0 { + _ = try await IdentityTopUpDidComplete.announcing( + walletId: wallet.walletId, network: network, identityId: identityId, + suppliedCredits: UInt64(lock.amountDuffs) * PlatformPaymentIdentityFundingPolicy.creditsPerDuff, + resume) + } else { + _ = try await resume() + } } DWCurrentUserIdentityInfo.shared.refreshFromSDK() return outcome diff --git a/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/DWCurrentUserIdentityInfo.swift b/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/DWCurrentUserIdentityInfo.swift index fd1b5aca42..dd330545b3 100644 --- a/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/DWCurrentUserIdentityInfo.swift +++ b/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/DWCurrentUserIdentityInfo.swift @@ -307,10 +307,14 @@ public final class DWCurrentUserIdentityInfo: NSObject { /// Fetch Platform credits and let the SDK persist them before invalidating UI. /// Capturing the wallet instance prevents a late response being applied to a /// newly selected wallet/network, even if the wallet IDs happen to match. + /// + /// Returns the credits read, or the failure; a failed read leaves the stored + /// balance as it was. + @discardableResult @nonobjc func refreshBalanceFromNetwork( identityId: Data, wallet: ManagedPlatformWallet, network: Network - ) async { + ) async -> Result { await IdentityBalanceRefresh.run( isCurrent: { let host = SwiftDashSDKHost.shared diff --git a/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/DWIdentityBalanceRefresh.swift b/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/DWIdentityBalanceRefresh.swift index 6edaaedb80..4c41f5ca08 100644 --- a/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/DWIdentityBalanceRefresh.swift +++ b/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/DWIdentityBalanceRefresh.swift @@ -10,25 +10,35 @@ enum IdentityBalanceRefresh { let identityId: Data } + /// The read was skipped or its answer dropped: the wallet, network or + /// identity it was for is no longer current, or the task was cancelled. + struct Superseded: Error {} + + /// Returns the balance read from the network, or why there is none — never + /// the stored balance and never zero in place of a failed read. + @discardableResult static func run( isCurrent: () -> Bool, previousBalance: () -> UInt64? = { nil }, refresh: () async throws -> UInt64, publish: (UInt64) -> Void, onFailure: (Error) -> Void - ) async { - guard !Task.isCancelled, isCurrent() else { return } + ) async -> Result { + guard !Task.isCancelled, isCurrent() else { return .failure(Superseded()) } let previous = previousBalance() do { let balance = try await refresh() - guard !Task.isCancelled, isCurrent() else { return } + guard !Task.isCancelled, isCurrent() else { return .failure(Superseded()) } // Still perform the SDK read and persistence flush when unchanged. - guard previous != balance else { return } - publish(balance) + if previous != balance { + publish(balance) + } + return .success(balance) } catch { // A failed read must not turn a confirmed DPNS registration into // a failure or replace the last known balance with zero. onFailure(error) + return .failure(error) } } } diff --git a/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/DWIdentityRegistrationCoordinator.swift b/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/DWIdentityRegistrationCoordinator.swift index e325cfb856..102f03932e 100644 --- a/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/DWIdentityRegistrationCoordinator.swift +++ b/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/DWIdentityRegistrationCoordinator.swift @@ -61,7 +61,7 @@ import SwiftDashSDK /// transition builder. Only the actual transition fee is deducted; unused /// reserve remains in the Platform-Payment address. enum PlatformPaymentIdentityFundingPolicy { - static let creditsPerDuff: UInt64 = 1_000 + static let creditsPerDuff = PlatformCreditsFormatter.creditsPerDuff /// 0.002 DASH of headroom reserved on the fee-source (BTreeMap input 0) /// address. The observed identity-from-addresses base fee is ~0.0004 DASH @@ -1464,21 +1464,29 @@ final class DWIdentityRegistrationCoordinator: ObservableObject { } let inputCheck = Self.coreInputCheck(amountDuffs: topUpDuffs) try AssetLockInputLimit.requireFits(inputCheck) - _ = try await AssetLockInputLimit.mappingRefusal(inputCheck) { - try await wallet.topUpIdentityWithFunding( - identityId: identityId, - amountDuffs: topUpDuffs, - accountIndex: Self.defaultAccountIndex) + _ = try await IdentityTopUpDidComplete.announcing( + walletId: wallet.walletId, network: network, identityId: identityId, + suppliedCredits: topUpDuffs * PlatformPaymentIdentityFundingPolicy.creditsPerDuff) { + try await AssetLockInputLimit.mappingRefusal(inputCheck) { + try await wallet.topUpIdentityWithFunding( + identityId: identityId, + amountDuffs: topUpDuffs, + accountIndex: Self.defaultAccountIndex) + } } case .platformPayment: let inputs = try buildPlatformPaymentInputs( walletId: wallet.walletId, modelContainer: plan.modelContainer, targetCredits: topUpDuffs * PlatformPaymentIdentityFundingPolicy.creditsPerDuff) - _ = try await wallet.topUpFromAddresses( - identityId: identityId, - inputs: inputs, - addressSigner: signer) + _ = try await IdentityTopUpDidComplete.announcing( + walletId: wallet.walletId, network: network, identityId: identityId, + suppliedCredits: topUpDuffs * PlatformPaymentIdentityFundingPolicy.creditsPerDuff) { + try await wallet.topUpFromAddresses( + identityId: identityId, + inputs: inputs, + addressSigner: signer) + } SwiftDashSDKWalletState.shared.refreshPlatformPaymentCredits() case .shielded: throw CoordinatorError.shieldedTopUpUnavailable(neededDuffs: topUpDuffs) @@ -1996,11 +2004,15 @@ final class DWIdentityRegistrationCoordinator: ObservableObject { let shortfallDuffs = Self.purchaseTopUpDuffs(priceCredits: priceCredits, heldCredits: heldCredits) if shortfallDuffs > 0 { Self.logger.info("🪪 IDENT-COORD :: purchase top-up shortfallDuffs=\(shortfallDuffs)") - _ = try await AssetLockInputLimit.mappingRefusal(Self.coreInputCheck(amountDuffs: shortfallDuffs)) { - try await wallet.topUpIdentityWithFunding( - identityId: existingId, - amountDuffs: shortfallDuffs, - accountIndex: Self.defaultAccountIndex) + _ = try await IdentityTopUpDidComplete.announcing( + walletId: wallet.walletId, network: network, identityId: existingId, + suppliedCredits: shortfallDuffs * PlatformPaymentIdentityFundingPolicy.creditsPerDuff) { + try await AssetLockInputLimit.mappingRefusal(Self.coreInputCheck(amountDuffs: shortfallDuffs)) { + try await wallet.topUpIdentityWithFunding( + identityId: existingId, + amountDuffs: shortfallDuffs, + accountIndex: Self.defaultAccountIndex) + } } } } else { diff --git a/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/IdentityTopUpDidComplete.swift b/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/IdentityTopUpDidComplete.swift new file mode 100644 index 0000000000..c15162e8d5 --- /dev/null +++ b/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/IdentityTopUpDidComplete.swift @@ -0,0 +1,80 @@ +import Foundation +import SwiftDashSDK + +/// Posted once after a top-up of an identity from this wallet completes, with +/// the balance its transition returned and the credits it was handed +/// (ADR-0034): by `IdentityTopUpViewModel.topUp`, by +/// `DWIdentityRegistrationCoordinator` for the top-ups it makes before a +/// registration or a name purchase, and by `AssetLockRecoveryService` for a +/// top-up retried from its asset lock. Always posted on the main actor. +struct IdentityTopUpDidComplete: Equatable { + static let name = Notification.Name("IdentityTopUpDidComplete") + + let walletId: Data + let network: Network + let identityId: Data + /// The identity's balance the top-up's transition returned. + let balanceAfter: UInt64 + /// The credits handed to the transition, the most it can have added. + let suppliedCredits: UInt64 + + init(walletId: Data, network: Network, identityId: Data, balanceAfter: UInt64, suppliedCredits: UInt64) { + self.walletId = walletId + self.network = network + self.identityId = identityId + self.balanceAfter = balanceAfter + self.suppliedCredits = suppliedCredits + } + + init?(notification: Notification) { + guard notification.name == Self.name, let event = notification.object as? Self else { return nil } + self = event + } + + @MainActor + func post(to center: NotificationCenter = .default) { + center.post(name: Self.name, object: self) + } + + /// Posts the event for a completed top-up (`balanceAfter` non-nil) and + /// nothing for a cancelled or failed one. + @MainActor + static func announce( + balanceAfter: UInt64?, + suppliedCredits: UInt64, + walletId: Data, + network: Network, + identityId: Data, + center: NotificationCenter = .default + ) { + guard let balanceAfter else { return } + IdentityTopUpDidComplete( + walletId: walletId, network: network, identityId: identityId, + balanceAfter: balanceAfter, suppliedCredits: suppliedCredits) + .post(to: center) + } + + /// Runs `topUp`, which returns the identity's balance after it, and + /// announces it when it returns; a top-up that throws announces nothing. + /// The top-up is in `inFlight` from before `topUp` runs until after the + /// event is posted or `topUp` throws. + @MainActor + static func announcing( + walletId: Data, + network: Network, + identityId: Data, + suppliedCredits: UInt64, + center: NotificationCenter = .default, + inFlight: IdentityTopUpsInFlight = .shared, + _ topUp: () async throws -> UInt64 + ) async rethrows -> UInt64 { + let key = IdentityTopUpsInFlight.Key(walletId: walletId, network: network, identityId: identityId) + inFlight.begin(key) + defer { inFlight.end(key) } + let balanceAfter = try await topUp() + announce( + balanceAfter: balanceAfter, suppliedCredits: suppliedCredits, + walletId: walletId, network: network, identityId: identityId, center: center) + return balanceAfter + } +} diff --git a/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/IdentityTopUpsInFlight.swift b/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/IdentityTopUpsInFlight.swift new file mode 100644 index 0000000000..5b3f0f975d --- /dev/null +++ b/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/IdentityTopUpsInFlight.swift @@ -0,0 +1,41 @@ +import Foundation +import SwiftDashSDK + +/// The own top-ups of each identity that are running now (ADR-0034). +/// +/// Platform raises an identity's balance a little before the top-up call +/// returns and `IdentityTopUpDidComplete` is posted, so the Identity option's +/// watch asks this registry before it takes a rise for a payment. +/// `IdentityTopUpDidComplete.announcing` and `IdentityTopUpViewModel.topUp` +/// register every top-up they run, from before the SDK call until after the +/// event is posted or the call throws. +/// +/// `shared` is process-wide on purpose: a top-up can start before the Receive +/// screen that watches its identity exists (the username flow closes while its +/// top-up still runs), so the record cannot belong to that screen. Tests inject +/// their own instance. +@MainActor +final class IdentityTopUpsInFlight { + struct Key: Hashable { + let walletId: Data + let network: Network + let identityId: Data + } + + static let shared = IdentityTopUpsInFlight() + + private var counts: [Key: Int] = [:] + + func begin(_ key: Key) { + counts[key, default: 0] += 1 + } + + func end(_ key: Key) { + guard let count = counts[key] else { return } + counts[key] = count > 1 ? count - 1 : nil + } + + func contains(_ key: Key) -> Bool { + counts[key] != nil + } +} diff --git a/DashWallet/Sources/Infrastructure/SwiftDashSDK/PlatformCreditsFormatter.swift b/DashWallet/Sources/Infrastructure/SwiftDashSDK/PlatformCreditsFormatter.swift index 798e787540..efa1d29a5c 100644 --- a/DashWallet/Sources/Infrastructure/SwiftDashSDK/PlatformCreditsFormatter.swift +++ b/DashWallet/Sources/Infrastructure/SwiftDashSDK/PlatformCreditsFormatter.swift @@ -7,6 +7,7 @@ import Foundation enum PlatformCreditsFormatter { static let creditsPerDash: UInt64 = 100_000_000_000 + static let creditsPerDuff: UInt64 = 1_000 /// Credits rendered as DASH at full credit precision, with no grouping and /// trailing zeros trimmed. diff --git a/DashWallet/Sources/UI/DashPay/Profile/SDKIdentityProfileSheet.swift b/DashWallet/Sources/UI/DashPay/Profile/SDKIdentityProfileSheet.swift index 9f1fe66c6b..2cb0b23397 100644 --- a/DashWallet/Sources/UI/DashPay/Profile/SDKIdentityProfileSheet.swift +++ b/DashWallet/Sources/UI/DashPay/Profile/SDKIdentityProfileSheet.swift @@ -601,7 +601,44 @@ final class IdentityTopUpViewModel: ObservableObject { } /// nil = cancelled or failed (errorMessage carries the failure). + /// + /// A completed top-up posts `IdentityTopUpDidComplete` with the balance it + /// returned, so Receive raises no Receipt for the wallet's own top-up; while + /// it runs it is in `IdentityTopUpsInFlight`. func topUp(identityId: Data, amountDuffs: UInt64, source: FundingSource) async -> UInt64? { + let wallet = SwiftDashSDKHost.shared.wallet + let network = SwiftDashSDKHost.shared.runningNetwork + var key: IdentityTopUpsInFlight.Key? + if let wallet, let network { + key = .init(walletId: wallet.walletId, network: network, identityId: identityId) + } + if let key { IdentityTopUpsInFlight.shared.begin(key) } + defer { if let key { IdentityTopUpsInFlight.shared.end(key) } } + let balanceAfter = await executeTopUp(identityId: identityId, amountDuffs: amountDuffs, source: source) + if let wallet, let network { + IdentityTopUpDidComplete.announce( + balanceAfter: balanceAfter, + suppliedCredits: Self.suppliedCredits(amountDuffs: amountDuffs, source: source), + walletId: wallet.walletId, + network: network, + identityId: identityId) + } + return balanceAfter + } + + /// The credits `source` hands to the identity for `amountDuffs`, before + /// the transition's fee: the whole amount, except on the Shielded route, + /// which claims it less the policy's fee headroom (the headroom stays at + /// the wallet's own Platform address). + static func suppliedCredits(amountDuffs: UInt64, source: FundingSource) -> UInt64 { + let credits = amountDuffs * PlatformPaymentIdentityFundingPolicy.creditsPerDuff + guard source == .shielded, credits > PlatformPaymentIdentityFundingPolicy.feeHeadroomCredits else { + return credits + } + return credits - PlatformPaymentIdentityFundingPolicy.feeHeadroomCredits + } + + private func executeTopUp(identityId: Data, amountDuffs: UInt64, source: FundingSource) async -> UInt64? { guard canTopUp(from: source) else { return nil } guard let wallet = SwiftDashSDKHost.shared.wallet, let modelContainer = SwiftDashSDKHost.shared.modelContainer else { @@ -731,9 +768,7 @@ final class IdentityTopUpViewModel: ObservableObject { // supplied credits; the unclaimed headroom stays at the address // (it is the wallet's own Platform balance, not lost). stepLabel = NSLocalizedString("Step 2 of 2 — topping up your identity…", comment: "Identity top-up sheet — shielded route progress") - let claim = credits > PlatformPaymentIdentityFundingPolicy.feeHeadroomCredits - ? credits - PlatformPaymentIdentityFundingPolicy.feeHeadroomCredits - : credits + let claim = Self.suppliedCredits(amountDuffs: amountDuffs, source: .shielded) let input = ManagedPlatformWallet.IdentityAddressInput( addressType: storageBytes[storageBytes.startIndex], hash: Data(storageBytes.dropFirst()), diff --git a/DashWallet/Sources/UI/Payments/Landing/Components/PaymentsReceiveContent.swift b/DashWallet/Sources/UI/Payments/Landing/Components/PaymentsReceiveContent.swift index a931493750..848b8b164b 100644 --- a/DashWallet/Sources/UI/Payments/Landing/Components/PaymentsReceiveContent.swift +++ b/DashWallet/Sources/UI/Payments/Landing/Components/PaymentsReceiveContent.swift @@ -30,6 +30,8 @@ struct PaymentsReceiveContent: View { var onCopyAddress: () -> Void var onShareAddress: () -> Void var onSpecifyAmount: () -> Void + /// Copies the Identity option's username; the host shows the toast. + var onCopyUsername: () -> Void = {} /// Opens the transaction behind a receipt. Passed through rather than /// acted on — which controller presents the details is the host's. var onViewTransaction: (Data) -> Void = { _ in } @@ -41,7 +43,7 @@ struct PaymentsReceiveContent: View { /// reads as a broken button. var onImportPrivateKey: (() -> Void)? = nil - /// Which way the last network change moved along `receiveNetworks`, so the + /// Which way the last network change moved along `receiveOptions`, so the /// incoming card slides in from the side it came from — the same rule the /// tab selector above follows. @State private var slidesForward = true @@ -80,36 +82,60 @@ struct PaymentsReceiveContent: View { /// pill control's own background would be a second surface on top of the /// card's. /// - /// `fillsWidth` on each so the three divide the row evenly; without it, - /// zero spacing would clump them at the leading edge. The selected one - /// carries the tint and the others are plain, because three identical - /// buttons would leave the screen unable to say which address is on it. + /// When every title fits whole, the options divide the row evenly; when + /// not (four options at 375 pt, or a large text size), the row scrolls + /// sideways and titles are never truncated. Every selection change — the + /// user's or one the model makes, such as falling back to Core — scrolls + /// the selected option fully into view. The selected one carries the tint + /// and the others are plain, because identical buttons would leave the + /// screen unable to say which option is on it. private var networkRow: some View { - HStack(spacing: 0) { - ForEach(viewModel.receiveNetworks) { network in - DashUIKit.DashButton( - text: network.title, - fillsWidth: true, - size: .medium, - style: network == viewModel.network ? .tintedGray : .plainBlack, - action: { select(network) } - ) + ViewThatFits(in: .horizontal) { + EvenOptionRow { + optionButtons(fillsWidth: true) + } + .padding(.horizontal, 20) + + ScrollViewReader { proxy in + ScrollView(.horizontal, showsIndicators: false) { + HStack(spacing: 0) { + optionButtons(fillsWidth: false) + } + .padding(.horizontal, 20) + } + .onAppear { proxy.scrollTo(viewModel.network) } + .onChange(of: viewModel.network) { _, selected in + withAnimation { proxy.scrollTo(selected) } + } } } - .padding(20) + .padding(.vertical, 20) + } + + private func optionButtons(fillsWidth: Bool) -> some View { + ForEach(viewModel.receiveOptions) { option in + DashUIKit.DashButton( + text: option.title, + fillsWidth: fillsWidth, + size: .medium, + style: option == viewModel.network ? .tintedGray : .plainBlack, + action: { select(option) } + ) + .id(option) + } } /// Everything that changes the network goes through here so the direction /// of travel is known before the change lands — the card has to enter from /// whichever side the new segment sits on, and only this knows which. - private var networkSelection: Binding { + private var networkSelection: Binding { Binding( get: { viewModel.network }, set: { select($0) }) } - private func select(_ network: ChainNetwork) { - let options = viewModel.receiveNetworks + private func select(_ network: ReceiveOption) { + let options = viewModel.receiveOptions guard let from = options.firstIndex(of: viewModel.network), let to = options.firstIndex(of: network), from != to @@ -176,9 +202,18 @@ struct PaymentsReceiveContent: View { } } - /// What the card shows for the selected network: the QR, the address and - /// the actions on it. + /// What the card shows for the selected option. + @ViewBuilder private var cardBody: some View { + if viewModel.network == .identity { + identityCardBody + } else { + addressCardBody + } + } + + /// The selected chain option: the QR, the address and the actions on it. + private var addressCardBody: some View { VStack(alignment: .leading, spacing: 0) { VStack(alignment: .center, spacing: 20) { @@ -280,6 +315,109 @@ struct PaymentsReceiveContent: View { } } + /// The Identity option: the QR of the bare Identity ID, the username and + /// the ID with their copy buttons, Share ID, Specify amount (not offered + /// for an identity), and why most senders cannot pay here (AC-01 – AC-04). + private var identityCardBody: some View { + VStack(alignment: .leading, spacing: 0) { + VStack(alignment: .center, spacing: 20) { + qrCard + + VStack(spacing: 12) { + copyRow( + label: NSLocalizedString("Username", comment: ""), + value: viewModel.receiveIdentity?.username, + copyLabel: NSLocalizedString("Copy username", comment: "Receive, Identity option"), + action: onCopyUsername) + + // One line, cut in the middle like an address: both ends + // are what a person compares. + copyRow( + label: NSLocalizedString("Identity ID", comment: ""), + value: viewModel.receiveIdentity?.identityIdBase58, + copyLabel: NSLocalizedString("Copy Identity ID", comment: "Receive, Identity option"), + action: onCopyAddress) + } + } + .frame(maxWidth: .infinity) + .padding(.horizontal, 20) + .padding(.top, 40) + .padding(.bottom, 10) + + HStack(spacing: 20) { + DashUIKit.DashButton( + text: NSLocalizedString("Share ID", comment: "Receive, Identity option"), + isEnabled: hasAddress, + size: .medium, + style: .tintedGray, + action: onShareAddress + ) + + // Shown and disabled: a request for an amount is not offered + // for an identity. + DashUIKit.DashButton( + text: NSLocalizedString("Specify amount", comment: "Payments"), + isEnabled: false, + size: .medium, + style: .tintedGray + ) + } + .frame(maxWidth: .infinity) + .padding(.horizontal, 20) + .padding(.top, 20) + + DashUIKit.SystemMessageView( + title: NSLocalizedString( + "Most exchanges and many wallets can send only to Core addresses", + comment: "Receive, Identity option warning"), + subtitle: NSLocalizedString( + "Funds sent to your identity pay for Dash apps and usernames.", + comment: "Receive, Identity option warning"), + icon: DashIcon.SystemMessage.warningTriangle.source, + backgroundColor: Color.dash.yellowAlpha10 + ) + .padding(.horizontal, 20) + .padding(.top, 20) + + watchingForPayment + .padding(.top, 14) + .padding(.bottom, 20) + } + } + + /// A labelled value on one line, cut in the middle when it does not fit, + /// with a copy button. Tapping the text copies too, as on the address row. + private func copyRow(label: String, value: String?, copyLabel: String, action: @escaping () -> Void) -> some View { + HStack(spacing: 12) { + VStack(alignment: .leading, spacing: 2) { + Text(label) + .dashFont(.footnote) + .foregroundStyle(Color.dash.secondaryText) + Text(value ?? "") + .dashFont(.subhead) + .foregroundColor(.dash.primaryText) + .lineLimit(1) + .truncationMode(.middle) + } + .frame(maxWidth: .infinity, alignment: .leading) + .contentShape(Rectangle()) + .onTapGesture(perform: action) + .accessibilityElement(children: .combine) + .accessibilityAddTraits(.isButton) + .accessibilityHint(Text(NSLocalizedString("Copy", comment: ""))) + + DashUIKit.DashButton( + leadingIcon: .custom(DashIcon.Icons.copyOutline.rawValue, bundle: .dashUIKit), + isEnabled: value != nil, + size: .medium, + style: .tintedGray, + accessibilityLabel: copyLabel, + action: action + ) + } + .padding(.vertical, 6) + } + /// Always laid out, and only faded when there is nothing to watch: an /// absent view takes its padding with it, which left the actions sitting /// on the card's bottom edge and made the card jump when watching began. @@ -442,15 +580,46 @@ struct ReceiveWatchingIndicator: View { } } +/// Lays its children out in equal widths. Its ideal width is the widest +/// child's times their count, so `ViewThatFits` only picks it when every +/// child gets at least its whole title. +private struct EvenOptionRow: Layout { + func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize { + let ideal = subviews.map { $0.sizeThatFits(.unspecified) } + let widest = ideal.map(\.width).max() ?? 0 + let width = proposal.width.map { max($0, widest * CGFloat(subviews.count)) } + ?? widest * CGFloat(subviews.count) + return CGSize(width: width, height: ideal.map(\.height).max() ?? 0) + } + + func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) { + guard !subviews.isEmpty else { return } + let width = bounds.width / CGFloat(subviews.count) + for (index, subview) in subviews.enumerated() { + subview.place( + at: CGPoint(x: bounds.minX + width * CGFloat(index), y: bounds.midY), + anchor: .leading, + proposal: ProposedViewSize(width: width, height: bounds.height)) + } + } +} + #if DEBUG @MainActor private func receiveSample( - network: ChainNetwork = .core, - coreAddress: String? = "XyZ8kFqW3nR5tHmB2vJcL7pQaS4dEuG9wN" + network: ReceiveOption = .core, + coreAddress: String? = "XyZ8kFqW3nR5tHmB2vJcL7pQaS4dEuG9wN", + isAdvancedMode: Bool = false, + identity: ReceiveIdentity? = nil, + isWatching: Bool = false ) -> some View { - PaymentsReceiveContent( - viewModel: .makeForPreview(activeTab: .receive, network: network, coreAddress: coreAddress), + let viewModel = PaymentsLandingViewModel.makeForPreview( + activeTab: .receive, coreAddress: coreAddress, isWatching: isWatching) + viewModel.updateReceiveState(isAdvancedMode: isAdvancedMode, identity: identity) + viewModel.network = network + return PaymentsReceiveContent( + viewModel: viewModel, onCopyAddress: {}, onShareAddress: {}, onSpecifyAmount: {}) @@ -470,4 +639,55 @@ private func receiveSample( receiveSample(coreAddress: nil) } +private let previewIdentity = ReceiveIdentity( + identityId: Data((1...32).map { UInt8($0) }), username: "alice") + +@available(iOS 17, *) +#Preview("Three options") { + receiveSample(network: .platform, isAdvancedMode: true) +} + +/// Four titles overflow 375 pt: the row scrolls, the selected Identity in view. +@available(iOS 17, *) +#Preview("Four options, 375 pt") { + receiveSample(network: .identity, isAdvancedMode: true, identity: previewIdentity) + .frame(width: 375) +} + +@available(iOS 17, *) +#Preview("Identity, watching") { + receiveSample(network: .identity, isAdvancedMode: true, identity: previewIdentity, isWatching: true) +} + +/// The first read has not succeeded: everything works, no watching claim. +@available(iOS 17, *) +#Preview("Identity, not watching") { + receiveSample(network: .identity, isAdvancedMode: true, identity: previewIdentity) +} + +/// Identity credits have no transaction to open and carry no memo (SCR-03). +@available(iOS 17, *) +#Preview("Identity receipt") { + ReceiveReceiptCard( + receipt: ReceiveReceipt( + id: "identity-preview", + rail: .identity, + amountDuffs: 50_000_000, + receivedAt: Date(timeIntervalSince1970: 1_793_000_000), + memo: nil, + transactionId: nil), + canViewTransaction: false, + onViewTransaction: { _ in }, + onReceiveAnother: {}, + onDone: {}) + .padding(20) + .background(Color.dash.primaryBackground) +} + +@available(iOS 17, *) +#Preview("Four options, xxxLarge") { + receiveSample(network: .shielded, isAdvancedMode: true, identity: previewIdentity) + .dynamicTypeSize(.xxxLarge) +} + #endif diff --git a/DashWallet/Sources/UI/Payments/Landing/IdentityCreditsWatcher.swift b/DashWallet/Sources/UI/Payments/Landing/IdentityCreditsWatcher.swift new file mode 100644 index 0000000000..25305fecac --- /dev/null +++ b/DashWallet/Sources/UI/Payments/Landing/IdentityCreditsWatcher.swift @@ -0,0 +1,209 @@ +// +// IdentityCreditsWatcher.swift +// DashWallet +// +// Copyright © 2026 Dash Core Group. All rights reserved. +// +// Licensed under the MIT License (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://opensource.org/licenses/MIT +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import Foundation +import SwiftDashSDK + +/// Watches the Current identity's credits while the Identity option is open +/// and decides when they rose enough for a Receipt. +/// +/// Platform reports a balance, not incoming transfers, so the watch compares +/// balances: the Starting balance is the first successful fresh read of the +/// session (never a stored value), a lower balance replaces it, an own top-up +/// (`IdentityTopUpDidComplete`) raises it to the balance the top-up returned, +/// at most by the credits it was handed, and a rise of at least 1 duff over it +/// is one Receipt for the whole rise, which ends the session. While an own +/// top-up of the identity runs (`IdentityTopUpsInFlight`) no Receipt is raised +/// and no Starting balance is taken. Reads run on the Platform option's cadence +/// and only while the gate is open (card visible, not covered, app in the +/// foreground): closing the gate cancels the timer and keeps the session, +/// opening it checks at once. Created and owned by `PaymentsLandingViewModel`; +/// not shared. +@MainActor +final class IdentityCreditsWatcher { + struct Session: Equatable { + let walletId: Data + let network: Network + let identityId: Data + } + + enum State: Equatable { + /// No successful read yet, the last read failed, or no session. + case notWatching + case watching + /// The rise over the Starting balance, in whole duffs. + case received(duffs: UInt64) + } + + typealias Read = @MainActor (Session) async -> Result + typealias Schedule = @MainActor (TimeInterval, @escaping @MainActor () async -> Void) -> Task + + /// Runs `tick` now and then every `interval` until cancelled. + static let repeating: Schedule = { interval, tick in + Task { @MainActor in + while !Task.isCancelled { + await tick() + try? await Task.sleep(nanoseconds: UInt64(interval * 1_000_000_000)) + } + } + } + + private(set) var state: State = .notWatching { + didSet { if state != oldValue { onStateChange?(state) } } + } + + var onStateChange: ((State) -> Void)? + + private let read: Read + private let schedule: Schedule + private let center: NotificationCenter + private let inFlight: IdentityTopUpsInFlight + private var session: Session? + private var startingBalance: UInt64? + private var isGateOpen = false + private var timer: Task? + private var topUpObserver: NSObjectProtocol? + /// Bumped by every start, stop, gate close and own top-up: a read answered under an + /// older token is dropped. + private var readToken: UInt64 = 0 + private var isReading = false + + init(read: @escaping Read, + schedule: @escaping Schedule = IdentityCreditsWatcher.repeating, + center: NotificationCenter = .default, + inFlight: IdentityTopUpsInFlight = .shared) { + self.read = read + self.schedule = schedule + self.center = center + self.inFlight = inFlight + #if DASHPAY + // Always posted on the main actor (see `IdentityTopUpDidComplete`). + topUpObserver = center.addObserver( + forName: IdentityTopUpDidComplete.name, object: nil, queue: nil + ) { [weak self] note in + guard let event = IdentityTopUpDidComplete(notification: note) else { return } + MainActor.assumeIsolated { self?.apply(event) } + } + #endif + } + + deinit { + timer?.cancel() + if let topUpObserver { center.removeObserver(topUpObserver) } + } + + func start(_ session: Session) { + stop() + self.session = session + if isGateOpen { startTimer() } + } + + func stop() { + timer?.cancel() + timer = nil + session = nil + startingBalance = nil + readToken &+= 1 + isReading = false + state = .notWatching + } + + /// Open while the card is visible, not covered and the app is active. + /// Own top-ups count whatever the gate. + func setGateOpen(_ open: Bool) { + guard open != isGateOpen else { return } + isGateOpen = open + if open { + if session != nil { startTimer() } + } else { + // Cancelling the timer cancels the read it runs; drop its answer. + timer?.cancel() + timer = nil + readToken &+= 1 + isReading = false + } + } + + private func startTimer() { + timer?.cancel() + timer = schedule(AttendedReceiveRefreshPolicy.platformInterval) { [weak self] in + await self?.check() + } + } + + private func check() async { + guard let session, isGateOpen, !isReading else { return } + let token = readToken + isReading = true + let result = await read(session) + guard token == readToken, self.session == session else { return } + isReading = false + + guard case .success(let balance) = result else { + state = .notWatching + return + } + // Platform raises the balance before an own top-up is announced, so + // while one runs a rise may be the wallet's own credits. + let ownTopUpRunning = inFlight.contains( + .init(walletId: session.walletId, network: session.network, identityId: session.identityId)) + guard let starting = startingBalance else { + // A top-up that started before the watch may or may not be in this + // balance: the Starting balance waits until it has ended. + guard !ownTopUpRunning else { return } + startingBalance = balance + state = .watching + return + } + guard balance >= starting else { + startingBalance = balance + state = .watching + return + } + let rise = balance - starting + let creditsPerDuff = PlatformCreditsFormatter.creditsPerDuff + guard rise >= creditsPerDuff, !ownTopUpRunning else { + state = .watching + return + } + timer?.cancel() + timer = nil + self.session = nil + state = .received(duffs: rise / creditsPerDuff) + } + + #if DASHPAY + private func apply(_ event: IdentityTopUpDidComplete) { + guard let session, + event.identityId == session.identityId, + event.walletId == session.walletId, + event.network == session.network + else { return } + // A read in flight may answer with the balance before the top-up. + readToken &+= 1 + isReading = false + // The top-up's own balance, less any Payer credits in it beyond what + // the top-up was handed. Not a delta over the whole top-up: a spend + // seen meanwhile has already lowered the Starting balance. + if let startingBalance { + self.startingBalance = min(event.balanceAfter, startingBalance + event.suppliedCredits) + } + } + #endif +} diff --git a/DashWallet/Sources/UI/Payments/Landing/PaymentsLandingHostingController.swift b/DashWallet/Sources/UI/Payments/Landing/PaymentsLandingHostingController.swift index 4eba8cdf2d..d4685885a7 100644 --- a/DashWallet/Sources/UI/Payments/Landing/PaymentsLandingHostingController.swift +++ b/DashWallet/Sources/UI/Payments/Landing/PaymentsLandingHostingController.swift @@ -119,12 +119,14 @@ final class PaymentsLandingHostingController: DWBasePayViewController { embedInternalTransfer: Bool = false, sendNetwork: ChainNetwork? = nil, showsHeader: Bool = true, - allowsTransactionDetails: Bool = true) { + allowsTransactionDetails: Bool = true, + isQuickReceive: Bool = false) { self.viewModel = PaymentsLandingViewModel( activeTab: activeTab, - network: receiveNetwork, + network: ReceiveOption(receiveNetwork), visibleTabs: visibleTabs, - allowsTransactionDetails: allowsTransactionDetails) + allowsTransactionDetails: allowsTransactionDetails, + isQuickReceive: isQuickReceive) self.showsHeader = showsHeader self.embeddedSendViewModel = SendViewModel(pinnedSource: sendNetwork) self.transferSendFrom = sendNetwork @@ -158,7 +160,8 @@ final class PaymentsLandingHostingController: DWBasePayViewController { activeTab: .receive, visibleTabs: [.receive], showsHeader: false, - allowsTransactionDetails: false) + allowsTransactionDetails: false, + isQuickReceive: true) let navigationController = BaseNavigationController(rootViewController: controller) navigationController.isNavigationBarHidden = true navigationController.isModalInPresentation = false @@ -204,7 +207,9 @@ final class PaymentsLandingHostingController: DWBasePayViewController { if transferReceivePinned { viewModel.$network .receive(on: RunLoop.main) - .sink { [weak self] network in + .sink { [weak self] option in + // Identity is not a transfer endpoint: the route stays on the last chain. + guard let network = option.chainNetwork else { return } self?.embeddedTransferViewModel.applyReceiveRoute(into: network) } .store(in: &cancellables) diff --git a/DashWallet/Sources/UI/Payments/Landing/PaymentsLandingScreen.swift b/DashWallet/Sources/UI/Payments/Landing/PaymentsLandingScreen.swift index 019f24f6e6..62f6d93bf9 100644 --- a/DashWallet/Sources/UI/Payments/Landing/PaymentsLandingScreen.swift +++ b/DashWallet/Sources/UI/Payments/Landing/PaymentsLandingScreen.swift @@ -194,8 +194,9 @@ struct PaymentsLandingScreen: View { /// /// Off in the balance-row sheets (`including: .subviews` above): there a /// tab is a whole form with a keypad, and paging away mid-entry would drop - /// what the user typed. The picker tabs have nothing to lose and no scroll - /// view of their own to fight over the gesture. + /// what the user typed. The picker tabs have nothing to lose. Receive's + /// vertical scroll view takes only vertical drags, so a sideways swipe over + /// it still changes tab. private var tabSwipe: some Gesture { DragGesture(minimumDistance: Layout.swipeMinimumDistance) .onEnded { value in @@ -269,7 +270,10 @@ struct PaymentsLandingScreen: View { private var tabContent: some View { switch viewModel.activeTab { case .receive: - pickerLayout { + // Scrolls only when the card is taller than the page: the Identity + // card is, and squeezed into the page its warning collapsed to one + // truncated line per sentence and Close was pushed off the top. + ScrollView(.vertical) { PaymentsReceiveContent( viewModel: viewModel, onCopyAddress: { @@ -278,6 +282,10 @@ struct PaymentsLandingScreen: View { }, onShareAddress: onShareAddress, onSpecifyAmount: onSpecifyAmount, + onCopyUsername: { + viewModel.copyUsernameToPasteboard() + showsCopiedToast = true + }, onViewTransaction: onViewTransaction, onDone: { viewModel.finishReceiving() @@ -286,6 +294,8 @@ struct PaymentsLandingScreen: View { ) .padding(.horizontal, Layout.cardHorizontalPadding) } + .scrollBounceBehavior(.basedOnSize) + .scrollIndicators(.hidden) case .internalTransfer: switch mode { @@ -314,7 +324,8 @@ struct PaymentsLandingScreen: View { viewModel: embeddedTransferViewModel, onCompleted: onTransferCompleted, showsHeader: false, - receiveInto: viewModel.network + // Identity is not a chain: the form keeps the route's pinned target. + receiveInto: viewModel.network.chainNetwork ?? embeddedTransferViewModel.receiveTarget ) .padding(.top, Layout.embeddedFormTopPadding) } @@ -386,12 +397,13 @@ struct PaymentsLandingScreen: View { @MainActor private func landingSample( activeTab: PaymentsLandingTab = .internalTransfer, - network: ChainNetwork = .core, + network: ReceiveOption = .core, visibleTabs: [PaymentsLandingTab] = PaymentsLandingTab.allCases, coreAddress: String? = "XyZ8kFqW3nR5tHmB2vJcL7pQaS4dEuG9wN", transferAmount: String = "0", transferSendFrom: ChainNetwork? = nil, transferReceivePinned: Bool = false, + transferReceiveInto: ChainNetwork? = nil, showsHeader: Bool = true ) -> some View { @@ -408,7 +420,7 @@ private func landingSample( onSpecifyAmount: {}, onViewTransaction: { _ in }, onScanQR: {}, - embeddedTransferViewModel: .makeForPreview(amountText: transferAmount), + embeddedTransferViewModel: .makeForPreview(receiveInto: transferReceiveInto, amountText: transferAmount), transferSendFrom: transferSendFrom, transferReceivePinned: transferReceivePinned, embeddedSendViewModel: .makeForPreview(pinnedSource: transferSendFrom), @@ -471,5 +483,18 @@ private func landingSample( showsHeader: false) } +/// Balance-row receive sheet with Identity picked on Receive: Identity is not +/// a chain, so the transfer form keeps the To card the route is pinned to. +@available(iOS 17, *) +#Preview("Receive sheet · Identity picked, pinned To kept") { + landingSample( + network: .identity, + visibleTabs: [.receive, .internalTransfer], + transferAmount: "0.5", + transferReceivePinned: true, + transferReceiveInto: .platform, + showsHeader: false) +} + #endif diff --git a/DashWallet/Sources/UI/Payments/Landing/PaymentsLandingViewModel.swift b/DashWallet/Sources/UI/Payments/Landing/PaymentsLandingViewModel.swift index 6206358b51..2687143e6c 100644 --- a/DashWallet/Sources/UI/Payments/Landing/PaymentsLandingViewModel.swift +++ b/DashWallet/Sources/UI/Payments/Landing/PaymentsLandingViewModel.swift @@ -50,7 +50,7 @@ enum CoreReceiptSettlementStatus: Int, Comparable { struct ReceiveReceipt: Identifiable, Equatable { let id: String - let rail: ChainNetwork + let rail: ReceiveOption let amountDuffs: UInt64 let receivedAt: Date let memo: String? @@ -101,11 +101,49 @@ enum AttendedReceiveRefreshPolicy { static let shieldedInterval: TimeInterval = 5 } +/// What the Identity option's card shows: the Current identity's ID and the +/// username the wallet presents as its own. Nil without either, so a wallet +/// with no identity, no username yet or a registration in progress has none. +struct ReceiveIdentity: Equatable { + /// The Identity ID in Base58 — the only content of the QR, the copied and + /// the shared text (AC-03). + let identityId: Data + let identityIdBase58: String + let username: String + + init?(identityId: Data?, username: String?) { + guard let identityId, !identityId.isEmpty, let username, !username.isEmpty else { return nil } + self.identityId = identityId + identityIdBase58 = ScriptAddressCodec.base58Encode(identityId) + self.username = username + } +} + +enum ReceiveOptionPolicy { + /// Which options the Receive tab offers. + /// + /// Core and Shielded are both ordinary destinations — a wallet can be paid + /// privately without calling itself advanced. Platform is the one that + /// needs the mode: it holds credits rather than spendable Dash, and + /// offering it by default invites payments the payer cannot spend back. + /// Identity needs the mode and a username, and is never offered on the + /// lock screen's Quick Receive, which runs before unlock. + static func options(isAdvancedMode: Bool, identity: ReceiveIdentity?, isQuickReceive: Bool) -> [ReceiveOption] { + guard isAdvancedMode else { return [.core, .shielded] } + guard identity != nil, !isQuickReceive else { return [.core, .shielded, .platform] } + return [.core, .shielded, .platform, .identity] + } +} + @MainActor final class PaymentsLandingViewModel: ObservableObject { - @Published var activeTab: PaymentsLandingTab - @Published var network: ChainNetwork = .core + /// Every set after `init` runs `activeTabDidChange`, including a set to + /// the same tab from a tab-bar entry point. + @Published var activeTab: PaymentsLandingTab { + didSet { activeTabDidChange() } + } + @Published var network: ReceiveOption = .core /// Which hero tabs this presentation offers. The full landing shows all /// three; the balance-row receive sheet narrows to Receive + Internal. let visibleTabs: [PaymentsLandingTab] @@ -117,14 +155,17 @@ final class PaymentsLandingViewModel: ObservableObject { /// the whole landing on every keystroke in the embedded amount field. @Published private(set) var isAdvancedMode = DWGlobalOptions.sharedInstance().advancedModeEnabled - /// Which addresses the Receive tab offers. - /// - /// Core and Shielded are both ordinary destinations — a wallet can be paid - /// privately without calling itself advanced. Platform is the one that - /// needs the mode: it holds credits rather than spendable Dash, and - /// offering it by default invites payments the payer cannot spend back. - var receiveNetworks: [ChainNetwork] { - isAdvancedMode ? [.core, .shielded, .platform] : [.core, .shielded] + /// The Current identity the Identity option shows, re-read on every + /// registration, wallet and network change; nil when it has no username. + @Published private(set) var receiveIdentity: ReceiveIdentity? + + /// The lock screen's Quick Receive, which never offers Identity. + let isQuickReceive: Bool + + /// Which options the Receive tab offers (`ReceiveOptionPolicy`). + var receiveOptions: [ReceiveOption] { + ReceiveOptionPolicy.options( + isAdvancedMode: isAdvancedMode, identity: receiveIdentity, isQuickReceive: isQuickReceive) } /// Whether the Send tab offers "Send to username". @@ -169,7 +210,7 @@ final class PaymentsLandingViewModel: ObservableObject { /// the baseline is read. private struct ReceiptSessionSeed { let generation: UInt64 - let rail: ChainNetwork + let rail: ReceiveOption let address: String let walletId: Data let environment: Network @@ -181,7 +222,7 @@ final class PaymentsLandingViewModel: ObservableObject { let baseline: ReceiptBaseline var generation: UInt64 { seed.generation } - var rail: ChainNetwork { seed.rail } + var rail: ReceiveOption { seed.rail } var address: String { seed.address } var walletId: Data { seed.walletId } var environment: Network { seed.environment } @@ -214,19 +255,34 @@ final class PaymentsLandingViewModel: ObservableObject { private var shieldedProjectionRefreshPending = false private var shieldedProjectionGeneration: UInt64 = 0 private var session: ReceiptSession? + /// Watches the Current identity's credits while the Identity option is on. + private let identityWatcher: IdentityCreditsWatcher + /// The active wallet and network an identity watch runs for; nil while + /// the SDK host is not running the selected network. + private let identityContext: () -> (walletId: Data, network: Network)? + /// The Current identity Receive offers, re-read on every registration + /// status update. + private let receiveIdentitySource: () -> ReceiveIdentity? + private var identityWatchSession: IdentityCreditsWatcher.Session? private var generation: UInt64 = 0 private var surfaceIsVisible = false private var presentationIsObscuring = false private var appIsActive = UIApplication.shared.applicationState == .active init(activeTab: PaymentsLandingTab, - network: ChainNetwork = .core, + network: ReceiveOption = .core, visibleTabs: [PaymentsLandingTab] = PaymentsLandingTab.allCases, - allowsTransactionDetails: Bool = true) { + allowsTransactionDetails: Bool = true, + isQuickReceive: Bool = false) { + identityWatcher = Self.makeIdentityWatcher() + identityContext = Self.currentIdentityContext + receiveIdentitySource = Self.currentReceiveIdentity self.activeTab = activeTab self.network = network self.visibleTabs = visibleTabs self.allowsTransactionDetails = allowsTransactionDetails + self.isQuickReceive = isQuickReceive + identityWatcher.onStateChange = { [weak self] in self?.identityWatcherDidChange($0) } reloadCoreAddress() reloadShieldedAddress() @@ -235,27 +291,24 @@ final class PaymentsLandingViewModel: ObservableObject { .receive(on: RunLoop.main) .sink { [weak self] _ in guard let self else { return } - self.isAdvancedMode = DWGlobalOptions.sharedInstance().advancedModeEnabled - // Platform is the only segment the mode takes away, and it can - // be the selected one at that moment — leaving the tab showing - // a Platform address with no segment left to move off it. - if !self.isAdvancedMode, !self.receiveNetworks.contains(self.network) { - self.network = .core - } + // Platform and Identity are the segments the mode takes away, + // and either can be the selected one at that moment. + self.updateReceiveState( + isAdvancedMode: DWGlobalOptions.sharedInstance().advancedModeEnabled, + identity: self.receiveIdentity) } .store(in: &cancellables) #if DASHPAY refreshCanSendToUsername() + refreshReceiveIdentity() // The identity can be adopted while this landing is already up — a // registration finishing, or a recovery resolving one — and the row // has to appear without the user leaving the tab. NotificationCenter.default.publisher(for: .DWDashPayRegistrationStatusUpdated) .receive(on: RunLoop.main) - .sink { [weak self] _ in - self?.refreshCanSendToUsername() - } + .sink { [weak self] _ in self?.registrationStatusDidChange() } .store(in: &cancellables) #endif @@ -322,12 +375,6 @@ final class PaymentsLandingViewModel: ObservableObject { } .store(in: &cancellables) - $activeTab - .dropFirst() - .receive(on: RunLoop.main) - .sink { [weak self] _ in self?.resetForRouteChange() } - .store(in: &cancellables) - $network .dropFirst() .receive(on: RunLoop.main) @@ -341,12 +388,28 @@ final class PaymentsLandingViewModel: ObservableObject { /// subscribes to nothing. private init( previewActiveTab: PaymentsLandingTab, - previewNetwork: ChainNetwork, + previewNetwork: ReceiveOption, previewVisibleTabs: [PaymentsLandingTab], previewCoreAddress: String?, previewPlatformAddress: String?, - previewShieldedAddress: String? + previewShieldedAddress: String?, + previewIsQuickReceive: Bool, + previewIdentityWatcher: IdentityCreditsWatcher?, + previewIdentityContext: @escaping () -> (walletId: Data, network: Network)?, + previewReceiveIdentitySource: @escaping () -> ReceiveIdentity?, + previewIsWatching: Bool ) { + isWatchingForReceipt = previewIsWatching + isQuickReceive = previewIsQuickReceive + #if DASHPAY + identityWatcher = previewIdentityWatcher + ?? IdentityCreditsWatcher(read: { _ in .failure(IdentityBalanceRefresh.Superseded()) }) + #else + identityWatcher = previewIdentityWatcher ?? Self.makeIdentityWatcher() + #endif + identityContext = previewIdentityContext + receiveIdentitySource = previewReceiveIdentitySource + appIsActive = true activeTab = previewActiveTab network = previewNetwork visibleTabs = previewVisibleTabs @@ -357,17 +420,23 @@ final class PaymentsLandingViewModel: ObservableObject { // so the receipt's "View transaction" stays hidden rather than drawing // a control that could not do anything. allowsTransactionDetails = false + identityWatcher.onStateChange = { [weak self] in self?.identityWatcherDidChange($0) } } /// Preview view model. Pass `nil` for an address to preview that /// network's placeholder state instead of the QR card. static func makeForPreview( activeTab: PaymentsLandingTab = .internalTransfer, - network: ChainNetwork = .core, + network: ReceiveOption = .core, visibleTabs: [PaymentsLandingTab] = PaymentsLandingTab.allCases, coreAddress: String? = "XyZ8kFqW3nR5tHmB2vJcL7pQaS4dEuG9wN", platformAddress: String? = "XmQ4rT7bN2vK9sD5xF8jH3kL6pW1aZcYuE", - shieldedAddress: String? = nil + shieldedAddress: String? = nil, + isQuickReceive: Bool = false, + identityWatcher: IdentityCreditsWatcher? = nil, + identityContext: @escaping () -> (walletId: Data, network: Network)? = { nil }, + receiveIdentitySource: @escaping () -> ReceiveIdentity? = { nil }, + isWatching: Bool = false ) -> PaymentsLandingViewModel { PaymentsLandingViewModel( previewActiveTab: activeTab, @@ -375,11 +444,21 @@ final class PaymentsLandingViewModel: ObservableObject { previewVisibleTabs: visibleTabs, previewCoreAddress: coreAddress, previewPlatformAddress: platformAddress, - previewShieldedAddress: shieldedAddress) + previewShieldedAddress: shieldedAddress, + previewIsQuickReceive: isQuickReceive, + previewIdentityWatcher: identityWatcher, + previewIdentityContext: identityContext, + previewReceiveIdentitySource: receiveIdentitySource, + previewIsWatching: isWatching) } #endif + /// What the card encodes in its QR, copies and shares: the address of the + /// selected chain option, or on Identity the bare Base58 Identity ID. var currentAddress: String? { + if network == .identity { + return receiveIdentity?.identityIdBase58 + } if session?.rail == network, let displayedAddress { return displayedAddress } @@ -390,11 +469,13 @@ final class PaymentsLandingViewModel: ObservableObject { allowsTransactionDetails && receipt?.transactionId != nil } - private func candidateAddress(for rail: ChainNetwork) -> String? { + private func candidateAddress(for rail: ReceiveOption) -> String? { switch rail { case .core: return coreAddress case .platform: return platformAddress case .shielded: return shieldedAddress + // The Identity card shows the Identity ID, not an address. + case .identity: return nil } } @@ -407,6 +488,11 @@ final class PaymentsLandingViewModel: ObservableObject { UIPasteboard.general.string = address } + func copyUsernameToPasteboard() { + guard let username = receiveIdentity?.username else { return } + UIPasteboard.general.string = username + } + func setReceiveSurfaceVisible(_ visible: Bool) { surfaceIsVisible = visible if visible { @@ -453,6 +539,11 @@ final class PaymentsLandingViewModel: ObservableObject { } #if DASHPAY + func registrationStatusDidChange() { + refreshCanSendToUsername() + refreshReceiveIdentity() + } + /// Reads the network-scoped SDK truth, the same source /// `JoinDashPayRegistrationPolicy` treats as authoritative. The legacy /// `DWGlobalOptions` username mirror is global and cleared on every network @@ -461,8 +552,132 @@ final class PaymentsLandingViewModel: ObservableObject { let identity = DWCurrentUserIdentityInfo.shared canSendToUsername = identity.hasIdentity && identity.username?.isEmpty == false } + + /// The snapshot is empty while the SDK host has not rebound to the selected + /// network, so a switch clears the previous identity before any new one. + private func refreshReceiveIdentity() { + updateReceiveState(isAdvancedMode: isAdvancedMode, identity: receiveIdentitySource()) + } #endif + /// Applies Advanced Mode and the Current identity, and moves the selection + /// to Core when the selected option is no longer offered. An option that + /// appears never moves the selection. + func updateReceiveState(isAdvancedMode: Bool, identity: ReceiveIdentity?) { + self.isAdvancedMode = isAdvancedMode + receiveIdentity = identity + if !receiveOptions.contains(network) { + network = .core + } + reconcileIdentityWatch() + } + + #if DASHPAY + /// The watcher's read: `refresh` runs only while `activeContext` is the + /// session's wallet and network; otherwise the read fails as superseded. + static func identityBalanceRead( + activeContext: @escaping @MainActor () -> (walletId: Data, network: Network?)?, + refresh: @escaping @MainActor (IdentityCreditsWatcher.Session) async -> Result + ) -> IdentityCreditsWatcher.Read { + { session in + guard let context = activeContext(), + context.walletId == session.walletId, + context.network == session.network + else { return .failure(IdentityBalanceRefresh.Superseded()) } + return await refresh(session) + } + } + + /// Reads through the same refresh as the Identities screen, so a read + /// persists the balance and notifies open screens (AC-07). + private static func makeIdentityWatcher() -> IdentityCreditsWatcher { + IdentityCreditsWatcher(read: identityBalanceRead( + activeContext: { + let host = SwiftDashSDKHost.shared + return host.wallet.map { ($0.walletId, host.runningNetwork) } + }, + refresh: { session in + guard let wallet = SwiftDashSDKHost.shared.wallet else { + return .failure(IdentityBalanceRefresh.Superseded()) + } + return await DWCurrentUserIdentityInfo.shared.refreshBalanceFromNetwork( + identityId: session.identityId, wallet: wallet, network: session.network) + })) + } + #else + /// Without DASHPAY there is no Current identity, so Receive never offers + /// Identity (`currentReceiveIdentity` is nil) and this watcher never starts. + private static func makeIdentityWatcher() -> IdentityCreditsWatcher { + IdentityCreditsWatcher(read: { _ in .failure(CancellationError()) }) + } + #endif + + private static func currentReceiveIdentity() -> ReceiveIdentity? { + #if DASHPAY + let identity = DWCurrentUserIdentityInfo.shared + return ReceiveIdentity(identityId: identity.snapshotForReading.identityId, username: identity.username) + #else + return nil + #endif + } + + private static func currentIdentityContext() -> (walletId: Data, network: Network)? { + guard let wallet = SwiftDashSDKHost.shared.wallet, + let network = SwiftDashSDKHost.shared.runningNetwork, + WalletEnvironment.network == network + else { return nil } + return (wallet.walletId, network) + } + + /// Runs one watch per (wallet, network, identity) while Identity is the + /// selected option, and keeps it across everything else — a username + /// change or a balance notification never resets its Starting balance. + /// While a Receipt is up the finished session is kept, so nothing restarts + /// until Receive another, another option, or a wallet or network change + /// (`invalidateReceiptSession`). + private func reconcileIdentityWatch() { + let wanted: IdentityCreditsWatcher.Session? + if receipt != nil { + wanted = identityWatchSession + } else if network == .identity, receiveOptions.contains(.identity), + let identity = receiveIdentity, let context = identityContext() { + wanted = IdentityCreditsWatcher.Session( + walletId: context.walletId, network: context.network, identityId: identity.identityId) + } else { + wanted = nil + } + if wanted != identityWatchSession { + identityWatchSession = wanted + if let wanted { + identityWatcher.start(wanted) + } else { + identityWatcher.stop() + } + } + identityWatcher.setGateOpen(canActivelyWatch) + if network == .identity, receipt == nil { + isWatchingForReceipt = canActivelyWatch && identityWatcher.state == .watching + } + } + + private func identityWatcherDidChange(_ state: IdentityCreditsWatcher.State) { + guard network == .identity, identityWatchSession != nil else { return } + switch state { + case .received(let duffs): + acceptReceipt(ReceiveReceipt( + id: "identity-\(UUID().uuidString)", + rail: .identity, + amountDuffs: duffs, + receivedAt: Date(), + memo: nil, + transactionId: nil)) + case .watching, .notWatching: + if receipt == nil { + isWatchingForReceipt = canActivelyWatch && state == .watching + } + } + } + /// Resolves the wallet's default Orchard payment address and encodes it /// for display. `shieldedDefaultAddress` returns nil until the shielded /// sub-wallet is bound (PlatformAddressSyncCoordinator does that at @@ -491,6 +706,7 @@ final class PaymentsLandingViewModel: ObservableObject { } private func reconcileReceiptWatching() { + defer { reconcileIdentityWatch() } guard canActivelyWatch else { suspendReceiptWatching() return @@ -558,7 +774,7 @@ final class PaymentsLandingViewModel: ObservableObject { /// the address can be acted on and nothing is ever withheld waiting for /// one. private func readReceiptBaseline( - for rail: ChainNetwork, + for rail: ReceiveOption, walletId: Data, environment: Network, startedAt: Date @@ -583,6 +799,9 @@ final class PaymentsLandingViewModel: ObservableObject { // superset is the right thing to exclude. return SwiftDashSDKWalletSource.persistedShieldedActivityIds() .map { .shielded(activityIds: $0) } + case .identity: + // Identity has no address, so no session reaches this read. + return nil } } @@ -615,6 +834,9 @@ final class PaymentsLandingViewModel: ObservableObject { } isWatchingForReceipt = true attachShieldedObserverIfNeeded(session: session) + case .identity: + // No Identity session exists: Identity has no address to start one on. + isWatchingForReceipt = false } } @@ -837,6 +1059,7 @@ final class PaymentsLandingViewModel: ObservableObject { private func suspendReceiptWatching() { isWatchingForReceipt = false + identityWatcher.setGateOpen(false) coreReceiptCancellable?.cancel() coreReceiptCancellable = nil platformReceiptCancellable?.cancel() @@ -856,6 +1079,19 @@ final class PaymentsLandingViewModel: ObservableObject { generation &+= 1 session = nil displayedAddress = nil + identityWatchSession = nil + identityWatcher.stop() + } + + /// A trip to another tab keeps a running Identity watch: only its gate + /// closes, so credits that land meanwhile raise a Receipt on return and an + /// own top-up meanwhile still moves the Starting balance (AC-08). + private func activeTabDidChange() { + if network == .identity, receipt == nil { + reconcileReceiptWatching() + } else { + resetForRouteChange() + } } private func resetForRouteChange() { @@ -878,6 +1114,7 @@ final class PaymentsLandingViewModel: ObservableObject { // The identity is network-scoped, so a network switch can invalidate // the Send tab's username row exactly as a registration change does. refreshCanSendToUsername() + refreshReceiveIdentity() #endif reconcileReceiptWatching() } diff --git a/DashWallet/Sources/UI/Payments/Landing/ReceiveOption.swift b/DashWallet/Sources/UI/Payments/Landing/ReceiveOption.swift new file mode 100644 index 0000000000..787b4644cf --- /dev/null +++ b/DashWallet/Sources/UI/Payments/Landing/ReceiveOption.swift @@ -0,0 +1,61 @@ +// +// ReceiveOption.swift +// DashWallet +// +// Copyright © 2026 Dash Core Group. All rights reserved. +// +// Licensed under the MIT License (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://opensource.org/licenses/MIT +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import Foundation + +/// One choice in the option row of the Receive card. +/// +/// Receive's own type, not `ChainNetwork`: the chain options map to their +/// chain, and Identity maps to none, so Identity cannot reach Send, Home or +/// Internal transfer, which keep using `ChainNetwork` (ADR-0035). +enum ReceiveOption: String, CaseIterable, Identifiable { + case core + case shielded + case platform + case identity + + init(_ network: ChainNetwork) { + switch network { + case .core: self = .core + case .shielded: self = .shielded + case .platform: self = .platform + } + } + + var id: String { rawValue } + + /// The chain this option receives on; nil for Identity, which is not a chain. + var chainNetwork: ChainNetwork? { + switch self { + case .core: return .core + case .shielded: return .shielded + case .platform: return .platform + case .identity: return nil + } + } + + var title: String { + chainNetwork?.title ?? NSLocalizedString("Identity", comment: "") + } + + /// The balance a Receipt on this option names. + var balanceName: String { + chainNetwork?.balanceName ?? NSLocalizedString("Identity", comment: "") + } +} diff --git a/DashWallet/ar.lproj/Localizable.strings b/DashWallet/ar.lproj/Localizable.strings index cc3ba166b9..b40284c812 100644 --- a/DashWallet/ar.lproj/Localizable.strings +++ b/DashWallet/ar.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "نسخ"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "تم نقل الأموال"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "المزيد من التحكم"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "الأكثر أصوات قفل"; @@ -4937,6 +4949,9 @@ /* Receive screen */ "Share address" = "Share address"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* No comment provided by engineer. */ "Share key" = "Share key"; diff --git a/DashWallet/bg.lproj/Localizable.strings b/DashWallet/bg.lproj/Localizable.strings index e1a76c9852..50e7e0e3af 100644 --- a/DashWallet/bg.lproj/Localizable.strings +++ b/DashWallet/bg.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Копирай"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Средствата са преместени"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "Повече контрол"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Най-много заключващи гласове"; @@ -4937,6 +4949,9 @@ /* Receive screen */ "Share address" = "Share address"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* No comment provided by engineer. */ "Share key" = "Share key"; diff --git a/DashWallet/ca.lproj/Localizable.strings b/DashWallet/ca.lproj/Localizable.strings index a9030f5806..b89e2c944c 100644 --- a/DashWallet/ca.lproj/Localizable.strings +++ b/DashWallet/ca.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Copia"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Fons moguts"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "More Control"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Més vots de bloqueig"; @@ -4937,6 +4949,9 @@ /* Receive screen */ "Share address" = "Share address"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* No comment provided by engineer. */ "Share key" = "Share key"; diff --git a/DashWallet/cs.lproj/Localizable.strings b/DashWallet/cs.lproj/Localizable.strings index 2a923531c1..c40228e0b1 100644 --- a/DashWallet/cs.lproj/Localizable.strings +++ b/DashWallet/cs.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopírovat"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Prostředky přesunuty"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "Lepší správa"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Nejvíce uzamykacích hlasů"; @@ -4937,6 +4949,9 @@ /* Receive screen */ "Share address" = "Share address"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* No comment provided by engineer. */ "Share key" = "Share key"; diff --git a/DashWallet/da.lproj/Localizable.strings b/DashWallet/da.lproj/Localizable.strings index c9e4f6f5f6..cbeb918ac7 100644 --- a/DashWallet/da.lproj/Localizable.strings +++ b/DashWallet/da.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopiér"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Midlerne er flyttet"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "More Control"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Flest låsestemmer"; @@ -4937,6 +4949,9 @@ /* Receive screen */ "Share address" = "Share address"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* No comment provided by engineer. */ "Share key" = "Share key"; diff --git a/DashWallet/de.lproj/Localizable.strings b/DashWallet/de.lproj/Localizable.strings index bc083870c5..bbff7cfd28 100644 --- a/DashWallet/de.lproj/Localizable.strings +++ b/DashWallet/de.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopieren"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Text kopieren"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Mittel verschoben"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "Mehr Kontrolle"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Meiste Sperrstimmen"; @@ -4935,6 +4947,9 @@ /* Receive screen */ "Share address" = "Adresse teilen"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* Share key */ "Share key" = "Key teilen"; diff --git a/DashWallet/el.lproj/Localizable.strings b/DashWallet/el.lproj/Localizable.strings index 7a05e589ba..12a036c16e 100644 --- a/DashWallet/el.lproj/Localizable.strings +++ b/DashWallet/el.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Αντιγραφή"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Αντιγράψτε το κείμενο"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Τα κεφάλαια μεταφέρθηκαν"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "Περισσότερος Έλεγχος"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Περισσότερες ψήφοι κλειδώματος"; @@ -4935,6 +4947,9 @@ /* Receive screen */ "Share address" = "Διαμοιρασμός διεύθυνσης"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* Share key */ "Share key" = "Μοιράστε το κλειδί"; diff --git a/DashWallet/en.lproj/Localizable.strings b/DashWallet/en.lproj/Localizable.strings index 031bf461a6..105ce0cd0f 100644 --- a/DashWallet/en.lproj/Localizable.strings +++ b/DashWallet/en.lproj/Localizable.strings @@ -1381,6 +1381,9 @@ /* No comment provided by engineer. */ "Copy" = "Copy"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1393,6 +1396,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2312,6 +2318,9 @@ /* CoinJoin */ "Funds moved" = "Funds moved"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3154,6 +3163,9 @@ /* No comment provided by engineer. */ "More Control" = "More Control"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Most lock votes"; @@ -4936,6 +4948,9 @@ /* Receive screen */ "Share address" = "Share address"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* Share key */ "Share key" = "Share key"; diff --git a/DashWallet/eo.lproj/Localizable.strings b/DashWallet/eo.lproj/Localizable.strings index 247e35a99d..4d7c12a5f0 100644 --- a/DashWallet/eo.lproj/Localizable.strings +++ b/DashWallet/eo.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopi"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Monrimedoj movitaj"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "More Control"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Plej multe da ŝlosaj voĉoj"; @@ -4937,6 +4949,9 @@ /* Receive screen */ "Share address" = "Share address"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* No comment provided by engineer. */ "Share key" = "Share key"; diff --git a/DashWallet/es.lproj/Localizable.strings b/DashWallet/es.lproj/Localizable.strings index 94c6e33ac3..ce3cd996e5 100644 --- a/DashWallet/es.lproj/Localizable.strings +++ b/DashWallet/es.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Copiar"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copiar texto"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Fondos movidos"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "Más Control"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Más votos de bloqueo"; @@ -4935,6 +4947,9 @@ /* Receive screen */ "Share address" = "Compartir dirección"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* Share key */ "Share key" = "Compartir llave"; diff --git a/DashWallet/et.lproj/Localizable.strings b/DashWallet/et.lproj/Localizable.strings index 6ff3140695..18a12f9034 100644 --- a/DashWallet/et.lproj/Localizable.strings +++ b/DashWallet/et.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Copy"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Vahendid liigutatud"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "More Control"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Kõige rohkem lukustushääli"; @@ -4937,6 +4949,9 @@ /* Receive screen */ "Share address" = "Share address"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* No comment provided by engineer. */ "Share key" = "Share key"; diff --git a/DashWallet/fa.lproj/Localizable.strings b/DashWallet/fa.lproj/Localizable.strings index 66655ac0ef..639bc7335a 100644 --- a/DashWallet/fa.lproj/Localizable.strings +++ b/DashWallet/fa.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "کپی"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "وجوه منتقل شد"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "مدیریت بیشتر"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "بیشترین رأی قفل"; @@ -4935,6 +4947,9 @@ /* Receive screen */ "Share address" = "Share address"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* Share key */ "Share key" = "به اشتراک‌گذاری کلید"; diff --git a/DashWallet/fi.lproj/Localizable.strings b/DashWallet/fi.lproj/Localizable.strings index 6801c723f8..f955e0a046 100644 --- a/DashWallet/fi.lproj/Localizable.strings +++ b/DashWallet/fi.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopioi"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Varat siirretty"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "More Control"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Eniten lukitusääniä"; @@ -4937,6 +4949,9 @@ /* Receive screen */ "Share address" = "Share address"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* No comment provided by engineer. */ "Share key" = "Share key"; diff --git a/DashWallet/fil.lproj/Localizable.strings b/DashWallet/fil.lproj/Localizable.strings index 4f9df1e296..434afeb564 100644 --- a/DashWallet/fil.lproj/Localizable.strings +++ b/DashWallet/fil.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopyahin"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Kopyahin ang text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Nailipat ang pondo"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "Mas marami pang kontrol"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Pinakamaraming lock vote"; @@ -4935,6 +4947,9 @@ /* Receive screen */ "Share address" = "Ibahagi ang address"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* Share key */ "Share key" = "Ibahagi ang susi"; diff --git a/DashWallet/fr.lproj/Localizable.strings b/DashWallet/fr.lproj/Localizable.strings index 24729cabf2..c144706bba 100644 --- a/DashWallet/fr.lproj/Localizable.strings +++ b/DashWallet/fr.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Copier"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copier le texte"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Fonds déplacés"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "Plus de contrôle"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Le plus de votes de verrouillage"; @@ -4935,6 +4947,9 @@ /* Receive screen */ "Share address" = "Partager l'adresse"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* Share key */ "Share key" = "Partager la clé"; diff --git a/DashWallet/hr.lproj/Localizable.strings b/DashWallet/hr.lproj/Localizable.strings index a6b8346cca..6fb5b1c003 100644 --- a/DashWallet/hr.lproj/Localizable.strings +++ b/DashWallet/hr.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopiraj"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Sredstva premještena"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "More Control"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Najviše glasova za zaključavanje"; @@ -4937,6 +4949,9 @@ /* Receive screen */ "Share address" = "Share address"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* No comment provided by engineer. */ "Share key" = "Share key"; diff --git a/DashWallet/hu.lproj/Localizable.strings b/DashWallet/hu.lproj/Localizable.strings index c5d91c9201..999859570d 100644 --- a/DashWallet/hu.lproj/Localizable.strings +++ b/DashWallet/hu.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Másolás"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "A pénz áthelyezve"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "More Control"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Legtöbb zárolási szavazat"; @@ -4937,6 +4949,9 @@ /* Receive screen */ "Share address" = "Share address"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* No comment provided by engineer. */ "Share key" = "Share key"; diff --git a/DashWallet/id.lproj/Localizable.strings b/DashWallet/id.lproj/Localizable.strings index 7b9989ee68..1caf6c1d47 100644 --- a/DashWallet/id.lproj/Localizable.strings +++ b/DashWallet/id.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Salin"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Salin teks"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Dana dipindahkan"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "Kontrol lebih lanjut"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Suara kunci terbanyak"; @@ -4935,6 +4947,9 @@ /* Receive screen */ "Share address" = "Bagikan alamat"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* Share key */ "Share key" = "Bagikan kunci"; diff --git a/DashWallet/it.lproj/Localizable.strings b/DashWallet/it.lproj/Localizable.strings index b9e91ba205..ba23a61411 100644 --- a/DashWallet/it.lproj/Localizable.strings +++ b/DashWallet/it.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Copia"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copia il testo"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Fondi spostati"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "Più Controllo"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Più voti di blocco"; @@ -4935,6 +4947,9 @@ /* Receive screen */ "Share address" = "Condividi indirizzo"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* Share key */ "Share key" = "Condividi la chiave"; diff --git a/DashWallet/ja.lproj/Localizable.strings b/DashWallet/ja.lproj/Localizable.strings index ff0138466d..86b3836b7e 100644 --- a/DashWallet/ja.lproj/Localizable.strings +++ b/DashWallet/ja.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "コピー"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "テキストをコピーする"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "資金を移動しました"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "コントロールの追加"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "ロック票が最多"; @@ -4935,6 +4947,9 @@ /* Receive screen */ "Share address" = "アドレスをシェアする"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* Share key */ "Share key" = "シェアキー"; diff --git a/DashWallet/ko.lproj/Localizable.strings b/DashWallet/ko.lproj/Localizable.strings index eb50e4ca20..ba13f523dd 100644 --- a/DashWallet/ko.lproj/Localizable.strings +++ b/DashWallet/ko.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "복사"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "문자 복사"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "자금 이동 완료"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "보다 큰 제어"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "잠금 투표 최다"; @@ -4935,6 +4947,9 @@ /* Receive screen */ "Share address" = "주소 공유하기"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* Share key */ "Share key" = "키 공유하기"; diff --git a/DashWallet/mk.lproj/Localizable.strings b/DashWallet/mk.lproj/Localizable.strings index 6350bf0440..79831b2636 100644 --- a/DashWallet/mk.lproj/Localizable.strings +++ b/DashWallet/mk.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Копирај"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Средствата се преместени"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "More Control"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Најмногу гласови за заклучување"; @@ -4937,6 +4949,9 @@ /* Receive screen */ "Share address" = "Share address"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* No comment provided by engineer. */ "Share key" = "Share key"; diff --git a/DashWallet/ms.lproj/Localizable.strings b/DashWallet/ms.lproj/Localizable.strings index 0ecf57f74f..dfe38eb359 100644 --- a/DashWallet/ms.lproj/Localizable.strings +++ b/DashWallet/ms.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Copy"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Dana dipindahkan"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "More Control"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Undi kunci terbanyak"; @@ -4937,6 +4949,9 @@ /* Receive screen */ "Share address" = "Share address"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* No comment provided by engineer. */ "Share key" = "Share key"; diff --git a/DashWallet/nb.lproj/Localizable.strings b/DashWallet/nb.lproj/Localizable.strings index b133d72135..79a52efd40 100644 --- a/DashWallet/nb.lproj/Localizable.strings +++ b/DashWallet/nb.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopier"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Midlene er flyttet"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "More Control"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Flest låsestemmer"; @@ -4937,6 +4949,9 @@ /* Receive screen */ "Share address" = "Share address"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* No comment provided by engineer. */ "Share key" = "Share key"; diff --git a/DashWallet/nl.lproj/Localizable.strings b/DashWallet/nl.lproj/Localizable.strings index a9ddd32a1d..c66131ffb1 100644 --- a/DashWallet/nl.lproj/Localizable.strings +++ b/DashWallet/nl.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopieer"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Kopieer tekst"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Tegoed verplaatst"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "Meer controle"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Meeste vergrendelstemmen"; @@ -4935,6 +4947,9 @@ /* Receive screen */ "Share address" = "Deel adres"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* Share key */ "Share key" = "Deel sleutel"; diff --git a/DashWallet/pl.lproj/Localizable.strings b/DashWallet/pl.lproj/Localizable.strings index 7812b11a18..c484138c55 100644 --- a/DashWallet/pl.lproj/Localizable.strings +++ b/DashWallet/pl.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopiuj"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Skopiuj tekst"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Środki przeniesione"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "Więcej Kontroli"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Najwięcej głosów blokujących"; @@ -4935,6 +4947,9 @@ /* Receive screen */ "Share address" = "Udostępnij Adres"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* Share key */ "Share key" = "Udostępnij klucz"; diff --git a/DashWallet/pt.lproj/Localizable.strings b/DashWallet/pt.lproj/Localizable.strings index 257f9fcc67..c80aa00cc8 100644 --- a/DashWallet/pt.lproj/Localizable.strings +++ b/DashWallet/pt.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Copiar"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copiar texto"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Fundos movidos"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "Mais Controle"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Mais votos de bloqueio"; @@ -4935,6 +4947,9 @@ /* Receive screen */ "Share address" = "Compartilhar endereço"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* Share key */ "Share key" = "Compartilhar chave"; diff --git a/DashWallet/ro.lproj/Localizable.strings b/DashWallet/ro.lproj/Localizable.strings index 773221c678..f123b6076e 100644 --- a/DashWallet/ro.lproj/Localizable.strings +++ b/DashWallet/ro.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Copiază"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Fonduri mutate"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "More Control"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Cele mai multe voturi de blocare"; @@ -4937,6 +4949,9 @@ /* Receive screen */ "Share address" = "Share address"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* No comment provided by engineer. */ "Share key" = "Share key"; diff --git a/DashWallet/ru.lproj/Localizable.strings b/DashWallet/ru.lproj/Localizable.strings index 0385b9b629..65cc4181a4 100644 --- a/DashWallet/ru.lproj/Localizable.strings +++ b/DashWallet/ru.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Копировать"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Копировать текст"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Средства перемещены"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "Больше контроля"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Больше всего голосов за блокировку"; @@ -4935,6 +4947,9 @@ /* Receive screen */ "Share address" = "Поделиться адресом"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* Share key */ "Share key" = "Поделиться ключом"; diff --git a/DashWallet/sk.lproj/Localizable.strings b/DashWallet/sk.lproj/Localizable.strings index 92480f26a2..2dc92c19d9 100644 --- a/DashWallet/sk.lproj/Localizable.strings +++ b/DashWallet/sk.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopírovať"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Skopírovať text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Prostriedky presunuté"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "Viac kontroly"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Najviac uzamykacích hlasov"; @@ -4935,6 +4947,9 @@ /* Receive screen */ "Share address" = "Zdieľať adresu"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* Share key */ "Share key" = "Zdieľať kľúč"; diff --git a/DashWallet/sl.lproj/Localizable.strings b/DashWallet/sl.lproj/Localizable.strings index 440f11c595..ca6834d89d 100644 --- a/DashWallet/sl.lproj/Localizable.strings +++ b/DashWallet/sl.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopiraj"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Sredstva premaknjena"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "More Control"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Največ glasov za zaklep"; @@ -4937,6 +4949,9 @@ /* Receive screen */ "Share address" = "Share address"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* No comment provided by engineer. */ "Share key" = "Share key"; diff --git a/DashWallet/sl_SI.lproj/Localizable.strings b/DashWallet/sl_SI.lproj/Localizable.strings index af17c51045..6aaebfc980 100644 --- a/DashWallet/sl_SI.lproj/Localizable.strings +++ b/DashWallet/sl_SI.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Copy"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Sredstva premaknjena"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "More Control"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Največ glasov za zaklep"; @@ -4937,6 +4949,9 @@ /* Receive screen */ "Share address" = "Share address"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* No comment provided by engineer. */ "Share key" = "Share key"; diff --git a/DashWallet/sq.lproj/Localizable.strings b/DashWallet/sq.lproj/Localizable.strings index 83e3a47daa..c7ed19e13d 100644 --- a/DashWallet/sq.lproj/Localizable.strings +++ b/DashWallet/sq.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopjo"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Fondet u zhvendosën"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "More Control"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Më shumë vota kyçjeje"; @@ -4937,6 +4949,9 @@ /* Receive screen */ "Share address" = "Share address"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* No comment provided by engineer. */ "Share key" = "Share key"; diff --git a/DashWallet/sr.lproj/Localizable.strings b/DashWallet/sr.lproj/Localizable.strings index 92c16049ee..7c044d3f32 100644 --- a/DashWallet/sr.lproj/Localizable.strings +++ b/DashWallet/sr.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopiraj"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Sredstva premeštena"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "More Control"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Najviše glasova za zaključavanje"; @@ -4937,6 +4949,9 @@ /* Receive screen */ "Share address" = "Share address"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* No comment provided by engineer. */ "Share key" = "Share key"; diff --git a/DashWallet/sv.lproj/Localizable.strings b/DashWallet/sv.lproj/Localizable.strings index b75f469653..254604fd40 100644 --- a/DashWallet/sv.lproj/Localizable.strings +++ b/DashWallet/sv.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopiera"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Medlen har flyttats"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "More Control"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Flest låsröster"; @@ -4937,6 +4949,9 @@ /* Receive screen */ "Share address" = "Share address"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* No comment provided by engineer. */ "Share key" = "Share key"; diff --git a/DashWallet/th.lproj/Localizable.strings b/DashWallet/th.lproj/Localizable.strings index ce2ca6ffff..c213c2c591 100644 --- a/DashWallet/th.lproj/Localizable.strings +++ b/DashWallet/th.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "คัดลอก"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "ย้ายเงินแล้ว"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "ควบคุมมากขึ้น"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "คะแนนล็อกมากที่สุด"; @@ -4935,6 +4947,9 @@ /* Receive screen */ "Share address" = "แบ่งปันที่อยู่"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* Share key */ "Share key" = "Share key"; diff --git a/DashWallet/tr.lproj/Localizable.strings b/DashWallet/tr.lproj/Localizable.strings index b74d9a7b3e..a1d15f9033 100644 --- a/DashWallet/tr.lproj/Localizable.strings +++ b/DashWallet/tr.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopyala"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Fonlar taşındı"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "Daha Fazla Kontrol"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "En çok kilitleme oyu"; @@ -4935,6 +4947,9 @@ /* Receive screen */ "Share address" = "Adresi paylaş"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* Share key */ "Share key" = "Share key"; diff --git a/DashWallet/uk.lproj/Localizable.strings b/DashWallet/uk.lproj/Localizable.strings index 95476da566..db04814854 100644 --- a/DashWallet/uk.lproj/Localizable.strings +++ b/DashWallet/uk.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Копіювати"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Скопіювати текст"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Кошти переміщено"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -2475,7 +2484,7 @@ "Identities" = "Ідентифікатори"; /* Voting */ -"Identity" = "Ідентично"; +"Identity" = "Ідентифікатор"; /* SDK identity profile sheet — the identity's credit balance */ "Identity Account Balance" = "Баланс облікового запису ідентифікатора"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "Більше контролю"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Найбільше голосів за блокування"; @@ -4935,6 +4947,9 @@ /* Receive screen */ "Share address" = "Поділитися адресою"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* Share key */ "Share key" = "Share key"; diff --git a/DashWallet/vi.lproj/Localizable.strings b/DashWallet/vi.lproj/Localizable.strings index ab23275a38..eda6e58c12 100644 --- a/DashWallet/vi.lproj/Localizable.strings +++ b/DashWallet/vi.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Sao chép"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "Đã chuyển tiền"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "Kiểm soát nhiều hơn"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "Nhiều phiếu khoá nhất"; @@ -4937,6 +4949,9 @@ /* Receive screen */ "Share address" = "Share address"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* No comment provided by engineer. */ "Share key" = "Share key"; diff --git a/DashWallet/zh-Hans.lproj/Localizable.strings b/DashWallet/zh-Hans.lproj/Localizable.strings index 8ce72b5967..cd28ed3747 100644 --- a/DashWallet/zh-Hans.lproj/Localizable.strings +++ b/DashWallet/zh-Hans.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Copy"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "资金已转移"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "More Control"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "锁定票最多"; @@ -4937,6 +4949,9 @@ /* Receive screen */ "Share address" = "Share address"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* No comment provided by engineer. */ "Share key" = "Share key"; diff --git a/DashWallet/zh-Hant-TW.lproj/Localizable.strings b/DashWallet/zh-Hant-TW.lproj/Localizable.strings index 2da23db76c..3cf61d5479 100644 --- a/DashWallet/zh-Hant-TW.lproj/Localizable.strings +++ b/DashWallet/zh-Hant-TW.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "Copy"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "Copy text"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "資金已轉移"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "More Control"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "鎖定票最多"; @@ -4937,6 +4949,9 @@ /* Receive screen */ "Share address" = "Share address"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* No comment provided by engineer. */ "Share key" = "Share key"; diff --git a/DashWallet/zh.lproj/Localizable.strings b/DashWallet/zh.lproj/Localizable.strings index ccb401c725..ca2f721482 100644 --- a/DashWallet/zh.lproj/Localizable.strings +++ b/DashWallet/zh.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "复制"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "复制文本"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "资金已转移"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "更多控制"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "锁定票最多"; @@ -4935,6 +4947,9 @@ /* Receive screen */ "Share address" = "分享地址"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* Share key */ "Share key" = "分享密钥"; diff --git a/DashWallet/zh_TW.lproj/Localizable.strings b/DashWallet/zh_TW.lproj/Localizable.strings index e19090993c..05faad02d6 100644 --- a/DashWallet/zh_TW.lproj/Localizable.strings +++ b/DashWallet/zh_TW.lproj/Localizable.strings @@ -1382,6 +1382,9 @@ /* No comment provided by engineer. */ "Copy" = "複製"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1394,6 +1397,9 @@ /* No comment provided by engineer. */ "Copy text" = "複製文字"; +/* Receive, Identity option */ +"Copy username" = "Copy username"; + /* AboutDash */ "Copyright © 2026 Dash Core Group" = "Copyright © 2026 Dash Core Group"; @@ -2313,6 +2319,9 @@ /* CoinJoin */ "Funds moved" = "資金已轉移"; +/* Receive, Identity option warning */ +"Funds sent to your identity pay for Dash apps and usernames." = "Funds sent to your identity pay for Dash apps and usernames."; + /* Usernames */ "Funds will be traceable to your username" = "Funds will be traceable to your username"; @@ -3158,6 +3167,9 @@ /* No comment provided by engineer. */ "More Control" = "更多控制選項"; +/* Receive, Identity option warning */ +"Most exchanges and many wallets can send only to Core addresses" = "Most exchanges and many wallets can send only to Core addresses"; + /* Voting */ "Most lock votes" = "鎖定票最多"; @@ -4935,6 +4947,9 @@ /* Receive screen */ "Share address" = "分享位址"; +/* Receive, Identity option */ +"Share ID" = "Share ID"; + /* Share key */ "Share key" = "共享金鑰"; diff --git a/DashWalletTests/IdentityBalanceRefreshTests.swift b/DashWalletTests/IdentityBalanceRefreshTests.swift index 75dbd4f12b..a4896262b4 100644 --- a/DashWalletTests/IdentityBalanceRefreshTests.swift +++ b/DashWalletTests/IdentityBalanceRefreshTests.swift @@ -75,6 +75,37 @@ final class IdentityBalanceRefreshTests: XCTestCase { await task.value } + /// The Identity watcher needs the balance it read, changed or not (AC-08: + /// the Starting balance is a fresh read, never a stored value). + func testSuccessfulReadReturnsTheFetchedBalanceWhetherOrNotItChanged() async { + for (previous, fetched): (UInt64?, UInt64) in [(nil, 7), (42, 42), (42, 0), (42, 43)] { + let result = await IdentityBalanceRefresh.run( + isCurrent: { true }, previousBalance: { previous }, + refresh: { fetched }, + publish: { _ in }, + onFailure: { XCTFail("Unexpected failure: \($0)") }) + XCTAssertEqual(try? result.get(), fetched) + } + } + + func testFailedReadReturnsTheErrorNeverTheStoredBalanceOrZero() async { + let result = await IdentityBalanceRefresh.run( + isCurrent: { true }, previousBalance: { 42 }, + refresh: { throw Failure.offline }, + publish: { _ in XCTFail("Failed read must not publish") }, + onFailure: { _ in }) + XCTAssertThrowsError(try result.get()) { XCTAssertEqual($0 as? Failure, .offline) } + } + + func testStaleContextReturnsAFailureNotABalance() async { + let result = await IdentityBalanceRefresh.run( + isCurrent: { false }, previousBalance: { 42 }, + refresh: { XCTFail("Old wallet must not be queried"); return 0 }, + publish: { _ in XCTFail("Old wallet must not be published") }, + onFailure: { _ in XCTFail("No operation expected") }) + XCTAssertThrowsError(try result.get()) + } + func testUnchangedBalanceStillPersistsWithoutPublishing() async { for balance: UInt64 in [0, 42] { var persisted = false diff --git a/DashWalletTests/IdentityCreditsWatcherTests.swift b/DashWalletTests/IdentityCreditsWatcherTests.swift new file mode 100644 index 0000000000..0cf0ccfa2e --- /dev/null +++ b/DashWalletTests/IdentityCreditsWatcherTests.swift @@ -0,0 +1,465 @@ +// +// IdentityCreditsWatcherTests.swift +// DashWalletTests +// +// Copyright © 2026 Dash Core Group. All rights reserved. +// +// Licensed under the MIT License (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://opensource.org/licenses/MIT +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import SwiftDashSDK +import XCTest +@testable import dashpay + +/// The Identity option's watch: a fresh Starting balance, checks on the +/// Platform cadence, own top-ups subtracted, and one Receipt for a rise of at +/// least 1 duff (AC-05, AC-06, AC-08, AC-13; sad.md QG-1). +@MainActor +final class IdentityCreditsWatcherTests: XCTestCase { + private enum Offline: Error { case unreachable } + + /// Answers reads from a queue; `hold()` makes the next read wait until + /// `release()`. Main-actor bound like the watcher, so a release can never + /// slip between a read and its hold. + @MainActor + private final class FakeSource { + var answers: [Result] = [] + private(set) var reads: [IdentityCreditsWatcher.Session] = [] + private var held: CheckedContinuation? + private var holdNext = false + private var releasedEarly = false + + func hold() { holdNext = true } + + func release() { + if let held { + held.resume() + self.held = nil + } else { + releasedEarly = true + } + } + + func read(_ session: IdentityCreditsWatcher.Session) async -> Result { + reads.append(session) + let answer = answers.isEmpty ? .failure(Offline.unreachable) : answers.removeFirst() + if holdNext { + holdNext = false + if releasedEarly { + releasedEarly = false + } else { + await withCheckedContinuation { held = $0 } + } + } + return answer + } + + /// Yields until `count` reads have started. + func waitForReads(_ count: Int) async { + while reads.count < count { await Task.yield() } + } + } + + /// Stores the tick instead of running it on a timer. The handle it returns + /// only sleeps, so its cancellation is readable at once. + @MainActor + private final class ManualScheduler { + private(set) var interval: TimeInterval? + private(set) var scheduledCount = 0 + private var tick: (@MainActor () async -> Void)? + private var timer: Task? + + var cancelled: Bool { timer?.isCancelled ?? false } + var isRunning: Bool { timer.map { !$0.isCancelled } ?? false } + + func schedule(_ interval: TimeInterval, _ tick: @escaping @MainActor () async -> Void) -> Task { + self.interval = interval + self.tick = tick + scheduledCount += 1 + let timer = Task { _ = try? await Task.sleep(nanoseconds: 3_600_000_000_000) } + self.timer = timer + return timer + } + + func fire() async { await tick?() } + } + + private let session = IdentityCreditsWatcher.Session( + walletId: Data(repeating: 1, count: 32), network: .testnet, identityId: Data(repeating: 2, count: 32)) + private let otherSession = IdentityCreditsWatcher.Session( + walletId: Data(repeating: 3, count: 32), network: .testnet, identityId: Data(repeating: 4, count: 32)) + + // XCTest makes a fresh instance per test, so these are per test too. + private let source = FakeSource() + private let scheduler = ManualScheduler() + private let center = NotificationCenter() + private let inFlight = IdentityTopUpsInFlight() + private lazy var watcher = IdentityCreditsWatcher( + read: { [source] in await source.read($0) }, + schedule: { [scheduler] in scheduler.schedule($0, $1) }, + center: center, + inFlight: inFlight) + + override func setUp() async throws { + watcher.setGateOpen(true) + } + + private func key(_ session: IdentityCreditsWatcher.Session) -> IdentityTopUpsInFlight.Key { + .init(walletId: session.walletId, network: session.network, identityId: session.identityId) + } + + private func answer(_ values: UInt64...) { + source.answers += values.map { .success($0) } + } + + private func topUp(after balanceAfter: UInt64, supplied: UInt64, for session: IdentityCreditsWatcher.Session) { + IdentityTopUpDidComplete( + walletId: session.walletId, network: session.network, identityId: session.identityId, + balanceAfter: balanceAfter, suppliedCredits: supplied) + .post(to: center) + } + + // MARK: Starting balance + + func testChecksRunOnThePlatformCadence() { + watcher.start(session) + XCTAssertEqual(scheduler.interval, AttendedReceiveRefreshPolicy.platformInterval) + } + + func testNotWatchingUntilTheFirstReadSucceedsThenThatReadIsTheStartingBalance() async { + watcher.start(session) + source.answers = [.failure(Offline.unreachable)] + await scheduler.fire() + XCTAssertEqual(watcher.state, .notWatching) + + answer(10_000, 11_000) + await scheduler.fire() + XCTAssertEqual(watcher.state, .watching) + await scheduler.fire() + XCTAssertEqual(watcher.state, .received(duffs: 1)) + } + + // MARK: Receipt decision + + func testTwoPaymentsBetweenChecksGiveOneReceiptForTheirSum() async { + watcher.start(session) + answer(10_000, 10_000 + 3_000_000 + 2_000_500) + await scheduler.fire() + await scheduler.fire() + XCTAssertEqual(watcher.state, .received(duffs: 5_000)) + } + + func testARiseBelowOneDuffWaitsUntilItAddsUpToOne() async { + watcher.start(session) + answer(10_000, 10_999, 11_000) + await scheduler.fire() + await scheduler.fire() + XCTAssertEqual(watcher.state, .watching) + await scheduler.fire() + XCTAssertEqual(watcher.state, .received(duffs: 1)) + } + + func testUnchangedBalanceRaisesNothing() async { + watcher.start(session) + answer(10_000, 10_000) + await scheduler.fire() + await scheduler.fire() + XCTAssertEqual(watcher.state, .watching) + } + + func testALowerBalanceBecomesTheStartingBalance() async { + watcher.start(session) + answer(10_000, 8_000, 9_000) + await scheduler.fire() + await scheduler.fire() + XCTAssertEqual(watcher.state, .watching) + await scheduler.fire() + XCTAssertEqual(watcher.state, .received(duffs: 1)) + } + + func testAReceiptEndsTheSession() async { + watcher.start(session) + answer(10_000, 20_000, 40_000) + await scheduler.fire() + await scheduler.fire() + XCTAssertEqual(watcher.state, .received(duffs: 10)) + let readsAtReceipt = source.reads.count + await scheduler.fire() + XCTAssertEqual(source.reads.count, readsAtReceipt) + XCTAssertEqual(watcher.state, .received(duffs: 10)) + } + + // MARK: Own top-ups + + func testOwnTopUpRaisesTheStartingBalance() async { + watcher.start(session) + answer(10_000, 15_000, 16_000) + await scheduler.fire() + topUp(after: 15_000, supplied: 5_000, for: session) + await scheduler.fire() + XCTAssertEqual(watcher.state, .watching) + await scheduler.fire() + XCTAssertEqual(watcher.state, .received(duffs: 1)) + } + + func testTopUpOfAnotherIdentityIsIgnored() async { + watcher.start(session) + answer(10_000, 15_000) + await scheduler.fire() + topUp(after: 15_000, supplied: 5_000, for: otherSession) + await scheduler.fire() + XCTAssertEqual(watcher.state, .received(duffs: 5)) + } + + func testTopUpCountsWhileTheCardIsCovered() async { + watcher.start(session) + answer(10_000, 15_000) + await scheduler.fire() + watcher.setGateOpen(false) + topUp(after: 15_000, supplied: 5_000, for: session) + watcher.setGateOpen(true) + await scheduler.fire() + XCTAssertEqual(watcher.state, .watching) + } + + /// A read that started before the top-up landed can return the old + /// balance; taking it would lower the Starting balance and turn the + /// top-up into a Receipt on the next check. + func testTopUpDropsTheReadInFlight() async { + watcher.start(session) + answer(10_000, 10_000, 15_000) + await scheduler.fire() + source.hold() + let readsBefore = source.reads.count + async let inFlight: Void = scheduler.fire() + await source.waitForReads(readsBefore + 1) + topUp(after: 15_000, supplied: 5_000, for: session) + source.release() + await inFlight + await scheduler.fire() + XCTAssertEqual(watcher.state, .watching) + } + + /// Platform raises the balance a little before the top-up call returns: a + /// check in that window must not take the wallet's own top-up for a + /// payment (review-2026-11-10-r3 Q1). + func testARiseSeenBeforeTheOwnTopUpIsAnnouncedRaisesNoReceipt() async { + watcher.start(session) + answer(10_000, 15_000, 15_000, 16_000) + await scheduler.fire() + inFlight.begin(key(session)) + await scheduler.fire() + XCTAssertEqual(watcher.state, .watching) + topUp(after: 15_000, supplied: 5_000, for: session) + inFlight.end(key(session)) + await scheduler.fire() + XCTAssertEqual(watcher.state, .watching) + await scheduler.fire() + XCTAssertEqual(watcher.state, .received(duffs: 1)) + } + + /// A top-up started before the option was opened (the username flow + /// dismisses while its top-up runs) may or may not be in the first read, + /// so the Starting balance waits for it to end. + func testATopUpRunningWhenTheWatchStartsDelaysTheStartingBalance() async { + inFlight.begin(key(session)) + watcher.start(session) + answer(10_000, 15_000, 16_000) + await scheduler.fire() + XCTAssertEqual(watcher.state, .notWatching) + topUp(after: 15_000, supplied: 5_000, for: session) + inFlight.end(key(session)) + await scheduler.fire() + XCTAssertEqual(watcher.state, .watching) + await scheduler.fire() + XCTAssertEqual(watcher.state, .received(duffs: 1)) + } + + /// A top-up that throws announces nothing; once it ends, a rise is a + /// Receipt again (the accepted limit for a top-up that failed after + /// Platform carried it out). + func testATopUpThatEndsUnannouncedReleasesTheHold() async { + watcher.start(session) + answer(10_000, 15_000, 15_000) + await scheduler.fire() + inFlight.begin(key(session)) + await scheduler.fire() + XCTAssertEqual(watcher.state, .watching) + inFlight.end(key(session)) + await scheduler.fire() + XCTAssertEqual(watcher.state, .received(duffs: 5)) + } + + /// A spend seen while a top-up runs lowers the Starting balance; the + /// top-up's own credits must still not come back as a Receipt + /// (review-2026-11-11-r1 S1). + func testADecreaseSeenWhileATopUpRunsDoesNotTurnTheTopUpIntoAReceipt() async { + watcher.start(session) + answer(20_000, 10_000, 15_000, 16_000) + await scheduler.fire() + inFlight.begin(key(session)) + await scheduler.fire() + topUp(after: 15_000, supplied: 5_000, for: session) + inFlight.end(key(session)) + await scheduler.fire() + XCTAssertEqual(watcher.state, .watching) + await scheduler.fire() + XCTAssertEqual(watcher.state, .received(duffs: 1)) + } + + /// A Payer's credits that land while a top-up runs are in the balance it + /// returns; only the part beyond the credits it was handed (its fee) can + /// be taken for the top-up's. + func testPayerCreditsInTheTopUpsBalanceStillRaiseAReceipt() async { + watcher.start(session) + answer(10_000, 17_000) + await scheduler.fire() + inFlight.begin(key(session)) + topUp(after: 17_000, supplied: 5_500, for: session) + inFlight.end(key(session)) + await scheduler.fire() + XCTAssertEqual(watcher.state, .received(duffs: 1)) + } + + func testATopUpOfAnotherIdentityDoesNotHoldTheReceipt() async { + watcher.start(session) + answer(10_000, 15_000) + await scheduler.fire() + inFlight.begin(key(otherSession)) + await scheduler.fire() + XCTAssertEqual(watcher.state, .received(duffs: 5)) + } + + // MARK: Gate and timer + + func testNoTimerRunsWhileTheGateIsClosed() { + watcher.setGateOpen(false) + watcher.start(session) + XCTAssertEqual(scheduler.scheduledCount, 0) + } + + func testClosingTheGateStopsTheTimer() async { + watcher.start(session) + answer(10_000) + await scheduler.fire() + watcher.setGateOpen(false) + XCTAssertTrue(scheduler.cancelled) + } + + func testOpeningTheGateChecksAtOnceAndKeepsTheStartingBalance() async { + watcher.start(session) + answer(10_000, 13_000) + await scheduler.fire() + watcher.setGateOpen(false) + watcher.setGateOpen(true) + // A new timer, whose first tick is immediate (`repeating`). + XCTAssertEqual(scheduler.scheduledCount, 2) + XCTAssertTrue(scheduler.isRunning) + await scheduler.fire() + XCTAssertEqual(watcher.state, .received(duffs: 3)) + } + + /// Closing the gate cancels the timer task and with it the read it runs, + /// which then answers with a failure. Reopening must check at once, and + /// the cancelled read's answer must not drop the watching note. + func testClosingTheGateMidReadDropsThatReadAndReopeningChecksAtOnce() async { + watcher.start(session) + answer(10_000) + await scheduler.fire() + source.hold() + source.answers.append(.failure(CancellationError())) + answer(10_000) + let readsBefore = source.reads.count + async let inFlight: Void = scheduler.fire() + await source.waitForReads(readsBefore + 1) + watcher.setGateOpen(false) + watcher.setGateOpen(true) + await scheduler.fire() + XCTAssertEqual(source.reads.count, readsBefore + 2) + source.release() + await inFlight + XCTAssertEqual(watcher.state, .watching) + } + + func testReopeningAnOpenGateKeepsTheTimer() { + watcher.start(session) + watcher.setGateOpen(true) + XCTAssertEqual(scheduler.scheduledCount, 1) + } + + func testRepeatingTicksBeforeItWaits() async { + let ticked = expectation(description: "first tick") + let timer = IdentityCreditsWatcher.repeating(3_600) { ticked.fulfill() } + await fulfillment(of: [ticked], timeout: 1) + timer.cancel() + } + + // MARK: Gaps + + func testNoReadWhileTheGateIsClosed() async { + watcher.start(session) + watcher.setGateOpen(false) + await scheduler.fire() + XCTAssertTrue(source.reads.isEmpty) + } + + func testAFailedCheckDropsWatchingAndTheFirstSuccessAfterTheGapRaisesTheReceipt() async { + watcher.start(session) + answer(10_000) + source.answers.append(.failure(Offline.unreachable)) + answer(13_000) + await scheduler.fire() + await scheduler.fire() + XCTAssertEqual(watcher.state, .notWatching) + await scheduler.fire() + XCTAssertEqual(watcher.state, .received(duffs: 3)) + } + + // MARK: Sessions + + func testAReplyForAnOldSessionIsDropped() async { + watcher.start(session) + answer(10_000) + await scheduler.fire() + answer(50_000) + source.hold() + let readsBefore = source.reads.count + async let inFlight: Void = scheduler.fire() + await source.waitForReads(readsBefore + 1) + watcher.start(otherSession) + source.release() + await inFlight + XCTAssertEqual(watcher.state, .notWatching) + } + + func testAReplyAfterStopIsDroppedAndTheTimerCancelled() async { + watcher.start(session) + answer(10_000) + source.hold() + let readsBefore = source.reads.count + async let inFlight: Void = scheduler.fire() + await source.waitForReads(readsBefore + 1) + watcher.stop() + source.release() + await inFlight + XCTAssertEqual(watcher.state, .notWatching) + XCTAssertTrue(scheduler.cancelled) + } + + func testReadsAreForTheStartedSession() async { + watcher.start(session) + answer(10_000) + await scheduler.fire() + XCTAssertEqual(source.reads, [session]) + } +} diff --git a/DashWalletTests/IdentityTopUpEventTests.swift b/DashWalletTests/IdentityTopUpEventTests.swift new file mode 100644 index 0000000000..96d80674ab --- /dev/null +++ b/DashWalletTests/IdentityTopUpEventTests.swift @@ -0,0 +1,154 @@ +// +// IdentityTopUpEventTests.swift +// DashWalletTests +// +// Copyright © 2026 Dash Core Group. All rights reserved. +// +// Licensed under the MIT License (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://opensource.org/licenses/MIT +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import SwiftDashSDK +import XCTest +@testable import dashpay + +/// A top-up from this wallet announces the credits it added, so the Identity +/// option on Receive raises no Receipt for it (AC-06, ADR-0034). +@MainActor +final class IdentityTopUpEventTests: XCTestCase { + private let walletId = Data(repeating: 1, count: 32) + private let identityId = Data(repeating: 2, count: 32) + + private enum Refused: Error { case byPlatform } + + private let center = NotificationCenter() + private let inFlight = IdentityTopUpsInFlight() + private var events: [IdentityTopUpDidComplete] = [] + private var token: NSObjectProtocol? + + override func setUp() { + token = center.addObserver(forName: IdentityTopUpDidComplete.name, object: nil, queue: nil) { [weak self] in + if let event = IdentityTopUpDidComplete(notification: $0) { self?.events.append(event) } + } + } + + override func tearDown() { + if let token { center.removeObserver(token) } + } + + private func announced(balanceAfter: UInt64?, suppliedCredits: UInt64) -> [IdentityTopUpDidComplete] { + IdentityTopUpDidComplete.announce( + balanceAfter: balanceAfter, + suppliedCredits: suppliedCredits, + walletId: walletId, + network: .testnet, + identityId: identityId, + center: center) + return events + } + + private func announcing(_ topUp: () async throws -> UInt64) async rethrows -> UInt64 { + try await IdentityTopUpDidComplete.announcing( + walletId: walletId, network: .testnet, identityId: identityId, + suppliedCredits: 1_000_000_000, center: center, inFlight: inFlight, topUp) + } + + private var key: IdentityTopUpsInFlight.Key { + .init(walletId: walletId, network: .testnet, identityId: identityId) + } + + /// The event carries the transition's own balance and what it was handed, + /// not a delta over the whole top-up: a spend from elsewhere during it + /// would cut that delta (review-2026-11-11-r1 S1). + func testSuccessfulTopUpPostsOneEventWithItsBalanceAndSuppliedCredits() { + let events = announced(balanceAfter: 2_958_500_000, suppliedCredits: 1_000_000_000) + XCTAssertEqual(events.count, 1) + XCTAssertEqual(events.first?.balanceAfter, 2_958_500_000) + XCTAssertEqual(events.first?.suppliedCredits, 1_000_000_000) + XCTAssertEqual(events.first?.identityId, identityId) + XCTAssertEqual(events.first?.walletId, walletId) + XCTAssertEqual(events.first?.network, .testnet) + } + + func testCancelledOrFailedTopUpPostsNothing() { + XCTAssertTrue(announced(balanceAfter: nil, suppliedCredits: 1_000_000_000).isEmpty) + } + + // MARK: The credits each funding source hands to the identity + + /// The Shielded route unshields the whole amount but claims it into the + /// identity less the fee headroom, which stays at the wallet's Platform + /// address. Announcing the whole amount would let the watcher absorb up to + /// the headroom of a Payer's credits with no Receipt. + func testShieldedTopUpSuppliesTheAmountLessTheFeeHeadroom() { + let amountDuffs: UInt64 = 5_000_000 + let credits = amountDuffs * PlatformPaymentIdentityFundingPolicy.creditsPerDuff + XCTAssertEqual( + IdentityTopUpViewModel.suppliedCredits(amountDuffs: amountDuffs, source: .shielded), + credits - PlatformPaymentIdentityFundingPolicy.feeHeadroomCredits) + } + + func testPlatformAndTransparentTopUpsSupplyTheWholeAmount() { + let amountDuffs: UInt64 = 5_000_000 + let credits = amountDuffs * PlatformPaymentIdentityFundingPolicy.creditsPerDuff + XCTAssertEqual(IdentityTopUpViewModel.suppliedCredits(amountDuffs: amountDuffs, source: .platform), credits) + XCTAssertEqual(IdentityTopUpViewModel.suppliedCredits(amountDuffs: amountDuffs, source: .transparent), credits) + } + + // MARK: The coordinator's top-ups (registration shortfall, name purchase) + + func testATopUpThatReturnsAnnouncesItsBalanceAndPassesItOn() async throws { + let after = try await announcing { 2_958_500_000 } + XCTAssertEqual(after, 2_958_500_000) + XCTAssertEqual(events.map(\.balanceAfter), [2_958_500_000]) + XCTAssertEqual(events.first?.identityId, identityId) + } + + func testATopUpThatThrowsAnnouncesNothing() async { + do { + _ = try await announcing { throw Refused.byPlatform } + XCTFail("The refusal must reach the caller") + } catch { + XCTAssertEqual(error as? Refused, .byPlatform) + } + XCTAssertTrue(events.isEmpty) + } + + /// The watch holds its Receipt while the top-up runs (review-2026-11-10-r3 Q1). + func testATopUpIsInFlightOnlyWhileItRuns() async throws { + var runningDuringTopUp = false + _ = try await announcing { + runningDuringTopUp = inFlight.contains(key) + return 2_958_500_000 + } + XCTAssertTrue(runningDuringTopUp) + XCTAssertFalse(inFlight.contains(key)) + } + + func testATopUpThatThrowsIsNoLongerInFlight() async { + _ = try? await announcing { throw Refused.byPlatform } + XCTAssertFalse(inFlight.contains(key)) + } + + func testTwoTopUpsOfOneIdentityStayInFlightUntilBothEnd() { + inFlight.begin(key) + inFlight.begin(key) + inFlight.end(key) + XCTAssertTrue(inFlight.contains(key)) + inFlight.end(key) + XCTAssertFalse(inFlight.contains(key)) + } + + func testANotificationOfAnotherNameIsNotAnEvent() { + XCTAssertNil(IdentityTopUpDidComplete(notification: Notification(name: .init("Other")))) + } +} diff --git a/DashWalletTests/PaymentsLandingIdentityOptionTests.swift b/DashWalletTests/PaymentsLandingIdentityOptionTests.swift new file mode 100644 index 0000000000..7db05bb7e4 --- /dev/null +++ b/DashWalletTests/PaymentsLandingIdentityOptionTests.swift @@ -0,0 +1,439 @@ +// +// PaymentsLandingIdentityOptionTests.swift +// DashWalletTests +// +// Copyright © 2026 Dash Core Group. All rights reserved. +// +// Licensed under the MIT License (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://opensource.org/licenses/MIT +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import SwiftDashSDK +import SwiftUI +import XCTest +@testable import dashpay + +/// When Receive offers the Identity option, what its card shows, and where +/// the selection goes when the option disappears (AC-03, AC-09 – AC-14). +@MainActor +final class PaymentsLandingIdentityOptionTests: XCTestCase { + private let identityId = Data((1...32).map { UInt8($0) }) + private let otherIdentityId = Data((0..<32).map { UInt8(255 - $0) }) + + private var identity: ReceiveIdentity { + get throws { try XCTUnwrap(ReceiveIdentity(identityId: identityId, username: "alice")) } + } + + // MARK: Card state + + func testIdentityCardCarriesTheBareBase58Id() throws { + let id = try identity.identityIdBase58 + XCTAssertEqual(id, ScriptAddressCodec.base58Encode(identityId)) + XCTAssertTrue((43...44).contains(id.count), "\(id.count)") + XCTAssertFalse(id.contains("alice")) + XCTAssertFalse(id.contains(":")) + XCTAssertEqual(try identity.username, "alice") + } + + func testNoIdentityOrNoUsernameMeansNoIdentityCard() { + XCTAssertNil(ReceiveIdentity(identityId: nil, username: "alice")) + XCTAssertNil(ReceiveIdentity(identityId: identityId, username: nil)) + XCTAssertNil(ReceiveIdentity(identityId: identityId, username: "")) + } + + // MARK: Offered options + + func testAdvancedModeOffIsTheBasicReceive() throws { + XCTAssertEqual( + ReceiveOptionPolicy.options(isAdvancedMode: false, identity: try identity, isQuickReceive: false), + [.core, .shielded]) + } + + func testAdvancedModeOnWithoutAUsernameOffersNoIdentity() { + XCTAssertEqual( + ReceiveOptionPolicy.options(isAdvancedMode: true, identity: nil, isQuickReceive: false), + [.core, .shielded, .platform]) + } + + func testAdvancedModeOnWithAUsernameAppendsIdentityAfterPlatform() throws { + XCTAssertEqual( + ReceiveOptionPolicy.options(isAdvancedMode: true, identity: try identity, isQuickReceive: false), + [.core, .shielded, .platform, .identity]) + } + + func testQuickReceiveNeverOffersIdentity() throws { + XCTAssertFalse( + ReceiveOptionPolicy.options(isAdvancedMode: true, identity: try identity, isQuickReceive: true) + .contains(.identity)) + let model = PaymentsLandingViewModel.makeForPreview(activeTab: .receive, isQuickReceive: true) + model.updateReceiveState(isAdvancedMode: true, identity: try identity) + XCTAssertFalse(model.receiveOptions.contains(.identity)) + } + + // MARK: Selection + + private func modelOnIdentity() throws -> PaymentsLandingViewModel { + let model = PaymentsLandingViewModel.makeForPreview(activeTab: .receive) + model.updateReceiveState(isAdvancedMode: true, identity: try identity) + model.network = .identity + return model + } + + func testAdvancedModeOffOnIdentityMovesToCore() throws { + let model = try modelOnIdentity() + model.updateReceiveState(isAdvancedMode: false, identity: try identity) + XCTAssertEqual(model.network, .core) + XCTAssertEqual(model.receiveOptions, [.core, .shielded]) + } + + func testUsernameAppearingKeepsTheSelection() throws { + let model = PaymentsLandingViewModel.makeForPreview(activeTab: .receive) + model.updateReceiveState(isAdvancedMode: true, identity: nil) + model.network = .platform + model.updateReceiveState(isAdvancedMode: true, identity: try identity) + XCTAssertEqual(model.network, .platform) + XCTAssertEqual(model.receiveOptions.last, .identity) + } + + func testLosingTheUsernameOnIdentityMovesToCoreAndClearsTheCard() throws { + let model = try modelOnIdentity() + model.updateReceiveState(isAdvancedMode: true, identity: nil) + XCTAssertEqual(model.network, .core) + XCTAssertNil(model.receiveIdentity) + } + + func testChangedUsernameStaysOnIdentityAndShowsTheNewName() throws { + let model = try modelOnIdentity() + model.updateReceiveState( + isAdvancedMode: true, identity: ReceiveIdentity(identityId: identityId, username: "bob")) + XCTAssertEqual(model.network, .identity) + XCTAssertEqual(model.receiveIdentity?.username, "bob") + } + + func testSwitchToAnotherIdentityShowsOnlyTheNewId() throws { + let model = try modelOnIdentity() + let other = try XCTUnwrap(ReceiveIdentity(identityId: otherIdentityId, username: "carol")) + model.updateReceiveState(isAdvancedMode: true, identity: other) + XCTAssertEqual(model.network, .identity) + XCTAssertEqual(model.receiveIdentity, other) + XCTAssertNotEqual(model.receiveIdentity?.identityIdBase58, try identity.identityIdBase58) + } + + // MARK: Card content + + /// The QR, Copy and Share all take `currentAddress`; on Identity it is the + /// bare Base58 ID and nothing else (AC-03). + func testOnIdentityTheCardEncodesCopiesAndSharesTheBareId() throws { + let model = try modelOnIdentity() + XCTAssertEqual(model.currentAddress, try identity.identityIdBase58) + UIPasteboard.general.string = nil + model.copyCurrentAddressToPasteboard() + XCTAssertEqual(UIPasteboard.general.string, try identity.identityIdBase58) + } + + func testCopyUsernameCopiesExactlyTheUsername() throws { + let model = try modelOnIdentity() + UIPasteboard.general.string = nil + model.copyUsernameToPasteboard() + XCTAssertEqual(UIPasteboard.general.string, "alice") + } + + func testIdentityWithoutUsernameHasNothingToEncode() { + let model = PaymentsLandingViewModel.makeForPreview(activeTab: .receive) + model.updateReceiveState(isAdvancedMode: true, identity: nil) + model.network = .identity + XCTAssertNil(model.currentAddress) + } + + func testIdentityReceiptNamesTheIdentityBalanceAndIsReceived() { + let receipt = ReceiveReceipt( + id: "identity-1", rail: .identity, amountDuffs: 1, receivedAt: Date(), memo: nil, transactionId: nil) + XCTAssertEqual(receipt.rail.balanceName, NSLocalizedString("Identity", comment: "")) + XCTAssertEqual(receipt.statusTitle, NSLocalizedString("Received", comment: "Receive payment status")) + } + + // MARK: Identity watch (T6) + + private let walletId = Data(repeating: 9, count: 32) + + /// Answers reads from a queue (failure when empty) and records them. + private final class FakeCredits { + var answers: [UInt64] = [] + private(set) var reads: [IdentityCreditsWatcher.Session] = [] + + func read(_ session: IdentityCreditsWatcher.Session) -> Result { + reads.append(session) + guard !answers.isEmpty else { return .failure(IdentityBalanceRefresh.Superseded()) } + return .success(answers.removeFirst()) + } + } + + /// Keeps the watcher's tick so the test fires it instead of a timer. + private final class Ticks { + var tick: (@MainActor () async -> Void)? + + func fire() async { await tick?() } + } + + private let credits = FakeCredits() + private let ticks = Ticks() + private let topUpCenter = NotificationCenter() + + private func watchedModel(isQuickReceive: Bool = false) throws -> PaymentsLandingViewModel { + let credits = credits + let ticks = ticks + let watcher = IdentityCreditsWatcher( + read: { credits.read($0) }, + schedule: { _, tick in + ticks.tick = tick + return Task {} + }, + center: topUpCenter) + let walletId = walletId + let model = PaymentsLandingViewModel.makeForPreview( + activeTab: .receive, + isQuickReceive: isQuickReceive, + identityWatcher: watcher, + identityContext: { (walletId, .testnet) }, + receiveIdentitySource: { [identityId] in ReceiveIdentity(identityId: identityId, username: "alice") }) + model.updateReceiveState(isAdvancedMode: true, identity: try identity) + model.network = .identity + model.setReceiveSurfaceVisible(true) + return model + } + + private var watchSession: IdentityCreditsWatcher.Session { + IdentityCreditsWatcher.Session(walletId: walletId, network: .testnet, identityId: identityId) + } + + func testPickingIdentityStartsAWatchForTheCurrentIdentity() async throws { + let model = try watchedModel() + credits.answers = [10_000] + await ticks.fire() + XCTAssertEqual(credits.reads, [watchSession]) + XCTAssertTrue(model.isWatchingForReceipt) + } + + func testARiseRaisesAnIdentityReceiptWithNoTransaction() async throws { + let model = try watchedModel() + credits.answers = [10_000, 5_010_000] + await ticks.fire() + await ticks.fire() + let receipt = try XCTUnwrap(model.receipt) + XCTAssertEqual(receipt.rail, .identity) + XCTAssertEqual(receipt.amountDuffs, 5_000) + XCTAssertNil(receipt.transactionId) + XCTAssertFalse(model.canViewTransaction) + XCTAssertFalse(model.isWatchingForReceipt) + } + + func testAFailedReadDropsTheWatchingNote() async throws { + let model = try watchedModel() + credits.answers = [10_000] + await ticks.fire() + XCTAssertTrue(model.isWatchingForReceipt) + await ticks.fire() + XCTAssertFalse(model.isWatchingForReceipt) + } + + func testARegistrationUpdateMidSessionKeepsTheStartingBalance() async throws { + let model = try watchedModel() + credits.answers = [10_000, 12_000] + await ticks.fire() + model.registrationStatusDidChange() + await ticks.fire() + XCTAssertEqual(model.network, .identity) + XCTAssertEqual(model.receipt?.amountDuffs, 2) + } + + func testQuickReceiveStartsNoWatchEvenWithIdentitySelected() async throws { + let model = try watchedModel(isQuickReceive: true) + model.network = .identity + model.setReceiveSurfaceVisible(true) + credits.answers = [10_000] + await ticks.fire() + XCTAssertTrue(credits.reads.isEmpty) + XCTAssertFalse(model.isWatchingForReceipt) + } + + func testUsernameChangeKeepsTheStartingBalance() async throws { + let model = try watchedModel() + credits.answers = [10_000, 12_000] + await ticks.fire() + model.updateReceiveState( + isAdvancedMode: true, identity: ReceiveIdentity(identityId: identityId, username: "bob")) + await ticks.fire() + XCTAssertEqual(model.receipt?.amountDuffs, 2) + } + + func testAnotherIdentityStartsANewSession() async throws { + let model = try watchedModel() + credits.answers = [10_000, 50_000] + await ticks.fire() + model.updateReceiveState( + isAdvancedMode: true, identity: ReceiveIdentity(identityId: otherIdentityId, username: "carol")) + await ticks.fire() + XCTAssertEqual(credits.reads.last?.identityId, otherIdentityId) + XCTAssertNil(model.receipt, "The new identity's first read is its Starting balance") + } + + func testAdvancedModeOffStopsTheWatch() async throws { + let model = try watchedModel() + credits.answers = [10_000, 50_000] + await ticks.fire() + model.updateReceiveState(isAdvancedMode: false, identity: try identity) + await ticks.fire() + XCTAssertEqual(credits.reads.count, 1) + XCTAssertNil(model.receipt) + } + + func testNoChecksWhileTheCardIsCovered() async throws { + let model = try watchedModel() + credits.answers = [10_000] + await ticks.fire() + model.setReceiptWatchingObscured(true) + await ticks.fire() + XCTAssertEqual(credits.reads.count, 1) + XCTAssertFalse(model.isWatchingForReceipt) + } + + // MARK: The production read (AC-07, AC-13) + + private enum Offline: Error { case unreachable } + + /// The read with a recording refresh; `context` is the active wallet and network. + private func productionRead( + context: (walletId: Data, network: Network?)?, + answer: Result = .success(42) + ) -> (IdentityCreditsWatcher.Read, () -> [IdentityCreditsWatcher.Session]) { + var refreshed: [IdentityCreditsWatcher.Session] = [] + let read = PaymentsLandingViewModel.identityBalanceRead( + activeContext: { context }, + refresh: { refreshed.append($0); return answer }) + return (read, { refreshed }) + } + + func testTheReadRefreshesTheSessionsIdentityInTheActiveContext() async { + let (read, refreshed) = productionRead(context: (walletId, .testnet)) + let result = await read(watchSession) + XCTAssertEqual(try? result.get(), 42) + XCTAssertEqual(refreshed(), [watchSession]) + } + + func testTheReadPassesARefreshFailureThrough() async { + let (read, _) = productionRead(context: (walletId, .testnet), answer: .failure(Offline.unreachable)) + let result = await read(watchSession) + XCTAssertThrowsError(try result.get()) { XCTAssertEqual($0 as? Offline, .unreachable) } + } + + func testTheReadNeverRefreshesForAnotherWalletNetworkOrNoWallet() async { + let contexts: [(walletId: Data, network: Network?)?] = [ + (Data(repeating: 7, count: 32), .testnet), + (walletId, .mainnet), + (walletId, nil), + nil + ] + for context in contexts { + let (read, refreshed) = productionRead(context: context) + let result = await read(watchSession) + XCTAssertThrowsError(try result.get()) + XCTAssertTrue(refreshed().isEmpty) + } + } + + // MARK: A trip to Internal transfer (AC-08) + + private func visitInternalTransfer(_ model: PaymentsLandingViewModel, while action: () -> Void = {}) { + model.activeTab = .internalTransfer + action() + model.activeTab = .receive + } + + func testPayerCreditsDuringInternalTransferRaiseAReceiptOnReturn() async throws { + let model = try watchedModel() + credits.answers = [10_000, 30_000] + await ticks.fire() + visitInternalTransfer(model) + await ticks.fire() + XCTAssertEqual(model.network, .identity) + XCTAssertEqual(model.receipt?.amountDuffs, 20) + } + + func testOwnTopUpDuringInternalTransferRaisesNoReceipt() async throws { + let model = try watchedModel() + credits.answers = [10_000, 30_000] + await ticks.fire() + visitInternalTransfer(model) { + IdentityTopUpDidComplete( + walletId: walletId, network: .testnet, identityId: identityId, + balanceAfter: 30_000, suppliedCredits: 20_000) + .post(to: topUpCenter) + } + await ticks.fire() + XCTAssertNil(model.receipt) + XCTAssertTrue(model.isWatchingForReceipt) + } + + func testNoChecksWhileOnInternalTransfer() async throws { + let model = try watchedModel() + credits.answers = [10_000] + await ticks.fire() + model.activeTab = .internalTransfer + await ticks.fire() + XCTAssertEqual(credits.reads.count, 1) + XCTAssertFalse(model.isWatchingForReceipt) + } + + func testReceiveAnotherStartsAFreshStartingBalance() async throws { + let model = try watchedModel() + credits.answers = [10_000, 20_000, 20_000] + await ticks.fire() + await ticks.fire() + XCTAssertEqual(model.receipt?.amountDuffs, 10) + model.receiveAnother() + await ticks.fire() + XCTAssertNil(model.receipt) + XCTAssertTrue(model.isWatchingForReceipt) + } + + // MARK: Layout + + /// The Identity card is the tallest Receive card. On a screen shorter + /// than it, the page must still fit what it is given (it scrolls) rather + /// than ask for more: an overflowing page squeezes the AC-04 warning to + /// one truncated line per sentence and pushes Close off the top. + func testIdentityReceivePageFitsTheHeightItIsGiven() throws { + let model = PaymentsLandingViewModel.makeForPreview(activeTab: .receive, isWatching: true) + model.updateReceiveState(isAdvancedMode: true, identity: try identity) + model.network = .identity + let screen = PaymentsLandingScreen( + viewModel: model, + onClose: {}, + onDone: {}, + onCopyAddress: {}, + onShareAddress: {}, + onSpecifyAmount: {}, + onViewTransaction: { _ in }, + onScanQR: {}, + embeddedTransferViewModel: .makeForPreview(), + embeddedSendViewModel: .makeForPreview(), + showsHeader: false) + let host = UIHostingController(rootView: screen) + // The payments sheet's content area on an iPhone 17 and on the + // smallest supported iPhone (375 × 667 pt, less the sheet's top gap + // and the home indicator). + for given in [CGSize(width: 402, height: 778), CGSize(width: 375, height: 600)] { + let needed = host.sizeThatFits(in: given) + XCTAssertLessThanOrEqual(needed.height, given.height, "page at \(given)") + } + } +} diff --git a/DashWalletTests/ReceiveOptionTests.swift b/DashWalletTests/ReceiveOptionTests.swift new file mode 100644 index 0000000000..e3816490d2 --- /dev/null +++ b/DashWalletTests/ReceiveOptionTests.swift @@ -0,0 +1,52 @@ +// +// ReceiveOptionTests.swift +// DashWalletTests +// +// Copyright © 2026 Dash Core Group. All rights reserved. +// +// Licensed under the MIT License (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://opensource.org/licenses/MIT +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import XCTest +@testable import dashpay + +/// `ReceiveOption` is Receive's own option type: its chain cases map to +/// `ChainNetwork` and back, and Identity maps to no chain, so it can never +/// reach Send, Home or Internal transfer (ADR-0035). +final class ReceiveOptionTests: XCTestCase { + func testEveryChainNetworkRoundTripsThroughReceiveOption() { + for network in ChainNetwork.allCases { + XCTAssertEqual(ReceiveOption(network).chainNetwork, network) + } + } + + func testChainOptionsMapToTheirChain() { + XCTAssertEqual(ReceiveOption.core.chainNetwork, .core) + XCTAssertEqual(ReceiveOption.shielded.chainNetwork, .shielded) + XCTAssertEqual(ReceiveOption.platform.chainNetwork, .platform) + } + + func testIdentityMapsToNoChain() { + XCTAssertNil(ReceiveOption.identity.chainNetwork) + } + + func testChainNetworkStillListsOnlyTheThreeChains() { + XCTAssertEqual(ChainNetwork.allCases, [.core, .platform, .shielded]) + } + + func testChainOptionsKeepTheChainTitles() { + for network in ChainNetwork.allCases { + XCTAssertEqual(ReceiveOption(network).title, network.title) + } + } +} diff --git a/docs/adr/0034-subtract-own-top-ups-via-a-typed-top-up-event.md b/docs/adr/0034-subtract-own-top-ups-via-a-typed-top-up-event.md new file mode 100644 index 0000000000..1ab93dd483 --- /dev/null +++ b/docs/adr/0034-subtract-own-top-ups-via-a-typed-top-up-event.md @@ -0,0 +1,49 @@ +# 0034 — Subtract own top-ups via a typed top-up event + +- **Status:** Proposed +- **Date:** 2026-11-09 +- **Deciders:** Roman Chornyi (owner), with Claude during the design pass. Becomes Accepted only on a non-author Reviewer's approval of the PR that carries it (ADR-0001 rule 3). + +## Context + +The Identity option raises a Receipt when the Current identity's credits rise above the Starting balance (spec AC-05), because Platform gives the wallet only the identity's balance, not a list of incoming transfers (spec §6.1). The wallet can raise the same balance itself: an identity top-up from Internal transfer or from the identity profile, both run by `IdentityTopUpViewModel.topUp`, and the top-ups `DWIdentityRegistrationCoordinator` makes for an existing identity before registering another username or buying a name. Spec AC-06 says such a top-up raises no Receipt and moves the Starting balance up with it; AC-08 says credits from a Payer that land while Internal transfer or Share covers the card still raise a Receipt at the first successful check after the gap. The top-up path and the Receive watcher are in different modules (`UI/Payments/InternalTransfer`, `UI/DashPay/Profile` and `UI/Payments/Landing`) and share no signal today; the only post after a balance refresh is the DashPay-named `DWDashPayRegistrationStatusUpdatedNotification`, which carries no amount. Simply taking a fresh Starting balance once Internal transfer closes is ruled out by AC-08: it would absorb a Payer's credits that landed meanwhile. + +## Decision drivers + +- No fake or early Receipt — spec §6.1 abuse case, §1 quality goal 1. +- No lost Receipt for a Payer's credits that land during a gap — spec AC-08. +- Repo guardrail 5 (`CLAUDE.md`): new state gets a new typed publisher or notification, never a re-post of another system's notification name. +- Repo guardrail 4: no new `static let shared` without a reason. + +## Considered options + +1. **A typed top-up event** — after a successful top-up, the top-up path posts a new `IdentityTopUpDidComplete` notification carrying the wallet, the network, the identity and the credits the top-up added; the Identity watcher raises its Starting balance by that amount, whether or not the card is covered at that moment. +2. **An in-memory ledger of own top-ups** — the top-up path records each top-up in a shared registry that the watcher reads on every check. Same information as option 1, pulled instead of pushed, at the cost of a new shared object. +3. **The typed event plus a registry of top-ups in flight** — option 1, and the top-up path also registers each top-up in a shared `IdentityTopUpsInFlight` from before the SDK call until after the event is posted or the call throws. While a top-up of the watched identity is in flight, the watcher raises no Receipt and takes no Starting balance. Platform raises the balance before the top-up call returns, so option 1 alone shows a check in that window as «Received» (PR #1344 review, review-2026-11-10-r3 Q1). + +## Decision outcome + +**Chosen:** option 3, a typed `IdentityTopUpDidComplete` event that the watcher subtracts from future increases by raising its Starting balance, plus a registry of top-ups in flight that holds the Receipt decision until that event arrives. The event carries the balance the top-up's transition returned and the credits it was handed, and the watcher sets its Starting balance to the lower of that balance and its Starting balance plus those credits: a delta over the whole top-up would be cut by a spend from elsewhere while it ran, which the watcher has already subtracted, and the top-up would come back as a Receipt (review-2026-11-11-r1 S1). The event alone (option 1) left the window between Platform raising the balance and the top-up call returning, in which a check took the own top-up for a payment and ended the watch. The registry is shared because a top-up can start before the Receive screen that watches its identity exists (the username flow closes while its top-up still runs); that is the reason guardrail 4 asks for, and the watcher takes it injected. The event stays a new, typed name rather than a re-post of the DashPay registration notification. + +## Consequences + +**Positive** +- A top-up from this wallet raises no Receipt, wherever it was started and whether a check sees its rise before or after it is announced: Internal transfer and the profile sheet run `IdentityTopUpViewModel.topUp`, and the registration coordinator's shortfall and name-purchase top-ups and the asset-lock recovery's top-up retry run through `IdentityTopUpDidComplete.announcing`; each is in flight while it runs and posts the event (the retry only when its lock row is stored, as the lock's value bounds the credits). +- A Payer's credits seen while an own top-up runs are not lost: the Receipt waits, and the event raises the Starting balance only by the top-up's credits. +- A Payer's credits that land while Internal transfer covers the card still raise a Receipt after it closes. +- Other future listeners (for example, a History entry for an own top-up) can use the same event. + +**Negative** +- Every top-up path gets a new outgoing contract: a top-up of an existing identity that neither runs `IdentityTopUpViewModel.topUp` nor goes through `IdentityTopUpDidComplete.announcing` raises a false Receipt. +- A new process-wide object, `IdentityTopUpsInFlight.shared`. A top-up that is in flight when the Identity option is opened delays the Starting balance until it ends, so the card says it is watching a little later. +- The event carries the transition's own balance, so a Payer's credits that land between the watcher's last check and the end of the top-up are in it. The Starting balance moves by at most the credits the top-up was handed, so at most the top-up's fee worth of them raises no Receipt (sad.md §11). +- A top-up that throws after Platform carried it out posts nothing; once it leaves the registry, its rise shows as «Received» (accepted limit, spec §6.1). + +**Neutral** +- A top-up of the same identity from another device holding the same recovery phrase still shows as «Received» — an accepted limit in spec §6.1 that this event cannot see. + +## Links + +- Feature summary (acceptance criteria and known limits): [identity-receive](../features/identity-receive/README.md) +- Android counterpart: [dashpay/dash-wallet#1677](https://github.com/dashpay/dash-wallet/pull/1677) +- Related ADR: [0035 — Model Receive options as a Receive-only enum](0035-model-receive-options-as-a-receive-only-enum.md) diff --git a/docs/adr/0035-model-receive-options-as-a-receive-only-enum.md b/docs/adr/0035-model-receive-options-as-a-receive-only-enum.md new file mode 100644 index 0000000000..3a2b280039 --- /dev/null +++ b/docs/adr/0035-model-receive-options-as-a-receive-only-enum.md @@ -0,0 +1,45 @@ +# 0035 — Model Receive options as a Receive-only enum + +- **Status:** Proposed +- **Date:** 2026-11-09 +- **Deciders:** Roman Chornyi (owner), with Claude during the design pass. Becomes Accepted only on a non-author Reviewer's approval of the PR that carries it (ADR-0001 rule 3). + +## Context + +Receive offers its options from `PaymentsLandingViewModel.receiveNetworks`, a list of `ChainNetwork` values (`core`, `platform`, `shielded`), and a Receipt names its option through `ReceiveReceipt.rail: ChainNetwork`. `ChainNetwork` is shared by 21 files: Home's balance rows, the Send toggle, and Internal transfer, which lists its endpoints from `ChainNetwork.allCases`. The feature adds Identity as a fourth Receive option (spec AC-01). The Current identity is not a chain and not one of the wallet's balances in those screens, and spec §3 keeps Identity out of Send and out of any new entry into Receive. + +## Decision drivers + +- Identity appears on Receive and nowhere else (spec §3 non-goals: no Send to an Identity ID, no new way into Receive). +- Correct identity, always — §1 quality goal 1: a Receipt names the option it was raised on and is never confused with a Platform one. +- Repo guardrail 7 (`CLAUDE.md`): a type's name matches its behaviour — `ChainNetwork` names a chain. +- Size S: the change stays inside `UI/Payments/Landing`. + +## Considered options + +1. **A Receive-only enum** `ReceiveOption` {core, shielded, platform, identity}: the three chain options map to `ChainNetwork`, identity maps to none; the option row, the selection, the card and `ReceiveReceipt` use it. +2. **Add `identity` to `ChainNetwork`** — fewest new types, but every exhaustive `switch` and every `allCases` in the 21 files has to exclude it by hand, starting with Internal transfer's endpoint list. + +## Decision outcome + +**Chosen:** option 1, a Receive-only `ReceiveOption` enum that maps its chain cases to `ChainNetwork`. It keeps Identity out of Send, Home and Internal transfer by construction rather than by filters each future call site must remember, and it confines the change to the Receive files. + +## Consequences + +**Positive** +- `ChainNetwork` and its 21 users do not change; `ChainNetwork.allCases` keeps meaning «chains». +- The compiler lists every Receive place that has to handle `identity` (its exhaustive `switch`es). +- `ReceiveReceipt.rail` says which Receive option a Receipt came from, including Identity. + +**Negative** +- Receive code gains a mapping (`ReceiveOption` → `ChainNetwork?`) and the selected-option property changes type; Home and the other callers that open Receive on a given chain pass through that mapping. +- Two enums with three overlapping cases: a reader has to know which one a screen uses. + +**Neutral** +- If Send later pays to an Identity ID (spec §8 open question), that is its own decision; this ADR does not make Identity a chain. + +## Links + +- Feature summary (acceptance criteria and known limits): [identity-receive](../features/identity-receive/README.md) +- Android counterpart: [dashpay/dash-wallet#1677](https://github.com/dashpay/dash-wallet/pull/1677) +- Related ADR: [0034 — Subtract own top-ups via a typed top-up event](0034-subtract-own-top-ups-via-a-typed-top-up-event.md) diff --git a/docs/adr/README.md b/docs/adr/README.md index 885879d967..26878de962 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -37,6 +37,8 @@ where they disagree, ADR-0001 wins. | [0031](0031-turn-off-unattributed-dashpay-profile-keys-with-any-disconnect.md) | Turn off unattributed DashPay profile keys with any disconnect | keys | Proposed | | | [0032](0032-pass-owners-read-from-platform-into-the-pure-projection.md) | Pass the owners read from Platform into the pure App Connect projection | platform | Proposed | | | [0033](0033-turn-off-only-the-unrecorded-keys-the-question-listed.md) | Turn off only the unrecorded keys the question listed | keys | Superseded | [0016](0016-turn-off-unrecorded-keys-on-disconnect-without-asking.md) | +| [0034](0034-subtract-own-top-ups-via-a-typed-top-up-event.md) | Subtract own top-ups via a typed top-up event | ui | Proposed | | +| [0035](0035-model-receive-options-as-a-receive-only-enum.md) | Model Receive options as a Receive-only enum | ui | Proposed | | Areas: `spv`, `platform`, `keys`, `storage`, `coinjoin`, `payments`, `swap`, `ui`, `build`, `process`. Each ADR takes one; a new Area is added to this list in the PR that first needs it. diff --git a/docs/features/identity-receive/README.md b/docs/features/identity-receive/README.md new file mode 100644 index 0000000000..353a53365b --- /dev/null +++ b/docs/features/identity-receive/README.md @@ -0,0 +1,75 @@ +# Receive to the identity + +**Owner:** romchornyi · Jira MO-1123 · Android counterpart [dash-wallet#1677](https://github.com/dashpay/dash-wallet/pull/1677) + +## Why + +A Wallet holder could be paid to their identity by its ID, but the wallet never showed that ID +where a Payer is pointed to, and gave no feedback when credits landed. +[ADR-0035](../../adr/0035-model-receive-options-as-a-receive-only-enum.md), +[ADR-0034](../../adr/0034-subtract-own-top-ups-via-a-typed-top-up-event.md). + +## What changed + +- **A fourth Receive option, Identity**, with Advanced Mode on and a username on the Current + identity, on both Receive presentations (Payments and the sheet from a balance row) and nowhere + else. Receive options are a Receive-only enum; Send and Internal transfer keep their own type. + [ADR-0035](../../adr/0035-model-receive-options-as-a-receive-only-enum.md). +- **The Identity card:** a QR of the bare Base58 Identity ID, the ID as text, the username, Copy, + Share ID, Specify amount unavailable, and a warning that identity funds pay for Dash apps and + usernames and that most exchanges and many wallets send only to Core. +- **A Receipt when credits arrive:** while the card is on screen and the app is in the foreground, + the wallet reads the identity's credits every 5 s, starting from a fresh read made on opening. + A rise shows a Receipt (amount in Dash and local currency, «Identity», «Received»). +- **No Receipt for the wallet's own top-ups:** every identity top-up announces the credits it + supplied, and the starting balance moves up by them. + [ADR-0034](../../adr/0034-subtract-own-top-ups-via-a-typed-top-up-event.md). + +## Acceptance criteria + +- **AC-01** The card shows a QR of the Identity ID, the ID as text (cut in the middle when it does + not fit) and the username; Copy and Share are available, Specify amount is not. +- **AC-02** Copy copies exactly the ID or the username, with the usual copy confirmation. +- **AC-03** The QR and the shared text are exactly the Base58 Identity ID, nothing added. +- **AC-04** The card warns what identity funds are for and that many senders pay only to Core. +- **AC-05** A check that finds the credits higher than at opening shows a Receipt for the + increase; payments between two checks give one Receipt for their sum. +- **AC-06** Credits that stay the same or go down raise no Receipt, and neither does a top-up of + the identity from this wallet while Receive is open. A lower balance becomes the new starting + balance, so a later rise is measured from it, even while the credits stay below the balance at + opening. +- **AC-07** After a Receipt, Identities and Internal transfer already show the new balance. +- **AC-08** Without Platform, the QR, ID, username, Copy and Share still work and the card does + not say it is watching; credits that land during a gap after the starting balance was read show at + the next successful check, while credits that land before the first successful read become part + of the starting balance and raise no Receipt. +- **AC-09** With Advanced Mode off, Receive is unchanged and shows no Identity ID. +- **AC-10** Without an identity, a username, or with a registration in progress, there is no + Identity option. +- **AC-11** Turning Advanced Mode off while on Identity moves Receive to Core. +- **AC-12** The option appears without leaving Receive once a username registration completes, or + once the username is read after a cold start or a network switch. +- **AC-13** A wallet or network switch shows the new Current identity or removes the option; + the previous identity's ID never shows and raises no Receipt. +- **AC-14** When the username is lost the option disappears; when it changes the card shows the + new one. + +## Known limits + +Platform reports only the identity's balance, not transfers, so a Receipt reports a balance +increase: + +- a top-up from another device with the same recovery phrase shows as «Received»; +- a fee and a payment between the same two checks show as their net; +- a lagging Platform node can lower the starting balance, so a later up-to-date read shows an + earlier payment or an own top-up as «Received»; +- an own top-up that fails after Platform carried it out shows as «Received» (while an own + top-up runs, no Receipt is raised); +- a Payer's credits that land between the last check and the end of an own top-up count as part + of it up to the credits it supplied, so at most the top-up's fee worth of them raises no + Receipt (they still show in the balance). + +## Not in scope + +- Specify amount on Identity. +- Paying to a scanned Identity ID from Send. diff --git a/scripts/fixtures/IdentityTopUpCompatibilityHarness.swift b/scripts/fixtures/IdentityTopUpCompatibilityHarness.swift index 9a55579dd9..837e770976 100644 --- a/scripts/fixtures/IdentityTopUpCompatibilityHarness.swift +++ b/scripts/fixtures/IdentityTopUpCompatibilityHarness.swift @@ -71,9 +71,11 @@ enum PlatformPaymentIdentityFundingPolicy { var wallet: ManagedPlatformWallet? = ManagedPlatformWallet() var manager: NativeManager? = NativeManager() var modelContainer: ModelContainer? = ModelContainer() - + var runningNetwork: Network? = .testnet } +enum Network: Hashable { case testnet } + @MainActor final class PlatformAddressSyncCoordinator { struct Address { let address: String } struct Addresses { var nextReceiveAddress: Address? = .init(address: "destination") } diff --git a/scripts/fixtures/IdentityTopUpCompatibilityTests.swift b/scripts/fixtures/IdentityTopUpCompatibilityTests.swift index b3e04cc2b1..0612ef6ec8 100644 --- a/scripts/fixtures/IdentityTopUpCompatibilityTests.swift +++ b/scripts/fixtures/IdentityTopUpCompatibilityTests.swift @@ -199,4 +199,20 @@ import XCTest XCTAssertEqual(host.manager!.unshieldCalls, 1) XCTAssertEqual(host.wallet!.topUpCalls, 1) } + + func testCompletedTopUpAnnouncesSuppliedCreditsAndLeavesNothingInFlight() async { + var events: [IdentityTopUpDidComplete] = [] + let observer = NotificationCenter.default.addObserver( + forName: IdentityTopUpDidComplete.name, object: nil, queue: nil + ) { notification in + if let event = IdentityTopUpDidComplete(notification: notification) { events.append(event) } + } + defer { NotificationCenter.default.removeObserver(observer) } + let result = await IdentityTopUpViewModel().topUp(identityId: Data([2]), amountDuffs: 100, source: .shielded) + XCTAssertEqual(result, 97) + XCTAssertEqual(events.map(\.balanceAfter), [97]) + XCTAssertEqual(events.map(\.suppliedCredits), [100 * 1_000 - 5]) + XCTAssertFalse(IdentityTopUpsInFlight.shared.contains( + .init(walletId: host.wallet!.walletId, network: .testnet, identityId: Data([2])))) + } } diff --git a/scripts/test_identity_top_up_compatibility.py b/scripts/test_identity_top_up_compatibility.py index 6feee98563..188961782a 100644 --- a/scripts/test_identity_top_up_compatibility.py +++ b/scripts/test_identity_top_up_compatibility.py @@ -28,11 +28,17 @@ def declaration(marker, text=production): tests.mkdir(parents=True) policy = repository / "DashWallet/Sources/Infrastructure/SwiftDashSDK/AssetLockInputPolicy.swift" (source / policy.name).write_text(policy.read_text().replace("import SwiftDashSDK\n", "")) + # The completion event and the in-flight registry the top-up posts to are production code too. + for name in ("IdentityTopUpDidComplete.swift", "IdentityTopUpsInFlight.swift"): + event = repository / "DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity" / name + (source / name).write_text(event.read_text().replace("import SwiftDashSDK\n", "")) # The production control flow and error classification are unchanged. # Only the native SDK, persistence, and address-provider boundaries are fakes. methods = "\n".join(declaration(marker) for marker in ( " func canTopUp(", " func topUp(", + " static func suppliedCredits(", + " private func executeTopUp(", " enum TopUpError: LocalizedError {", " private func topUpFromShielded(", ))