Skip to main content

validate_response

Function validate_response 

Source
pub fn validate_response(
    message: &Message,
    expected_request_id: Option<u64>,
) -> Result<(), MostroError>
Expand description

Validate a response received from a Mostro node.

  • Returns Err(MostroCantDo(reason)) when the payload is CantDo.
  • Returns Err(MostroInternalErr(...)) when expected_request_id is provided and the inner message carries a different id, or no id at all on an action that requires one.
  • Otherwise returns Ok(()).

The allow-list of actions that may arrive without a request_id (server push messages such as state transitions, DMs, payment failures, etc.) is intentionally kept on the caller side, because the exact set depends on the client flow; this function only enforces the universal rules.