Skip to content

refactor(platform-wallet)!: remove dead C ABI exports (9 audit entries) - #4641

Closed
llbartekll wants to merge 1 commit into
refactor/wallet-dead-code-swift-sdkfrom
refactor/wallet-dead-code-c-abi
Closed

refactor(platform-wallet)!: remove dead C ABI exports (9 audit entries)#4641
llbartekll wants to merge 1 commit into
refactor/wallet-dead-code-swift-sdkfrom
refactor/wallet-dead-code-c-abi

Conversation

@llbartekll

@llbartekll llbartekll commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

Final part of the cleanup following the 2026-09-08 audit (dead-code category). Scope: C ABI removals — 9 entries, in a single commit, because they all change the same surface and the cbindgen header has to be regenerated once.

⚠️ Stacked: the base is #4640, not v4.2-dev. The dependency is real: the only Swift consumers of platform_wallet_info_* / identity_manager_* are the classes removed in #4640. Merge order: #4639#4640 → this one.

What was done?

rs-platform-wallet-ffi:

Entry What goes
rust-ffi-011 established_contact_{get_incoming_request,get_outgoing_request,is_payment_channel_broken} and the original _get_contact_id (its body moved into the _get_contact_identity_id alias that Swift actually calls); contact_request_create; managed_identity_{send,accept}_contact_request and _ignore_contact_sender — these operate on a cloned snapshot handle, so even if called they could not change wallet state; the counts-only platform_wallet_dpns_marketplace_sync (Swift and the JNI both call _detailed); the ContactRequest/EstablishedContact structs in types.rs, absent from the generated header
rust-ffi-039 platform_wallet_info.rs, identity_manager.rs, WALLET_INFO_STORAGE, IDENTITY_MANAGER_STORAGE — a second, unmanaged way to build a wallet and identity manager
rust-ffi-041 asset_lock_manager_recover — 58 lines of unsafe deserializing host-supplied tx and proof bytes, with no consumer
rust-ffi-042 platform_address_wallet_{add_provider,restore_sync_state,sync_balances,free_sync_result}, the platform_addresses/sync.rs module, and the AddressSyncResultFFI/FoundAddressEntryFFI/AbsentAddressEntryFFI/AddressSyncMetricsFFI types plus their From impl. AddressSyncConfigFFI stays
rust-ffi-043 platform_address_wallet_withdraw — the raw-script variant that bypasses the network check; _withdraw_to_address stays
rust-ffi-044 platform_wallet_ffi_init, _ffi_version, _identifier_{to,from}_hex, _{serialize,deserialize}_*_json_bytes, platform_wallet_get_id, _pubkey_hash_from_private_key, the non-birth-height _create_wallet_from_{seed,mnemonic} pair, and _list_masternodes/_free_masternodes v1
rust-ffi-081 two PLATFORM_WALLET_PERSISTENCE_CAPABILITY_* alias constants
rust-ffi-086 impl Default for WalletRestoreEntryFFI — 39 lines to keep in sync with a 26-field struct

rs-sdk-ffi (rust-sdk-ffi-005): token/emergency_action.rs, token/purchase.rs, token/config_update.rs (the last returned "not yet implemented" for 4 of 9 variants and never read params.action_takers), and dash_sdk_document_make_handle + DashSDKDocumentHandleParams.

swift-sdk: the wrappers over the removed exports — ContactRequest.create and ManagedIdentity.{sendContactRequest,acceptContactRequest,ignoreContactSender}. None had a call site in SwiftDashSDK or SwiftExampleApp.

Total: 31 files, 4,353 deletions, 55 insertions.

Incidental findings

  • MasternodeEntryFFI (v1) stays — V2 embeds it. The layout tests that built v1 arrays got a local release helper in place of the removed public free function.
  • rust-ffi-081 duplicates half of rust-core-146 — the same symbol reported twice in the audit. Counted once.
  • A test was passing for the wrong reason. test_get_dashpay_profile_unmanaged_identity_reports_not_found built its handle in WALLET_INFO_STORAGE while platform_wallet_get_dashpay_profile reads PLATFORM_WALLET_STORAGE — so it never had a real wallet and only ever pinned "unknown handle → NotFound". The test stays, but now says what it actually checks. If the intent was to pin "known wallet, unmanaged identity", it needs to be written afresh.

