Uniswap Sniper Bot  1.0
Public Types | Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Transaction Class Reference

#include <transaction.hpp>

Public Types

enum  Field {
  Nonce , GasPrice , GasLimit , To ,
  Value , Data , V , R ,
  S
}
 Enum containing available transaction fields. More...
 

Public Member Functions

 Transaction ()
 Constructs a new Transaction object. Creates SECP256K1 context. More...
 
 ~Transaction ()
 Destroys the Transaction object. Destroys SECP256K1 context. More...
 
void setField (Field field, const char *value)
 Sets the transaction field value. More...
 
void setField (Field field, Buffer value, std::size_t size)
 Sets the transaction field value. More...
 
std::size_t sign (const char *privateKey, Utils::Buffer transaction)
 Signs transaction. More...
 
std::size_t sign (Utils::Buffer privateKey, Utils::Buffer transaction)
 Signs transaction. More...
 

Static Public Attributes

static constexpr std::size_t FieldsCount = 9
 Transaction's fields count. More...
 

Private Types

enum  FieldType { DATA , QUANTITY }
 Enum containing available transaction fields types. More...
 

Private Member Functions

std::size_t _keccak256 (Utils::Buffer input, std::size_t inputLength, Utils::Buffer hash)
 KECCAK256 hashing function. More...
 
std::size_t _ecdsa (Utils::Buffer hash, Utils::Buffer privateKey, Utils::Buffer signature, int *recid)
 ECDSA hashing function. More...
 

Private Attributes

secp256k1_context * secp256k1Context
 SECP256K1 context, allows preinitialization as it's very slow to create. More...
 
Utils::Byte nonce [Config::Size::TransactionQuantityBuffer]
 
Utils::Byte gasPrice [Config::Size::TransactionQuantityBuffer]
 
Utils::Byte gasLimit [Config::Size::TransactionQuantityBuffer]
 
Utils::Byte to [Config::Size::TransactionAddressBuffer]
 
Utils::Byte value [Config::Size::TransactionQuantityBuffer]
 
Utils::Byte data [Config::Size::TransactionDataBuffer]
 
Utils::Byte v [Config::Size::TransactionQuantityBuffer]
 
Utils::Byte r [Config::Size::TransactionQuantityBuffer]
 
Utils::Byte s [Config::Size::TransactionQuantityBuffer]
 
RLP::Item rlpInput [FieldsCount]
 RLP input data to encode. More...
 

Static Private Attributes

static constexpr FieldType fieldTypeMapping [FieldsCount] = { QUANTITY, QUANTITY, QUANTITY, DATA, QUANTITY, DATA, QUANTITY, QUANTITY, QUANTITY }
 Transaction field to its type mapping. More...
 

Member Enumeration Documentation

◆ Field

Enum containing available transaction fields.

Enumerator
Nonce 
GasPrice 
GasLimit 
To 
Value 
Data 

◆ FieldType

enum Transaction::FieldType
private

Enum containing available transaction fields types.

Enumerator
DATA 
QUANTITY 

Constructor & Destructor Documentation

◆ Transaction()

Transaction::Transaction ( )
inline

Constructs a new Transaction object. Creates SECP256K1 context.

◆ ~Transaction()

Transaction::~Transaction ( )
inline

Destroys the Transaction object. Destroys SECP256K1 context.

Member Function Documentation

◆ _keccak256()

std::size_t Transaction::_keccak256 ( Utils::Buffer  input,
std::size_t  inputLength,
Utils::Buffer  hash 
)
inlineprivate

KECCAK256 hashing function.

Parameters
inputinput buffer
inputLengthinput buffer length
hashoutput hash buffer
Returns
output buffer length (always 32)

◆ _ecdsa()

std::size_t Transaction::_ecdsa ( Utils::Buffer  hash,
Utils::Buffer  privateKey,
Utils::Buffer  signature,
int *  recid 
)
inlineprivate

ECDSA hashing function.

