code wiki / (root) / nx_iso20022_lib.nx

nx_iso20022_lib.nx

buildroot/runtime/nx_iso20022_lib.nx

6398 B163 linesdepth 7pulls 12 transitivereach 3 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_iso20022_lib.nx -- F989: ISO 20022 payment-message parse + integrity validation. 2026 is the inflection: Fedwire migrated to ISO 20022 in July 2025 and Swift ends MT coexistence in November. A pain.001 (customer credit-transfer initiation) carries its OWN integrity fields -- NbOfTxs (the declared transaction count) and CtrlSum (the declared total). The sovereign property here is that these are CHECKED against the actual message content, never trusted: a corrupted or TAMPERED payment file -- one where an amount was altered but the control sum was not -- is REJECTED by construction. Money is integer minor units; a control sum is compared to the exact cent, no float, no tolerance. FAIL-CLOSED: a missing required field (NbOfTxs / CtrlSum) is a rejection, not a default -- a payment message you cannot validate is a payment message you do not process. SCOPE (declared, honest): this parses element text and validates the two internal-integrity invariants. Full XSD schema validation, namespace resolution, and variable-fraction-digit currencies (this assumes 2 fraction digits, correct for USD/EUR/most) are DECLARED follow-ons, not silently handled. DRY: composes nx_matter_lib (sys_*/mt_*). A validated message feeds nx_ledger as transfers. license_tier: ORIGINAL LIB.

dependencies 1 imports · 2 importers

nx_matter_lib.nx nx_iso20022_lib.nx nx_iso20022_gate.nx nx_xbrl_lib.nx

imports: nx_matter_lib.nx

imported by: nx_iso20022_gate.nxnx_xbrl_lib.nx

structs

none

consts

20const ISO_OK: i64 = 0
21const ISO_NO_FIELD: i64 = 0 - 1 // a required field is absent (malformed)
22const ISO_TX_MISMATCH: i64 = 0 - 2 // NbOfTxs != actual CdtTrfTxInf count
23const ISO_NO_CTRL: i64 = 0 - 3 // CtrlSum absent
24const ISO_SUM_MISMATCH: i64 = 0 - 4 // CtrlSum != actual sum of amounts (tamper/corruption)

functions

26func iso_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 2: mainmain
29func iso_find(hay: *u8, hl: i64, needle: *u8, nl: i64, from: i64) -> i64
44func iso_open(tag: *u8, out: *u8) -> i64
55func iso_close(tag: *u8, out: *u8) -> i64
68func iso_element(xml: *u8, xl: i64, tag: *u8, out: *u8) -> i64
86func iso_count(xml: *u8, xl: i64, tag: *u8) -> i64
called by 2: mainiso_validate calls 2: iso_openiso_find
100func iso_amount_to_cents(s: *u8) -> i64
120func iso_sum_amounts(xml: *u8, xl: i64, tag: *u8) -> i64
149func iso_validate(xml: *u8, xl: i64) -> i64