Skip to content

Refactor receive::ReplyableError for bidirectional conversion across FFI Boundary #605

@DanGould

Description

@DanGould

We have so far been unable to expose UncheckedProposal::extract_err_req and process_err_res across the FFI boundary because ReplyableError encapsulates internal variants that don't make it across the boundary. Because the internals of the type does not completely convert across the boundary, it cannot be returned back into rust for use in extract_err_req, even though extract_err_req only relies on impl JsonError to extract the error request.

see the issue LtbLightning/payjoin-ffi#59 for details. In summary, we may not want to expose JsonError as a public trait because it would allow users to return arbitrary JSON, and leaked data through JSON can be a security vulnerability, e.g. if a receiver returned some internal error message about their wallet state.

The JsonError implementation only maps the error to an error code with a template message. With the exception of the UnknownVersion error, which returns the supported versions, the encapsulated variant tuple contents are not serialized to JSON.

We must figure out some way to cross the foreign language barrier both ways to return these errors to senders for correct operation of the protocol.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions