Skip to content

Rename DSChainNewBlockNotification -> DSChainNewChainTipBlockNotifica… - #16

Merged
QuantumExplorer merged 1 commit into
developfrom
fix/rename-notification
Dec 1, 2018
Merged

QuantumExplorer merged 1 commit into
developfrom
fix/rename-notification

Conversation

@podkovyrin

Copy link
Copy Markdown
Contributor

…tion

@QuantumExplorer
QuantumExplorer merged commit 1074410 into develop Dec 1, 2018
@podkovyrin
podkovyrin deleted the fix/rename-notification branch December 5, 2018 12:24
llbartekll added a commit that referenced this pull request Apr 9, 2026
M6 stopped DashSync's SPV but left BalanceModel reading from
DSWallet.balance, which is now frozen at whatever DashSync had cached
the moment M6 ran. This commit unfreezes the home screen balance by
sourcing it from SwiftDashSDK via a new SwiftDashSDKWalletState
singleton.

A new SwiftDashSDKWalletState class is the right home for wallet-side
@published state: SPV chain sync (handled by SwiftDashSDKSPVCoordinator)
and wallet state (balance, transactions, addresses) are different
concerns even though the FFI couples their event delivery. Future
follow-ups for transactions (#6), addresses (#1), and identities (#16)
will live alongside `balance` in this class instead of bloating the
SPV coordinator.

- Add SwiftDashSDKWalletState singleton with @published var balance,
  applyBalance(_:), seedInitialBalance(walletManager:walletId:), and
  clearBalance() methods. Holds the WalletBalance struct (4 UInt64
  fields, with `total` and `spendable` computed). 💰 WALLET :: log tag.
- SwiftDashSDKSPVCoordinator: WalletEventsHandler.onBalanceUpdated
  becomes a thin forwarder to SwiftDashSDKWalletState.shared.applyBalance.
  performStart calls SwiftDashSDKWalletState.shared.seedInitialBalance
  after walletManager.importWallet succeeds. Coordinator no longer
  owns any wallet-side @published state.
- BalanceModel subscribes to SwiftDashSDKWalletState.shared.\$balance
  via Combine and reads from .balance?.total instead of
  DWEnvironment.sharedInstance().currentWallet.balance.
- SwiftDashSDKWalletWiper calls SwiftDashSDKWalletState.shared.clearBalance()
  after the SwiftData wipe so post-wipe state doesn't show the
  previous wallet's balance.
- Register the new file in both dashwallet and dashpay targets in
  project.pbxproj (UUID family A5D5DD000000000000010C/D/E).

Other DashSync balance consumers (BalanceNotifier, SendAmountModel,
DWPhoneWCSessionManager, DashPay/CrowdNode/CoinJoin/DashSpendPay) still
read from DSWallet and remain stale. Each gets its own follow-up commit.
Aim of this commit is the smallest change that fixes the most visible
part of the M6 regression — the home screen number — with the right
architectural shape so #6 and beyond can build on it cleanly.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
llbartekll added a commit that referenced this pull request May 21, 2026
PR 1 of the row #16 migration (new-user identity + DPNS username from
DashSync to SwiftDashSDK). Scaffolding only, behind a disabled
`DASHPAY_SWIFT_SDK_REGISTRATION` flag — nothing calls these files yet,
DashSync remains the live path. PR 2 wires `DWDashPayModel.m` +
`DWCheckExistenceUsernameValidationRule.m` into the new path.

Migration doc updates (re-verified 2026-05-20):

- Row #16 / #17 / #19 flipped to 🟢 ready; row #18 flipped from 🔴 to
  🟡 (SDK APIs exist, no example walkthrough). Earlier "6+ FFI signature
  mismatches" claim resolved upstream via 33fde4e67f (cbindgen ABI),
  e22f816a2e (asset-lock proofs), c556a86db2 (KeychainSigner sweep),
  e9e56f3636 (account_index plumbed through).
- Hard Blockers: struck through #16 with the four resolving commits.
- Recommended order Wave 3 marked unblocked for #16/#17/#19.

New files in `DashWallet/Sources/Infrastructure/SwiftDashSDK/Identity/`:

- `DWRegistrationPhaseAdapter.swift` — pure mapping collapsing the SDK's
  5 internal phases (controller phase + `PersistentAssetLock.statusRaw`)
  onto the existing 3-state `DWDPRegistrationState` UI enum. Unit-tested.
- `DWIdentityRegistrationController.swift` — `@MainActor ObservableObject`
  phase holder (idle / preparingKeys / inFlight / completed / failed),
  ported from the SwiftExampleApp reference and stripped to a pure state
  carrier (v1 pins identityIndex=0; coordinator drives transitions).
- `DWIdentityAuthorizer.swift` — async PIN/biometric gate wrapping
  `DSAuthenticationManager.authenticate`. Mirrors the private
  `SendAuthorizer` pattern from `WalletSendService.swift:129-172`.
