OlinCoin
Test
Functions
validate_tx.c File Reference
#include "base_tx.h"
#include "utxo_pool.h"
#include "mempool.h"
#include "constants.h"
#include "crypto.h"
#include "create_block.h"
#include "validate_tx.h"
#include "utxo_to_tx.h"
#include "double_spend_set.h"
Include dependency graph for validate_tx.c:

Functions

void create_blank_sig_txhash (unsigned char *blank_hash, Transaction *tx)
 Create a copy of a transaction with blank signatures and hash it for signature validation. More...
 
int check_input_unlockable (Input *input, unsigned char *blank_tx_hash)
 Check if a given input is unlockable iwth it's unlock script. More...
 
int validate_input_matches_utxopool (Input *input)
 Check if the inputs to a transaction exists in the utxo pool ignoring spent flag now. This cna likely be replaced by just checkign to see if the tx is in the mempool. More...
 
int validate_input (Input *input, unsigned char *blank_tx_hash)
 Wrapper to validate a transactions input in various ways, inputs size, utxo available, unlockable. More...
 
int validate_tx_parts_not_null (Transaction *tx)
 Check if a Transaction (Not a coinbase tx) is malformed this should be the first check run on a transaction. More...
 
int validate_coinbase_tx_parts_not_null (Transaction *coinbase_tx)
 Check if a coinbase TX has a Null value in an improper place. More...
 
int validate_tx_shared (Transaction *tx)
 Overall wrapper to validate an entire transaction that is NOT a Coinbase_tx. More...
 
int check_tx_double_spent (Transaction *tx)
 Check if UTXO is double-spent in a transaction. More...
 
int check_inputs_not_in_mempool (Transaction *tx)
 Check if an UTXO in a transaction is already referenced in the mempool. More...
 
int validate_tx_incoming (Transaction *tx)
 Validate incoming transactions from the network (different than block transaction validation) More...
 

Detailed Description

Author
Nathan Faber nfabe.nosp@m.r@ol.nosp@m.in.ed.nosp@m.u
Version
0.1
Date
2022-03-20

Function Documentation

◆ check_input_unlockable()

int check_input_unlockable ( Input input,
unsigned char *  blank_tx_hash 
)

Check if a given input is unlockable iwth it's unlock script.

Parameters
inputinput to check
blank_tx_hashblank tx hash that the tx was signed with
Returns
int 0 if unlockable not zero if unusable

◆ check_inputs_not_in_mempool()

int check_inputs_not_in_mempool ( Transaction tx)

Check if an UTXO in a transaction is already referenced in the mempool.

Parameters
txtransaction to check
Returns
int 0 if valid, not zero if conflict found

◆ check_tx_double_spent()

int check_tx_double_spent ( Transaction tx)

Check if UTXO is double-spent in a transaction.

Parameters
txtransaction to check
Returns
int 0 if valid, not zero if invalid

◆ create_blank_sig_txhash()

void create_blank_sig_txhash ( unsigned char *  blank_hash,
Transaction tx 
)

Create a copy of a transaction with blank signatures and hash it for signature validation.

Parameters
blank_hashdestination for the blank signature hash
txtransaction to blank and hash

◆ validate_coinbase_tx_parts_not_null()

int validate_coinbase_tx_parts_not_null ( Transaction tx)

Check if a coinbase TX has a Null value in an improper place.

Parameters
txcoinbase tx to check
Returns
int 0 if a valid transaction, not zero if invalid

◆ validate_input()

int validate_input ( Input input,
unsigned char *  blank_tx_hash 
)

Wrapper to validate a transactions input in various ways, inputs size, utxo available, unlockable.

Parameters
inputinput to validate
blank_tx_hashtx hash of the larger transaction with signatures blanked
Returns
int 0 if valid input, not zero if invalid input

◆ validate_input_matches_utxopool()

int validate_input_matches_utxopool ( Input input)

Check if the inputs to a transaction exists in the utxo pool ignoring spent flag now. This cna likely be replaced by just checkign to see if the tx is in the mempool.

Parameters
inputinput to validate
Returns
int 0 if input referneces a valid utxo, not zero if not

◆ validate_tx_incoming()

int validate_tx_incoming ( Transaction tx)

Validate incoming transactions from the network (different than block transaction validation)

Parameters
txtransaction to validate
Returns
int 0 if incoming tx is valid, not zero if invalid

◆ validate_tx_parts_not_null()

int validate_tx_parts_not_null ( Transaction tx)

Check if a Transaction (Not a coinbase tx) is malformed this should be the first check run on a transaction.

Parameters
txtransaction to validate
Returns
int 0 if transaction is valid, not zero if nor

◆ validate_tx_shared()

int validate_tx_shared ( Transaction tx)

Overall wrapper to validate an entire transaction that is NOT a Coinbase_tx.

Parameters
txtransaction to validate
Returns
int 0 if transaction is valid, not zero if invalid