cryptnox-pos 1.0.0
Standalone USDC payment terminal firmware (ESP32 + Cryptnox smart card)
Loading...
Searching...
No Matches
tron_tx.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: LGPL-3.0-or-later
3 * Copyright (c) 2026 Cryptnox SA
4 */
5
25
26#ifndef TRON_TX_H
27#define TRON_TX_H
28
29#include <stdint.h>
30#include <stdbool.h>
31#include <stddef.h>
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
38#define TRON_ADDR_HEX_LEN 42U
39
41#define TRON_SIG_HEX_LEN 130U
42
44#define TRON_TRC20_SELECTOR "a9059cbb"
45
47#define TRON_TRC20_PARAM_HEX_LEN 128U
48
51#define TRON_TX_MAX_EXPIRY_MS (15ULL * 60ULL * 1000ULL)
52
63size_t tron_varint_hex(uint64_t v, char *out, size_t out_size);
64
83bool tron_tx_contract_ok(const char *raw_data_hex, const char *owner_hex,
84 const char *to_hex, uint64_t amount_sun,
85 uint64_t now_ms, uint64_t *expiration_ms);
86
101size_t tron_trc20_param_hex(const char *to_hex, uint64_t amount,
102 char *out, size_t out_size);
103
128bool tron_tx_trc20_ok(const char *raw_data_hex, const char *owner_hex,
129 const char *contract_hex, const char *to_hex,
130 uint64_t amount, uint64_t fee_limit_sun,
131 uint64_t now_ms, uint64_t *expiration_ms);
132
144size_t tron_tx_envelope_hex(const char *raw_data_hex, const char *sig_hex,
145 char *out, size_t out_size);
146
147#ifdef __cplusplus
148}
149#endif
150
151#endif /* TRON_TX_H */
static uint64_t now_ms(void)
Unix time in ms, 0 if the clock is unset (the checks then refuse).
Definition tron_rpc.cpp:117
bool tron_tx_contract_ok(const char *raw_data_hex, const char *owner_hex, const char *to_hex, uint64_t amount_sun, uint64_t now_ms, uint64_t *expiration_ms)
Verify that a node-serialised raw_data really transfers what we asked.
Definition tron_tx.cpp:316
bool tron_tx_trc20_ok(const char *raw_data_hex, const char *owner_hex, const char *contract_hex, const char *to_hex, uint64_t amount, uint64_t fee_limit_sun, uint64_t now_ms, uint64_t *expiration_ms)
Verify that a node-serialised raw_data really is the TRC-20 transfer we asked for.
Definition tron_tx.cpp:365
size_t tron_trc20_param_hex(const char *to_hex, uint64_t amount, char *out, size_t out_size)
ABI-encode the arguments of transfer(address,uint256), hex.
Definition tron_tx.cpp:341
size_t tron_varint_hex(uint64_t v, char *out, size_t out_size)
Hex-encode a value as a protobuf base-128 varint.
Definition tron_tx.cpp:76
size_t tron_tx_envelope_hex(const char *raw_data_hex, const char *sig_hex, char *out, size_t out_size)
Build the hex of a signed Transaction protobuf for broadcasthex.
Definition tron_tx.cpp:406