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

Minimal RLP encoder for EIP-1559 (type 2) Ethereum transactions. More...

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

Go to the source code of this file.

Classes

struct  eth_tx_t
 EIP-1559 (type 2) transaction parameters. More...

Functions

size_t eth_rlp_encode_unsigned (const eth_tx_t *tx, uint8_t *out, size_t out_max)
 Encode an unsigned EIP-1559 transaction: 0x02 || RLP([chainId, nonce, ...]).
size_t eth_rlp_encode_signed (const eth_tx_t *tx, uint8_t v, const uint8_t r[32], const uint8_t s[32], uint8_t *out, size_t out_max)
 Encode a signed EIP-1559 transaction: 0x02 || RLP([..., v, r, s]).

Detailed Description

Minimal RLP encoder for EIP-1559 (type 2) Ethereum transactions.

Definition in file eth_rlp.h.

Function Documentation

◆ eth_rlp_encode_signed()

size_t eth_rlp_encode_signed ( const eth_tx_t * tx,
uint8_t v,
const uint8_t r[32],
const uint8_t s[32],
uint8_t * out,
size_t out_max )

Encode a signed EIP-1559 transaction: 0x02 || RLP([..., v, r, s]).

Parameters
[in]txTransaction parameters.
[in]vSignature parity bit; must be 0 or 1.
[in]r32-byte big-endian ECDSA r component.
[in]s32-byte big-endian ECDSA s component.
[out]outOutput buffer for the encoded bytes.
[in]out_maxCapacity of out.
Returns
Total bytes written, or 0 if the output would overflow out_max or tx->calldata_len exceeds the internal scratch bound.

Definition at line 268 of file eth_rlp.cpp.

References encode_common_fields(), ITEMS_BUF_MAX, rlp_int256(), rlp_list_header(), and rlp_uint64().

Referenced by sign_and_broadcast().

◆ eth_rlp_encode_unsigned()

size_t eth_rlp_encode_unsigned ( const eth_tx_t * tx,
uint8_t * out,
size_t out_max )

Encode an unsigned EIP-1559 transaction: 0x02 || RLP([chainId, nonce, ...]).

Parameters
[in]txTransaction parameters.
[out]outOutput buffer for the encoded bytes.
[in]out_maxCapacity of out.
Returns
Total bytes written, or 0 if the output would overflow out_max or tx->calldata_len exceeds the internal scratch bound.

Definition at line 244 of file eth_rlp.cpp.

References encode_common_fields(), ITEMS_BUF_MAX, and rlp_list_header().

Referenced by sign_and_broadcast().