Add print-genesis-tx option.

This commit is contained in:
Albert Werner 2014-07-18 14:49:01 +04:00
parent f4769d87ad
commit 7f23949066
30 changed files with 68 additions and 45 deletions

View file

@ -1,9 +1,10 @@
// Copyright (c) 2012-2013 The Cryptonote developers
// Copyright (c) 2011-2014 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#pragma once
#include <algorithm>
#include <mutex>
#include <vector>

View file

@ -90,3 +90,5 @@
#define THREAD_STACK_SIZE 5 * 1024 * 1024
#define GENESIS_COINBASE_TX_HEX ""

View file

@ -617,25 +617,30 @@ namespace cryptonote
return p;
}
//---------------------------------------------------------------
void generate_genesis_tx(transaction& tx) {
account_public_address ac = boost::value_initialized<account_public_address>();
std::vector<size_t> sz;
construct_miner_tx(0, 0, 0, 0, 0, ac, tx); // zero fee in genesis
blobdata txb = tx_to_blob(tx);
}
std::string get_genesis_tx_hex() {
transaction tx;
generate_genesis_tx(tx);
blobdata txb = tx_to_blob(tx);
std::string hex_tx_represent = string_tools::buff_to_hex_nodelimer(txb);
return hex_tx_represent;
}
bool generateGenesisBlock(block& bl)
{
//genesis block
bl = boost::value_initialized<block>();
//TODO Uncomment this code block on the first network launch. It will generate and print you genesis block's hash.
//TODO Then you must copy it and put to genesis_coinbase_tx_hex variable
/*
account_public_address ac = boost::value_initialized<account_public_address>();
std::vector<size_t> sz;
construct_miner_tx(0, 0, 0, 0, 0, ac, bl.miner_tx); // zero fee in genesis
blobdata txb = tx_to_blob(bl.miner_tx);
std::string hex_tx_represent = string_tools::buff_to_hex_nodelimer(txb);
std::cout << "Genesis coinbase tx hex: " << hex_tx_represent << std::endl;
*/
//hard code coinbase tx in genesis block, because "true" generating tx use random, but genesis should be always the same
//TODO After you obtain hash of the genesis block put it here and recompile sources!
std::string genesis_coinbase_tx_hex = "";
//hard code coinbase tx in genesis block, because "tru" generating tx use random, but genesis should be always the same
std::string genesis_coinbase_tx_hex = GENESIS_COINBASE_TX_HEX;
blobdata tx_bl;
string_tools::parse_hexstr_to_binbuff(genesis_coinbase_tx_hex, tx_bl);

View file

@ -81,6 +81,7 @@ namespace cryptonote
crypto::hash get_block_longhash(crypto::cn_context &context, const block& b, uint64_t height);
bool generateGenesisBlock(block& bl);
bool generateTestnetGenesisBlock(block& bl);
std::string get_genesis_tx_hex();
bool parse_and_validate_block_from_blob(const blobdata& b_blob, block& b);
bool get_inputs_money_amount(const transaction& tx, uint64_t& money);
uint64_t get_outs_money_amount(const transaction& tx);

View file

@ -38,10 +38,20 @@ namespace
const command_line::arg_descriptor<bool> arg_console = {"no-console", "Disable daemon console commands"};
const command_line::arg_descriptor<bool> arg_testnet_on = {"testnet", "Used to deploy test nets. Checkpoints and hardcoded seeds are ignored, "
"network id is changed. Use it with --data-dir flag. The wallet must be launched with --testnet flag.", false};
const command_line::arg_descriptor<bool> arg_print_genesis_tx = {"print-genesis-tx", "Prints genesis' block tx hex to insert it to config and exits"};
}
bool command_line_preprocessor(const boost::program_options::variables_map& vm);
void print_genesis_tx_hex() {
std::string tx_hex = cryptonote::get_genesis_tx_hex();
std::cout << "Insert this line into your coin configuration file as is: " << std::endl;
std::cout << "#define GENESIS_COINBASE_TX_HEX \"" << tx_hex << "\"" << std::endl;
return;
}
int main(int argc, char* argv[])
{
@ -69,6 +79,7 @@ int main(int argc, char* argv[])
command_line::add_arg(desc_cmd_sett, arg_log_level);
command_line::add_arg(desc_cmd_sett, arg_console);
command_line::add_arg(desc_cmd_sett, arg_testnet_on);
command_line::add_arg(desc_cmd_sett, arg_print_genesis_tx);
cryptonote::core::init_options(desc_cmd_sett);
cryptonote::core_rpc_server::init_options(desc_cmd_sett);
@ -90,6 +101,11 @@ int main(int argc, char* argv[])
return false;
}
if (command_line::get_arg(vm, arg_print_genesis_tx)) {
print_genesis_tx_hex();
return false;
}
std::string data_dir = command_line::get_arg(vm, command_line::arg_data_dir);
std::string config = command_line::get_arg(vm, arg_config_file);

View file

@ -1,4 +1,4 @@
#define BUILD_COMMIT_ID "@VERSION@"
#define PROJECT_VERSION "1.0.0"
#define PROJECT_VERSION "1.0.1"
#define PROJECT_VERSION_BUILD_NO "1"
#define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO "(" BUILD_COMMIT_ID ")"

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012-2013 The Cryptonote developers
// Copyright (c) 2011-2014 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012-2013 The Cryptonote developers
// Copyright (c) 2011-2014 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012-2013 The Cryptonote developers
// Copyright (c) 2011-2014 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012-2013 The Cryptonote developers
// Copyright (c) 2011-2014 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012-2013 The Cryptonote developers
// Copyright (c) 2011-2014 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012-2013 The Cryptonote developers
// Copyright (c) 2011-2014 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012-2013 The Cryptonote developers
// Copyright (c) 2011-2014 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012-2013 The Cryptonote developers
// Copyright (c) 2011-2014 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012-2013 The Cryptonote developers
// Copyright (c) 2011-2014 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012-2013 The Cryptonote developers
// Copyright (c) 2011-2014 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012-2013 The Cryptonote developers
// Copyright (c) 2011-2014 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012-2013 The Cryptonote developers
// Copyright (c) 2011-2014 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012-2013 The Cryptonote developers
// Copyright (c) 2011-2014 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,9 +1,7 @@
/*
* WalletTransactionSender.cpp
*
* Created on: 18 июня 2014 г.
* Author: milo
*/
// Copyright (c) 2011-2014 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "WalletTransactionSender.h"
#include "WalletUtils.h"

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012-2013 The Cryptonote developers
// Copyright (c) 2011-2014 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012-2013 The Cryptonote developers
// Copyright (c) 2011-2014 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012-2013 The Cryptonote developers
// Copyright (c) 2011-2014 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012-2013 The Cryptonote developers
// Copyright (c) 2011-2014 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012-2013 The Cryptonote developers
// Copyright (c) 2011-2014 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012-2013 The Cryptonote developers
// Copyright (c) 2011-2014 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012-2013 The Cryptonote developers
// Copyright (c) 2011-2014 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012-2013 The Cryptonote developers
// Copyright (c) 2011-2014 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012-2013 The Cryptonote developers
// Copyright (c) 2011-2014 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012-2013 The Cryptonote developers
// Copyright (c) 2011-2014 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.