- `DWIdentityRegistrationCoordinator.swift` — `@MainActor` singleton
  orchestrating the full chain: PIN gate → `prePersistIdentityKeysForRegistration`
  → `registerIdentityWithFunding` → `registerDpnsName`. Polls
  `PersistentAssetLock.statusRaw` every 0.5s while `.inFlight` for the
  3-state UI mapping. Mirrors success into
  `DWGlobalOptions.dashpayUsername` + `dashpayRegistrationCompleted` so
  the 87 existing Obj-C identity-read sites keep working until row #17
  migrates them individually.
- `DWIdentityRegistrationBridge.swift` — `@objc @mainactor @objcMembers`
  facade for `DWDashPayModel.m` / `DWCheckExistenceUsernameValidationRule.m`.
  Cached `@objc` state mirrored from the coordinator via one
  `Publishers.CombineLatest($phase, $assetLockStatus)` subscription
  (passing emitted values directly avoids the `@Published` willSet
  re-read race). Posts `DWDashPayRegistrationStatusUpdatedNotification`
  on every transition.

Tests: `DashWalletTests/DWRegistrationPhaseAdapterTests.swift` — 12 cases
covering the full mapping matrix plus the failure-classification edge.

Project file:
- `DASHPAY_SWIFT_SDK_REGISTRATION=0` appended to all 5 GCC blocks that
  already contain `DASHPAY=1` (defined-but-falsy; PR 3 flips per-config).
- New Swift files registered on the `dashpay` target only — they reference
  DashPay-only Obj-C symbols (`DWDP_MIN_BALANCE_TO_CREATE_USERNAME`,
  `DWGlobalOptions.dashpayUsername` / `dashpayRegistrationCompleted`),
  which don't exist in the `dashwallet` target build.
- Test file registered on the `DashWalletTests` target.

v1 scope (documented for follow-up):
- Invitations stay on DashSync (no SDK equivalent for
  `DSBlockchainInvitation`).
- Existing DashSync identities not migrated — keys live in DashSync's
  keychain, not in `WalletStorage`. Future "import identity" stage.
- No crash-resume via `resumeIdentityWithAssetLock` (deferred to v2).
- Platform Payment funding path (`registerIdentityFromAddresses`) not
  wired — users with Platform credits but no Core balance still see the
  0.03 Dash error.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
llbartekll added a commit that referenced this pull request May 21, 2026
PR 2 of the row #16 migration. With `DASHPAY_SWIFT_SDK_REGISTRATION` still
at `0`, every `#if` branch is unselected, every `#else` is byte-identical
to pre-PR-1 behavior — no runtime change. Flipping the flag (PR 3, testnet
only) activates the new path end-to-end.

`DWIdentityRegistrationBridge.swift`:

- Add `@objc public static let stateChangedNotification` (a new internal
  name, `DWIdentityRegistrationBridgeStateChangedNotification`) and have
  `refreshFromCoordinator(...)` post it instead of the canonical
  `DWDashPayRegistrationStatusUpdatedNotification` it was posting in PR 1.
  Reason: NSNotificationCenter delivers in registration order, so existing
  UI consumers of the canonical name (`HomeViewModel.swift:855`,
  `MainTabbarController.swift:129`, `DWUserProfileContainerView.m:93`)
  could fire before `DWDashPayModel` updated its `registrationStatus` and
  read stale model state. Now only `DWDashPayModel` observes the bridge,
  mirrors state, and posts the canonical notification — single ordered
  hop. Docstring on `wireCoordinatorObservation` updated to reflect this.

`DashWallet/Sources/UI/Home/Models/DWDashPayModel.m`:

- Add an observer in `init` for the bridge's `stateChangedNotification`,
  guarded by `#if DASHPAY_SWIFT_SDK_REGISTRATION`.
- New selector `bridgeRegistrationStateChanged:` (also `#if`-guarded)
  that reads the bridge's cached `@objc` state, mirrors it into
  `self.registrationStatus` / `self.lastRegistrationError`, and posts
  the canonical notification. On `bridge.isCompleted` it intentionally
  does NOT call `completeRegistration` because that method nils
  `DWGlobalOptions.dashpayUsername` (assuming
  `wallet.defaultBlockchainIdentity.currentDashpayUsername` becomes the
  source of truth), but the SDK path has no DashSync identity — nil-ing
  would make `self.username` permanently nil and break the 87 downstream
  Obj-C identity-read sites until row #17 migrates them. Mirrors the
  other success effects (`shouldShowInvitationsBadge = YES`, clear
  `registrationStatus`, post canonical) inline.
- `createUsername:invitation:` routes the new-user no-invitation case
  (`wallet.defaultBlockchainIdentity == nil`) through
  `[DWIdentityRegistrationBridge.shared startCreateUsername:completion:]`
  under `#if`. Existing-identity case falls through to unchanged
  DashSync code. Invitation branch (lines 135-168) untouched.
- The bridge completion is a safety net for early-exit failures that
  don't reach a terminal-phase notification — SDK preconditions
  (no wallet / no network / no model container) throw before the
  controller is wired, and auth-cancel calls `resetState()` which
  clears `bridge.currentUsername` before the model observer reads it.
  In those cases `dashpayUsername` (cached at line 131) would stay set
  forever. The completion clears it and surfaces the error when
  `registrationStatus == nil` (i.e. the notification path didn't
  surface a failed state). For mid-flight failures the notification
  path already wrote a `.failed` status, so the early-return preserves
  that UI state.

`DashPay/Presentation/Setup/CreateUsername/Models/DWCheckExistenceUsernameValidationRule.m`:

- Conditional `#import "dashwallet-Swift.h"` under
  `#if DASHPAY_SWIFT_SDK_REGISTRATION`.
- Wrap the body of `performValidationWithUsername:` in `#if / #else`.
  The `#if` branch calls
  `[DWIdentityRegistrationBridge.shared checkAvailability:completion:]`
  with the same `DWUsernameValidationRuleResult` semantics
  (available=Valid, taken=InvalidCritical, error=Error). The `#else`
  keeps the existing `DSIdentitiesManager.searchIdentityByDashpayUsername:`
  call unchanged (the `DSIdentitiesManager *manager` local moves into
  the `#else` block since the new path doesn't need it). The
  `MOCK_DASHPAY` early-return and the debounce mechanism in
  `validateText:` are preserved across both branches; the
  `self.username == username` guard inside the completion handles
  stale-result discarding.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
llbartekll added a commit that referenced this pull request May 21, 2026
End-to-end verified on testnet 2026-05-20 — first DashPay identity
created from dashwallet-ios via SwiftDashSDK
(identity `5150b96d…`, name `433v2gnfdggdfs.dash`). The full coordinator
chain — PIN gate → `prePersistIdentityKeysForRegistration` →
`registerIdentityWithFunding` → `registerDpnsName` — completed cleanly
with `PersistentAssetLock` transitioning `1 → 2 → 4` (Broadcast →
InstantSendLocked → Consumed) on a funded testnet wallet.

Three things land in this commit:

1. **Form rewire** — `CreateUsernameViewModel.submitUsernameRequest`
   was running mock code (write a fake `UsernameRequest` DTO with a
   random UUID identity to `UsernameRequestsDAOImpl.shared`, set
   `UsernamePrefs.shared.requestedUsernameId`, sleep 2s, return true).
   The actual `dashPayModel.createUsername(...)` call was commented
   out. Replaced with the real call; the mock DAO write,
   `joinDashPayDismissed` toggle, and fake sleep are gone. Signature
   now takes `dashPayModel: DWDashPayProtocol` — the SwiftUI view
   already holds it via `@State var dashPayModel: DWDashPayProtocol`,
   so both call sites in `CreateUsernameView` (the simple Continue
   path at line 143 and the post-verify-identity confirm-spend path
   at line 206) just thread it through.

2. **`checkIfBlocked` short-circuit** — was sleeping 2s and setting
   `usernameBlockedRule = .warning`, which forced the user through
   the contested-username "verify identity" sheet on Continue. The
   sheet's voting-prompt copy + verify-identity proof URL flow is
   out of scope for the SDK v1 migration (contested-username
   resolution lives in the SDK's
   `dpnsGetContestedVoteState` / `dpnsGetCurrentContests` APIs but
   we don't surface them yet). Set `.valid` directly so Continue
   hits the simple submit path. Real DPNS availability detection
   lives in `DWIdentityRegistrationBridge.checkAvailability` and is
   exercised by the legacy `DWCheckExistenceUsernameValidationRule`
   flow if/when that flow becomes the active UI.

3. **Flag flip to `=1`** — `DASHPAY_SWIFT_SDK_REGISTRATION=0` →
   `DASHPAY_SWIFT_SDK_REGISTRATION=1` in all 5 GCC preprocessor
   blocks that contain `DASHPAY=1`. Same value everywhere; not
   scoped per-configuration. Combined with the earlier PR 1
   (`b91c0a144`) + PR 2 (`5291371f4`) wiring, this activates the
   SDK code path end-to-end. `dashwallet` target is unaffected
   (new files only registered on the `dashpay` target).

`DASHSYNC_MIGRATION.md` updates:

- Row #16 Status column flipped from `—` → `🌗 Flipped` and a new
  detailed "Where we are" entry added at the top of the doc with
  commit hashes (`b91c0a144`, `5291371f4`, and this one), the
  testnet verification identity ID + name, and the known v1 gaps
  (orphan asset-lock on crash, half-state on DPNS-failure retry,
  Platform Payment funding still unwired).

**Out of scope** (separate stages):

- Invitation branch (`DSBlockchainInvitation.acceptInvitation:`)
  stays on DashSync — no SDK equivalent.
- Existing DashSync identities (very rare in this branch state)
  fall through to the unchanged DashSync path. Future "import
  DashSync identity into SwiftDashSDK" stage needed.
- Contested-username voting flow bypassed.
- Platform Payment funding (`registerIdentityFromAddresses`) — users
  with Platform credits but no Core balance still see the 0.03
  Dash form check.
- Cleanup of the now-dead mock viewmodel fields
  (`currentUsernameRequest`, `hasUsernameRequest`,
  `fetchUsernameRequestData`, `cancelRequest`, `updateRequest`,
  `hasRequests(for:)`, the `dao` + `prefs` properties) — separate
  cleanup PR.
- Row #17 (`DSBlockchainIdentity` read-site migration, 87 files)
  is now unblocked but separate.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
llbartekll added a commit that referenced this pull request May 25, 2026
After the row #16 migration shipped (`b91c0a144`, `5291371f4`,
`97398f7ca`), `CreateUsernameViewModel.checkIfBlocked` always sets
`usernameBlockedRule = .valid`. The `.warning` rule was the only thing
that routed the Continue button through the contested-username
verify-identity sheet, so that whole branch is unreachable now.

`DashWallet/Sources/UI/DashPay/Setup/CreateUsername/CreateUsernameViewController.swift` (~120 lines net deleted):

- Drop `@State` vars: `showVerifyIdentity`, `confirmUsernameRequest`,
  `prove`, `showVotingInfo` — all triggered only by removed paths.
- Drop the `showVerifyConfirmation: (any View) -> Void` view parameter
  (and the matching `showModalDialog(dialog:)` closure at the
  controller's `init` call site).
- Drop the `dismissDialog: () -> Void` view parameter — was only
  consumed by the deleted `getVerifyConfirmation` modal dialog actions
  (Verify / Skip), and the controller's matching `dismiss(animated:)`
  closure goes with it.
- Drop the `if usernameBlockedRule == .warning` "What is username
  voting?" button block under the validators.
- Continue handler: collapse the `if .valid / else` to just the Task
  block. `viewModel.uiState.canContinue` is only true after
  `checkIfBlocked` flips the rule to `.valid`, so the button is
  already gated on the same condition.
- Drop three `.sheet` modifiers:
  - `.sheet(isPresented: $showVotingInfo)` — voting-info bottom sheet
  - `.sheet(isPresented: $showVerifyIdentity)` — `VerifyIdentityScreen`
    + the `viewModel.updateRequest(with:)` onDismiss call
  - `.sheet(isPresented: $confirmUsernameRequest)` — `ConfirmSpendDialog`,
    which held the second `submitUsernameRequest` call site (the
    post-verify-identity one)
- Drop `getVerifyConfirmation()` `@ViewBuilder` private func.
- Simplify `getMessageForBlockedRule()` to `.loading → ""` + default
  "Username is available". The now-unreachable `.warning` case (with
  its stale "March 14, 2024" placeholder), `.invalid`, and
  `.invalidCritical` cases are dropped.

`DashWallet/Sources/UI/DashPay/Setup/CreateUsername/CreateUsernameViewModel.swift` (~18 lines deleted):

- Remove `hasUsernameRequest: Bool` — zero external readers.
- Remove `hasRequests(for:) async -> Bool` — zero external readers.
- Remove `updateRequest(with: URL)` — was only called from the now-
  deleted `.sheet(isPresented: $showVerifyIdentity)` onDismiss handler.

Kept (used by separate flows):

- `currentUsernameRequest`, `fetchUsernameRequestData`, `cancelRequest`
  — consumed by `RequestDetailsViewController` (voting feature).
- `shouldRequestPayment`, `static let shared`, `dao`, `prefs` — consumed
  by `JoinDashPayScreen` / `RequestDetailsViewController`.
- `VerifyIdentityScreen.swift` file — unused by this view now, kept on
  disk for a future contested-username path that wires the SDK's
  `dpnsGetContestedVoteState` / `dpnsGetCurrentContests` APIs.

No behavior change for the post-migration happy path: form still shows
the validators, Continue still kicks off the SwiftDashSDK coordinator,
home-screen banner still tracks progress via
`DWDashPayRegistrationStatusUpdatedNotification`.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
llbartekll added a commit that referenced this pull request May 28, 2026
- Mark "Known SDK issues §1" (`could not decode data contracts query`)
  as RESOLVED 2026-05-27 via the Platform protocol v11 pin
  (`SwiftDashSDKHost.swift` → `SDK(network: protocolVersion: 11)`,
  backed by upstream PR #3734).
- Row #17 stage B "Where we are": drop the "blocked by upstream
  SwiftDashSDK bug" caveat; profile editing is end-to-end verified.
- Row #17 functional-table row: same cleanup.
- Row #18a entry: rephrase the "status view comes back once
  upstream is fixed" line — it's now a scope/product decision, not
  a blocker.
- Add a new "Where we are" entry covering the v11 pin + DPNS lookup
  finalisation: `usernames: [String]` exposure, cold-launch cache
  fix, wallet-side query, Edit Profile entry-point gate on
  `hasIdentity`, tab-bar restore workaround, and the
  `DASHPAY_SWIFT_SDK_REGISTRATION` flag retirement.
- Row #19 (DPNS lookup) flips from "—" to 🌗 Flipped; consumers
  column splits availability check (done) vs. prefix search
  (`DWUserSearchModel`, travels with #18 because the consumer
  factory expects `DSBlockchainIdentity`).
- Wave 3 row: update from "not started" to "Flipped for #16/#17/#19,
  #18 still pending".
- Row #16 "Where we are": flag retirement footnote so a future
  reader doesn't grep for it and find only stale references.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
QuantumExplorer added a commit that referenced this pull request Jul 8, 2026
… DashSync subsystem

Migration Row #18 — the contacts feature (dead at runtime since the
post-M6 DashSync freeze) is rebuilt end-to-end on SwiftDashSDK and the
entire DashSync implementation is removed in the same change.
E2E-verified on testnet against SwiftExampleApp driving the far side:
request sent → reciprocated → established → paid both directions.

New SDK boundary (Sources/Infrastructure/SwiftDashSDK/Contacts/):
- SwiftDashSDKContactsService: SwiftData read model (established =
  both direction rows, single row = pending; debounced
  NSManagedObjectContextDidSave refresh), PIN-gated send/accept via
  DWIdentityAuthorizer + KeychainSigner, ignoreSender (replaces the
  legacy decline, which was a TODO stub that faked failure), DPNS
  prefix search + reverse lookup (dpnsGetUsername, base58), contact
  meta (alias/note/hide via EstablishedContact + flushPersist),
  notifications read-state on the legacy DWGlobalOptions slot, and
  the payments projection (see below).
- DWIdentityKeyUpgrader: dashwallet registration derives
  AUTHENTICATION keys only, so identities registered here could not
  send contact requests. Before the first contact action, one
  IdentityUpdate adds the missing ENCRYPTION + DECRYPTION keys
  (ECDSA, MEDIUM, bounds SingleContractDocumentType(DashPay,
  "contactRequest") — Drive rejects unbound or contract-level bounds).
- DashPay background sync (15s six-step pass) start/stop wired into
  PlatformAddressSyncCoordinator alongside BLAST + shielded.
- SDK.enableLogging installed at host init — the app previously ran
  the whole SDK with Rust diagnostics muted.

Payments correctness (found live-testing):
- PersistentDashpayPayment rows exist only via the app-pulled
  projection (PlatformWalletManager.refreshDashPayPayments); the Rust
  persister never pushes them, and Sent entries are unrecoverable if
  the app dies before a projection. The service now projects on every
  sync pass, at most once a minute on snapshot refresh, on profile
  open, and immediately after every successful send.
- WalletSendService.sendToContact: pay-to-contact through the send
  boundary — spend-auth gate, then the single-shot SDK
  sendDashPayPayment (derives the DIP-15 address Rust-side), invoked
  only after the user's explicit Pay tap. Returns the exact network
  fee of the broadcast transaction (requires the platform fee-
  threading commit; see the DASHSYNC_MIGRATION.md platform pin).

SwiftUI screens (UI/DashPay/Contacts/SwiftUI/), styled to the Android
dash-wallet DashPay design (dashpay_contact_row.xml et al.): contacts
home (card rows, Accept pill + round ignore, golden pending state,
Android empty state), add-contact (debounced DPNS search, collision
detection, DashPay-key eligibility marking via identityGetKeys
mirroring the send path's key predicate), contact profile (Pay CTA,
tap-the-header collapsible contact settings, payments history, green
accept / ignore pane), notifications (New/Earlier, inline accept),
and the Android HSV avatar algorithm (hue = charIndex/36, S 0.3,
V 0.6). DPNS names render without the implied ".dash" suffix.

Deleted (163 files): the DWDP* item/factory hierarchy, contacts
VCs/models/FRC data sources, GlobalSearch, DWDashPayContactsUpdater/
Actions, DWNotificationsProvider/Data/VC/cells, the other-user
profile stack, DWDPAmount*View, dead DWFilterHeaderView, and the
pay-to-user payment plumbing (paymentInputWithUserItem — a frozen
DSIncomingFundsDerivationPath read — plus the performPayToUser chain;
the payment-confirm accept-contact checkbox is now honestly hidden).
Kept: Items/Protocols headers (type the always-nil payment userItem;
fall with the C8 processor rewrite), DWDPAvatarView (current-user
surfaces), the invitation flow (out of scope per Row #16).

The Contacts/Explore tabs now gate on
DWCurrentUserIdentityInfo.hasIdentity — the old DashSync
defaultBlockchainIdentity gate hid them from SDK-registered
identities.

Requires ../platform on local/tx-decode-plus-v4.1-dev (see the
platform pin note in DASHSYNC_MIGRATION.md) and an xcframework
rebuild.

Co-Authored-By: Claude Fable 5 <[email protected]>
QuantumExplorer added a commit that referenced this pull request Jul 9, 2026
… DashSync subsystem

Migration Row #18 — the contacts feature (dead at runtime since the
post-M6 DashSync freeze) is rebuilt end-to-end on SwiftDashSDK and the
entire DashSync implementation is removed in the same change.
E2E-verified on testnet against SwiftExampleApp driving the far side:
request sent → reciprocated → established → paid both directions.

New SDK boundary (Sources/Infrastructure/SwiftDashSDK/Contacts/):
- SwiftDashSDKContactsService: SwiftData read model (established =
  both direction rows, single row = pending; debounced
  NSManagedObjectContextDidSave refresh), PIN-gated send/accept via
  DWIdentityAuthorizer + KeychainSigner, ignoreSender (replaces the
  legacy decline, which was a TODO stub that faked failure), DPNS
  prefix search + reverse lookup (dpnsGetUsername, base58), contact
  meta (alias/note/hide via EstablishedContact + flushPersist),
  notifications read-state on the legacy DWGlobalOptions slot, and
  the payments projection (see below).
- DWIdentityKeyUpgrader: dashwallet registration derives
  AUTHENTICATION keys only, so identities registered here could not
  send contact requests. Before the first contact action, one
  IdentityUpdate adds the missing ENCRYPTION + DECRYPTION keys
  (ECDSA, MEDIUM, bounds SingleContractDocumentType(DashPay,
  "contactRequest") — Drive rejects unbound or contract-level bounds).
- DashPay background sync (15s six-step pass) start/stop wired into
  PlatformAddressSyncCoordinator alongside BLAST + shielded.
- SDK.enableLogging installed at host init — the app previously ran
  the whole SDK with Rust diagnostics muted.

Payments correctness (found live-testing):
- PersistentDashpayPayment rows exist only via the app-pulled
  projection (PlatformWalletManager.refreshDashPayPayments); the Rust
  persister never pushes them, and Sent entries are unrecoverable if
  the app dies before a projection. The service now projects on every
  sync pass, at most once a minute on snapshot refresh, on profile
  open, and immediately after every successful send.
- WalletSendService.sendToContact: pay-to-contact through the send
  boundary — spend-auth gate, then the single-shot SDK
  sendDashPayPayment (derives the DIP-15 address Rust-side), invoked
  only after the user's explicit Pay tap. Returns the exact network
  fee of the broadcast transaction (requires the platform fee-
  threading commit; see the DASHSYNC_MIGRATION.md platform pin).

SwiftUI screens (UI/DashPay/Contacts/SwiftUI/), styled to the Android
dash-wallet DashPay design (dashpay_contact_row.xml et al.): contacts
home (card rows, Accept pill + round ignore, golden pending state,
Android empty state), add-contact (debounced DPNS search, collision
detection, DashPay-key eligibility marking via identityGetKeys
mirroring the send path's key predicate), contact profile (Pay CTA,
tap-the-header collapsible contact settings, payments history, green
accept / ignore pane), notifications (New/Earlier, inline accept),
and the Android HSV avatar algorithm (hue = charIndex/36, S 0.3,
V 0.6). DPNS names render without the implied ".dash" suffix.

Deleted (163 files): the DWDP* item/factory hierarchy, contacts
VCs/models/FRC data sources, GlobalSearch, DWDashPayContactsUpdater/
Actions, DWNotificationsProvider/Data/VC/cells, the other-user
profile stack, DWDPAmount*View, dead DWFilterHeaderView, and the
pay-to-user payment plumbing (paymentInputWithUserItem — a frozen
DSIncomingFundsDerivationPath read — plus the performPayToUser chain;
the payment-confirm accept-contact checkbox is now honestly hidden).
Kept: Items/Protocols headers (type the always-nil payment userItem;
fall with the C8 processor rewrite), DWDPAvatarView (current-user
surfaces), the invitation flow (out of scope per Row #16).

The Contacts/Explore tabs now gate on
DWCurrentUserIdentityInfo.hasIdentity — the old DashSync
defaultBlockchainIdentity gate hid them from SDK-registered
identities.

Requires ../platform on local/tx-decode-plus-v4.1-dev (see the
platform pin note in DASHSYNC_MIGRATION.md) and an xcframework
rebuild.

Co-Authored-By: Claude Fable 5 <[email protected]>
QuantumExplorer added a commit that referenced this pull request Jul 9, 2026
…subsystem (#787)

* fix(tx): pass ManagedPlatformWallet to the core TransactionBuilder calls

setFunding/addInputs/buildSigned take ManagedPlatformWallet on every
published platform ref (v4.1-dev's #3970 API); the ManagedCoreWallet
overloads the call sites were written against never shipped. The
platform wallet is already in scope; ManagedCoreWallet stays for
broadcastTransaction only.

Co-Authored-By: Claude Fable 5 <[email protected]>

* feat(contacts)!: rebuild DashPay contacts on SwiftDashSDK, delete the DashSync subsystem

Migration Row #18 — the contacts feature (dead at runtime since the
post-M6 DashSync freeze) is rebuilt end-to-end on SwiftDashSDK and the
entire DashSync implementation is removed in the same change.
E2E-verified on testnet against SwiftExampleApp driving the far side:
request sent → reciprocated → established → paid both directions.

New SDK boundary (Sources/Infrastructure/SwiftDashSDK/Contacts/):
- SwiftDashSDKContactsService: SwiftData read model (established =
  both direction rows, single row = pending; debounced
  NSManagedObjectContextDidSave refresh), PIN-gated send/accept via
  DWIdentityAuthorizer + KeychainSigner, ignoreSender (replaces the
  legacy decline, which was a TODO stub that faked failure), DPNS
  prefix search + reverse lookup (dpnsGetUsername, base58), contact
  meta (alias/note/hide via EstablishedContact + flushPersist),
  notifications read-state on the legacy DWGlobalOptions slot, and
  the payments projection (see below).
- DWIdentityKeyUpgrader: dashwallet registration derives
  AUTHENTICATION keys only, so identities registered here could not
  send contact requests. Before the first contact action, one
  IdentityUpdate adds the missing ENCRYPTION + DECRYPTION keys
  (ECDSA, MEDIUM, bounds SingleContractDocumentType(DashPay,
  "contactRequest") — Drive rejects unbound or contract-level bounds).
- DashPay background sync (15s six-step pass) start/stop wired into
  PlatformAddressSyncCoordinator alongside BLAST + shielded.
- SDK.enableLogging installed at host init — the app previously ran
  the whole SDK with Rust diagnostics muted.

Payments correctness (found live-testing):
- PersistentDashpayPayment rows exist only via the app-pulled
  projection (PlatformWalletManager.refreshDashPayPayments); the Rust
  persister never pushes them, and Sent entries are unrecoverable if
  the app dies before a projection. The service now projects on every
  sync pass, at most once a minute on snapshot refresh, on profile
  open, and immediately after every successful send.
- WalletSendService.sendToContact: pay-to-contact through the send
  boundary — spend-auth gate, then the single-shot SDK
  sendDashPayPayment (derives the DIP-15 address Rust-side), invoked
  only after the user's explicit Pay tap. Returns the exact network
  fee of the broadcast transaction (requires the platform fee-
  threading commit; see the DASHSYNC_MIGRATION.md platform pin).

SwiftUI screens (UI/DashPay/Contacts/SwiftUI/), styled to the Android
dash-wallet DashPay design (dashpay_contact_row.xml et al.): contacts
home (card rows, Accept pill + round ignore, golden pending state,
Android empty state), add-contact (debounced DPNS search, collision
detection, DashPay-key eligibility marking via identityGetKeys
mirroring the send path's key predicate), contact profile (Pay CTA,
tap-the-header collapsible contact settings, payments history, green
accept / ignore pane), notifications (New/Earlier, inline accept),
and the Android HSV avatar algorithm (hue = charIndex/36, S 0.3,
V 0.6). DPNS names render without the implied ".dash" suffix.

Deleted (163 files): the DWDP* item/factory hierarchy, contacts
VCs/models/FRC data sources, GlobalSearch, DWDashPayContactsUpdater/
Actions, DWNotificationsProvider/Data/VC/cells, the other-user
profile stack, DWDPAmount*View, dead DWFilterHeaderView, and the
pay-to-user payment plumbing (paymentInputWithUserItem — a frozen
DSIncomingFundsDerivationPath read — plus the performPayToUser chain;
the payment-confirm accept-contact checkbox is now honestly hidden).
Kept: Items/Protocols headers (type the always-nil payment userItem;
fall with the C8 processor rewrite), DWDPAvatarView (current-user
surfaces), the invitation flow (out of scope per Row #16).

The Contacts/Explore tabs now gate on
DWCurrentUserIdentityInfo.hasIdentity — the old DashSync
defaultBlockchainIdentity gate hid them from SDK-registered
identities.

Requires ../platform on local/tx-decode-plus-v4.1-dev (see the
platform pin note in DASHSYNC_MIGRATION.md) and an xcframework
rebuild.

Co-Authored-By: Claude Fable 5 <[email protected]>

* feat(dashpay): restore four legacy contact affordances on SwiftDashSDK

From a deleted-vs-new gap audit of the Row #18 contacts rebuild, restore
the four legacy behaviors worth keeping:

1. Un-cap DPNS search (limit 10 → 0 = SDK default 100, the legacy page
   size); move eligibility checks to lazy per-row onAppear so a large
   result set doesn't fan out a key query per hit.
2. Enrich the contact-profile payment rows: current-rate fiat, tap
   through to the standard tx-detail screen (reusing TXDetailVCWrapper
   via navigationDestination), and the 'direct-to-address payments
   aren't retained' caption. Non-resolving txs stay non-tappable.
3. Add outgoing 'You sent a contact request to X' notification entries.
4. Add a search-result preview/confirm sheet (avatar, name, framing,
   collision-appropriate CTA) as the single send/accept surface.

Honest limitation: the SDK has no on-chain profile fetch for an
arbitrary identity (cache-only reads), so a true stranger shows
username + placeholder, not a fetched bio.

Deliberately not restored: the pay-confirm accept-contact checkbox and
post-payment profile modal (superseded), and the invitation promos
(blocked on the not-yet-migrated DashSync invitation flow).

Co-Authored-By: Claude Fable 5 <[email protected]>

* feat(home): testnet faucet shortcut, default over Spend on testnet

New 'Request 1 tDash' shortcut (testnet only): copies the wallet's
receive address and opens the testnet faucet in-app, mirroring the
Explore screen's get-test-dash flow. On testnet it replaces Spend as
the default fourth shortcut and joins the customization list; a saved
faucet shortcut degrades to Spend while on mainnet (config untouched).

The request itself stays in the web page — the faucet API requires its
anti-bot challenge token, which only the page can produce (verified:
bare POST to /api/core-faucet returns 400 'Captcha token required').

Also fixes the Explore faucet link: the faucet no longer answers on
port 80, so the http:// URL opened nothing.

The new enum case is appended last — raw values persist in
DWGlobalOptions.shortcuts.

Co-Authored-By: Claude Fable 5 <[email protected]>

* style(home): shorten the faucet shortcut label to '1 tDash'

Co-Authored-By: Claude Fable 5 <[email protected]>

* feat(home): faucet shortcut drives the request in-app, web only as fallback

The '1 tDash' shortcut now calls the SDK's TestnetFaucet client
(promoted from SwiftExampleApp — platform 5f53767be7): solve the
faucet's soft cap.js proof-of-work on-device, POST the receive address
to /api/core-faucet, show the result in a HUD. No web page on the
happy path. Rate limit or any failure falls back to the previous
behavior: copy the address, open the web faucet in-app, log why.

Mechanism live-verified against faucet.thepasta.org: challenge ->
solve -> redeem -> 200, 1 tDash delivered (txid 395eeb08...).

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(dashpay): enforce the spending limit and reject overflowing amounts on pay-to-contact

Review fixes (llbartekll):
- sendToContact now passes spendAmount to authorizeSend, engaging the
  C7.4 biometric spending limit; without it the gate was non-monetary
  and Face ID alone authorized a contact payment of any size.
- PayContactSheet validates the entered amount in Decimal space before
  the UInt64 conversion; NSDecimalNumber.uint64Value wraps modulo
  2^64, so 2^64+1 duffs aliased to 1 duff, passed the range check, and
  broadcast the wrong amount while the success screen echoed the
  typed text.

Co-Authored-By: Claude Fable 5 <[email protected]>

---------

Co-authored-by: Claude Fable 5 <[email protected]>
romchornyi pushed a commit that referenced this pull request Aug 28, 2026
DashUIKit#14 is merged, so pin back to `branch = master` (resolved at
`83cf65a`, which also carries #16) instead of `e8d9243`. That commit was
the first of #14's branch and predates three of its own follow-ups —
notably `8097d16`, which stops `BottomSheetDismissalModifier` from
branching on `isEnabled` inside a `@ViewBuilder`. Without it, flipping
`isDismissalEnabled` swaps `_ConditionalContent` branches and SwiftUI
rebuilds the sheet's content from scratch — every time a transfer starts
and ends.

Tracking master changes the dismissal contract, so the call sites have to
follow:

- `perform` now calls `onClose` unconditionally, and the button is live
  when `isCloseButtonEnabled && (isDismissalEnabled || hasCustomCloseAction)`.
  Every sheet here passes `onClose`, so without `isCloseButtonEnabled` the
  X would stay tappable through signing, locking, proving and broadcasting.
  Each site now mirrors its own `isDismissalEnabled` condition.
- `onClose` took a single handler while these sheets have phases whose own
  buttons call something else. Route close per phase: on success the send
  and internal-transfer sheets run `onCompleted` (which unwinds the flow)
  and the evonode sheet runs `onCompleted(remaining)` (which reports the
  new balance), rather than `onCancel`, which only closes the sheet.

`UsernameMarketplaceScreen` passes no `onClose`, so its close button is
already gated by `isDismissalEnabled` alone and needs no change.

Also make `CoinJoinMoveFundsSheet`'s choice body scrollable: it is the only
migrated sheet presented at `.medium`, and the 82pt of chrome came out of
the bottom, where "Later" — the only exit that records the deferral — sits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants