bool handle_command_line(const boost::program_options::variables_map& vm) { if (!command_line::has_arg(vm, arg_genesis_nonce_string)) { LOG_PRINT_RED_L0("Must provide genesis nonce string"); return false; } if (!command_line::has_arg(vm, arg_genesis_timestamp)) { LOG_PRINT_RED_L0("Must provide genesis timestamp"); return false; } if (!command_line::has_arg(vm, arg_coinbase_tx_hex)) { LOG_PRINT_RED_L0("Must provide coinbase tx hex"); return false; } if (!command_line::has_arg(vm, arg_block_id_hex)) { LOG_PRINT_RED_L0("Must provide genesis block id hash hex"); return false; } genesis_info &p_default = cryptonote::config::testnet ? testnet_info : mainnet_info; str_genesis_nonce_string = p_default.get_genesis_nonce_string(command_line::get_arg(vm, arg_genesis_nonce_string)); genesis_timestamp = p_default.get_timestamp(command_line::get_arg(vm, arg_genesis_timestamp)); str_coinbase_tx_hex = p_default.get_coinbase_tx_hex(command_line::get_arg(vm, arg_coinbase_tx_hex)); str_block_id_hex = p_default.get_block_id_hex(command_line::get_arg(vm, arg_block_id_hex)); GENESIS_NONCE_STRING = str_genesis_nonce_string.c_str(); GENESIS_TIMESTAMP = &genesis_timestamp; GENESIS_COINBASE_TX_HEX = str_coinbase_tx_hex.c_str(); GENESIS_BLOCK_ID_HEX = str_block_id_hex.c_str(); cryptonote::block bl; if (!generate_genesis_block(bl)) return false; if (command_line::has_arg(vm, arg_work_hash_hex)) { str_work_hash_hex = p_default.get_work_hash_hex(command_line::get_arg(vm, arg_work_hash_hex)); if (!str_work_hash_hex.empty()) { GENESIS_WORK_HASH_HEX = str_work_hash_hex.c_str(); } } if (command_line::has_arg(vm, arg_hash_signature_hex)) { str_hash_signature_hex = p_default.get_hash_signature_hex(command_line::get_arg(vm, arg_hash_signature_hex)); if (!str_hash_signature_hex.empty()) { GENESIS_HASH_SIGNATURE_HEX = str_hash_signature_hex.c_str(); } } return true; }
//----------------------------------------------------------------------------------------------- bool core::handle_incoming_tx(const blobdata& tx_blob, tx_verification_context& tvc, bool keeped_by_block) { tvc = boost::value_initialized<tx_verification_context>(); //want to process all transactions sequentially CRITICAL_REGION_LOCAL(m_incoming_tx_lock); if(tx_blob.size() > m_currency.maxTxSize()) { LOG_PRINT_L0("WRONG TRANSACTION BLOB, too big size " << tx_blob.size() << ", rejected"); tvc.m_verifivation_failed = true; return false; } crypto::hash tx_hash = null_hash; crypto::hash tx_prefixt_hash = null_hash; Transaction tx; if(!parse_tx_from_blob(tx, tx_hash, tx_prefixt_hash, tx_blob)) { LOG_PRINT_L0("WRONG TRANSACTION BLOB, Failed to parse, rejected"); tvc.m_verifivation_failed = true; return false; } //std::cout << "!"<< tx.vin.size() << std::endl; if(!check_tx_syntax(tx)) { LOG_PRINT_L0("WRONG TRANSACTION BLOB, Failed to check tx " << tx_hash << " syntax, rejected"); tvc.m_verifivation_failed = true; return false; } if(!check_tx_semantic(tx, keeped_by_block)) { LOG_PRINT_L0("WRONG TRANSACTION BLOB, Failed to check tx " << tx_hash << " semantic, rejected"); tvc.m_verifivation_failed = true; return false; } bool r = add_new_tx(tx, tx_hash, tx_prefixt_hash, tx_blob.size(), tvc, keeped_by_block); if(tvc.m_verifivation_failed) { if (!tvc.m_tx_fee_too_small) { LOG_PRINT_RED_L0("Transaction verification failed: " << tx_hash); } else { LOG_PRINT_L0("Transaction verification failed: " << tx_hash); } } else if(tvc.m_verifivation_impossible) { LOG_PRINT_RED_L0("Transaction verification impossible: " << tx_hash); } if (tvc.m_added_to_pool) { LOG_PRINT_L1("tx added: " << tx_hash); poolUpdated(); } return r; }
//----------------------------------------------------------------------------------------------- bool core::check_tx_semantic(const Transaction& tx, bool keeped_by_block) { if(!tx.vin.size()) { LOG_PRINT_RED_L0("tx with empty inputs, rejected for tx id= " << get_transaction_hash(tx)); return false; } if(!check_inputs_types_supported(tx)) { LOG_PRINT_RED_L0("unsupported input types for tx id= " << get_transaction_hash(tx)); return false; } if(!check_outs_valid(tx)) { LOG_PRINT_RED_L0("tx with invalid outputs, rejected for tx id= " << get_transaction_hash(tx)); return false; } if(!check_money_overflow(tx)) { LOG_PRINT_RED_L0("tx have money overflow, rejected for tx id= " << get_transaction_hash(tx)); return false; } uint64_t amount_in = m_currency.getTransactionAllInputsAmount(tx); uint64_t amount_out = get_outs_money_amount(tx); if(amount_in <= amount_out) { LOG_PRINT_RED_L0("tx with wrong amounts: ins " << amount_in << ", outs " << amount_out << ", rejected for tx id= " << get_transaction_hash(tx)); return false; } if(!keeped_by_block && get_object_blobsize(tx) >= m_blockchain_storage.get_current_comulative_blocksize_limit() - m_currency.minerTxBlobReservedSize()) { LOG_PRINT_RED_L0("transaction is too big " << get_object_blobsize(tx) << ", maximum allowed size is " << (m_blockchain_storage.get_current_comulative_blocksize_limit() - m_currency.minerTxBlobReservedSize())); return false; } //check if tx use different key images if(!check_tx_inputs_keyimages_diff(tx)) { LOG_PRINT_RED_L0("tx has a few inputs with identical keyimages"); return false; } if (!checkMultisignatureInputsDiff(tx)) { LOG_PRINT_RED_L0("tx has a few multisignature inputs with identical output indexes"); return false; } return true; }
BOOL WINAPI SignalHandler::winHandler(DWORD type) { if (CTRL_C_EVENT == type || CTRL_BREAK_EVENT == type) { handleSignal(); return TRUE; } else { LOG_PRINT_RED_L0("Got control signal " << type << ". Exiting without saving..."); return FALSE; } return TRUE; }