How Has This Been Tested?

Full chain, all green:

  • cargo check --workspace --all-targets
  • cargo test -p platform-wallet-ffi343 passed, 0 failed
  • cargo clippy -p platform-wallet -p platform-wallet-ffi --all-features --all-targets
  • packages/swift-sdk/build_ios.sh --target sim ✅ — regenerates the cbindgen header and rebuilds DashSDKFFI.xcframework
  • xcodebuild -scheme SwiftDashSDK -sdk iphonesimulator ✅ — against the regenerated header
  • xcodebuild -scheme SwiftExampleApp -sdk iphonesimulator
  • packages/kotlin-sdk/build_android.sh --abi x86_64 --profile dev ✅ — rs-unified-sdk-jni links into libdash_sdk_jni.so
  • ./gradlew :sdk:assembleDebug ✅ — BUILD SUCCESSFUL

The regenerated header was checked in both directions. Every removed symbol is
gone from DashSDKFFI.xcframework (platform_wallet_ffi_init,
platform_wallet_identifier_to_hex, contact_request_create,
asset_lock_manager_recover, platform_address_wallet_add_provider,
dash_sdk_token_purchase, dash_sdk_document_make_handle,
PLATFORM_WALLET_PERSISTENCE_CAPABILITY_ACCOUNT_ADDRESS_POOLS — 0 hits each),
and the surviving siblings are still there
(platform_wallet_manager_list_masternodes_v2,
established_contact_get_contact_identity_id,
platform_address_wallet_withdraw_to_address,
platform_wallet_dpns_marketplace_sync_detailed,
platform_wallet_manager_create_wallet_from_seed_with_birth_height).

Environment notes for whoever reproduces this:

  • The iPhone 16 destination in CLAUDE.md does not exist on the test machine;
    builds ran on iPhone 17. Worth updating the doc.
  • packages/kotlin-sdk/BUILD_GUIDE_FOR_AI.md requires NDK r28+; only 27.1 was
    available, and the native build succeeded on it. The 16 KB-alignment
    --verify path was not exercised, so that guide's requirement stands
    unconfirmed here — it is orthogonal to this change.

Breaking Changes

Yes — C ABI change. The listed symbols disappear from the generated header. All consumers are in-repo and were verified not to use them, but kotlin-sdk / rs-unified-sdk-jni need a rebuild, and rs-sdk-ffi may have out-of-repo header consumers we cannot see.

Public Swift symbols go too, as a side effect (ContactRequest.create and three ManagedIdentity methods).

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

Nine audit entries in one commit, because they all change the same ABI surface
and the cbindgen header has to be regenerated once.

rs-platform-wallet-ffi:
- rust-ffi-011: `established_contact_{get_incoming_request,get_outgoing_request,
  is_payment_channel_broken}` and the original `_get_contact_id` (its body moved
  into the `_get_contact_identity_id` alias Swift actually calls);
  `contact_request_create`; `managed_identity_{send,accept}_contact_request` and
  `_ignore_contact_sender` (they operate on a cloned snapshot handle, so even if
  called they could not change wallet state); the counts-only
  `platform_wallet_dpns_marketplace_sync` (Swift and the JNI call `_detailed`);
  the `ContactRequest`/`EstablishedContact` structs in types.rs, absent from the
  generated header.
- rust-ffi-039: `platform_wallet_info.rs`, `identity_manager.rs`,
  `WALLET_INFO_STORAGE`, `IDENTITY_MANAGER_STORAGE` — a second, unmanaged way to
  build a wallet and identity manager.
- rust-ffi-041: `asset_lock_manager_recover` — 58 lines of unsafe deserializing
  host-supplied tx and proof bytes, with no consumer.
- rust-ffi-042: `platform_address_wallet_{add_provider,restore_sync_state,
  sync_balances,free_sync_result}`, the `platform_addresses/sync.rs` module, and
  the `AddressSyncResultFFI`/`FoundAddressEntryFFI`/`AbsentAddressEntryFFI`/
  `AddressSyncMetricsFFI` types with their `From` conversion.
  `AddressSyncConfigFFI` stays.
- rust-ffi-043: `platform_address_wallet_withdraw` (the raw-script variant that
  bypasses the network check); `_withdraw_to_address` stays.