Parameters
hash32 byte hash
privateKey32 byte private key
signatureoutput signature buffer
recidoutput recovery id
Returns
output signature buffer length (always 64)

◆ setField() [1/2]

void Transaction::setField ( Field  field,
const char *  value 
)
inline

Sets the transaction field value.

Parameters
fieldfield name
valueinput c-string

◆ setField() [2/2]

void Transaction::setField ( Field  field,
Buffer  value,
std::size_t  size 
)
inline

Sets the transaction field value.

Parameters
fieldfield name
valueinput buffer
sizeinput buffer size

◆ sign() [1/2]

std::size_t Transaction::sign ( const char *  privateKey,
Utils::Buffer  transaction 
)
inline

Signs transaction.

Parameters
privateKeyprivate key c-string to sign with
transactionoutput transaction buffer
Returns
transaction buffer length

◆ sign() [2/2]

std::size_t Transaction::sign ( Utils::Buffer  privateKey,
Utils::Buffer  transaction 
)
inline

Signs transaction.

Parameters
privateKeyprivate key buffer to sign with
transactionoutput transaction buffer
Returns
transaction buffer length

Member Data Documentation

◆ FieldsCount

constexpr std::size_t Transaction::FieldsCount = 9
inlinestaticconstexpr

Transaction's fields count.

◆ fieldTypeMapping

constexpr FieldType Transaction::fieldTypeMapping[FieldsCount] = { QUANTITY, QUANTITY, QUANTITY, DATA, QUANTITY, DATA, QUANTITY, QUANTITY, QUANTITY }
inlinestaticconstexprprivate

Transaction field to its type mapping.

◆ secp256k1Context

secp256k1_context* Transaction::secp256k1Context
private

SECP256K1 context, allows preinitialization as it's very slow to create.

The purpose of context structures is to cache large precomputed data tables that are expensive to construct, and also to maintain the randomization data for blinding.

Do not create a new context object for each operation, as construction is far slower than all other API calls (~100 times slower than an ECDSA verification).

◆ nonce

◆ gasPrice

Utils::Byte Transaction::gasPrice[Config::Size::TransactionQuantityBuffer]
private

◆ gasLimit

Utils::Byte Transaction::gasLimit[Config::Size::TransactionQuantityBuffer]
private

◆ to

◆ value

◆ data

◆ v

◆ r

◆ s

◆ rlpInput

RLP::Item Transaction::rlpInput[FieldsCount]
private
Initial value:
= {
{ .buffer = nonce, .length = 0 },
{ .buffer = gasPrice, .length = 0 },
{ .buffer = gasLimit, .length = 0 },
{ .buffer = to, .length = 0 },
{ .buffer = value, .length = 0 },
{ .buffer = data, .length = 0 },
{ .buffer = v, .length = 0 },
{ .buffer = r, .length = 0 },
{ .buffer = s, .length = 0 },
}
Utils::Byte nonce[Config::Size::TransactionQuantityBuffer]
Definition: transaction.hpp:55
Utils::Byte r[Config::Size::TransactionQuantityBuffer]
Definition: transaction.hpp:62
Utils::Byte data[Config::Size::TransactionDataBuffer]
Definition: transaction.hpp:60
Utils::Byte s[Config::Size::TransactionQuantityBuffer]
Definition: transaction.hpp:63
Utils::Byte v[Config::Size::TransactionQuantityBuffer]
Definition: transaction.hpp:61
Utils::Byte gasLimit[Config::Size::TransactionQuantityBuffer]
Definition: transaction.hpp:57
Utils::Byte gasPrice[Config::Size::TransactionQuantityBuffer]
Definition: transaction.hpp:56
Utils::Byte to[Config::Size::TransactionAddressBuffer]
Definition: transaction.hpp:58
Utils::Byte value[Config::Size::TransactionQuantityBuffer]
Definition: transaction.hpp:59

RLP input data to encode.


The documentation for this class was generated from the following file: