OlinCoin
Test
Classes | Macros | Functions | Variables
shell.h File Reference

Shell for running blockchain functions. More...

#include <uthash.h>
Include dependency graph for shell.h:

Go to the source code of this file.

Classes

struct  Command
 
struct  CommandPool
 

Macros

#define COMMAND_NAME_LEN   128
 

Functions

size_t arg_len (char **args)
 
void str_to_buf (unsigned char *dest, char *hex_str, size_t dest_len, size_t src_len)
 Converts a string of hex values to a buffer. More...
 
int shell_mine (char **args)
 
int shell_build_tx (char **args)
 
int shell_print_chain (char **args)
 
int shell_print_block (char **args)
 
int shell_exit (char **args)
 
int shell_help (char **args)
 
char * shell_read_line ()
 
char ** shell_tokenize (char *line)
 
int shell_execute (size_t num_args, char **args)
 
void shell_loop ()
 
void shell_init_globals ()
 
void shell_init_commands ()
 
void shell_init ()
 

Variables

CommandPoolshell_command_pool
 

Detailed Description

Shell for running blockchain functions.

The shell allows users to interact with the local blockchain. Primary use case if for running a wallet, but currently also allows users to run a miner.

Commands are defined by a name, function, number of arguments and help string. A mapping of command name to the function to call when the command is executed is built on program start. After commands are initialized, the shell runs in a loop until the program is exited with CTRL+C, CTRL+D or exit. While in the loop, new lines of text are read, tokenized then executed.

Function Documentation

◆ str_to_buf()

void str_to_buf ( unsigned char *  dest,
char *  hex_str,
size_t  dest_len,
size_t  src_len 
)

Converts a string of hex values to a buffer.

Fills the destination with 0s and terminates early if either input is shorter than the other. This means that a string of hex values less than 64 characters long produces a buffer with a bunch of 0s on the end.

Parameters
destbuffer to write to
hex_strhex string to read from
dest_lenlength of destination buffer
src_lenlength of source string