Skip to main content

parse_nef

Function parse_nef 

Source
pub fn parse_nef(bytes: &[u8]) -> Result<ParsedNef, String>
Expand description

Parse a Neo N3 NEF3 file produced by build_nef_with_tokens.

Validates, in order:

  • the 4-byte NEF3 magic,
  • the trailing sha256(sha256(prefix))[..4] checksum,
  • that every varint length prefix (source, token count, method name, script) is consistent with the remaining buffer,
  • the single reserved byte (post-source) and two reserved bytes (pre-script) are all zero,
  • method-token invariants matching those enforced by the builder (method.len() <= MAX_TOKEN_METHOD_LENGTH, !method.starts_with('_'), call_flags & !MAX_CALL_FLAGS == 0, tokens.len() <= MAX_METHOD_TOKENS).

Returns Err with a human-readable diagnostic on any violation.