Skip to content

feat(platform-wallet): derive application encryption keys with the DIP-13 rotation level - #5649

Merged
PastaPastaPasta merged 2 commits into
v5.1-devfrom
feat/connect-key-encryption-rotation
Oct 29, 2026
Merged

PastaPastaPasta merged 2 commits into
v5.1-devfrom
feat/connect-key-encryption-rotation

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Problem

The platform wallet SDK derives DashPay Connect app encryption keys at the 8-level DIP-13 path m/9'/coin'/5'/7'/0'/identityId'/contractId'/purpose'. Once mainnet keys are registered there, the path can't change, and it has no level for rotating a pair. DIP-13 (dashpay/dips#191) and the App Connect DIP (dashpay/dips#181) now end the path with a hardened 31-bit rotation' level, with 0' as the first pair:

m/9'/coin'/5'/7'/0'/identityId'/contractId'/purpose'/rotation'

Keys already registered on testnet and devnet use the old 8-level path, so wallets still need a way to derive them to recognise those keys.

Fix

  • platform-wallet: ConnectKey::AppEncryption gains a rotation: u32 field, and new keys are derived with this variant. The new ConnectKey::AppEncryptionLegacy variant derives the old 8-level key, so the old path is only used when a caller asks for it. ConnectKey::derivation_path now returns a Result and rejects rotations of 2^31 or more with InvalidParameter instead of wrapping them onto another key.
  • platform-wallet also owns the mapping from raw values to a key. ConnectKey::from_parts(sub_feature, identity_id, leaf, purpose, rotation) accepts only the valid DIP-13 combinations, and ConnectKey::legacy_app_encryption_from_parts(identity_id, contract_id, purpose) builds the old layout. The FFI only converts C values and calls these.
  • FFI: dash_sdk_derive_connect_key_with_resolver is replaced by dash_sdk_derive_connect_key_v2_with_resolver, which takes a new rotation: u32 argument after purpose. The old symbol is removed, not kept alongside, so a caller built against the old signature fails to link instead of passing its out pointer where rotation now sits. Rotation is required for sub-feature 7 and must be 0 for the session key (sub-feature 6). The new sibling dash_sdk_derive_legacy_app_encryption_key_with_resolver(network, wallet_id, resolver, identity_id, contract_id, purpose, out_key) derives the old layout. No argument value has a special meaning such as "legacy". Both functions check the key before asking the resolver for the seed.
  • JNI and Kotlin follow the same shape:
    • deriveConnectKeyWithResolver is renamed to deriveConnectKeyV2WithResolver(..., purpose, rotation), so a stale Kotlin class or native library fails with UnsatisfiedLinkError instead of a mismatched signature. There is also a new deriveLegacyAppEncryptionKeyWithResolver.
    • PlatformWalletManager.deriveConnectKey is split into a session overload and an app-encryption overload, which requires purpose and rotation.
    • New deriveLegacyAppEncryptionKey.

Temporary local append

The pinned rust-dashcore rev only builds the 8-level path, so platform-wallet adds ChildNumber::Hardened { index: rotation } itself. dashpay/rust-dashcore#1250 (branch feat/key-wallet-encryption-rotation) adds the level to key-wallet. When platform moves to a rust-dashcore rev that includes it, two calls replace the local code:

  • DerivationPath::application_encryption_path(network, identity_id, contract_id, purpose, rotation) replaces the append.
  • DerivationPath::application_encryption_path_without_rotation replaces the legacy arm.

The pinned vectors below ensure that switch changes no keys. This PR doesn't bump rust-dashcore.

Migration (Swift / Kotlin / C callers)

  • Swift: deriveConnectKey(subFeature: .appEncryption, ..., purpose:) now requires a rotation: UInt32 argument, with no default. Existing app-encryption call sites therefore fail to compile until they pass a rotation. Pass 0 for an identity's first pair for a contract.
  • Swift, legacy keys: derive keys registered before the change with deriveLegacyAppEncryptionKey(identityId:contractId:purpose:network:storage:).
  • Swift, session keys: deriveConnectKey(subFeature: .sessionAuthentication, identityId:leaf:network:) calls don't change.
  • Kotlin: same as Swift. deriveConnectKey(walletId, APP_ENCRYPTION, identityId, leaf, purpose, rotation) and deriveLegacyAppEncryptionKey(walletId, identityId, contractId, purpose).
  • C: switch from dash_sdk_derive_connect_key_with_resolver to dash_sdk_derive_connect_key_v2_with_resolver and pass rotation (0 for the session key). Call dash_sdk_derive_legacy_app_encryption_key_with_resolver to get the old layout. The header is generated by cbindgen.
  • Kotlin native callers: switch from IdentityNative.deriveConnectKeyWithResolver to deriveConnectKeyV2WithResolver.

How tested

Vectors from BIP-39 abandon ×11 about, empty passphrase, mainnet. 0x35… is 32 bytes of 0x35, 0x6b… is 32 bytes of 0x6b, asc is bytes 00..1f and desc is bytes ff..e0. All are pinned in connect_keypairs_match_the_pinned_vectors:

path suffix public key
0x35…'/0x6b…'/1'/0' 031a882c119e2b1f8e0349b444d877afa2599efeef49a26930fd25518cb6e9d57a
0x35…'/0x6b…'/1'/1' 03d0f6f0f48d968b9554d8e7fe467d7135bacf29d5c4994ca593bd10ebeed696f6
asc'/desc'/1'/0' 02dfed57ddaaea8c0758e8da44513520038eb8d6b0b92109953c14d6ab1087259b
asc'/desc'/2'/0' 020bcde800f41ad1f924477a9502f111445224cc9ab70114ae4e5099ba02bdd034
asc'/desc'/2'/1' 021b97869c21933673076a938337c28848c8bf8094bbe6883e3a4acbf33c639072
legacy 0x35…'/0x6b…'/1' 03e989de1b62f137231cc06659c810c17100becd1f5e23d5710faa7602769fe434
legacy asc'/desc'/1' 03c4e462229f176595ec17e28e9096d3cfbc42496fb8ed4d48f8f58355d6105aa9
legacy asc'/desc'/2' 031fd0a3cfc01bebb89d43c2e12a6321c37ebdacb62c09495899e5b65a24fa5c99

Other tests check:

  • ConnectKey::from_parts and legacy_app_encryption_from_parts build each valid combination and reject the invalid ones;
  • the rotated path is exactly the legacy path plus a hardened rotation' level;
  • rotations of 2^31 or more are rejected;
  • every key kind, purpose, rotation and layout derives a distinct key;
  • the FFI entry points derive the pinned vectors, and bad purpose or rotation combinations are rejected before the resolver is used.

The existing Swift ConnectKeyDerivationTests are updated, with no tests removed, and cover the new overloads, the legacy derive and the rejection cases.

  • cargo fmt --all
  • cargo clippy -p platform-wallet -p platform-wallet-ffi -p rs-unified-sdk-jni --all-features --all-targets -- -D warnings: clean
  • cargo test -p platform-wallet --lib identity_handle::tests: 9 passed
  • cargo test -p platform-wallet-ffi --lib derive_connect_key: 9 passed
  • cargo test -p rs-unified-sdk-jni --lib connect: 1 passed
  • build_ios.sh --target mac --profile dev followed by swift test --filter ConnectKeyDerivationTests: 4 passed
  • The Kotlin SDK was not compiled locally. Its JNI signatures match the Rust exports.

🤖 Generated with Claude Code

PR Hygiene · c11751f

  • Bots — thepastaclaw ✓
  • Self-review — post /self-reviewed
  • Reviewer requests paused — your 5 review slots are occupied; this PR is excluded from reviewers' queues. Required approvals still count without a slot.
  • Build green
  • Approvals
    • kotlin-sdk (packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/ffi/IdentityNative.kt, packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/PlatformWalletManager.kt) — HashEngineering
    • rs-platform-wallet-ffi (packages/rs-platform-wallet-ffi/src/derive_connect_key.rs) — HashEngineering or ZocoLini or llbartekll or romchornyi
    • rs-platform-wallet (packages/rs-platform-wallet/src/wallet/identity/network/identity_handle.rs) — HashEngineering or ZocoLini or llbartekll or romchornyi
    • files with no dedicated owner (packages/rs-unified-sdk-jni/src/identity.rs) — QuantumExplorer or shumkov
    • swift-sdk (packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift, packages/swift-sdk/SwiftTests/SwiftDashSDKTests/ConnectKeyDerivationTests.swift) — llbartekll or romchornyi

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

