feat(swift-sdk): fund identity creation from shielded balance - #3838
Conversation
Adds 'Shielded Balance' as a funding origin in CreateIdentityView, wired to the existing Type-20 IdentityCreateFromShieldedPool stack. The UI offers the option when the selected wallet is bound to ShieldedService with a positive pool balance, replaces the free-form amount with the versioned fixed-denomination picker, derives the required creation-failure fallback address from the wallet's Platform Payment account, and routes submission through the RegistrationCoordinator so the Halo 2 proof survives sheet dismissal. Also fixes a gap in the Rust path: the operation now extracts the proof-verified Identity from the broadcast result and the manager wrapper registers it in the local IdentityManager at the new identity_index parameter (mirroring register_from_addresses), so the host persister emits the identity row like every other registration path. identity_index is threaded through the FFI and Swift wrapper. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThe PR adds support for explicit DIP-9 identity-slot selection during shielded pool identity creation. The Rust operations layer now returns both the proven identity ID and its verified struct. The wallet coordinates proof broadcast with subsequent local identity manager registration under scoped locking. The parameter is threaded through FFI and Swift SDK. The example app gains a shielded balance funding path with fixed denominations and fallback address handling. ChangesShielded Identity Registration Stack
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v3.1-dev #3838 +/- ##
=========================================
Coverage 87.04% 87.04%
=========================================
Files 2677 2678 +1
Lines 329918 329994 +76
=========================================
+ Hits 287182 287258 +76
Misses 42736 42736
🚀 New features to boost your workflow:
|
|
✅ DashSDKFFI.xcframework built for this PR.
SwiftPM (host the zip at a stable URL, then use): .binaryTarget(
name: "DashSDKFFI",
url: "https://your.cdn.example/DashSDKFFI.xcframework.zip",
checksum: "9d5fb4ffc15b21b706c0feb755106331e65a96d840944e28803cca18b0afd8c1"
)Xcode manual integration:
|
Issue being fixed or feature implemented
The Create Identity screen in SwiftExampleApp could not use the shielded (Orchard) balance as a funding origin, even though the Type-20
IdentityCreateFromShieldedPoolstate transition and its full stack (rs-dpp builder → platform-wallet op → FFI → Swift wrapper) already exist. This PR surfaces that path in the UI and closes a persistence gap in the Rust flow that would have left the newly created identity invisible to the app.What was done?
Rust (platform-wallet)
identity_create_from_shielded_pool(operations.rs) now captures the SDK broadcast'sStateTransitionProofResultand extracts the proof-verifiedIdentityfromVerifiedIdentityWithShieldedNullifiers, back-fillingpublic_keys()from the submitted set if the result echoes them empty (same defensive pattern asregister_from_addresses), and returns it alongside the derived id. An unexpected proof-result variant is warn-and-synthesize rather than an error, since the broadcast already succeeded.PlatformWallet::shielded_identity_create_from_pooltakes a newidentity_index: u32and, after a successful broadcast, registers the verified identity in the localIdentityManagerviaadd_identity+ persister — mirroringregister_from_addressesStep 3 — so the host persister emits theIdentityChangeSet/IdentityKeysChangeSetthat creates the app'sPersistentIdentityrow. Previously no other layer did this, so the shielded path never produced an identity row. A registration failure after a successful broadcast is logged and swallowed (the identity exists on chain; sync heals).FFI / Swift SDK (marshal-only)
platform_wallet_manager_shielded_identity_create_from_poolgainsidentity_index: u32(afteraccount);shieldedIdentityCreateFromPoolgains the matchingidentityIndex: UInt32and passes it through.SwiftExampleApp (CreateIdentityView)
FundingSelection.shieldedBalanceoption: "Shielded Balance — X DASH" appears in the Funding Source picker when the selected wallet is the one bound toShieldedService, the pool balance is positive, and a fallback platform address exists.shielded_identity_create_denominationsin rs-platform-version v8 with a source-of-truth doc pointer, filtered to denominations the pool covers). Footer explains the exact-equality fee model (fee metered FROM the denomination; excess returns as pool change).send_to_address_on_creation_failure(21 rawPlatformAddressbytes) is derived from the wallet's lowest-index Platform Payment address — the same(addressType, hash)pairing the address-funded path feeds the FFI.RegistrationCoordinator-hosted controller (like the Core-funded path) because the Halo 2 proof takes tens of seconds — the registration survives sheet dismissal and stays visible under Pending Registrations. The shared completion path patches the persisted row and marks the DIP-9 slot used.How Has This Been Tested?
cargo check -p platform-wallet --all-features --all-targetsandcargo check -p platform-wallet-ffi --all-features --all-targets— pass.cargo fmt --all --check— clean../build_ios.sh --target simrebuilt the xcframework (regenerated header carriesuint32_t identity_index) and SwiftExampleApp BUILD SUCCEEDED against it (iPhone 16 simulator).Breaking Changes
None (not consensus-breaking). The FFI/Swift signature change to
shielded_identity_create_from_poolis pre-release public-API churn.Checklist:
For repository code-owners and collaborators only
🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Refactor