- rust-ffi-044: `platform_wallet_ffi_init`, `_ffi_version`,
  `_identifier_to_hex`, `_identifier_from_hex`, `_serialize_to_json_bytes`,
  `_deserialize_from_json_bytes`, `platform_wallet_get_id`,
  `_pubkey_hash_from_private_key`, the non-birth-height
  `platform_wallet_manager_create_wallet_from_{seed,mnemonic}` pair, and
  `_list_masternodes`/`_free_masternodes` v1. `MasternodeEntryFFI` stays — V2
  embeds it, and the layout tests got a local release helper.
- rust-ffi-081: two `PLATFORM_WALLET_PERSISTENCE_CAPABILITY_*` alias constants
  ("source-compatible alias") with no consumers. This is the same symbol as the
  FFI half of rust-core-146 — a duplicate in the audit, counted once.
- rust-ffi-086: `impl Default for WalletRestoreEntryFFI` — 39 lines to keep in
  sync with a 26-field struct, with no callers.

rs-sdk-ffi (rust-sdk-ffi-005):
- `token/emergency_action.rs`, `token/purchase.rs`, `token/config_update.rs`
  (the last returned "not yet implemented" for 4 of 9 variants and never read
  `params.action_takers`), and `dash_sdk_document_make_handle` together with
  `DashSDKDocumentHandleParams`.

swift-sdk: the wrappers over the removed exports — `ContactRequest.create` and
`ManagedIdentity.{sendContactRequest,acceptContactRequest,ignoreContactSender}`.
None had a call site in SwiftDashSDK or SwiftExampleApp.

The `test_get_dashpay_profile_unmanaged_identity_reports_not_found` test was
passing for the wrong reason: it built its handle in `WALLET_INFO_STORAGE` while
`platform_wallet_get_dashpay_profile` reads `PLATFORM_WALLET_STORAGE` — it never
had a real wallet and only ever pinned "unknown handle -> NotFound". It stays,
but now says what it actually checks.

Verified end to end: `cargo check --workspace --all-targets`,
`cargo test -p platform-wallet-ffi` (343 tests), clippy, cbindgen header
regeneration via `swift-sdk/build_ios.sh --target sim`, the SwiftDashSDK and
SwiftExampleApp builds against the regenerated header, the Android
`libdash_sdk_jni.so` link, and `./gradlew :sdk:assembleDebug`. The regenerated
header was checked both ways: every removed symbol is gone from it, and the
surviving siblings (`_list_masternodes_v2`, `_get_contact_identity_id`,
`_withdraw_to_address`, `_sync_detailed`, `_create_wallet_from_seed_with_birth_height`)
are still present.

BREAKING CHANGE: the listed symbols disappear from the generated C header;
kotlin-sdk and rs-unified-sdk-jni need a rebuild (neither referenced any of the
removed names — grep-verified).

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

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 76fe1e9a-66da-4598-bc68-e3f35a27eb94

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@llbartekll llbartekll changed the title refactor(platform-wallet-ffi)!: usunięcie martwych eksportów C ABI (9 wpisów audytu) refactor(platform-wallet-ffi)!: remove dead C ABI exports (9 audit entries) Sep 9, 2026
@llbartekll
llbartekll force-pushed the refactor/wallet-dead-code-swift-sdk branch from 4537473 to 3b10eef Compare September 9, 2026 12:14
@llbartekll
llbartekll force-pushed the refactor/wallet-dead-code-c-abi branch 2 times, most recently from 2c70977 to c1ca65f Compare September 9, 2026 13:08
@llbartekll
llbartekll marked this pull request as ready for review September 9, 2026 13:09
@thepastaclaw

thepastaclaw commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

🕓 Queued for automated review — 22nd in line, estimated start in ~7 h (commit 2d95728)
Estimated review time once started: ~40 min (two-phase automated review; median of recent runs).

  • Request priority review — tick this box and the review moves to the front of the queue.

@llbartekll llbartekll changed the title refactor(platform-wallet-ffi)!: remove dead C ABI exports (9 audit entries) refactor(platform-wallet)!: remove dead C ABI exports (9 audit entries) Sep 9, 2026
@llbartekll
llbartekll force-pushed the refactor/wallet-dead-code-c-abi branch from c1ca65f to 2d95728 Compare September 9, 2026 13:19
@llbartekll llbartekll closed this Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants