From 79f5d91df200aae1aab541e76147d675e318431f Mon Sep 17 00:00:00 2001 From: romchornyi Date: Tue, 10 Nov 2026 10:55:14 +0200 Subject: [PATCH 1/5] feat(dashpay): receive to the identity on Receive, with a Receipt when its credits rise With Advanced Mode on and a username on the Current identity, Receive offers a fourth option, Identity, on both Receive presentations. The card shows a QR of the bare Base58 Identity ID, the ID and the username with Copy, Share ID, a disabled Specify amount, and a warning that identity funds pay for Dash apps and usernames and that most exchanges send only to Core. The option follows Advanced Mode, registration, the active wallet, the network and the username while Receive is open. IdentityCreditsWatcher reads the identity's credits every 5 s while the card is on screen and the app is in the foreground, from a fresh read on opening, and shows a Receipt when they rise. Every own identity top-up posts IdentityTopUpDidComplete with the credits it supplied, and the watcher moves its starting balance up by them. Receive options are a Receive-only ReceiveOption enum. The option row scrolls sideways when the four titles do not fit. ADR-0033, ADR-0034; summary in docs/features/identity-receive. Co-Authored-By: Claude Opus 5.5 SDD-Published-From: e1ead3523146b0a11852b80a2e027e69c97767a5 --- DashWallet.xcodeproj/project.pbxproj | 32 ++ .../Identity/DWCurrentUserIdentityInfo.swift | 6 +- .../Identity/DWIdentityBalanceRefresh.swift | 20 +- .../DWIdentityRegistrationCoordinator.swift | 45 +- .../Identity/IdentityTopUpDidComplete.swift | 75 ++++ .../PlatformCreditsFormatter.swift | 1 + .../Profile/SDKIdentityProfileSheet.swift | 36 +- .../Components/PaymentsReceiveContent.swift | 268 ++++++++++-- .../Landing/IdentityCreditsWatcher.swift | 188 ++++++++ .../PaymentsLandingHostingController.swift | 15 +- .../Landing/PaymentsLandingScreen.swift | 8 +- .../Landing/PaymentsLandingViewModel.swift | 313 ++++++++++++-- .../UI/Payments/Landing/ReceiveOption.swift | 61 +++ DashWallet/ar.lproj/Localizable.strings | 15 + DashWallet/bg.lproj/Localizable.strings | 15 + DashWallet/ca.lproj/Localizable.strings | 15 + DashWallet/cs.lproj/Localizable.strings | 15 + DashWallet/da.lproj/Localizable.strings | 15 + DashWallet/de.lproj/Localizable.strings | 15 + DashWallet/el.lproj/Localizable.strings | 15 + DashWallet/en.lproj/Localizable.strings | 15 + DashWallet/eo.lproj/Localizable.strings | 15 + DashWallet/es.lproj/Localizable.strings | 15 + DashWallet/et.lproj/Localizable.strings | 15 + DashWallet/fa.lproj/Localizable.strings | 15 + DashWallet/fi.lproj/Localizable.strings | 15 + DashWallet/fil.lproj/Localizable.strings | 15 + DashWallet/fr.lproj/Localizable.strings | 15 + DashWallet/hr.lproj/Localizable.strings | 15 + DashWallet/hu.lproj/Localizable.strings | 15 + DashWallet/id.lproj/Localizable.strings | 15 + DashWallet/it.lproj/Localizable.strings | 15 + DashWallet/ja.lproj/Localizable.strings | 15 + DashWallet/ko.lproj/Localizable.strings | 15 + DashWallet/mk.lproj/Localizable.strings | 15 + DashWallet/ms.lproj/Localizable.strings | 15 + DashWallet/nb.lproj/Localizable.strings | 15 + DashWallet/nl.lproj/Localizable.strings | 15 + DashWallet/pl.lproj/Localizable.strings | 15 + DashWallet/pt.lproj/Localizable.strings | 15 + DashWallet/ro.lproj/Localizable.strings | 15 + DashWallet/ru.lproj/Localizable.strings | 15 + DashWallet/sk.lproj/Localizable.strings | 15 + DashWallet/sl.lproj/Localizable.strings | 15 + DashWallet/sl_SI.lproj/Localizable.strings | 15 + DashWallet/sq.lproj/Localizable.strings | 15 + DashWallet/sr.lproj/Localizable.strings | 15 + DashWallet/sv.lproj/Localizable.strings | 15 + DashWallet/th.lproj/Localizable.strings | 15 + DashWallet/tr.lproj/Localizable.strings | 15 + DashWallet/uk.lproj/Localizable.strings | 15 + DashWallet/vi.lproj/Localizable.strings | 15 + DashWallet/zh-Hans.lproj/Localizable.strings | 15 + .../zh-Hant-TW.lproj/Localizable.strings | 15 + DashWallet/zh.lproj/Localizable.strings | 15 + DashWallet/zh_TW.lproj/Localizable.strings | 15 + .../IdentityBalanceRefreshTests.swift | 31 ++ .../IdentityCreditsWatcherTests.swift | 369 ++++++++++++++++ DashWalletTests/IdentityTopUpEventTests.swift | 153 +++++++ .../PaymentsLandingIdentityOptionTests.swift | 405 ++++++++++++++++++ DashWalletTests/ReceiveOptionTests.swift | 52 +++ ...-receive-options-as-a-receive-only-enum.md | 45 ++ ...ct-own-top-ups-via-a-typed-top-up-event.md | 46 ++ docs/adr/README.md | 2 + docs/features/identity-receive/README.md | 71 +++ 65 files changed, 2794 insertions(+), 93 deletions(-) create mode 100644 DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/IdentityTopUpDidComplete.swift create mode 100644 DashWallet/Sources/UI/Payments/Landing/IdentityCreditsWatcher.swift create mode 100644 DashWallet/Sources/UI/Payments/Landing/ReceiveOption.swift create mode 100644 DashWalletTests/IdentityCreditsWatcherTests.swift create mode 100644 DashWalletTests/IdentityTopUpEventTests.swift create mode 100644 DashWalletTests/PaymentsLandingIdentityOptionTests.swift create mode 100644 DashWalletTests/ReceiveOptionTests.swift create mode 100644 docs/adr/0033-model-receive-options-as-a-receive-only-enum.md create mode 100644 docs/adr/0034-subtract-own-top-ups-via-a-typed-top-up-event.md create mode 100644 docs/features/identity-receive/README.md diff --git a/DashWallet.xcodeproj/project.pbxproj b/DashWallet.xcodeproj/project.pbxproj index 5d0d701e48..bf04bf6c48 100644 --- a/DashWallet.xcodeproj/project.pbxproj +++ b/DashWallet.xcodeproj/project.pbxproj @@ -83,6 +83,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 */; }; @@ -1093,6 +1095,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 */; }; @@ -1257,6 +1263,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 */; }; @@ -2022,6 +2030,7 @@ 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 */; }; F44028CBF49F4A2FE6268874 /* UsernameRegistrationRecoveryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 701E95B66E2409DD2F80D7AB /* UsernameRegistrationRecoveryTests.swift */; }; C0F1E5ED0A14B2C3D4E5F603 /* ContestedUsernameFeeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0F1E5ED0A14B2C3D4E5F604 /* ContestedUsernameFeeTests.swift */; }; B17E5A0C9D3F4E21A6C80B01 /* BulkVotePlanTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B17E5A0C9D3F4E21A6C80B02 /* BulkVotePlanTests.swift */; }; @@ -3247,6 +3256,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 = ""; }; @@ -3853,6 +3866,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 = ""; }; @@ -3880,6 +3895,7 @@ 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 = ""; }; 701E95B66E2409DD2F80D7AB /* UsernameRegistrationRecoveryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UsernameRegistrationRecoveryTests.swift; sourceTree = ""; }; C0F1E5ED0A14B2C3D4E5F604 /* ContestedUsernameFeeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContestedUsernameFeeTests.swift; sourceTree = ""; }; B17E5A0C9D3F4E21A6C80B02 /* BulkVotePlanTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BulkVotePlanTests.swift; sourceTree = ""; }; @@ -6969,6 +6985,8 @@ E735446F9E918618E97EDD38 /* PaymentsLandingScreen.swift */, C0172000000000000003A1 /* PaymentsTabRootController.swift */, FE64C10DA9C338D408982EBE /* PaymentsLandingViewModel.swift */, + 06171096D5D5ACB796FB3D68 /* IdentityCreditsWatcher.swift */, + 5686334C0BC09D6EC6968F6A /* ReceiveOption.swift */, B401E660599FEF6B18087F91 /* PaymentsLandingHostingController.swift */, ); path = Landing; @@ -7388,6 +7406,10 @@ CB9200012FE3000000000001 /* PassiveWalletStateUITailTests.swift */, AA0003032CA0F58E00A1B402 /* SwapAddressValidatorTests.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 */, @@ -7489,6 +7511,7 @@ D826C39F49D5CD6EC19C8C8E /* DWIdentityRegistrationCoordinator.swift */, CF36BF1A7ACD652EDDA7D25D /* DWUsernameRegistrationRecovery.swift */, BABA10000000000000000001 /* DWIdentityBalanceRefresh.swift */, + BABA10000000000000000101 /* IdentityTopUpDidComplete.swift */, D54F8E662513F09BA840FB94 /* DWIdentityRegistrationBridge.swift */, 5B30DA60B985C3CC3ED05B64 /* DWCurrentUserIdentityInfo.swift */, 82926C69F3BB675BEF1A1FFD /* DWProfileUpdateCoordinator.swift */, @@ -10531,6 +10554,8 @@ 15F9C3B621487500E2919619 /* SendViewModel.swift in Sources */, 8B8898971DC24152E171DABC /* PaymentsLandingScreen.swift in Sources */, 12DE15416F9F7A0B8749CAF1 /* PaymentsLandingViewModel.swift in Sources */, + 8820AD0A74800EDA9BBE4481 /* IdentityCreditsWatcher.swift in Sources */, + DAE070BBE395099DE28F91E4 /* ReceiveOption.swift in Sources */, 908AB7EFCC69D3828BBD70A8 /* PaymentsLandingHostingController.swift in Sources */, C029D3337FF6DAD231B33C4B /* SendToContactScreen.swift in Sources */, 1F2E9228002A59F638346E1F /* SendToContactViewController.swift in Sources */, @@ -10703,6 +10728,10 @@ CB9200022FE3000000000002 /* PassiveWalletStateUITailTests.swift in Sources */, AA0003042CA0F58E00A1B402 /* SwapAddressValidatorTests.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 */, @@ -11578,6 +11607,7 @@ F4202BDB27E7066201C23A58 /* DWIdentityRegistrationCoordinator.swift in Sources */, 7843C0A14DF4CBD4FFA605CD /* DWUsernameRegistrationRecovery.swift in Sources */, BABA10000000000000000002 /* DWIdentityBalanceRefresh.swift in Sources */, + BABA10000000000000000102 /* IdentityTopUpDidComplete.swift in Sources */, A11E57A70006C0DE0006B006 /* DWInvitationLinkNormalizer.swift in Sources */, A11E57A70007C0DE0007B007 /* DWInvitationService.swift in Sources */, C85067CBF3243AC0B42E9A2C /* InvitationValidation.swift in Sources */, @@ -11633,6 +11663,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/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 a59027b8e5..673d0032dc 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 @@ -1430,21 +1430,31 @@ 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, + balanceBefore: heldCredits, + 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, + balanceBefore: heldCredits, + suppliedCredits: topUpDuffs * PlatformPaymentIdentityFundingPolicy.creditsPerDuff) { + try await wallet.topUpFromAddresses( + identityId: identityId, + inputs: inputs, + addressSigner: signer) + } SwiftDashSDKWalletState.shared.refreshPlatformPaymentCredits() case .shielded: throw CoordinatorError.shieldedTopUpUnavailable(neededDuffs: topUpDuffs) @@ -1944,11 +1954,16 @@ 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, + balanceBefore: try? wallet.managedIdentity(identityId: existingId).getBalance(), + 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..bea7460883 --- /dev/null +++ b/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/IdentityTopUpDidComplete.swift @@ -0,0 +1,75 @@ +import Foundation +import SwiftDashSDK + +/// Posted once after a top-up of an identity from this wallet completes, with +/// the credits it added (ADR-0034): by `IdentityTopUpViewModel.topUp`, and by +/// `DWIdentityRegistrationCoordinator` for the top-ups it makes before a +/// registration or a name purchase. Always posted on the main actor. +struct IdentityTopUpDidComplete: Equatable { + static let name = Notification.Name("IdentityTopUpDidComplete") + + let walletId: Data + let network: Network + let identityId: Data + let creditsAdded: UInt64 + + init(walletId: Data, network: Network, identityId: Data, creditsAdded: UInt64) { + self.walletId = walletId + self.network = network + self.identityId = identityId + self.creditsAdded = creditsAdded + } + + 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. The credits added are the rise + /// over `balanceBefore`, capped at the credits handed to the transition, + /// the most it can have added: `balanceBefore` is the stored balance, so + /// the rise can include a Payer's credits that landed since it was last + /// refreshed. With no balance before, the credits handed to the transition. + @MainActor + static func announce( + balanceBefore: UInt64?, + balanceAfter: UInt64?, + suppliedCredits: UInt64, + walletId: Data, + network: Network, + identityId: Data, + center: NotificationCenter = .default + ) { + guard let balanceAfter else { return } + let rise = balanceBefore.map { balanceAfter > $0 ? balanceAfter - $0 : 0 } ?? suppliedCredits + let creditsAdded = min(rise, suppliedCredits) + IdentityTopUpDidComplete( + walletId: walletId, network: network, identityId: identityId, creditsAdded: creditsAdded) + .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. + @MainActor + static func announcing( + walletId: Data, + network: Network, + identityId: Data, + balanceBefore: UInt64?, + suppliedCredits: UInt64, + center: NotificationCenter = .default, + _ topUp: () async throws -> UInt64 + ) async rethrows -> UInt64 { + let balanceAfter = try await topUp() + announce( + balanceBefore: balanceBefore, balanceAfter: balanceAfter, suppliedCredits: suppliedCredits, + walletId: walletId, network: network, identityId: identityId, center: center) + return balanceAfter + } +} 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 3cca38e398..97aa881610 100644 --- a/DashWallet/Sources/UI/DashPay/Profile/SDKIdentityProfileSheet.swift +++ b/DashWallet/Sources/UI/DashPay/Profile/SDKIdentityProfileSheet.swift @@ -600,7 +600,39 @@ final class IdentityTopUpViewModel: ObservableObject { } /// nil = cancelled or failed (errorMessage carries the failure). + /// + /// A completed top-up posts `IdentityTopUpDidComplete` with the credits it + /// added, so Receive raises no Receipt for the wallet's own top-up. func topUp(identityId: Data, amountDuffs: UInt64, source: FundingSource) async -> UInt64? { + let wallet = SwiftDashSDKHost.shared.wallet + let network = SwiftDashSDKHost.shared.runningNetwork + let balanceBefore = try? wallet?.managedIdentity(identityId: identityId).getBalance() + let balanceAfter = await executeTopUp(identityId: identityId, amountDuffs: amountDuffs, source: source) + if let wallet, let network { + IdentityTopUpDidComplete.announce( + balanceBefore: balanceBefore, + 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 !isProcessing else { return nil } guard let wallet = SwiftDashSDKHost.shared.wallet, let modelContainer = SwiftDashSDKHost.shared.modelContainer else { @@ -718,9 +750,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..394195c6a9 --- /dev/null +++ b/DashWallet/Sources/UI/Payments/Landing/IdentityCreditsWatcher.swift @@ -0,0 +1,188 @@ +// +// 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 by the credits added, and a rise of +/// at least 1 duff over it is one Receipt for the whole rise, which ends the +/// session. 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 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) { + self.read = read + self.schedule = schedule + self.center = center + #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 + } + guard let starting = startingBalance, balance >= starting else { + startingBalance = balance + state = .watching + return + } + let rise = balance - starting + let creditsPerDuff = PlatformCreditsFormatter.creditsPerDuff + guard rise >= creditsPerDuff 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 + if let startingBalance { + self.startingBalance = startingBalance + event.creditsAdded + } + } + #endif +} diff --git a/DashWallet/Sources/UI/Payments/Landing/PaymentsLandingHostingController.swift b/DashWallet/Sources/UI/Payments/Landing/PaymentsLandingHostingController.swift index 92def5764b..b8f1a19637 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..a0114b5ef8 100644 --- a/DashWallet/Sources/UI/Payments/Landing/PaymentsLandingScreen.swift +++ b/DashWallet/Sources/UI/Payments/Landing/PaymentsLandingScreen.swift @@ -278,6 +278,10 @@ struct PaymentsLandingScreen: View { }, onShareAddress: onShareAddress, onSpecifyAmount: onSpecifyAmount, + onCopyUsername: { + viewModel.copyUsernameToPasteboard() + showsCopiedToast = true + }, onViewTransaction: onViewTransaction, onDone: { viewModel.finishReceiving() @@ -314,7 +318,7 @@ struct PaymentsLandingScreen: View { viewModel: embeddedTransferViewModel, onCompleted: onTransferCompleted, showsHeader: false, - receiveInto: viewModel.network + receiveInto: viewModel.network.chainNetwork ) .padding(.top, Layout.embeddedFormTopPadding) } @@ -386,7 +390,7 @@ 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", 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..d6707963d0 --- /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-0033). +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 ec5eed7e7f..55f0e61852 100644 --- a/DashWallet/ar.lproj/Localizable.strings +++ b/DashWallet/ar.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "نسخ"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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" = "الأكثر أصوات قفل"; @@ -4823,6 +4835,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 5fb4394ee5..e67d7afc5f 100644 --- a/DashWallet/bg.lproj/Localizable.strings +++ b/DashWallet/bg.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Копирай"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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" = "Най-много заключващи гласове"; @@ -4823,6 +4835,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 a165bdbb67..93ff299d71 100644 --- a/DashWallet/ca.lproj/Localizable.strings +++ b/DashWallet/ca.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Copia"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4823,6 +4835,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 55487d990e..cbe8325601 100644 --- a/DashWallet/cs.lproj/Localizable.strings +++ b/DashWallet/cs.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopírovat"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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ů"; @@ -4823,6 +4835,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 dbb538a243..45f090506f 100644 --- a/DashWallet/da.lproj/Localizable.strings +++ b/DashWallet/da.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopiér"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4823,6 +4835,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 a148881a73..d2abdfb747 100644 --- a/DashWallet/de.lproj/Localizable.strings +++ b/DashWallet/de.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopieren"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4821,6 +4833,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 9e70b27028..dcb294fd10 100644 --- a/DashWallet/el.lproj/Localizable.strings +++ b/DashWallet/el.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Αντιγραφή"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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" = "Περισσότερες ψήφοι κλειδώματος"; @@ -4821,6 +4833,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 50c1d1a3cc..edafe199de 100644 --- a/DashWallet/en.lproj/Localizable.strings +++ b/DashWallet/en.lproj/Localizable.strings @@ -1348,6 +1348,9 @@ /* No comment provided by engineer. */ "Copy" = "Copy"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1360,6 +1363,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"; @@ -2261,6 +2267,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"; @@ -3085,6 +3094,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"; @@ -4822,6 +4834,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 81329f5402..a7b21f8681 100644 --- a/DashWallet/eo.lproj/Localizable.strings +++ b/DashWallet/eo.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopi"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4823,6 +4835,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 ce24e7d29e..f1d17d4ff9 100644 --- a/DashWallet/es.lproj/Localizable.strings +++ b/DashWallet/es.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Copiar"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4821,6 +4833,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 9803b7bd0b..fc0ad3e91b 100644 --- a/DashWallet/et.lproj/Localizable.strings +++ b/DashWallet/et.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Copy"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4823,6 +4835,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 55550a4aef..b35a2b5425 100644 --- a/DashWallet/fa.lproj/Localizable.strings +++ b/DashWallet/fa.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "کپی"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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" = "بیشترین رأی قفل"; @@ -4821,6 +4833,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 202a50ada5..12e4dee935 100644 --- a/DashWallet/fi.lproj/Localizable.strings +++ b/DashWallet/fi.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopioi"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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ä"; @@ -4823,6 +4835,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 452045a6ee..40c62bdb6d 100644 --- a/DashWallet/fil.lproj/Localizable.strings +++ b/DashWallet/fil.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopyahin"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4821,6 +4833,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 c247a0cff7..97392199eb 100644 --- a/DashWallet/fr.lproj/Localizable.strings +++ b/DashWallet/fr.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Copier"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4821,6 +4833,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 b81f8c91e7..06efe617d9 100644 --- a/DashWallet/hr.lproj/Localizable.strings +++ b/DashWallet/hr.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopiraj"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4823,6 +4835,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 85a3180c37..aa95f4302e 100644 --- a/DashWallet/hu.lproj/Localizable.strings +++ b/DashWallet/hu.lproj/Localizable.strings @@ -1349,6 +1349,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"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4823,6 +4835,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 40b60f5821..d2f94e0b5f 100644 --- a/DashWallet/id.lproj/Localizable.strings +++ b/DashWallet/id.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Salin"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4821,6 +4833,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 11ff458c49..5c38b45d9e 100644 --- a/DashWallet/it.lproj/Localizable.strings +++ b/DashWallet/it.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Copia"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4821,6 +4833,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 87a4e6a842..d6a02b4a03 100644 --- a/DashWallet/ja.lproj/Localizable.strings +++ b/DashWallet/ja.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "コピー"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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" = "ロック票が最多"; @@ -4821,6 +4833,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 c4da27c570..8ff006e644 100644 --- a/DashWallet/ko.lproj/Localizable.strings +++ b/DashWallet/ko.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "복사"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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" = "잠금 투표 최다"; @@ -4821,6 +4833,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 a68da9f177..dc020d38b8 100644 --- a/DashWallet/mk.lproj/Localizable.strings +++ b/DashWallet/mk.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Копирај"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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" = "Најмногу гласови за заклучување"; @@ -4823,6 +4835,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 1215e22446..582118ad16 100644 --- a/DashWallet/ms.lproj/Localizable.strings +++ b/DashWallet/ms.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Copy"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4823,6 +4835,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 656ff5ec9c..f752cce2e6 100644 --- a/DashWallet/nb.lproj/Localizable.strings +++ b/DashWallet/nb.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopier"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4823,6 +4835,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 a73f1a827f..8b685a56e7 100644 --- a/DashWallet/nl.lproj/Localizable.strings +++ b/DashWallet/nl.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopieer"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4821,6 +4833,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 a29a67080f..612e782235 100644 --- a/DashWallet/pl.lproj/Localizable.strings +++ b/DashWallet/pl.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopiuj"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4821,6 +4833,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 28c2ed884a..4bc8b397fb 100644 --- a/DashWallet/pt.lproj/Localizable.strings +++ b/DashWallet/pt.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Copiar"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4821,6 +4833,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 d871477be5..e034247e67 100644 --- a/DashWallet/ro.lproj/Localizable.strings +++ b/DashWallet/ro.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Copiază"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4823,6 +4835,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 70998c1a12..a5065b6be1 100644 --- a/DashWallet/ru.lproj/Localizable.strings +++ b/DashWallet/ru.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Копировать"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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" = "Больше всего голосов за блокировку"; @@ -4821,6 +4833,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 b41cca063c..711c6339e7 100644 --- a/DashWallet/sk.lproj/Localizable.strings +++ b/DashWallet/sk.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopírovať"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4821,6 +4833,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 c903a035c1..5cd5c6609b 100644 --- a/DashWallet/sl.lproj/Localizable.strings +++ b/DashWallet/sl.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopiraj"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4823,6 +4835,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 97df180742..6543a83664 100644 --- a/DashWallet/sl_SI.lproj/Localizable.strings +++ b/DashWallet/sl_SI.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Copy"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4823,6 +4835,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 cc2c6c35d6..3272aa510d 100644 --- a/DashWallet/sq.lproj/Localizable.strings +++ b/DashWallet/sq.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopjo"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4823,6 +4835,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 0674748fe7..9532fbf11f 100644 --- a/DashWallet/sr.lproj/Localizable.strings +++ b/DashWallet/sr.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopiraj"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4823,6 +4835,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 70c9c2b384..bc340d022b 100644 --- a/DashWallet/sv.lproj/Localizable.strings +++ b/DashWallet/sv.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopiera"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4823,6 +4835,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 e1a4062dbc..d50a9c8661 100644 --- a/DashWallet/th.lproj/Localizable.strings +++ b/DashWallet/th.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "คัดลอก"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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" = "คะแนนล็อกมากที่สุด"; @@ -4821,6 +4833,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 567a892339..b006371894 100644 --- a/DashWallet/tr.lproj/Localizable.strings +++ b/DashWallet/tr.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Kopyala"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4821,6 +4833,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 60351ad1b4..939e740653 100644 --- a/DashWallet/uk.lproj/Localizable.strings +++ b/DashWallet/uk.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Копіювати"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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" = "Найбільше голосів за блокування"; @@ -4821,6 +4833,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 1c3c0fa1ca..1b9020d3d2 100644 --- a/DashWallet/vi.lproj/Localizable.strings +++ b/DashWallet/vi.lproj/Localizable.strings @@ -1349,6 +1349,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"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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"; @@ -4823,6 +4835,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 c69efd6a99..2184388849 100644 --- a/DashWallet/zh-Hans.lproj/Localizable.strings +++ b/DashWallet/zh-Hans.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Copy"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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" = "锁定票最多"; @@ -4823,6 +4835,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 e008313b73..77f6b3cf90 100644 --- a/DashWallet/zh-Hant-TW.lproj/Localizable.strings +++ b/DashWallet/zh-Hant-TW.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "Copy"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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" = "鎖定票最多"; @@ -4823,6 +4835,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 a2e8eea215..0586332526 100644 --- a/DashWallet/zh.lproj/Localizable.strings +++ b/DashWallet/zh.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "复制"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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" = "锁定票最多"; @@ -4821,6 +4833,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 ad1120c68e..7eed7366df 100644 --- a/DashWallet/zh_TW.lproj/Localizable.strings +++ b/DashWallet/zh_TW.lproj/Localizable.strings @@ -1349,6 +1349,9 @@ /* No comment provided by engineer. */ "Copy" = "複製"; +/* Receive, Identity option */ +"Copy Identity ID" = "Copy Identity ID"; + /* Log export */ "Copy Logs" = "Copy Logs"; @@ -1361,6 +1364,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"; @@ -2262,6 +2268,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"; @@ -3089,6 +3098,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" = "鎖定票最多"; @@ -4821,6 +4833,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..dba0e0ffa2 --- /dev/null +++ b/DashWalletTests/IdentityCreditsWatcherTests.swift @@ -0,0 +1,369 @@ +// +// 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 lazy var watcher = IdentityCreditsWatcher( + read: { [source] in await source.read($0) }, + schedule: { [scheduler] in scheduler.schedule($0, $1) }, + center: center) + + override func setUp() async throws { + watcher.setGateOpen(true) + } + + private func answer(_ values: UInt64...) { + source.answers += values.map { .success($0) } + } + + private func topUp(_ credits: UInt64, for session: IdentityCreditsWatcher.Session) { + IdentityTopUpDidComplete( + walletId: session.walletId, network: session.network, + identityId: session.identityId, creditsAdded: credits) + .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(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(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(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(5_000, for: session) + source.release() + await inFlight + await scheduler.fire() + XCTAssertEqual(watcher.state, .watching) + } + + // 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..64732fbf1b --- /dev/null +++ b/DashWalletTests/IdentityTopUpEventTests.swift @@ -0,0 +1,153 @@ +// +// 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 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( + balanceBefore: UInt64?, balanceAfter: UInt64?, suppliedCredits: UInt64 + ) -> [IdentityTopUpDidComplete] { + IdentityTopUpDidComplete.announce( + balanceBefore: balanceBefore, + balanceAfter: balanceAfter, + suppliedCredits: suppliedCredits, + walletId: walletId, + network: .testnet, + identityId: identityId, + center: center) + return events + } + + private func announcing( + balanceBefore: UInt64?, _ topUp: () async throws -> UInt64 + ) async rethrows -> UInt64 { + try await IdentityTopUpDidComplete.announcing( + walletId: walletId, network: .testnet, identityId: identityId, + balanceBefore: balanceBefore, suppliedCredits: 1_000_000_000, center: center, topUp) + } + + func testSuccessfulTopUpPostsOneEventWithTheCreditsItAdded() { + let events = announced( + balanceBefore: 2_000_000_000, balanceAfter: 2_958_500_000, suppliedCredits: 1_000_000_000) + XCTAssertEqual(events.count, 1) + XCTAssertEqual(events.first?.creditsAdded, 958_500_000) + XCTAssertEqual(events.first?.identityId, identityId) + XCTAssertEqual(events.first?.walletId, walletId) + XCTAssertEqual(events.first?.network, .testnet) + } + + func testCancelledOrFailedTopUpPostsNothing() { + XCTAssertTrue(announced( + balanceBefore: 2_000_000_000, balanceAfter: nil, suppliedCredits: 1_000_000_000).isEmpty) + } + + /// Without a stored balance to subtract from, the credits handed to the + /// transition are the most the top-up can have added. + func testUnknownBalanceBeforeFallsBackToTheSuppliedCredits() { + let events = announced( + balanceBefore: nil, balanceAfter: 5_000_000_000, suppliedCredits: 1_000_000_000) + XCTAssertEqual(events.map(\.creditsAdded), [1_000_000_000]) + } + + /// The balance before is the stored one, so a Payer's credits that landed + /// since it was last refreshed are part of the rise. The top-up cannot have + /// added more than it supplied, so the rest still raises a Receipt. + func testPayerCreditsInTheRiseAreNotCountedAsTheTopUp() { + let payerCredits: UInt64 = 700_000_000 + let events = announced( + balanceBefore: 2_000_000_000, + balanceAfter: 2_000_000_000 + payerCredits + 958_500_000, + suppliedCredits: 1_000_000_000) + XCTAssertEqual(events.map(\.creditsAdded), [1_000_000_000]) + } + + func testBalanceThatDidNotRiseAddsNothing() { + let events = announced( + balanceBefore: 3_000_000_000, balanceAfter: 2_900_000_000, suppliedCredits: 1_000_000_000) + XCTAssertEqual(events.map(\.creditsAdded), [0]) + } + + // 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 cap 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 testATopUpThatReturnsAnnouncesTheRiseAndPassesTheBalanceOn() async throws { + let after = try await announcing(balanceBefore: 2_000_000_000) { 2_958_500_000 } + XCTAssertEqual(after, 2_958_500_000) + XCTAssertEqual(events.map(\.creditsAdded), [958_500_000]) + XCTAssertEqual(events.first?.identityId, identityId) + } + + func testATopUpThatThrowsAnnouncesNothing() async { + do { + _ = try await announcing(balanceBefore: 2_000_000_000) { throw Refused.byPlatform } + XCTFail("The refusal must reach the caller") + } catch { + XCTAssertEqual(error as? Refused, .byPlatform) + } + XCTAssertTrue(events.isEmpty) + } + + 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..0f43d3b791 --- /dev/null +++ b/DashWalletTests/PaymentsLandingIdentityOptionTests.swift @@ -0,0 +1,405 @@ +// +// 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 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, creditsAdded: 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) + } +} diff --git a/DashWalletTests/ReceiveOptionTests.swift b/DashWalletTests/ReceiveOptionTests.swift new file mode 100644 index 0000000000..87765cc682 --- /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-0033). +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/0033-model-receive-options-as-a-receive-only-enum.md b/docs/adr/0033-model-receive-options-as-a-receive-only-enum.md new file mode 100644 index 0000000000..b2502cfc6f --- /dev/null +++ b/docs/adr/0033-model-receive-options-as-a-receive-only-enum.md @@ -0,0 +1,45 @@ +# 0033 — 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/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..bb35420611 --- /dev/null +++ b/docs/adr/0034-subtract-own-top-ups-via-a-typed-top-up-event.md @@ -0,0 +1,46 @@ +# 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. + +## Decision outcome + +**Chosen:** option 1, a typed `IdentityTopUpDidComplete` event that the watcher subtracts from future increases by raising its Starting balance. It meets AC-06 and AC-08 together without adding the shared object option 2 needs, and it is a new, typed name rather than a re-post of the DashPay registration notification. + +## Consequences + +**Positive** +- A completed top-up from this wallet raises no Receipt once it is announced, wherever it was started: Internal transfer and the profile sheet run `IdentityTopUpViewModel.topUp`, and the registration coordinator's shortfall and name-purchase top-ups run through `IdentityTopUpDidComplete.announcing`; each posts the event. +- 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. +- The amount the event carries is what the top-up path knows: the rise over the stored balance it started from, capped at the credits it supplied. A Payer's credits that land in between are counted as the top-up's only up to that cap, so at most the top-up's fee worth of them raises no Receipt (sad.md §11). +- The event is posted when the top-up call returns, after Platform has already raised the balance: a check in that window shows the own top-up as «Received», and a top-up that throws after Platform carried it out posts nothing (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: [0033 — Model Receive options as a Receive-only enum](0033-model-receive-options-as-a-receive-only-enum.md) diff --git a/docs/adr/README.md b/docs/adr/README.md index d3a290bece..ce8d3f7e32 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -18,6 +18,8 @@ where they disagree, ADR-0001 wins. | [0024](0024-pin-shortcut-raw-values-and-refill-the-retired-slot.md) | Pin shortcut raw values and refill the retired slot | ui | Proposed | | | [0025](0025-remove-crowdnode-defaults-by-exact-key-list-on-activation.md) | Remove CrowdNode defaults by exact key list on activation | storage | Proposed | | | [0026](0026-retire-the-crowdnode-topic-by-marking-events-seen.md) | Retire the CrowdNode topic by marking its events seen | storage | Proposed | | +| [0033](0033-model-receive-options-as-a-receive-only-enum.md) | Model Receive options as a Receive-only enum | ui | Proposed | | +| [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 | | Areas: `spv`, `platform`, `keys`, `storage`, `coinjoin`, `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..7ff937f6c4 --- /dev/null +++ b/docs/features/identity-receive/README.md @@ -0,0 +1,71 @@ +# 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-0033](../../adr/0033-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-0033](../../adr/0033-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. +- **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 show at the next successful check. +- **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 whose rise is seen before the top-up call returns can show as «Received», and so + can one that fails after Platform carried it out; +- a Payer's credits that land between the stored balance's last refresh 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. From a4f646db156f7e650f80d7069e1cdbb2617d1335 Mon Sep 17 00:00:00 2001 From: romchornyi Date: Tue, 10 Nov 2026 13:04:09 +0200 Subject: [PATCH 2/5] fix(dashpay): scroll the Receive card when it is taller than the page The Identity card is taller than the payments page on an iPhone 17: laid out without a scroll view, it squeezed the warning to one truncated line per sentence and pushed Close off the top. The Receive tab now scrolls vertically, only when its card does not fit; a sideways swipe still changes tab. Co-Authored-By: Claude Opus 5.5 SDD-Published-From: d96f6c94b29a3e626644e2df1da230a712066ad4 --- .../Landing/PaymentsLandingScreen.swift | 12 +++++-- .../PaymentsLandingIdentityOptionTests.swift | 33 +++++++++++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/DashWallet/Sources/UI/Payments/Landing/PaymentsLandingScreen.swift b/DashWallet/Sources/UI/Payments/Landing/PaymentsLandingScreen.swift index a0114b5ef8..7d6ad6ebb5 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: { @@ -290,6 +294,8 @@ struct PaymentsLandingScreen: View { ) .padding(.horizontal, Layout.cardHorizontalPadding) } + .scrollBounceBehavior(.basedOnSize) + .scrollIndicators(.hidden) case .internalTransfer: switch mode { diff --git a/DashWalletTests/PaymentsLandingIdentityOptionTests.swift b/DashWalletTests/PaymentsLandingIdentityOptionTests.swift index 0f43d3b791..b62b8123ba 100644 --- a/DashWalletTests/PaymentsLandingIdentityOptionTests.swift +++ b/DashWalletTests/PaymentsLandingIdentityOptionTests.swift @@ -18,6 +18,7 @@ // import SwiftDashSDK +import SwiftUI import XCTest @testable import dashpay @@ -402,4 +403,36 @@ final class PaymentsLandingIdentityOptionTests: XCTestCase { 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)") + } + } } From 715a71970069410f3f71066383b6dc91b7da9d97 Mon Sep 17 00:00:00 2001 From: romchornyi Date: Tue, 10 Nov 2026 23:16:11 +0200 Subject: [PATCH 3/5] fix(dashpay): hold the Identity Receipt while an own top-up runs Closes the review finding on the own-top-up ordering race: every announced identity top-up is registered in IdentityTopUpsInFlight while it runs, and the Receive watcher raises no Receipt and takes no Starting balance meanwhile. Regression tests cover a rise read before the announcement and a top-up already running when the watch starts. ADR-0034 updated. SDD-Published-From: dd5a4713945c6882e1a0f5e4c22272b84803fff5 --- DashWallet.xcodeproj/project.pbxproj | 6 ++ .../Identity/IdentityTopUpDidComplete.swift | 6 ++ .../Identity/IdentityTopUpsInFlight.swift | 41 ++++++++++++ .../Profile/SDKIdentityProfileSheet.swift | 9 ++- .../Landing/IdentityCreditsWatcher.swift | 27 ++++++-- .../IdentityCreditsWatcherTests.swift | 67 ++++++++++++++++++- DashWalletTests/IdentityTopUpEventTests.swift | 32 ++++++++- ...ct-own-top-ups-via-a-typed-top-up-event.md | 9 ++- docs/features/identity-receive/README.md | 4 +- 9 files changed, 188 insertions(+), 13 deletions(-) create mode 100644 DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/IdentityTopUpsInFlight.swift diff --git a/DashWallet.xcodeproj/project.pbxproj b/DashWallet.xcodeproj/project.pbxproj index 144a75bced..cb88828640 100644 --- a/DashWallet.xcodeproj/project.pbxproj +++ b/DashWallet.xcodeproj/project.pbxproj @@ -2040,6 +2040,8 @@ 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 */; }; B17E5A0C9D3F4E21A6C80B01 /* BulkVotePlanTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B17E5A0C9D3F4E21A6C80B02 /* BulkVotePlanTests.swift */; }; @@ -3912,6 +3914,7 @@ 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 = ""; }; B17E5A0C9D3F4E21A6C80B02 /* BulkVotePlanTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BulkVotePlanTests.swift; sourceTree = ""; }; @@ -7534,6 +7537,7 @@ CF36BF1A7ACD652EDDA7D25D /* DWUsernameRegistrationRecovery.swift */, BABA10000000000000000001 /* DWIdentityBalanceRefresh.swift */, BABA10000000000000000101 /* IdentityTopUpDidComplete.swift */, + BABA10000000000000000201 /* IdentityTopUpsInFlight.swift */, D54F8E662513F09BA840FB94 /* DWIdentityRegistrationBridge.swift */, 5B30DA60B985C3CC3ED05B64 /* DWCurrentUserIdentityInfo.swift */, 82926C69F3BB675BEF1A1FFD /* DWProfileUpdateCoordinator.swift */, @@ -10579,6 +10583,7 @@ 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 */, @@ -11638,6 +11643,7 @@ 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 */, diff --git a/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/IdentityTopUpDidComplete.swift b/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/IdentityTopUpDidComplete.swift index fd25445069..2a2324630e 100644 --- a/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/IdentityTopUpDidComplete.swift +++ b/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/IdentityTopUpDidComplete.swift @@ -57,6 +57,8 @@ struct IdentityTopUpDidComplete: Equatable { /// 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, @@ -65,8 +67,12 @@ struct IdentityTopUpDidComplete: Equatable { balanceBefore: UInt64?, 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( balanceBefore: balanceBefore, balanceAfter: balanceAfter, suppliedCredits: suppliedCredits, 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/UI/DashPay/Profile/SDKIdentityProfileSheet.swift b/DashWallet/Sources/UI/DashPay/Profile/SDKIdentityProfileSheet.swift index 97aa881610..0ac11bd956 100644 --- a/DashWallet/Sources/UI/DashPay/Profile/SDKIdentityProfileSheet.swift +++ b/DashWallet/Sources/UI/DashPay/Profile/SDKIdentityProfileSheet.swift @@ -602,11 +602,18 @@ final class IdentityTopUpViewModel: ObservableObject { /// nil = cancelled or failed (errorMessage carries the failure). /// /// A completed top-up posts `IdentityTopUpDidComplete` with the credits it - /// added, so Receive raises no Receipt for the wallet's own top-up. + /// added, 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 let balanceBefore = try? wallet?.managedIdentity(identityId: identityId).getBalance() + 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( diff --git a/DashWallet/Sources/UI/Payments/Landing/IdentityCreditsWatcher.swift b/DashWallet/Sources/UI/Payments/Landing/IdentityCreditsWatcher.swift index 394195c6a9..fc2ff69ad9 100644 --- a/DashWallet/Sources/UI/Payments/Landing/IdentityCreditsWatcher.swift +++ b/DashWallet/Sources/UI/Payments/Landing/IdentityCreditsWatcher.swift @@ -28,8 +28,10 @@ import SwiftDashSDK /// session (never a stored value), a lower balance replaces it, an own top-up /// (`IdentityTopUpDidComplete`) raises it by the credits added, and a rise of /// at least 1 duff over it is one Receipt for the whole rise, which ends the -/// session. 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 +/// 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 @@ -70,6 +72,7 @@ final class IdentityCreditsWatcher { 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 @@ -82,10 +85,12 @@ final class IdentityCreditsWatcher { init(read: @escaping Read, schedule: @escaping Schedule = IdentityCreditsWatcher.repeating, - center: NotificationCenter = .default) { + 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( @@ -153,14 +158,26 @@ final class IdentityCreditsWatcher { state = .notWatching return } - guard let starting = startingBalance, balance >= starting else { + // 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 else { + guard rise >= creditsPerDuff, !ownTopUpRunning else { state = .watching return } diff --git a/DashWalletTests/IdentityCreditsWatcherTests.swift b/DashWalletTests/IdentityCreditsWatcherTests.swift index dba0e0ffa2..d8ed6cd4fa 100644 --- a/DashWalletTests/IdentityCreditsWatcherTests.swift +++ b/DashWalletTests/IdentityCreditsWatcherTests.swift @@ -103,15 +103,21 @@ final class IdentityCreditsWatcherTests: XCTestCase { 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) + 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) } } @@ -244,6 +250,65 @@ final class IdentityCreditsWatcherTests: XCTestCase { 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(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(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)) + } + + 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() { diff --git a/DashWalletTests/IdentityTopUpEventTests.swift b/DashWalletTests/IdentityTopUpEventTests.swift index 64732fbf1b..78a3b4d5db 100644 --- a/DashWalletTests/IdentityTopUpEventTests.swift +++ b/DashWalletTests/IdentityTopUpEventTests.swift @@ -31,6 +31,7 @@ final class IdentityTopUpEventTests: XCTestCase { private enum Refused: Error { case byPlatform } private let center = NotificationCenter() + private let inFlight = IdentityTopUpsInFlight() private var events: [IdentityTopUpDidComplete] = [] private var token: NSObjectProtocol? @@ -63,7 +64,11 @@ final class IdentityTopUpEventTests: XCTestCase { ) async rethrows -> UInt64 { try await IdentityTopUpDidComplete.announcing( walletId: walletId, network: .testnet, identityId: identityId, - balanceBefore: balanceBefore, suppliedCredits: 1_000_000_000, center: center, topUp) + balanceBefore: balanceBefore, suppliedCredits: 1_000_000_000, center: center, inFlight: inFlight, topUp) + } + + private var key: IdentityTopUpsInFlight.Key { + .init(walletId: walletId, network: .testnet, identityId: identityId) } func testSuccessfulTopUpPostsOneEventWithTheCreditsItAdded() { @@ -147,6 +152,31 @@ final class IdentityTopUpEventTests: XCTestCase { 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(balanceBefore: 2_000_000_000) { + runningDuringTopUp = inFlight.contains(key) + return 2_958_500_000 + } + XCTAssertTrue(runningDuringTopUp) + XCTAssertFalse(inFlight.contains(key)) + } + + func testATopUpThatThrowsIsNoLongerInFlight() async { + _ = try? await announcing(balanceBefore: 2_000_000_000) { 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/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 index abe98bf933..b8f4e68f23 100644 --- 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 @@ -19,22 +19,25 @@ The Identity option raises a Receipt when the Current identity's credits rise ab 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 1, a typed `IdentityTopUpDidComplete` event that the watcher subtracts from future increases by raising its Starting balance. It meets AC-06 and AC-08 together without adding the shared object option 2 needs, and it is a new, typed name rather than a re-post of the DashPay registration notification. +**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 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 completed top-up from this wallet raises no Receipt once it is announced, wherever it was started: 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 posts the event (the retry only when its lock row is stored, as the lock's value bounds the credits). +- 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 amount the event carries is what the top-up path knows: the rise over the stored balance it started from, capped at the credits it supplied. A Payer's credits that land in between are counted as the top-up's only up to that cap, so at most the top-up's fee worth of them raises no Receipt (sad.md §11). -- The event is posted when the top-up call returns, after Platform has already raised the balance: a check in that window shows the own top-up as «Received», and a top-up that throws after Platform carried it out posts nothing (accepted limit, spec §6.1). +- 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. diff --git a/docs/features/identity-receive/README.md b/docs/features/identity-receive/README.md index 7ff937f6c4..4e8bc91f6e 100644 --- a/docs/features/identity-receive/README.md +++ b/docs/features/identity-receive/README.md @@ -59,8 +59,8 @@ increase: - 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 whose rise is seen before the top-up call returns can show as «Received», and so - can one that fails after Platform carried it out; +- 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 stored balance's last refresh 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). From de83d0cda9fe5a7f25b2b014f5649fd77a6e4831 Mon Sep 17 00:00:00 2001 From: romchornyi Date: Wed, 11 Nov 2026 00:19:09 +0200 Subject: [PATCH 4/5] fix(dashpay): reconcile an own identity top-up with the balance it returned Closes the review finding on own-top-up attribution: IdentityTopUpDidComplete now carries the balance the top-up's transition returned and the credits it was handed, and the Receive watcher sets its Starting balance to the lower of that balance and its Starting balance plus those credits. A spend from elsewhere while the top-up runs no longer turns it into a Receipt. Regression test added; ADR-0034 updated. SDD-Published-From: 4816425e490280eba3e42cfdecc91d3ac1949840 --- .../AssetLockRecoveryService.swift | 1 - .../DWIdentityRegistrationCoordinator.swift | 3 - .../Identity/IdentityTopUpDidComplete.swift | 28 ++++---- .../Profile/SDKIdentityProfileSheet.swift | 6 +- .../Landing/IdentityCreditsWatcher.swift | 22 ++++--- .../IdentityCreditsWatcherTests.swift | 49 +++++++++++--- DashWalletTests/IdentityTopUpEventTests.swift | 65 +++++-------------- .../PaymentsLandingIdentityOptionTests.swift | 3 +- ...ct-own-top-ups-via-a-typed-top-up-event.md | 4 +- docs/features/identity-receive/README.md | 6 +- 10 files changed, 93 insertions(+), 94 deletions(-) diff --git a/DashWallet/Sources/Infrastructure/SwiftDashSDK/AssetLockRecoveryService.swift b/DashWallet/Sources/Infrastructure/SwiftDashSDK/AssetLockRecoveryService.swift index 123f746655..a2647dff07 100644 --- a/DashWallet/Sources/Infrastructure/SwiftDashSDK/AssetLockRecoveryService.swift +++ b/DashWallet/Sources/Infrastructure/SwiftDashSDK/AssetLockRecoveryService.swift @@ -654,7 +654,6 @@ struct AssetLockRecoveryService { lock.amountDuffs > 0 { _ = try await IdentityTopUpDidComplete.announcing( walletId: wallet.walletId, network: network, identityId: identityId, - balanceBefore: try? wallet.managedIdentity(identityId: identityId).getBalance(), suppliedCredits: UInt64(lock.amountDuffs) * PlatformPaymentIdentityFundingPolicy.creditsPerDuff, resume) } else { diff --git a/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/DWIdentityRegistrationCoordinator.swift b/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/DWIdentityRegistrationCoordinator.swift index 673d0032dc..268e3c5e99 100644 --- a/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/DWIdentityRegistrationCoordinator.swift +++ b/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/DWIdentityRegistrationCoordinator.swift @@ -1432,7 +1432,6 @@ final class DWIdentityRegistrationCoordinator: ObservableObject { try AssetLockInputLimit.requireFits(inputCheck) _ = try await IdentityTopUpDidComplete.announcing( walletId: wallet.walletId, network: network, identityId: identityId, - balanceBefore: heldCredits, suppliedCredits: topUpDuffs * PlatformPaymentIdentityFundingPolicy.creditsPerDuff) { try await AssetLockInputLimit.mappingRefusal(inputCheck) { try await wallet.topUpIdentityWithFunding( @@ -1448,7 +1447,6 @@ final class DWIdentityRegistrationCoordinator: ObservableObject { targetCredits: topUpDuffs * PlatformPaymentIdentityFundingPolicy.creditsPerDuff) _ = try await IdentityTopUpDidComplete.announcing( walletId: wallet.walletId, network: network, identityId: identityId, - balanceBefore: heldCredits, suppliedCredits: topUpDuffs * PlatformPaymentIdentityFundingPolicy.creditsPerDuff) { try await wallet.topUpFromAddresses( identityId: identityId, @@ -1956,7 +1954,6 @@ final class DWIdentityRegistrationCoordinator: ObservableObject { Self.logger.info("🪪 IDENT-COORD :: purchase top-up shortfallDuffs=\(shortfallDuffs)") _ = try await IdentityTopUpDidComplete.announcing( walletId: wallet.walletId, network: network, identityId: existingId, - balanceBefore: try? wallet.managedIdentity(identityId: existingId).getBalance(), suppliedCredits: shortfallDuffs * PlatformPaymentIdentityFundingPolicy.creditsPerDuff) { try await AssetLockInputLimit.mappingRefusal(Self.coreInputCheck(amountDuffs: shortfallDuffs)) { try await wallet.topUpIdentityWithFunding( diff --git a/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/IdentityTopUpDidComplete.swift b/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/IdentityTopUpDidComplete.swift index 2a2324630e..c15162e8d5 100644 --- a/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/IdentityTopUpDidComplete.swift +++ b/DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/IdentityTopUpDidComplete.swift @@ -2,7 +2,8 @@ import Foundation import SwiftDashSDK /// Posted once after a top-up of an identity from this wallet completes, with -/// the credits it added (ADR-0034): by `IdentityTopUpViewModel.topUp`, by +/// 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. @@ -12,13 +13,17 @@ struct IdentityTopUpDidComplete: Equatable { let walletId: Data let network: Network let identityId: Data - let creditsAdded: UInt64 + /// 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, creditsAdded: UInt64) { + init(walletId: Data, network: Network, identityId: Data, balanceAfter: UInt64, suppliedCredits: UInt64) { self.walletId = walletId self.network = network self.identityId = identityId - self.creditsAdded = creditsAdded + self.balanceAfter = balanceAfter + self.suppliedCredits = suppliedCredits } init?(notification: Notification) { @@ -32,14 +37,9 @@ struct IdentityTopUpDidComplete: Equatable { } /// Posts the event for a completed top-up (`balanceAfter` non-nil) and - /// nothing for a cancelled or failed one. The credits added are the rise - /// over `balanceBefore`, capped at the credits handed to the transition, - /// the most it can have added: `balanceBefore` is the stored balance, so - /// the rise can include a Payer's credits that landed since it was last - /// refreshed. With no balance before, the credits handed to the transition. + /// nothing for a cancelled or failed one. @MainActor static func announce( - balanceBefore: UInt64?, balanceAfter: UInt64?, suppliedCredits: UInt64, walletId: Data, @@ -48,10 +48,9 @@ struct IdentityTopUpDidComplete: Equatable { center: NotificationCenter = .default ) { guard let balanceAfter else { return } - let rise = balanceBefore.map { balanceAfter > $0 ? balanceAfter - $0 : 0 } ?? suppliedCredits - let creditsAdded = min(rise, suppliedCredits) IdentityTopUpDidComplete( - walletId: walletId, network: network, identityId: identityId, creditsAdded: creditsAdded) + walletId: walletId, network: network, identityId: identityId, + balanceAfter: balanceAfter, suppliedCredits: suppliedCredits) .post(to: center) } @@ -64,7 +63,6 @@ struct IdentityTopUpDidComplete: Equatable { walletId: Data, network: Network, identityId: Data, - balanceBefore: UInt64?, suppliedCredits: UInt64, center: NotificationCenter = .default, inFlight: IdentityTopUpsInFlight = .shared, @@ -75,7 +73,7 @@ struct IdentityTopUpDidComplete: Equatable { defer { inFlight.end(key) } let balanceAfter = try await topUp() announce( - balanceBefore: balanceBefore, balanceAfter: balanceAfter, suppliedCredits: suppliedCredits, + balanceAfter: balanceAfter, suppliedCredits: suppliedCredits, walletId: walletId, network: network, identityId: identityId, center: center) return balanceAfter } diff --git a/DashWallet/Sources/UI/DashPay/Profile/SDKIdentityProfileSheet.swift b/DashWallet/Sources/UI/DashPay/Profile/SDKIdentityProfileSheet.swift index 0ac11bd956..86c50b6802 100644 --- a/DashWallet/Sources/UI/DashPay/Profile/SDKIdentityProfileSheet.swift +++ b/DashWallet/Sources/UI/DashPay/Profile/SDKIdentityProfileSheet.swift @@ -601,13 +601,12 @@ final class IdentityTopUpViewModel: ObservableObject { /// nil = cancelled or failed (errorMessage carries the failure). /// - /// A completed top-up posts `IdentityTopUpDidComplete` with the credits it - /// added, so Receive raises no Receipt for the wallet's own top-up; while + /// 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 - let balanceBefore = try? wallet?.managedIdentity(identityId: identityId).getBalance() var key: IdentityTopUpsInFlight.Key? if let wallet, let network { key = .init(walletId: wallet.walletId, network: network, identityId: identityId) @@ -617,7 +616,6 @@ final class IdentityTopUpViewModel: ObservableObject { let balanceAfter = await executeTopUp(identityId: identityId, amountDuffs: amountDuffs, source: source) if let wallet, let network { IdentityTopUpDidComplete.announce( - balanceBefore: balanceBefore, balanceAfter: balanceAfter, suppliedCredits: Self.suppliedCredits(amountDuffs: amountDuffs, source: source), walletId: wallet.walletId, diff --git a/DashWallet/Sources/UI/Payments/Landing/IdentityCreditsWatcher.swift b/DashWallet/Sources/UI/Payments/Landing/IdentityCreditsWatcher.swift index fc2ff69ad9..25305fecac 100644 --- a/DashWallet/Sources/UI/Payments/Landing/IdentityCreditsWatcher.swift +++ b/DashWallet/Sources/UI/Payments/Landing/IdentityCreditsWatcher.swift @@ -26,14 +26,15 @@ import SwiftDashSDK /// 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 by the credits added, 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. +/// (`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 { @@ -197,8 +198,11 @@ final class IdentityCreditsWatcher { // 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 = startingBalance + event.creditsAdded + self.startingBalance = min(event.balanceAfter, startingBalance + event.suppliedCredits) } } #endif diff --git a/DashWalletTests/IdentityCreditsWatcherTests.swift b/DashWalletTests/IdentityCreditsWatcherTests.swift index d8ed6cd4fa..0cf0ccfa2e 100644 --- a/DashWalletTests/IdentityCreditsWatcherTests.swift +++ b/DashWalletTests/IdentityCreditsWatcherTests.swift @@ -122,10 +122,10 @@ final class IdentityCreditsWatcherTests: XCTestCase { source.answers += values.map { .success($0) } } - private func topUp(_ credits: UInt64, for session: IdentityCreditsWatcher.Session) { + private func topUp(after balanceAfter: UInt64, supplied: UInt64, for session: IdentityCreditsWatcher.Session) { IdentityTopUpDidComplete( - walletId: session.walletId, network: session.network, - identityId: session.identityId, creditsAdded: credits) + walletId: session.walletId, network: session.network, identityId: session.identityId, + balanceAfter: balanceAfter, suppliedCredits: supplied) .post(to: center) } @@ -205,7 +205,7 @@ final class IdentityCreditsWatcherTests: XCTestCase { watcher.start(session) answer(10_000, 15_000, 16_000) await scheduler.fire() - topUp(5_000, for: session) + topUp(after: 15_000, supplied: 5_000, for: session) await scheduler.fire() XCTAssertEqual(watcher.state, .watching) await scheduler.fire() @@ -216,7 +216,7 @@ final class IdentityCreditsWatcherTests: XCTestCase { watcher.start(session) answer(10_000, 15_000) await scheduler.fire() - topUp(5_000, for: otherSession) + topUp(after: 15_000, supplied: 5_000, for: otherSession) await scheduler.fire() XCTAssertEqual(watcher.state, .received(duffs: 5)) } @@ -226,7 +226,7 @@ final class IdentityCreditsWatcherTests: XCTestCase { answer(10_000, 15_000) await scheduler.fire() watcher.setGateOpen(false) - topUp(5_000, for: session) + topUp(after: 15_000, supplied: 5_000, for: session) watcher.setGateOpen(true) await scheduler.fire() XCTAssertEqual(watcher.state, .watching) @@ -243,7 +243,7 @@ final class IdentityCreditsWatcherTests: XCTestCase { let readsBefore = source.reads.count async let inFlight: Void = scheduler.fire() await source.waitForReads(readsBefore + 1) - topUp(5_000, for: session) + topUp(after: 15_000, supplied: 5_000, for: session) source.release() await inFlight await scheduler.fire() @@ -260,7 +260,7 @@ final class IdentityCreditsWatcherTests: XCTestCase { inFlight.begin(key(session)) await scheduler.fire() XCTAssertEqual(watcher.state, .watching) - topUp(5_000, for: session) + topUp(after: 15_000, supplied: 5_000, for: session) inFlight.end(key(session)) await scheduler.fire() XCTAssertEqual(watcher.state, .watching) @@ -277,7 +277,7 @@ final class IdentityCreditsWatcherTests: XCTestCase { answer(10_000, 15_000, 16_000) await scheduler.fire() XCTAssertEqual(watcher.state, .notWatching) - topUp(5_000, for: session) + topUp(after: 15_000, supplied: 5_000, for: session) inFlight.end(key(session)) await scheduler.fire() XCTAssertEqual(watcher.state, .watching) @@ -300,6 +300,37 @@ final class IdentityCreditsWatcherTests: XCTestCase { 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) diff --git a/DashWalletTests/IdentityTopUpEventTests.swift b/DashWalletTests/IdentityTopUpEventTests.swift index 78a3b4d5db..96d80674ab 100644 --- a/DashWalletTests/IdentityTopUpEventTests.swift +++ b/DashWalletTests/IdentityTopUpEventTests.swift @@ -45,11 +45,8 @@ final class IdentityTopUpEventTests: XCTestCase { if let token { center.removeObserver(token) } } - private func announced( - balanceBefore: UInt64?, balanceAfter: UInt64?, suppliedCredits: UInt64 - ) -> [IdentityTopUpDidComplete] { + private func announced(balanceAfter: UInt64?, suppliedCredits: UInt64) -> [IdentityTopUpDidComplete] { IdentityTopUpDidComplete.announce( - balanceBefore: balanceBefore, balanceAfter: balanceAfter, suppliedCredits: suppliedCredits, walletId: walletId, @@ -59,64 +56,38 @@ final class IdentityTopUpEventTests: XCTestCase { return events } - private func announcing( - balanceBefore: UInt64?, _ topUp: () async throws -> UInt64 - ) async rethrows -> UInt64 { + private func announcing(_ topUp: () async throws -> UInt64) async rethrows -> UInt64 { try await IdentityTopUpDidComplete.announcing( walletId: walletId, network: .testnet, identityId: identityId, - balanceBefore: balanceBefore, suppliedCredits: 1_000_000_000, center: center, inFlight: inFlight, topUp) + suppliedCredits: 1_000_000_000, center: center, inFlight: inFlight, topUp) } private var key: IdentityTopUpsInFlight.Key { .init(walletId: walletId, network: .testnet, identityId: identityId) } - func testSuccessfulTopUpPostsOneEventWithTheCreditsItAdded() { - let events = announced( - balanceBefore: 2_000_000_000, balanceAfter: 2_958_500_000, suppliedCredits: 1_000_000_000) + /// 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?.creditsAdded, 958_500_000) + 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( - balanceBefore: 2_000_000_000, balanceAfter: nil, suppliedCredits: 1_000_000_000).isEmpty) - } - - /// Without a stored balance to subtract from, the credits handed to the - /// transition are the most the top-up can have added. - func testUnknownBalanceBeforeFallsBackToTheSuppliedCredits() { - let events = announced( - balanceBefore: nil, balanceAfter: 5_000_000_000, suppliedCredits: 1_000_000_000) - XCTAssertEqual(events.map(\.creditsAdded), [1_000_000_000]) - } - - /// The balance before is the stored one, so a Payer's credits that landed - /// since it was last refreshed are part of the rise. The top-up cannot have - /// added more than it supplied, so the rest still raises a Receipt. - func testPayerCreditsInTheRiseAreNotCountedAsTheTopUp() { - let payerCredits: UInt64 = 700_000_000 - let events = announced( - balanceBefore: 2_000_000_000, - balanceAfter: 2_000_000_000 + payerCredits + 958_500_000, - suppliedCredits: 1_000_000_000) - XCTAssertEqual(events.map(\.creditsAdded), [1_000_000_000]) - } - - func testBalanceThatDidNotRiseAddsNothing() { - let events = announced( - balanceBefore: 3_000_000_000, balanceAfter: 2_900_000_000, suppliedCredits: 1_000_000_000) - XCTAssertEqual(events.map(\.creditsAdded), [0]) + 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 cap absorb up to + /// 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 @@ -135,16 +106,16 @@ final class IdentityTopUpEventTests: XCTestCase { // MARK: The coordinator's top-ups (registration shortfall, name purchase) - func testATopUpThatReturnsAnnouncesTheRiseAndPassesTheBalanceOn() async throws { - let after = try await announcing(balanceBefore: 2_000_000_000) { 2_958_500_000 } + func testATopUpThatReturnsAnnouncesItsBalanceAndPassesItOn() async throws { + let after = try await announcing { 2_958_500_000 } XCTAssertEqual(after, 2_958_500_000) - XCTAssertEqual(events.map(\.creditsAdded), [958_500_000]) + XCTAssertEqual(events.map(\.balanceAfter), [2_958_500_000]) XCTAssertEqual(events.first?.identityId, identityId) } func testATopUpThatThrowsAnnouncesNothing() async { do { - _ = try await announcing(balanceBefore: 2_000_000_000) { throw Refused.byPlatform } + _ = try await announcing { throw Refused.byPlatform } XCTFail("The refusal must reach the caller") } catch { XCTAssertEqual(error as? Refused, .byPlatform) @@ -155,7 +126,7 @@ final class IdentityTopUpEventTests: XCTestCase { /// 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(balanceBefore: 2_000_000_000) { + _ = try await announcing { runningDuringTopUp = inFlight.contains(key) return 2_958_500_000 } @@ -164,7 +135,7 @@ final class IdentityTopUpEventTests: XCTestCase { } func testATopUpThatThrowsIsNoLongerInFlight() async { - _ = try? await announcing(balanceBefore: 2_000_000_000) { throw Refused.byPlatform } + _ = try? await announcing { throw Refused.byPlatform } XCTAssertFalse(inFlight.contains(key)) } diff --git a/DashWalletTests/PaymentsLandingIdentityOptionTests.swift b/DashWalletTests/PaymentsLandingIdentityOptionTests.swift index b62b8123ba..7db05bb7e4 100644 --- a/DashWalletTests/PaymentsLandingIdentityOptionTests.swift +++ b/DashWalletTests/PaymentsLandingIdentityOptionTests.swift @@ -374,7 +374,8 @@ final class PaymentsLandingIdentityOptionTests: XCTestCase { await ticks.fire() visitInternalTransfer(model) { IdentityTopUpDidComplete( - walletId: walletId, network: .testnet, identityId: identityId, creditsAdded: 20_000) + walletId: walletId, network: .testnet, identityId: identityId, + balanceAfter: 30_000, suppliedCredits: 20_000) .post(to: topUpCenter) } await ticks.fire() 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 index b8f4e68f23..6dcc74a875 100644 --- 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 @@ -23,7 +23,7 @@ The Identity option raises a Receipt when the Current identity's credits rise ab ## 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 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. +**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 @@ -36,7 +36,7 @@ The Identity option raises a Receipt when the Current identity's credits rise ab **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 amount the event carries is what the top-up path knows: the rise over the stored balance it started from, capped at the credits it supplied. A Payer's credits that land in between are counted as the top-up's only up to that cap, so at most the top-up's fee worth of them raises no Receipt (sad.md §11). +- 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** diff --git a/docs/features/identity-receive/README.md b/docs/features/identity-receive/README.md index 4e8bc91f6e..42c39d438f 100644 --- a/docs/features/identity-receive/README.md +++ b/docs/features/identity-receive/README.md @@ -61,9 +61,9 @@ increase: 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 stored balance's last refresh 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). +- 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 From 562cbb9ce68211f346150ff284b03a37c8cabf09 Mon Sep 17 00:00:00 2001 From: romchornyi Date: Thu, 12 Nov 2026 17:28:24 +0200 Subject: [PATCH 5/5] fix(dashpay): keep IdentityTopUpsInFlight in the dashwallet target, drop the no-op guard IdentityCreditsWatcher is compiled in dashwallet and uses the in-flight registry, so the file goes back into that target. dashwallet defines DASHPAY in every configuration, so the recovery announcement guard added in the previous commit changed nothing and is removed. Co-Authored-By: Claude Opus 5.5 SDD-Published-From: 99a8c5f0e6834b30a7a15a3c1e9bad06aa39e249 --- DashWallet.xcodeproj/project.pbxproj | 2 ++ .../SwiftDashSDK/AssetLockRecoveryService.swift | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/DashWallet.xcodeproj/project.pbxproj b/DashWallet.xcodeproj/project.pbxproj index fb366f228d..0458df3668 100644 --- a/DashWallet.xcodeproj/project.pbxproj +++ b/DashWallet.xcodeproj/project.pbxproj @@ -2031,6 +2031,7 @@ 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 */; }; @@ -10522,6 +10523,7 @@ 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 */, diff --git a/DashWallet/Sources/Infrastructure/SwiftDashSDK/AssetLockRecoveryService.swift b/DashWallet/Sources/Infrastructure/SwiftDashSDK/AssetLockRecoveryService.swift index 898d8fe889..7eb894acc0 100644 --- a/DashWallet/Sources/Infrastructure/SwiftDashSDK/AssetLockRecoveryService.swift +++ b/DashWallet/Sources/Infrastructure/SwiftDashSDK/AssetLockRecoveryService.swift @@ -647,7 +647,6 @@ struct AssetLockRecoveryService { outPointTxid: txidWire, outPointVout: vout) } - #if DASHPAY // 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 @@ -663,9 +662,6 @@ struct AssetLockRecoveryService { } else { _ = try await resume() } - #else - _ = try await resume() - #endif } DWCurrentUserIdentityInfo.shared.refreshFromSDK() return outcome