nx_iso20022_lib.nx
buildroot/runtime/nx_iso20022_lib.nx
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
imports: nx_matter_lib.nx
imported by: nx_iso20022_gate.nxnx_xbrl_lib.nx
structs
| none |
consts
| 20 | const ISO_OK: i64 = 0 |
| 21 | const ISO_NO_FIELD: i64 = 0 - 1 // a required field is absent (malformed) |
| 22 | const ISO_TX_MISMATCH: i64 = 0 - 2 // NbOfTxs != actual CdtTrfTxInf count |
| 23 | const ISO_NO_CTRL: i64 = 0 - 3 // CtrlSum absent |
| 24 | const ISO_SUM_MISMATCH: i64 = 0 - 4 // CtrlSum != actual sum of amounts (tamper/corruption) |
functions
| 26 | func iso_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 29 | func iso_find(hay: *u8, hl: i64, needle: *u8, nl: i64, from: i64) -> i64 |
| 44 | func iso_open(tag: *u8, out: *u8) -> i64 |
| 55 | func iso_close(tag: *u8, out: *u8) -> i64 |
| 68 | func iso_element(xml: *u8, xl: i64, tag: *u8, out: *u8) -> i64 |
| 86 | func iso_count(xml: *u8, xl: i64, tag: *u8) -> i64 |
| 100 | func iso_amount_to_cents(s: *u8) -> i64 |
| 120 | func iso_sum_amounts(xml: *u8, xl: i64, tag: *u8) -> i64 |
| 149 | func iso_validate(xml: *u8, xl: i64) -> i64 |