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

Turn a node's JSON-RPC refusal into a line an operator can act on. More...

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

Go to the source code of this file.

Functions

static bool rpc_err_contains (const char *hay, const char *needle)
 Case-insensitive substring search — node wording varies by client.
static void rpc_error_text (const char *node_msg, bool native, bool polygon, char *out, size_t n)
 Render a broadcast refusal for the Declined screen.

Detailed Description

Turn a node's JSON-RPC refusal into a line an operator can act on.

Every reason a node gives for rejecting a transaction used to arrive on the panel as the same four words, "Broadcast failed", which names the symptom and hides the cause. The cause is the whole value of the message: an empty gas tank, a fee under the network's floor and a duplicate submission need three different responses from whoever is standing at the till, and two of them are not "try again".

Header-only so it can be tested on the host without ESP-IDF or a network — same shape as card_status.h and ota_version.h.

Definition in file rpc_error.h.

Function Documentation

◆ rpc_err_contains()

bool rpc_err_contains ( const char * hay,
const char * needle )
inlinestatic

Case-insensitive substring search — node wording varies by client.

Definition at line 35 of file rpc_error.h.

Referenced by rpc_error_text().

◆ rpc_error_text()

void rpc_error_text ( const char * node_msg,
bool native,
bool polygon,
char * out,
size_t n )
inlinestatic

Render a broadcast refusal for the Declined screen.

Parameters
[in]node_msgThe node's error.message, or NULL/"" when the request never got an answer worth quoting.
[in]nativetrue when the sale is the network's own coin, so the balance has to cover the amount as well as the gas.
[in]polygontrue on Polygon, which names its gas coin POL not ETH.
[out]outPanel line, always NUL-terminated.
[in]nCapacity of out (the panel's own buffer is 64).

Definition at line 64 of file rpc_error.h.

References rpc_err_contains().

Referenced by sign_and_broadcast().