Skip to content

Guard the shielded-tree rebuild FFI export against Rust panics #6455

Backlog

Description

@lklimek

TL;DR: The FFI function that rebuilds the shielded commitment tree does not catch a Rust panic, unlike the other shielded FFI exports, so a panic inside it would cross the C boundary instead of returning an error to the app.

User story

As an iOS or Android wallet app developer, I want every wallet FFI call to return an error result when Rust panics, to avoid an abort or undefined behaviour in the app.

Scenario

Base flow

The app calls platform_wallet_manager_shielded_rebuild_tree.

Actual behavior

The export has no panic guard. No ordinary rebuild path is known to panic, but a panic would unwind across extern "C".

Expected behavior

A panic is caught and reported through the usual FFI error result, like the other shielded exports.

Detailed discussion

Code: packages/rs-platform-wallet-ffi/src/shielded_sync.rs (platform_wallet_manager_shielded_rebuild_tree). Follow the existing catch_unwind pattern in shielded_send.rs, shielded_wallet_drain.rs and txo_reconcile.rs of the same crate, with a test that a panic maps to the error code.

Prior work

🤖 Co-authored by Claudius the Magnificent AI Agent

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions