18#ifndef SETTINGS_RULES_H
19#define SETTINGS_RULES_H
38#define TZ_OFFSET_BIAS 720
79#define FEE_GWEI_MIN 1UL
80#define FEE_GWEI_MAX 500UL
104#define ADMIN_SALT_LEN 16U
105#define ADMIN_HASH_LEN 32U
109#define ADMIN_CODE_HASH_MAX 32U
129 CW_Utils::secure_wipe(buf,
sizeof(buf));
151 if ((addr == NULL) || (addr[0] ==
'\0')) {
return false; }
157 const bool prefixed = (addr[0] ==
'0') && ((addr[1] ==
'x') || (addr[1] ==
'X'));
TZ-independent calendar arithmetic and date-string parsing.
void keccak256(const uint8_t *input, size_t length, uint8_t digest[32])
Compute the Keccak-256 digest of a buffer.
Original Keccak-256 digest as used by Ethereum.
Persistent device settings stored in NVS (backlight, Wi-Fi creds).
#define TZ_OFFSET_MIN
Widest real-world UTC offsets, in minutes: UTC-12:00 to UTC+14:00.
#define SETTINGS_PAYOUT_MAX
Longest payout address plus NUL — "0x" + 40 hex, or 34 base58 Tron.
static void admin_derive(const char *code, const uint8_t *salt, uint8_t out[ADMIN_HASH_LEN])
Derive the stored digest: a single keccak256 over salt || code.
static bool settings_addr_normalise(bool tron, const char *addr, char norm[SETTINGS_PAYOUT_MAX])
The form a payout address or contract is stored in: Tron as given, Ethereum "0x"-prefixed whichever w...
static uint32_t tz_offset_encode(int16_t minutes)
A valid offset in its stored, biased form.
fee_pair_t
Verdict on a (max fee, tip) pair from the config page.
static bool tz_dst_valid(long rule)
true for a DST rule the clock knows.
#define ADMIN_CODE_HASH_MAX
static uint8_t tz_dst_decode(uint8_t r)
A stored DST rule, or no DST if it is not one the clock knows.
static int16_t tz_offset_decode(uint32_t raw)
The stored form back to minutes; nonsense in NVS is UTC, not a wild clock.
static bool tz_offset_valid(long minutes)
true for an offset the clock accepts (TZ_OFFSET_MIN .. _MAX).
static fee_pair_t fee_pair_check(unsigned long max_gwei, unsigned long prio_gwei)
Check a (max fee, tip) pair in Gwei; the range is checked first.