} else { // Is NOT a valid integer $amount_valid = FALSE; } // Validate transaction against known public key balance if (check_crypt_balance($public_key) >= $transaction_amount_sent && $transaction_amount_sent > 0 && $amount_valid == TRUE) { // Balance checks out // Check hash value for tampering of crypt1, crypt2, or crypt3 fields if (hash('sha256', $crypt1 . $crypt2 . $crypt3) == $hash_check) { // Find destination public key $public_key_to_1 = tk_decrypt($public_key, base64_decode($crypt1)); $public_key_to_2 = tk_decrypt($public_key, base64_decode($crypt2)); $public_key_to = filter_sql($public_key_to_1 . $public_key_to_2); if (strlen($public_key) > 300 && strlen($public_key_to) > 300 && $public_key !== $public_key_to) { // Public key not found, insert into final transaction history $sql = "INSERT INTO `transaction_history` (`timestamp` ,`public_key_from` , `public_key_to` , `crypt_data1` ,`crypt_data2` ,`crypt_data3` ,`hash` ,`attribute`)\n\t\t\t\t\t\t\t\tVALUES ({$time_created}, '{$public_key}', '" . filter_public_key($public_key_to) . "' , '{$crypt1}', '{$crypt2}', '{$crypt3}', '{$hash_check}', 'T')"; if (mysql_query($sql) == FALSE) { //Something didn't work write_log("Transaction Database Insert Failed for this Key: " . base64_encode($public_key), "T"); $record_failure_counter++; } else { $record_insert_counter++; } } else { // Invalid or blank Public Key(s) write_log("Transaction Public Key Error for this Key: " . base64_encode($public_key), "T"); $safe_delete_transaction = TRUE; $record_failure_counter++; } } else { // Hash check failed
$found_duplicate = mysql_result(mysql_query("SELECT timestamp FROM `transaction_history` WHERE `timestamp` = '{$transaction_timestamp}' AND `hash` = '{$transaction_hash}' LIMIT 1"), 0, 0); } else { // Use duplicate test to fail this transaction data $found_duplicate = "INVALID"; } } else { // Transaction Cycle Hash, continue duplicate record test $found_duplicate = mysql_result(mysql_query("SELECT timestamp FROM `transaction_history` WHERE `timestamp` = '{$transaction_timestamp}' AND `hash` = '{$transaction_hash}' LIMIT 1"), 0, 0); } if (empty($found_duplicate) == TRUE) { $norm_record_insert_counter++; // How many records are spooling up if ($norm_record_insert_counter == 1) { $norm_record_insert = "('{$transaction_timestamp}', '" . filter_public_key($transaction_public_key_from) . "', '" . filter_public_key($transaction_public_key_to) . "', '{$transaction_crypt1}', '{$transaction_crypt2}' , '{$transaction_crypt3}', '{$transaction_hash}' , '{$transaction_attribute}')"; } else { $norm_record_insert .= ",('{$transaction_timestamp}', '" . filter_public_key($transaction_public_key_from) . "', '" . filter_public_key($transaction_public_key_to) . "', '{$transaction_crypt1}', '{$transaction_crypt2}' , '{$transaction_crypt3}', '{$transaction_hash}' , '{$transaction_attribute}')"; } if ($norm_record_insert_counter >= 500) { // Insert Spooling Finished, write to database $sql = "INSERT INTO `transaction_history` (`timestamp`,`public_key_from`,`public_key_to`,`crypt_data1`,`crypt_data2`,`crypt_data3`, `hash`, `attribute`) VALUES " . $norm_record_insert; if (mysql_query($sql) == TRUE) { // Flag for a re-check afterwards $double_check_block = TRUE; // Reset Counter $norm_record_insert_counter = 0; $norm_record_insert = NULL; } } } } $tc++;
if ($transaction_amount_sent_test == $transaction_amount_sent) { // Is a valid integer $amount_valid = TRUE; } else { // Is NOT a valid integer $amount_valid = FALSE; } // Validate transaction against known public key balance if (check_crypt_balance($public_key) >= $transaction_amount_sent && $transaction_amount_sent > 0 && $amount_valid == TRUE) { // Balance checks out // Check hash value for tampering of crypt1, crypt2, or crypt3 fields if (hash('sha256', $crypt1 . $crypt2 . $crypt3) == $hash_check) { // Find destination public key $public_key_to_1 = tk_decrypt($public_key, base64_decode($crypt1)); $public_key_to_2 = tk_decrypt($public_key, base64_decode($crypt2)); $public_key_to = filter_public_key(filter_sql($public_key_to_1 . $public_key_to_2)); if (strlen($public_key) > 300 && strlen($public_key_to) > 300 && $public_key !== $public_key_to) { // Public key not found, insert into final transaction history $sql = "INSERT INTO `transaction_history` (`timestamp` ,`public_key_from` , `public_key_to` , `crypt_data1` ,`crypt_data2` ,`crypt_data3` ,`hash` ,`attribute`)\n\t\t\t\t\t\t\t\tVALUES ({$time_created}, '{$public_key}', '{$public_key_to}' , '{$crypt1}', '{$crypt2}', '{$crypt3}', '{$hash_check}', 'T')"; if (mysql_query($sql) == FALSE) { //Something didn't work write_log("Transaction Database Insert Failed for this Key: " . base64_encode($public_key), "T"); $record_failure_counter++; } else { $record_insert_counter++; } } else { // Invalid or blank Public Key(s) write_log("Transaction Public Key Error for this Key: " . base64_encode($public_key), "T"); $safe_delete_transaction = TRUE; $record_failure_counter++;