Skip to content

platform-wallet-ffi: a bad address in key reveal is reported as ErrorUnknown #5739

Open

Description

@xdustinface

Defect

A malformed or wrong-network address passed to platform_wallet_address_private_key comes back to Swift and Kotlin as ErrorUnknown, not ErrorInvalidParameter. PlatformWallet::derive_core_address_private_key reports both cases as PlatformWalletError::AddressOperation, and the FFI error conversion has no arm for that variant, so it falls through to ErrorUnknown. A host cannot tell "you passed a bad address" apart from an internal failure.

Evidence

  • origin/v5.1-dev: packages/rs-platform-wallet/src/wallet/core_address_key.rs, the Address::from_str and require_network error mappings in derive_core_address_private_key, both PlatformWalletError::AddressOperation(..).
  • origin/v5.1-dev: packages/rs-platform-wallet-ffi/src/error.rs, test unmapped_variants_fall_through_to_unknown pins AddressOperation → ErrorUnknown.
  • The rest of the FFI reports the same input as ErrorInvalidParameter. Once #5727 lands, platform_wallet_address_validate returns ErrorInvalidParameter for a string that platform_wallet_address_private_key and the new platform_wallet_find_bip44_address_path report as ErrorUnknown.

Fix

Report an unparsable or wrong-network address as PlatformWalletError::InvalidParameter in one shared parse function in rs-platform-wallet. #5727 adds parse_address in core_address_key.rs, which is the natural owner. Have platform_wallet_address_validate call that function as well, so address validation lives in one place. Pin the resulting ErrorInvalidParameter code in the FFI tests for the key reveal and the scan.

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