Skip to content

fix(platform-wallet): map not-found errors to NotFound at FFI #5742

Open

Description

@xdustinface

Problem

impl From<PlatformWalletError> for PlatformWalletFFIResult in rs-platform-wallet-ffi/src/error.rs has no arm for PlatformWalletError::WalletNotFound or PlatformWalletError::AddressNotFound, so both reach the host as ErrorUnknown. Hosts cannot tell an expected absence from an unclassified failure without parsing the message. Related absences already map to NotFound: a missing registry handle, WalletRemovedBeforeSend, DpnsNameNotFound and DecisionProposalNotFound.

On v5.1-dev, platform_wallet_address_private_key already returns AddressNotFound as ErrorUnknown for an address outside the wallet's pools. #5727 adds two more paths with the same result: platform_wallet_find_bip44_address_path and platform_wallet_bip44_address_private_key return WalletNotFound once the wallet was removed, and the BIP-44 reveal returns AddressNotFound when the scan does not reach the address.

Proposed direction

Add WalletNotFound and AddressNotFound arms that map to NotFound, and pin the boundary codes in tests.

WalletNotFound is used in about 140 places in platform-wallet, so the change alters the code hosts see on many existing calls. Before it lands, check the Swift and Kotlin error mapping for anything that branches on ErrorUnknown for these cases, and check classify_preflight_error in platform_addresses/withdrawal.rs, which treats WalletNotFound as structural.

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