cryptnox-pos 1.0.0
Standalone USDC payment terminal firmware (ESP32 + Cryptnox smart card)
Loading...
Searching...
No Matches
addr_check.h File Reference

Structural address checks for the config portal. More...

#include <stddef.h>
#include <string.h>
Include dependency graph for addr_check.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ADDR_TRON_LEN   34U
 Length of a base58 Tron address, without the NUL.

Functions

static bool addr_is_base58 (const char *s)
 true if every character of s is in the Bitcoin/Tron base58 set.
static bool addr_tron_plausible (const char *s)
 Structural check on a Tron address: 34 characters, 'T', base58.
static bool addr_tron_decode (const char *s, unsigned char out[25])
 Decode a base58 Tron address into its 25 bytes (0x41 || 20-byte key hash || 4-byte checksum).

Detailed Description

Structural address checks for the config portal.

Header-only and free of ESP-IDF dependencies, for the same reason form_parse.h is: this is the code that judges a string a stranger on the network claims is where the money should go, so it is kept where a host-side test can reach it (tests/units/test_addr_check.cpp).

The Ethereum side is NOT here — eth_addr_parse() already verifies the EIP-55 checksum. For Tron this has the structural check and the base58 decode; the checksum over the decoded bytes (double SHA-256) is done in provision.cpp, which has mbedtls — see addr_plausible() there.

Definition in file addr_check.h.

Macro Definition Documentation

◆ ADDR_TRON_LEN

#define ADDR_TRON_LEN   34U

Length of a base58 Tron address, without the NUL.

Definition at line 29 of file addr_check.h.

Referenced by addr_tron_plausible().

Function Documentation

◆ addr_is_base58()

bool addr_is_base58 ( const char * s)
inlinestatic

true if every character of s is in the Bitcoin/Tron base58 set.

Definition at line 32 of file addr_check.h.

Referenced by addr_tron_plausible().

◆ addr_tron_decode()

bool addr_tron_decode ( const char * s,
unsigned char out[25] )
inlinestatic

Decode a base58 Tron address into its 25 bytes (0x41 || 20-byte key hash || 4-byte checksum).

Returns
false if s is not a plausible Tron address or does not decode to exactly 25 bytes. The checksum is NOT verified here.

Definition at line 66 of file addr_check.h.

References addr_tron_plausible().

Referenced by addr_plausible().

◆ addr_tron_plausible()

bool addr_tron_plausible ( const char * s)
inlinestatic

Structural check on a Tron address: 34 characters, 'T', base58.

Deliberately not the checksum — see the file comment. A value that passes here is still decoded (and can still be refused) on the main task before it is used.

Definition at line 53 of file addr_check.h.

References addr_is_base58(), and ADDR_TRON_LEN.

Referenced by addr_tron_decode().