…P-13 rotation level

DIP-13's application encryption path now ends with a hardened 31-bit
rotation level: m/9'/coin'/5'/7'/0'/identityId'/contractId'/purpose'/rotation'.

- ConnectKey::AppEncryption gains `rotation`; the pre-rotation 8-level
  layout is the explicit ConnectKey::AppEncryptionLegacy, kept so wallets
  recognise testnet/devnet keys registered before the change.
  derivation_path returns a Result and refuses rotations >= 2^31.
- The rotation level is appended locally because the pinned rust-dashcore
  only builds the 8-level path; it is replaced by key-wallet's
  application_encryption_path(..., rotation) from dashpay/rust-dashcore#1250
  once platform bumps, and the pinned vectors keep that swap a no-op.
- FFI: dash_sdk_derive_connect_key_with_resolver takes `rotation`; new
  dash_sdk_derive_legacy_app_encryption_key_with_resolver.
- Swift: the app-encryption deriveConnectKey overload requires
  `rotation: UInt32`; deriveLegacyAppEncryptionKey derives the old layout.
  Session-key calls are unchanged.
- JNI/Kotlin mirror the same shape.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added this to the v5.1.0 milestone Oct 28, 2026
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 15 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 42f59e6 and c11751f.

Files selected for processing: 6
  • packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/ffi/IdentityNative.kt
  • packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/PlatformWalletManager.kt
  • packages/rs-platform-wallet-ffi/src/derive_connect_key.rs
  • packages/rs-platform-wallet/src/wallet/identity/network/identity_handle.rs
  • packages/rs-unified-sdk-jni/src/identity.rs
  • packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between a828103 and 42f59e6.

Files selected for processing: 7
  • packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/ffi/IdentityNative.kt
  • packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/PlatformWalletManager.kt
  • packages/rs-platform-wallet-ffi/src/derive_connect_key.rs
  • packages/rs-platform-wallet/src/wallet/identity/network/identity_handle.rs
  • packages/rs-unified-sdk-jni/src/identity.rs
  • packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift
  • packages/swift-sdk/SwiftTests/SwiftDashSDKTests/ConnectKeyDerivationTests.swift

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

Connect key derivation now supports rotation-aware app-encryption keys and a separate legacy path for pre-rotation keys. The Rust wallet, FFI, JNI, Kotlin, and Swift layers expose these derivations and validate supported parameters.

Changes: Connect key derivation

Layer / File(s) Summary
Rotated and legacy derivation paths
packages/rs-platform-wallet/src/wallet/identity/network/identity_handle.rs
AppEncryption paths now include a validated rotation level. AppEncryptionLegacy retains the prior path. Tests cover path structure, limits, vectors, and distinct derived keys.
FFI APIs and validation
packages/rs-platform-wallet-ffi/src/derive_connect_key.rs
The current API accepts rotation and validates sub-feature, purpose, and rotation combinations. A legacy API derives keys without rotation. Tests cover vectors and invalid inputs.
Kotlin and JNI APIs
packages/rs-unified-sdk-jni/src/identity.rs, packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/ffi/IdentityNative.kt, packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/PlatformWalletManager.kt
The APIs pass rotation for app-encryption derivation and provide a separate legacy method. JNI result handling frees FFI output and clears private-key copies on the described paths.
Swift API and tests
packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift, packages/swift-sdk/SwiftTests/SwiftDashSDKTests/ConnectKeyDerivationTests.swift
The wallet exposes session-authentication, rotation-aware app-encryption, and legacy derivation methods. Tests check vectors, distinct keys, and invalid parameters.

Priority: Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant SDK
  participant FFI as dash_sdk_derive_connect_key_with_resolver
  participant KeyPath as ConnectKey.derivation_path
  participant Resolver as Mnemonic resolver
  participant Master as Master key derivation
  SDK->>FFI: Request key derivation
  FFI->>KeyPath: Validate derivation path
  FFI->>Resolver: Resolve seed
  Resolver-->>FFI: Return seed
  FFI->>Master: Derive key from path
  Master-->>SDK: Return derived key
Loading

Suggested reviewers: quantumexplorer, lklimek, romchornyi

Merge Risk: Minimal · previous review 42f59

The rotation-aware and legacy derivation APIs appear ready to merge after normal checks. The Kotlin SDK has not been compiled locally, but no broken caller was found.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: application encryption keys are now derived with the DIP-13 rotation level. The changeset matches this. ConnectKey::AppEncryption gains a rotation field, the FFI, JNI,…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: application encryption keys are now derived with the DIP-13 rotation level. The changeset matches this. ConnectKey::AppEncryption gains a rotation field, the FFI, JNI, Kotlin, and Swift APIs accept rotation, and a separate legacy derivation path is added for pre-rotation keys. The title is specific and uses the correct domain term. It is 88 characters, which is longer than ideal for a short title, but this does not affect the assessment.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 14 functions across 7 files.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Oct 28, 2026
@thepastaclaw

thepastaclaw commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit c11751f) · triage: critical

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final validation — Phase 1 + Phase 2

The rotation derivation logic and legacy path are otherwise coherent, and the Rust workspace and Kotlin checks passed. However, the PR changes the calling convention of an existing exported C function and JNI method without preserving the old symbol, which can cause undefined behavior for previously compiled consumers; the new tuple-dispatch rules also belong in platform-wallet rather than the FFI layer. The Swift build check remains in progress.

🔴 2 blocking | 🟡 2 suggestion(s)

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 7: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 8: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 9: gpt-6-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 11: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 12: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — This is a large, cross-language change to cryptographic key derivation and legacy-key compatibility in platform-wallet, including Rust, FFI, JNI, Swift, and Kotlin surfaces.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — general (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort xhigh); agent phase2-reviewer
  • Model comparison: every Phase-2 reviewer also ran on gpt-6-astra; the verifier weighed both sets without knowing which model wrote which
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `packages/rs-platform-wallet-ffi/src/derive_connect_key.rs`:
- [BLOCKING] packages/rs-platform-wallet-ffi/src/derive_connect_key.rs:126-136: Preserve the existing connect-key ABI when adding rotation
  The existing exported symbol `dash_sdk_derive_connect_key_with_resolver` keeps its name but inserts `rotation` before `out_key`. The previous C ABI accepted `out_key` as the eighth parameter; an older compiled caller will therefore pass its output pointer where the new function expects `rotation`, while the new function reads an unprovided ninth argument as `out_key`. The resulting invalid write can crash or corrupt memory before an error is returned. The same incompatibility exists for the unchanged JNI symbol when an older compiled Kotlin class is paired with the new native library. The migration instructions only help callers that are recompiled and do not protect already-built native consumers. Retain the old symbol and behavior, and add a versioned or differently named rotation-aware C/JNI entry point, or make an explicit ABI-major-version change for the shipped native library.
- [BLOCKING] packages/rs-platform-wallet-ffi/src/derive_connect_key.rs:143-165: Keep Connect-key dispatch and combination validation in platform-wallet
  This FFI function interprets the raw `(sub_feature, purpose, rotation)` tuple, selects `ConnectKey::SessionAuthentication` versus `ConnectKey::AppEncryption`, and enforces which purpose and rotation combinations are valid. The new legacy entry point also directly selects `ConnectKey::AppEncryptionLegacy`. Those are wallet-domain decisions, not argument marshalling. Put the conversion and validation behind a typed constructor or request conversion owned by `rs-platform-wallet`, and have the FFI only convert C values and invoke that owner-level API. Otherwise native callers and future bindings can bypass or duplicate the canonical Connect-key invariants.
- [SUGGESTION] packages/rs-platform-wallet-ffi/src/derive_connect_key.rs:228-233: Document the safety contracts of the private unsafe helpers
  `read_leaf` dereferences a raw pointer based on a precondition enforced only by each caller's preceding `check_ptr!`, and `derive_into` similarly relies on its callers to validate `out_key`. These assumptions are currently satisfied, but the private helpers have no local `# Safety` contract, making a future caller's omission an immediate null-dereference or over-read risk. Add `# Safety` documentation describing the required pointer validity and readable lengths to both unsafe helpers.

In `packages/rs-platform-wallet/src/wallet/identity/network/identity_handle.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/identity_handle.rs:182-208: Use key-wallet's canonical rotation-aware path builders when available
  The current code locally appends a hardened child to key-wallet's old eight-level application-encryption path and uses that old builder for the explicit legacy variant. This is behaviorally correct for the pinned dependency, but it duplicates path-shape and hardened-index ownership in platform-wallet. The linked rust-dashcore#1250 is still open and adds the canonical rotation-aware and without-rotation builders. Once that dependency is available, replace these local arms with those key-wallet APIs so the path definition cannot drift between crates.

@github-actions

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Oct 28, 2026
…and move key selection into platform-wallet

- Rename dash_sdk_derive_connect_key_with_resolver to
  dash_sdk_derive_connect_key_v2_with_resolver (and the JNI/Kotlin
  deriveConnectKeyWithResolver to deriveConnectKeyV2WithResolver) so a
  caller compiled against the pre-rotation signature fails to link instead
  of passing its out pointer where `rotation` now sits.
- ConnectKey::from_parts and ConnectKey::legacy_app_encryption_from_parts
  in platform-wallet now map raw (sub_feature, purpose, rotation) levels to
  a key and refuse invalid combinations; the FFI only converts C values and
  calls them.
- Document the safety requirements of the FFI helpers read_leaf and
  derive_into.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@github-actions

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Oct 28, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

The reviewed head correctly centralizes Connect-key selection and validation in platform-wallet, preserves the legacy derivation path, and uses versioned C/JNI symbols to prevent ABI mismatches. The Rust, FFI, JNI, Swift, and Kotlin implementations agree on rotation bounds, path layout, error handling, and secret cleanup; no in-scope findings remain. Rust workspace tests, Kotlin tests, and the Swift schema check were still running, with no failed code checks reported.

🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 7: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 8: gpt-6-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 9: gpt-6-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 10: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 11: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 12: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); reviewer 13: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 14: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 15: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 16: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 17: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — This large cross-language change modifies cryptographic key derivation, rotation-path handling, and FFI/JNI/Swift/Kotlin boundaries in platform-wallet.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — general (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
  • Model comparison: every Phase-2 reviewer also ran on gpt-6-astra; the verifier weighed both sets without knowing which model wrote which
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

No unresolved findings remain from the prior review on this head.

@github-actions

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Oct 28, 2026
@PastaPastaPasta
PastaPastaPasta merged commit 03945d3 into v5.1-dev Oct 29, 2026
43 of 45 checks passed
@PastaPastaPasta
PastaPastaPasta deleted the feat/connect-key-encryption-rotation branch October 29, 2026 06:38
romchornyi added a commit to dashpay/dashwallet-ios that referenced this pull request Nov 13, 2026
#1399)

* fix(dashpay): a devnet pointed at other nodes is another scope for a DashConnect approval

- The scope an operation runs for now also names where the network is
  reached (the devnet's quorum URL), so consent given for a devnet is not
  used after it is pointed at other nodes under the same name. Rows and
  grant records stay keyed by wallet and devnet name.
- When the protocol version cannot be read at approve time the approval
  fails as an unresolved login and the sheet is rebuilt: it offers "Try
  again" while it still cannot tell, and otherwise says why nothing was
  approved.
- States what `active` means for a one-QR connection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): record a one-QR session key before its registration is submitted

An identity update can land on Platform and still report a failure. The
grant was recorded only after the update returned, so such a key stayed
live with no record and no row to turn it off from.

- The grant is recorded unconfirmed (the key's hash) just before the update
  is submitted. After a reported failure the identity is read again and
  the login goes on if the key is there; otherwise the failure stands and
  the record stays unconfirmed.
- An unconfirmed record is confirmed, and its app given a row, once its own
  key (id and hash, live) is seen on the identity — at every one-QR
  approval and every disconnect. Until then it takes no part in a
  disconnect, and it is never dropped on the strength of a view that may be
  behind.
- A confirmed record is never replaced by a new unconfirmed one: a retry
  that does not see its key stops as "identity keys out of date".
- The context read for an operation checks that the SDK runtime is still
  the one it started from after the devnet settings are read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): confirm a recovered one-QR key only with its bound and limits; read Platform off the main actor

- A key found after a reported failure, or later, confirms its record only
  if it is the key that was submitted with everything it was given: the
  data, AUTH/HIGH/HASH160, live, the recorded budget and expiry, and a
  stored bound to the record's app. A bound the store does not show is not
  taken on trust, and an unconfirmed record no longer counts as proof of a
  key's bound when the same request is approved again.
- The App Connect response lookup and the protocol-version read run on
  their own queues instead of through the SDK's main-actor queries, so a
  network round trip no longer holds the UI.
- The protocol version a login is chosen by comes from a proved read of
  the current epoch, which fails instead of falling back; an SDK pinned to
  a version (testnet) keeps deciding by its pin, with no network read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): free a native result string through a typed C pointer

`dash_sdk_string_free` takes a `char *`; the adapter passed the raw result
pointer, which only compiled against a header that declares it `void *`.
Also drops a doc comment left over from the previous protocol-version
lookup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): activate an app's existing row when its one-QR key is confirmed

Recovering an unconfirmed one-QR registration only added rows for apps
that had none, so a two-QR row still waiting for its second scan kept
that banner over a live session key, and a later pass could not repair
it once the grant was confirmed. The row now becomes active and one-QR,
keeping its branding and scope.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): give a confirmed one-QR key its row back if the row was never saved

The one-QR login confirmed the grant and then resolved the connection
preview again (protocol version, contract metadata, username) before
saving the row. An app terminated during those reads left a live key
with a confirmed grant and no row, or an approved two-QR row without a
disconnect switch, and nothing repaired it: recovery looked only at
unconfirmed grants.

The row is now built from the approved sheet's request, so no network
read sits between the two writes. Recovery also reconciles every app
this identity holds a live key of by a confirmed grant: a missing or
two-QR row becomes an active one-QR row on the next one-QR approval or
disconnect.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* build: pin the platform SDK to v5.1-dev with platform#4844

DashConnect v2 needs `deriveConnectKey` and the reshaped
`ParsedStateTransition` (platform#4844), the delete-by-values entry
point (platform#5419) and the contract-group read (platform#5421), all
merged into v5.1-dev at a9336f9486. develop's pin (5.0.0-rc.1) has none
of them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): settle a pending one-QR registration before a disconnect, and find a key id past the last one

A one-QR upgrade over a two-QR row whose identity update landed but
reported a failure left an unconfirmed record and the two-QR row. A
disconnect then took the local two-QR path, downgraded the row and
left the session key on with no switch to turn it off. The disconnect
now reads the active identity again first when it has such a record of
the app: a key confirmed there makes the row one-QR and the full
disconnect runs; a failed read, or a key that is live under the
record's id but cannot be confirmed, stops it with the row in place.

A key on the identity under the last id (an app can register one there
through the two-QR flow) made every new one-QR login fail with no free
key id. The lowest id no key has is taken instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): choose the disconnect from a fresh view, and settle a one-QR registration by its revision

A disconnect picked one-QR or two-QR from the row alone. A two-QR row
with a one-QR registration whose outcome was not known was turned off
locally, and the key could land afterwards with no row; a confirmed
grant whose row write was lost had its repaired row overwritten as
two-QR again.

The registration now notes the identity revision its update was built
for. Platform takes an identity update only at one above the
identity's revision, so once the identity is there without the key the
update can never land. The revocation reads the identity's keys and
revision after the PIN and then settles each pending registration of
the app: a live key that cannot be confirmed stops the disconnect, one
that can never land is dropped, and one that may still land makes the
disconnect one-QR, whose disable update leaves it unable to land; with
nothing to disable the disconnect stops with a new message. A live key
of a confirmed grant also makes it one-QR. The caller removes or
downgrades the row by what the revocation returns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): open an App Connect callback only for a request opened as a link

A QR code scanned off another screen is answered on that screen: opening
its callback on this phone started an unrelated session of the app in
the phone's browser. The view model knows how the request arrived, and
opens `cb` only for one delivered by `onURIReceived`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): report the user's last answer to an App Connect callback

A failed attempt left `ac=failed` behind: a retry cancelled at the PIN
prompt, or a sheet rebuilt after the approval went out of date, then
closed with the earlier failure. A cancelled prompt now clears it, and
so does each rebuild, so closing the sheet reports a decline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): check an App Connect v2 request against the app's website

- A request for an app in the wallet's brand map whose callback is on a
  host the app does not have is refused (`invalid`): the sheet would be
  branded as the app and return somewhere else.
- The sheet warns when the app is not in the brand map (its name and
  website come from the request), and when a known app's request does
  not return to its website. "Only approve if you just started signing
  in on …" names the app's website first, not the request's callback.
- A key the app asked for with no budget is shown as able to spend the
  identity's credits without a limit.
- `v=2` is recognised in the form-decoded query, as the v2 parser reads
  it, so `v=%32` is no longer sent to the v1 parser.

New strings ship in English in every locale (Transifex translates).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): send an App Connect v2 key again only as the binding's, by its record

A key on the identity at a binding's derived payload was sent again when
its level and limits fit: a request repeating another's ephemeral key
derives the same payload, and with the grant record lost nothing tied
the key to this request. Now it is sent again only when the wallet's
store shows it with exactly the binding's bound (contract, document type
or group) and the grant recorded for this request names it. Otherwise
the approval fails closed and the app asks again.

The store's key records carry the full bound for this (`StoredBound`).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): settle a registration that lands during a disconnect, and keep the row for another identity's

- A one-QR registration that could still land when the disconnect picked
  its keys may land before the disable update, which a reload elsewhere
  can then build on the newer identity. Once a disable update has landed
  none of them can land any more, so one more read settles each: a key
  that turned up is disabled too, one that never will is dropped, and a
  read still below the update keeps the records and the row.
- A registration on another identity of the wallet that may still land
  keeps the row (`registrationPendingOnAnotherIdentity`) instead of a
  local downgrade on this one; only that identity's own read settles it.
  This identity's own pending registration is reported first, so the
  two identities never send the user back and forth.
- A confirmed grant not yet recorded as off makes a disconnect one-QR
  while no two-QR login key is live, so a retry after a one-QR
  disconnect that stopped after disabling still removes the row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): close the second round of App Connect v2 review blockers

- Disconnect finds unrecorded v2 keys bound to any contract or group the
  app's owner owns, which are the bindings the owner check lets a request
  have, not only the app's own contract (`appsV2KeyIds`, `ownedByOwner`).
  The other identities of the wallet are scanned for those shapes too,
  from the store; an owner lookup that fails leaves the row in place.
- A retry sends a recorded response again only while the encryption keys
  it carries are still the identity's: `AppConnectGrant.encryptionKeyIds`
  is recorded, and a retry whose keys changed stops with
  `appConnectEncryptionKeyChanged` before anything is registered.
- A contract group with administrators is disclosed on the sheet: they
  can add their own contracts, and a group key acts in the contracts the
  group holds when it signs.
- The budget line says it is a limit on the identity's credits, and a
  CRITICAL group key's line says that limit does not cap the tokens it
  can move.

New strings ship in English in every locale (Transifex translates).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): take an App Connect v2 key that settled late only as it was added

- After an update reported a failure, a key under an added id counted
  as landed by its payload alone. A stale first read and a request that
  repeated an earlier one's ephemeral key could then export that
  request's broader key. It now has to carry everything it was added
  with, the bound as the store reads it included (`isAddedKey`).
- A response recorded by a build that did not note its encryption keys
  cannot be checked, and a retry of it is refused.
- A disconnect that finds a stored v2 key of the app missing from the
  fetched identity stops with `identityKeysOutOfDate`: the node that
  answered is behind, and the key could not be shown to be off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): take the app's current encryption key from Platform

The current encryption key for the app's MultipleReferenceToLatest
requirement was taken to be the identity's live key of that purpose with
the highest id. Platform names the key registered last instead, which can
have a lower id, and keeps naming it after it is disabled. A wallet whose
older key 5 is live after another wallet registered and disabled key 9
would export key 5, which the app's verifier refuses, and still answer ok.

The login now reads the current key with a proved identities.contractKeys
query and sends this wallet's key only while it is that key and live. A
response that leaves out the identity or the purpose throws.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): send the current encryption key only when both reads agree

The fetched identity keys and Platform's current-key reference are two
reads, and either can be behind. The login now goes ahead only when the
fetched keys show the referenced key as Platform does (same id, data and
disabled state), and a live key of this wallet's bound to the app with no
reference at all stops it as out of date instead of dropping the slot.
That also keeps a stale list from offering the referenced key's id to a
new key, and keeps a disabled own key from being registered again.

A contract whose requirement is Multiple keeps no current key, so a login
that asks for one is refused up front. The contract keys are read once
per contract, and their numbers only when exact.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): follow the contract's current-key rule for the app's encryption key

Unique keeps the first key ever registered current, even after it is
disabled, and refuses a second one: the slot is left out there instead
of a registration that fails the whole update. With no current key at
all, a live key the store cannot place is bound elsewhere and no longer
holds the slot back. The rule travels with the plan from the contract
read the sheet already makes.

When a key this login registered is passed over by another wallet's
registration that landed later, the slot is left out of the response.
The contract keys are read beside the identity's keys, once, and a
failed read or a disagreement between the two now has its own sign-in
message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): wait for a second read before trusting an answer a lagging node could give

Two answers about the app's encryption key look the same whether
Platform's read is behind or not: no current key beside a live key the
store cannot place, and a disabled current key beside a live key of the
app's. They now hold only once a read a few seconds later names the same
current keys; answers that keep changing stop the login as out of date.
The same goes for a key this login registered that a read shows passed
over: the slot is left out only when a second read names the same key.

The first read runs in its own task, so a login that fails before it is
needed does not wait for it, and an answer this build cannot read says
to update the wallet instead of to try again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): never take a lagging read of the current keys over a newer one

Platform never takes a current-key reference away and never gives a
disabled key back, so a later read that lacks a key an earlier one
named, or shows it live again, is behind: it is set aside instead of
being taken, and cannot turn "leave the slot out" into a registration.
The re-reads now also run when the first answer is out of date, and the
loop is a function of its own with tests. With no current key at all,
this wallet's own key on the identity means Platform's read is behind.

A key sent again is checked after the update too, not only a key this
login registered. A requirement value this build cannot read asks to
update the wallet instead of blaming the app.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): confirm every answer about the app's current key on a second read

Two reads that name different keys cannot be ordered, key ids saying
nothing of order, so they no longer count as one being newer: the
answer stays unconfirmed. An answer a newer read gives now needs a later
read that agrees, like one that waits on a later read; only an answer
from the first read is taken as it is.

The check after the update for a key passed over by another wallet's
registration is gone: telling a passed-over key from a lagging read
needs the same guesswork, and a slot it gets wrong blocks every retry.
A key passed over that way is refused by the app's verifier, and the
next sign-in sends the key that is current then. The requirement value
is read once, into one answer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): wait on a second read beside any other live key of the app's

Under MultipleReferenceToLatest a live current key beside another live
key of the app's may come from a read taken before that key was
registered, so the answer, sending this wallet's key or leaving the slot
out, now waits on a later read too. A read that conflicts with an
earlier one ends the login as out of date, since there is no telling
which of the two is behind; a read that fails is set aside like one
that is behind. The first re-read comes after a second, the later ones
after three.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): treat a disabled key of the app's as proof of a current key

With no current key reported, a disabled key the store places on the
app's contract also means Platform's read is behind: the key made itself
current when it was registered. Under Unique a login would otherwise add
a second key that Platform refuses.

A first read of the current keys that fails is tried again like a later
one, and when no read answers at all the login reports that the keys
could not be read rather than that the network is catching up. The
reads run on a concurrent queue, so one a failed login left behind does
not hold up the next.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): register the app's key behind a confirmed disabled current one

Once a later read confirms that a disabled key is still the app's
current one, a live key registered before it is no longer current
either, and this wallet's key shadows nothing: it is registered instead
of the slot being left out, unless this wallet's own key is already on
the identity.

An answer this build cannot read ends the reads at once, a contract
whose config cannot be read counts as one whose key requirements are
unknown, and an approval cancelled during the reads registers nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): count disabled keys of the app's beside a live current key

A disabled key the store places on the app may be the key registered
last, so beside a live current key it makes the answer wait on a later
read, as a live one does. An answer this build cannot read is now a
refusal the app hears as unsupported, like a contract it cannot read,
and the cancellation check before the identity update is gone: nothing
cancels an approval in progress.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): weigh a disabled key the store cannot place, and show a refusal as the answer

A key of the purpose the store cannot place now makes the answer wait
on a later read in any state, not only while live. A refusal thrown by
an approval turns the sheet into that refusal instead of keeping
Approve on offer for a request that fails the same way every time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* build: pin the platform SDK to v5.1-dev with platform#5491

The current-key reads resolve the encryption and decryption slots through
`identityContractKeys`. At a9336f9486 the FFI ran the proved query and then
returned an empty map, so every encryption-bearing v2 approval failed before
the identity update. 063589bf0a returns the proved result.

`startSpv` is async at that revision, so the coordinator awaits it, as
develop already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(dashpay): accept App Connect requests on dashpay://connect

DIP #181 never allows the dash-key: carrier on mainnet, and dashpay://
is the scheme invitations already use, so apps will move to
dashpay://connect?v=2&n=<m|t|d>&r=<base64url body>[&cb=<https URL>].
The wallet sent such a link to the "Not a Dash URL" alert and the
scanner did not know it.

The request body is the one a dash-key: v2 URI carries and is decoded
and processed identically; only the wrapper differs.

- DashConnectUri.parseConnectRequest applies the DIP's URI rules: scheme
  and host case-insensitive, empty or "/" path, no userinfo, port or
  fragment, form-decoded query, a repeated v/n/r/cb is invalid, unknown
  parameters are ignored, v must be 2, r is required, the whole URI is
  at most 4,096 bytes and r at most 1,366 characters, both checked
  before decoding. cb keeps its rules.
- DashConnectUri.base64URLDecode is a strict RFC 4648 section 5 decoder
  with no padding: it refuses =, +, /, other characters, a length of
  1 mod 4 and non-zero trailing bits.
- The dash-key: v2 parser shares its query and finishing steps with the
  new one; its behaviour is unchanged.
- DashConnectDeepLink.uri(from:) recognises the link, which routes the OS
  link (DWURLParser), Home scan and the in-app scanner (parseQR) through
  the existing path, including the network check before any read.
- An unknown dashpay:// verb such as sign says the link needs a newer
  version of the wallet. dashpay://invite and dashpay://user are left
  alone.
- The Testnet configuration of the dashpay target used a separate
  Info.plist without the dashpay scheme; it is registered there too.

The mainnet gate and the dash-key:/dash-st: carriers are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): bound the work dashpayHost does before the size limit

dashpayHost copied and scanned the whole text after dashpay:// into an
array. It runs from DashConnectDeepLink, isUnsupportedDashpayVerb and
parseQR before parseConnectRequest checks the 4,096-byte limit, so a
long dashpay:// string without a "/", "?" or "#" cost memory and time
in proportion to its length.

Read at most 256 scalars after the scheme. A verb, userinfo and port fit
well inside that, so routing is unchanged: an oversized dashpay://connect
link still reaches the parser and is refused as too large. A longer
authority is classified from its first scalars, as an unknown verb.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* build: pin platform to 03945d3a for the encryption rotation level

dashpay/platform#5649 (03945d3a on v5.1-dev) adds the DIP-13 rotation'
level to App Connect encryption keys: deriveConnectKey for .appEncryption
now requires a rotation, and deriveLegacyAppEncryptionKey derives the
earlier 8-level path. The path becomes permanent with the first mainnet
key, so the wallet has to derive it before mainnet ships.

The only compile break in the 55 commits since 063589bf is the removed
rotation-less .appEncryption overload; the call site passes rotation 0
here. Until the next commit selects keys by the DIP rules, this derives
only rotation 0', so testnet keys at the old path read as another
wallet's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(dashpay): select App Connect encryption keys by the DIP rotation rules

The wallet derived one encryption key per binding and compared it with
Platform's current key. With the rotation level, the identity's current
key may be any rotation this wallet registered, or on testnet a key at
the earlier 8-level path that today's builds registered. And a disabled
current key of another wallet's read as absent under
MultipleReferenceToLatest, so the login registered a new key beside it,
where DIP rule 2 says to leave the slot out.

Per granted binding the wallet now derives rotation 0', then 1', 2', ...
while each is on the identity in any state (stopping at the first that is
not), plus the earlier path on testnet and devnet only. A live current
key among them is sent and nothing is registered; any other live current
key, or a disabled one, leaves the slot out; only an identity with no key
for the contract and purpose gets rotation 0' registered. The keys are
derived after the identity's keys are fetched, and the candidates no slot
carries are wiped before the update and the publish.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(dashpay): leave unattributed DashPay profile keys on a disconnect and offer to revoke them

A DashPay profile key's bound names no app, so with no grant record a
disconnect cannot tell which app was given it. Disconnecting one app used to
disable every such key, which could revoke another app's access. A disconnect
now leaves them, says how many are still active, and the Connections screen
offers "Revoke shared profile access", which disables them all after a
confirmation, a PIN prompt and a fresh read of the identity.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): pin the shared profile revoke to its identity and refuse an untrusted view

- The count carries the identity it was read for; the revoke refuses another.
- A count the store could not read is shown as unknown, not as none.
- The revoke refuses a fresh view with a live v2 key the store cannot place,
  as the disconnect does, and no longer waits on unrelated registrations: a
  v2 approval records its keys only once they land, so a pending record is
  never a profile key.
- Expired keys are neither counted nor disabled.
- The store is reloaded after the disable, so the row clears.
- Only the latest count read is shown, and only a one-QR disconnect mentions
  the keys.
- The key selection moved into AppConnect and is tested there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): keep an expired key from blocking the shared profile revoke

- An expired v2 key with no readable stored bound no longer makes the view
  untrusted: it can no longer sign, so it is not one of the keys to revoke.
- A one-QR disconnect reloads the identity after its disable, so the count it
  reports does not include the key it just turned off.
- A wallet that could not be read gives an unknown count, not none; only a
  wallet with no identity gives none. The count leaves out every key a record
  names, unconfirmed records included.
- A confirmed revoke that cannot run says why. The count is read again when
  the screen appears and when the rows change, not on every publish.
- The millisecond conversion reuses AppConnect.milliseconds, and the new
  strings are in every locale catalog with their English text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): revoke shared profile access only on the identity that was counted

- The count and the revoke name the same keys as recorded: confirmed records.
- An access whose identity could not be read offers no revoke.
- Expiry allows the clock tolerance the rest of App Connect uses.
- disconnect and revoke share one busy check.
- The count is read when the screen appears, not again for the value the
  publisher replays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): clearer shared profile copy, card styling and an honest unknown on confirm

- The row and the disconnect alert say what the keys do (they can update the
  DashPay profile) instead of "no connection accounts for".
- A confirm whose access lost its identity meanwhile says the keys could not
  be checked, not that none needed revoking.
- The row sits in the same card as connection rows, its texts read as one
  VoiceOver element and the button names what it revokes.
- Whether the row shows and can revoke is decided in the view model.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(dashpay): cover the shared profile revoke's wallet pin and an unknown count

The revoke compares the counted wallet before it reads the SDK context, so a
count from another wallet is refused the same way with or without one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(wallet): pin testnet to Platform protocol 14 on this stack

The stack's platform pin (03945d3a) brings dashpay/platform#5561, which refuses
any request that needs a newer protocol than the SDK is pinned to. With
testnet pinned to 13 that refused the contract-group read App Connect makes
on a disconnect and an approval ("get_contract_group_info needs Platform
protocol version 14; this SDK is pinned to an earlier protocol version").

This takes the pin from #1222, already on develop; the rest of that change
reaches the stack when develop is merged up through it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(wallet): pin testnet to Platform protocol 14 on this stack

The stack's platform pin (03945d3a) brings dashpay/platform#5561, which refuses
any request that needs a newer protocol than the SDK is pinned to. With
testnet pinned to 13 that refused the contract-group read App Connect makes
on a disconnect and an approval ("get_contract_group_info needs Platform
protocol version 14; this SDK is pinned to an earlier protocol version").

This takes the pin from #1222, already on develop; the rest of that change
reaches the stack when develop is merged up through it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 1ddb5d031a7a20a7bd25afa508e946ec97c9c9b2)

* docs(dashpay): say testnet gets the App Connect login now that it is pinned to 14

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): refuse an App Connect v2 renewal that cannot turn off every replaced key

A renewal disabled only the first maxKeysDisabledPerUpdate superseded keys
of the connection and reported success while the rest stayed live. It is
now refused before anything is submitted; a disconnect takes the keys in
batches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(dashconnect): add a confirming connection status

A connection whose App Connect v2 identity update was submitted but whose
outcome is not known yet. Its keys may be on the identity, so the row
offers the disconnect switch as an active one does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): record an App Connect v2 grant before submitting its identity update

The grant and a confirming row were written only after the update was
seen to land. An update that landed while every follow-up read failed
left live keys with no record and no row to disconnect them from.

The record is now written first, with every key the update adds. Its
outcome is settled without guessing a revision: every key there as added
means it landed; an expected id held by another key, or its encryption
key under another id, means it never can; an update of this wallet that
landed after it means an absent one never will; auth-only keys past
their expiry end it. Settling runs at every approval, disconnect and
shared-profile revoke, publishes the response of one that landed, and a
retry of the same request resubmits the same keys under the same ids.
Renewal, disconnect, the shared-profile count, the other-identity check,
key-id allocation and the publish-time cleanup know the pending form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): settle a pending App Connect v2 update by a noted later update

Every identity update of this wallet that returns success is noted, by the
keys it added and the ids it disabled, on the v2 records still waiting for
theirs; a later view that shows it settles them. A disconnect whose
follow-up read is behind therefore no longer leaves its record waiting for
good, and finishes marking and deleting what it turned off before keeping
the row.

Also: nothing is published at the start of an approval; a recovered
response is published without the cleanup of the app's other responses; a
retry reseals the response with the identity's current encryption keys;
the app's earlier row comes back when its update can never land.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): fail closed on unknown shared profile counts and let the user keep the keys

- No revoke while the count is unknown, in the view model and the data
  source.
- A live unrecorded v2 key in the store whose bound this build cannot read
  makes the count unknown and refuses the revoke, even when the fetched view
  lacks it; one the fetched view shows off does not.
- An access lost to an unreadable wallet is not reported as nothing to
  revoke.
- Keep: after the PIN prompt, the shown keys that are still shared are noted
  on this device and are no longer counted or revoked from here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): show the shared profile row in the connections card

With connections on screen the row sat outside their scroll view and could
end up below it. It is now the card's last row; without connections it
stands on its own as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): keep a confirmed App Connect v2 grant on a lagging view, and resubmit a pending update as it was

A confirmed grant of the request whose keys a view lacks means the view is
behind; the approval stops instead of turning the record pending again. A
retry resubmits the earlier update with its disables, so the record's
retirements hold whichever update lands. An own update is noted on the
other waiting records whenever its landing is known, not only on success.
A pending update that landed and whose keys are off again is dropped with
what it retired marked done. A replaced grant's response is not published,
responses found at the start of an approval are published once it went
through, and a two-QR approved row a confirming one replaced comes back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): finish what an App Connect disconnect turned off, and keep one-QR ids reserved

A disconnect that turned the app's keys off but could not turn off keys
that landed late now marks and cleans up what it did before reporting it.
A renewal that sends nothing still retires the grants it replaces. A
one-QR registration that may still land keeps its id from a v2 approval.
The responses of other grants found to have landed are published at the
start of an approval, so a later refusal does not lose them, and the
settle after this approval runs once its own response is out. A
confirming row is not shown as an existing connection, and a retry that
can never land puts the approved row back by what the record says.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): publish recovered App Connect responses until they go out

A v2 grant found to have landed is marked as waiting for its response,
and every settle point that can sign publishes the marked ones (the
one-QR approval among them) until one goes out, instead of only those
confirmed in the same call. A pending update with some of its keys off
again landed and keeps its record; only one with every key off is
dropped. A retry whose connection changed since its first submission
waits for that one to settle. A second confirming approval keeps the
approved row to restore, and a confirming row is never shown as an
existing connection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): pin a shared profile revoke to what was shown and fail closed on unknown records

- The revoke confirmation keeps the access it was opened for; a different
  current access is refused, and only the key ids shown are turned off.
- A grant row the store cannot read that may belong to the identity makes
  the shared count unknown and refuses keep and revoke (before the PIN for
  the revoke).
- No stored keys means not loaded: the count loads the identity once, and
  stays unknown if the store is still empty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): confirm a late-landed App Connect v2 grant without publishing its response

A grant found to have landed after its approval stopped waiting is now
only confirmed and shown; its response is not published, and the app asks
again. This removes the recovered-publish path and its flag.

Also: rows of dropped records are left as they are when the key store
cannot be read, instead of being judged against no keys; one helper
writes them for both the approval and the settle; a retry whose
connection changed since says so instead of describing a disconnect; the
unused exception of noteOwnUpdateLanded is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): turn off only live keys of late-landed App Connect grants, and judge orphaned confirming rows

Keys of a grant found to have landed late are turned off only where a
fresh view shows them live. An update whose auth keys are all off is done,
whatever its encryption key: nothing here turns that one off. A confirming
row whose record went while the key store could not be read is judged at
the next settle. The settle after an approval runs even when its publish
fails. Every DashConnect identity update outside a v2 approval goes
through one helper that notes it on the waiting records.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): judge a vanished shared profile access by the identity it was confirmed for

- The view model keeps the latest read with its scope and identity. A
  confirmed revoke or keep whose access a read of another wallet or identity
  replaced with none is refused; none for the confirmed identity is reported
  as none.
- Keep checks the store before the PIN prompt, and asks for nothing when
  none of the shown keys is still shared.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): restore a replaced two-QR row before judging by bound keys

A dropped v2 record that replaced a two-QR approved row restores that row
even while the two-QR login's keys, bound to the app, are live; only a
confirmed grant of the app makes it active first. An orphaned confirming
row is not judged while a grant record of the identity cannot be read,
and row ids are decoded as everywhere else.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): judge a dropped App Connect row by auth keys only, and retry a partial update

A dropped record's row stays active only for a live auth key bound to the
app; its encryption key stays on after a disconnect and connects nothing.
A failed submit that adds keys is settled by the record it was given, not
by a reread of the store. An orphaned confirming row is not judged while
any grant record of the wallet cannot be read. A retry of an update that
added only some of the request's keys maps the ones it adds. The
recordedKeyIds forwarder is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): compare App Connect key expiries as unsigned timestamps

The SDK carries the protocol's unsigned expiry in an Int64's bits, so an
expiry past Int64.max read as already expired and hid a live shared
profile key from the count, the revoke and the unplaced-key check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): note an App Connect update only when its own submission succeeded

Keys found after a failed submission may be an earlier submission's of the
same grant, which says nothing about other waiting records, so only a
submission that returned success is noted on them. The keys a waiting v2
record sends again count as that grant's for the shared profile count. A
dropped record's row stays for a v2 auth key bound to a document type of
the app. A retry keeps the earlier record's note, and one whose derived
keys no longer match the earlier update says so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): a resubmitted App Connect update starts without the earlier note

A retry is built past any update noted on its earlier submission and can
land after it, so its record starts with no note; carrying it over dropped
a retry that could still land. An update whose expired keys are on the
identity but not yet placed by the store stays unknown instead of being
dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(dashconnect): an expired App Connect update whose keys are there stays unknown

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): judge an App Connect row by the dropped record's identity, active rows included

A v2 record that can never land is dropped only once its rows are judged
by the store's keys of its own identity; while those cannot be read it is
kept, and the next settle drops it. No confirming row is left without a
record, so the sweep that judged such rows by the active identity's keys
is gone. An active one-QR row a waiting record kept is judged too, and
goes once nothing holds the app.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): a disconnected app's two-QR row stays gone, and settled records go after their rows

A one-QR disconnect of an app clears, on its waiting v2 records, the
two-QR row they would put back: that row's keys are off too. A settle
writes the rows of dropped records before it saves the store without
them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): retries stay within the approval, raised key limits keep the record, replacements wait for their disables

- A retry of a v2 approval whose outcome is not known sends the earlier
  keys only when their terms are within this approval's (same bound,
  level and budget, an expiry still ahead and no later) and the
  connection is the same; otherwise earlierApprovalPending.
- A key limits update only raises a limit, so a recorded key with a
  higher budget or a later expiry is still the record's key, for v2 and
  one-QR records. Expiry is read with its unsigned bits.
- An update whose keys are there but whose disables are not was not
  this update: the grant is confirmed and nothing it replaced is retired.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): a waiting approval's reused keys reach its retry, a recovered grant completes only within its limits

- An approval whose earlier attempt reused some keys and added others,
  and whose outcome is not known, is matched by the keys it sends again
  (AppConnect.resentKeyIds), so its retry is reached.
- A failed update found landed completes the approval only when every
  key it added is live with the limits it was added with
  (AppConnect.showsAddedLimits); otherwise the grant is recorded so a
  disconnect turns it off, and the failure stands.
- A disconnect turns off the live keys a waiting record sends again; a
  view that lacks one, or a store that cannot place one, stops it.
- Late-landed grants: only keys a login could have granted are turned
  off, and a grant naming a key left on or not shown is not marked off.
- A retry adds the superseded grants confirmed since to those it retires.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): one-QR recovery hands out only the approved limits, no drop on the device clock, one-QR keeps off a waiting v2 record's ids

- A one-QR registration found landed after a failure is handed out only
  when its key is live with exactly the limits it was registered with
  (AppConnect.showsRecordedLimits); a key whose limits were raised since
  is recorded so a disconnect turns it off, and the failure stands.
- A v2 update whose outcome is not known is no longer taken as unable to
  land when its auth keys look expired: Platform judges expiry by block
  time, which a view does not carry.
- A one-QR login reserves the ids of the same request's v2 record still
  waiting for its update, so it cannot take that record's id or record.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): keep a row while the app may still hold keys, settle predecessors only on placed keys, approved expiry as a ceiling

- A row that a dropped record would take away stays while the app may
  still hold a key no record names, on this identity or another one of
  the wallet (identityHoldsAppKeys, shared with the disconnect's check);
  not known counts as held, so the user keeps the way to disconnect.
- A renewal turns off a waiting predecessor's added keys only where the
  store places them, and waits while one is live but unplaced.
- A one-QR login reserves a waiting v2 record's own ids as well.
- The approved expiry is a ceiling when keys are sent again, for a
  waiting record and for keys already on the identity.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): a kept row stays as it was, a disconnect clears a row whose update never left, a renewal checks its view

- A row kept after a record is dropped, while the app may still hold
  keys, keeps its status instead of showing the app as connected; keys
  of other apps' records no longer make that answer unknown.
- A disconnect with no live key of the app and a v2 update still waiting
  removes the row and keeps the record: an update that never left the
  device no longer leaves a row that cannot be disconnected, and one
  that lands after all shows the app again.
- A renewal waits while the view lacks a key a waiting predecessor sends
  again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): only an added key witnesses an update, a dropped record's re-sent keys show again, a disconnect turns off placed pending keys

- An update that only disables keys is no witness that a waiting update
  can no longer land: Platform takes a disable of a key that is already
  off. Only updates that added keys are noted and shown.
- When a waiting record is dropped, the keys it sent again are taken off
  the shared profile keys the user kept, so they show in shared profile
  access, where they can be revoked.
- A disconnect also turns off the keys a waiting record adds that the
  store places as added, and waits while one is live but unplaced.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): keep disables as an update's witness, a disconnect does not wait on unplaced pending keys

Restores the disable witness of an own update: without it no disconnect
settles a waiting record and the first one ends in an error after its
keys are off. The repeatable-disable gap is noted as a TODO against the
SDK's transition handle. A disconnect no longer refuses while a waiting
record's added key is unplaced, which could block it for good; it turns
off the keys the record holds (AppConnect.waitingKeyIds).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(dashconnect): redesign the Connections page and add a connection sheet

- Connections: a + that opens the scanner, Active / Disconnected /
  Expired tabs once anything was connected, one card of apps (name and
  website); a row opens the connection's sheet.
- Connection sheet: status, App ID, username and identity (from the
  app's grant records), the largest key budget with an info sheet on
  identity funding limits, the expiry or disconnect date, collapsible
  lists of what the app can and cannot do, and Disconnect or Reconnect
  (the scanner). Actions report on the sheet.
- Disconnected apps are kept per wallet and network in their own store,
  written by a disconnect before the row goes and cleared by a new
  approval; never removed by hand. Entries this build cannot read are
  kept as stored.
- Expired is read from Platform (every key still on past its expiry),
  in turn with the operations that sign; until then a row stays Active.
- What an approval gave is recorded on its grant (grantedAccess) and
  listed as its approval sheet listed it; the permission text is shared
  with the approval sheet.
- Shared profile access is a system message with Dismiss (Keep) and
  Revoke.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): a disconnect waits while the fetched view lacks a key a waiting record holds

The view-is-behind check covered only the keys a waiting record sends
again; it now covers the keys it adds that the store places as added
too, so a lagging view cannot let the row go while such a key is live.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(dashconnect): a disconnect turns off unattributed DashPay profile keys; remove Keep and the shared profile row

Product decision: DashPay profile keys that no grant record names are
turned off automatically. A disconnect that signs an update for the app
also disables the active identity's live, unexpired profile keys no
confirmed record names (AppConnect.sharedProfileKeyIdsToDisable), and
stops with identityKeysOutOfDate when that set cannot be told. The
disconnect returns how many it turned off, and the screen says so.

The Keep feature, its store, the shared profile access row with its
Revoke, SharedProfileAccess and the data source's sharedProfileAccess,
revokeSharedProfileAccess and keepSharedProfileAccess are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): the app's revoke is never blocked by the profile keys; they go only with a disconnect that ends here

- Unattributed DashPay profile keys join a disconnect only when it is of
  an app this identity holds keys or a grant of and it ends here (not
  held, or unchecked, on another identity); a retry after a failed later
  batch still reaches them.
- When they cannot be told apart, the app's keys still go and the result
  says the profile keys were not checked. disconnect returns
  DashConnectDisconnectResult, which the screen reports.
- The kept shared profile keys an earlier build noted are removed once
  when the data source starts.
- The protocol and helper docs say what a disconnect now does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): connection sheet and tab states, history per app and wipe, expiry read only when it can judge

- The connection sheet shows its details loading or unreadable instead of
  leaving sections out; the granted lines come from the view model.
- Tabs show a spinner while their apps are unknown, a note when expiries
  could not be checked (with Retry), and a message per empty tab; no
  empty state before the history is read.
- A disconnect from the sheet turns it into the disconnected app: it waits
  for a status read that started after it. The history shows without
  waiting on Platform.
- A request that reads closes an open connection sheet and takes the
  screen; one that does not read leaves it up, with the error on it.
- An app with no live grant on the active identity is `notJudged`, not a
  failed expiry check. Platform is not read without an active one-QR row
  to judge.
- History: one entry per app (the latest); an entry this build cannot
  read of the same app is replaced or removed with it; a deleted wallet's
  history is cleared.
- Globe icon before the URL, collapsible titles per status, the info sheet
  scrolls, the connection sheet has a grabber, and segment labels shrink
  a little instead of being cut off.
- Each new string is in every catalog under its own comment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): profile keys go only with a disconnect that leaves none of the app's records waiting

A disconnect that leaves one of the app's v2 records waiting ends in
registrationPending (or lets the row go without settling it), so it
does not take the unattributed profile keys. The profile selection's
doc and a test now cover a waiting record of another app holding its
re-sent and placed profile keys.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): the disconnect confirmation says what this row's disconnect does, and a disconnect that cannot run says why

A two-QR row is only turned off on this device; a one-QR row's keys go
on Platform and unattributed DashPay profile keys may go with them. A
confirmed disconnect refused because another request is in progress now
says so instead of doing nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): the connection sheet hands over to a request on dismiss, shows funding left and the connection date

- A request that reads while a connection's sheet is up closes it and
  waits for the sheet to be gone (onDismiss) before its own sheet shows;
  a connection's sheet does not open while a request reads or is shown.
  A request refused during a disconnect is said on the sheet.
- A disconnect ends once the local history shows its result; the expiry
  read follows. A failed disconnect reads the sheet and the status again.
- The confirmation and the expiry judging follow how the data source
  will run the disconnect (disconnectRevokesKeys), not the row's kind;
  every active row gets an expiry answer, and no identity is not judged.
- The sheet shows when the connection was made and what is left of each
  key's budget (Platform's keys-remaining-budgets query), per key.
- A granted-access value this build cannot read is written back as it
  was stored.
- The sheet's details are read again only when its app or whether it is
  still connected changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): sheet details survive a status check, a closing sheet is waited for, unknown budgets stay unknown

- A details read is kept unless the app, its row (status or kind) or
  whether it is still connected changed; the same rule decides when the
  sheet reads again, so confirming → active refreshes what it shows.
- A request waits for a connection's sheet still leaving the screen, not
  only for one still shown.
- An older record's key whose budget is not known shows "Not known" (or
  what Platform says is left), never "No limit"; a key two grants name is
  read and listed once.
- A failed expiry read leaves the apps it would judge unknown and the
  others not judged.
- The disconnect's own row change reads the expiries again; no extra
  read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): the whole Disconnect button takes the tap

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* revert(ui): leave the shared SegmentedControl as it is

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): a waiting record holding a live key is kept, a disable-only update witnesses nothing, renewals check placed pending keys

- A waiting v2 record that would be dropped (cannot land, or landed and
  off) while it holds a live grantable auth key, one it sends again or a
  placed one it added, stays waiting: it keeps the app's row and lets a
  disconnect turn that key off. Once nothing of it is live it is dropped.
  Same in the failed-submit path of the registration.
- An own update that only disables is not noted, and a view that shows
  it is no witness: Platform takes a disable of a key already off. An
  older note of such an update gives way to the next one that adds keys.
- A disconnect whose app still has waiting records ends with success,
  the row going and the records kept, when the identity read after its
  update shows none of their keys live (placed or not); otherwise
  registrationPending.
- A renewal requires every key a waiting predecessor holds (sent again,
  or added and placed) in the fetched view.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): a row held by a waiting record shows its grant, a landed update clears its history entry

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): funding only for confirmed grants, history cleared once the row is back

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): a waiting record keeps the keys the store gives it, and a disconnect checks its follow-up view

- A waiting record is dropped only when it holds no key by the store or
  the view (AppConnect.heldKeyIds): its re-sent keys and its added keys
  the store places count even when a lagging view omits them, unless
  the view shows them off or under another key or the store has them
  disabled; an added key live as added with no readable store record
  counts as unknown. Used by the settle and the failed-submit path.
- A disconnect lets the row go with records still waiting only when its
  follow-up view shows every auth key the store gives them
  (AppConnect.showsWaitingKeys) and none of them is held.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): the funding limits info sheet is as tall as its text

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): a later own update settles nothing; a waiting record that holds a key gets a row back

- `pendingV2Outcome` no longer takes a later update of this wallet as
  proof that a waiting one cannot land: the SDK's copy of the identity
  can be reloaded while an update is on its way. A waiting record settles
  only on its own keys, an id held by other data, or its encryption key
  under another id. `outlivedBy` is only decoded; nothing notes it.
- A waiting record that holds a key a disconnect can turn off gets a
  confirming row when the app has none offering a disconnect; a two-QR
  row waiting for its second scan is remembered for the drop.
- Another identity's waiting record holds the row only while the store
  shows it holding an auth key, so one whose update never left the device
  does not block that app's disconnects elsewhere for good; nor does it
  keep a disconnect from turning off the unattributed profile keys.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): a row a waiting record brings back keeps the app's name and its disconnected entry

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(dashconnect): Disconnect and Reconnect on each Connections row

Following the updated design, each row carries its action: Disconnect on
Active and Confirming rows, Reconnect on Disconnected and Expired ones.
A row's Disconnect opens the connection's sheet, which asks there, so
there is one disconnect question. The Expired sheet offers Reconnect,
with Disconnect under it: an expired connection's keys stay on Platform
until a disconnect, or a renewal of the same connection, turns them off.

What a disconnect does is read from the data source when the question is
asked (disconnectRevokesKeys), and again when it is confirmed: if it no
longer holds, nothing runs and the sheet says why. A scan is refused, with
a message, while something signs or an approval is on screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashconnect): an incomplete expiry check says so, and the sheet follows its wallet

- An expiry read that could not tell a listed app's expiry is not shown
  as complete: the Expired tab keeps what an earlier read told and shows
  "could not be checked" with Retry. An app whose recorded keys are all
  off (`ConnectionExpiry.keysOff`) reads the same every time and does
  not ask for a retry.
- When the rows republish with another wallet's row of the app a
  connection sheet shows, the sheet closes, and its question with it.
- A connection's end date is not shown when one of its records has no
  expiry noted.
- A disconnect's history entry is dated when the revocation ends.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): expiry checks keep to their wallet and the chain's time; disconnect history and keys-off are said

- The expiry read returns the wallet it was read for. A read of another
  wallet than the rows shown is not applied, the rows switching wallet
  drop the expiries, and an earlier Expired is carried over an
  incomplete read only for a row unchanged since (no renewal). A listed
  active app with no answer makes the check incomplete.
- An app counts as expired only once both the phone's clock and the
  time of the last Core block SPV has synced are past its keys' expiry;
  until then, or without a chain time, it is not told.
- An app whose recorded keys are all off shows "Keys turned off".
- A disconnect whose app could not be saved among the disconnected apps
  says so, on the page once a closing sheet has gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(dashpay): take the connection expiry check out of the Connections page

The Expired tab, the expiry read from Platform and its chain time, and the
keys-off status move to a pull request of their own. The connection sheet
shows the date the keys expire under a neutral label.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(dashpay): take the disconnected-apps history out of the Connections page

The Disconnected tab, the history store, its writers and its clearing on a
wallet wipe, and Reconnect move to a pull request of their own. The page is
one list of the connected apps; a disconnect closes its sheet once it has
ended.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): a disconnect does what its question said; grant receipts note only the keys sent

- A disconnect's question has three answers: its keys are turned off,
  only its local status changes, or either as Platform shows (a two-QR row
  with a grant). The data source holds the disconnect to the answer the
  user confirmed: before the revocation in turn, and again once the
  identity is read, before anything is turned off.
- A v2 grant record notes message access only when its response carries
  an encryption key; a retry sealed again notes it again.
- Only the latest read of the connection sheet's details is shown: one
  started before the sheet closed, opened again or read again is dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): a two-QR row's disconnect question does not promise a revocation

The question is told from the wallet's records alone, which do not say
which records are the active identity's: only a one-QR row is sure to turn
its keys off. A two-QR row with a grant depends on what the identity shows,
and its early two-QR return is held to the answer too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): one rule decides whether a disconnect is what its question said

A disconnect is held to its question by one rule, `accepts`, applied to
the effect the records give before the PIN prompt and to the one the
identity gives after its read. The data-source tests send the answer the
screen would have asked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): a retried grant keeps its first terms; the disconnect check is one rule in one place

- A grant record keeps the keys and terms its first attempt noted: a retry
  registers those keys. Its message access follows the slots sent.
- `DashConnectDisconnectEffect.accepts` is the rule the sheet's confirm and
  the disconnect's turn both apply; the turn checks it before the PIN
  prompt, and refuses when the row is gone.
- A refused disconnect says the question changed, without "Could not
  disconnect".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): the Connections page waits for its rows; one decision for a disconnect's effect

- Until the rows are delivered the page shows progress, not the empty
  state.
- `disconnectEffect` alone tells what a disconnect does from the records;
  the refusal of one whose row is gone says the connection changed.
- Leftovers of the removed disconnected-app sheet are gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): a disconnect of a gone row says so; a session key's record stays one

A row gone before the disconnect's turn throws its own error, so the sheet
says the connection changed without guessing from the published rows. A
refused disconnect leaves the sheet up and its Disconnect asks again.
GrantedAccess.noted keeps isSessionKeyLogin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dashpay): the Connections page follows every write to its rows

The connection store announces each save, and a data source republishes
its wallet's rows on it, so a row another data source over the same rows
removed (a page opened again while an earlier one's operation runs)
leaves the page, and its sheet closes with the reason on the page. The
mock refuses a row it does not li…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-self-review Waiting for the author to post /self-reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants