pull/93/merge
moneroexamples 6 years ago
parent 0fdc8f43aa
commit 0e8b0aa34a

@ -34,7 +34,7 @@
"wallet_import" :
{
"_comment": "if fee is 0, then importing is free. fee is in base 1e12, e.g., 0.1 xmr is 0.1 x 1e12 = 100000000000",
"fee" : 0,
"fee" : 100000000000,
"testnet" :
{
"address" : "9tzmPMTViHYM3z6NAgQni1Qm1Emzxy5hQFibPgWD3LVTAz91yok5Eni1pH6zKhBHzpTU15GZooPHSGHXFvFuXEdmEG2sWAZ",
@ -64,4 +64,4 @@
"ssl-crt": "file:///tmp/server.crt",
"dh-pem" : "file:///tmp/dh2048.pem"
}
}
}

@ -3,7 +3,7 @@ var config = {
mainnetExplorerUrl: "https://xmrchain.com/",
testnetExplorerUrl: "https://testnet.xmrchain.com/",
stagenetExplorerUrl: "http://162.210.173.150:8083/",
nettype: 2, /* 0 - MAINNET, 1 - TESTNET, 2 - STAGENET */
nettype: 1, /* 0 - MAINNET, 1 - TESTNET, 2 - STAGENET */
coinUnitPlaces: 12,
txMinConfirms: 10, // corresponds to CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE in Monero
txCoinbaseMinConfirms: 60, // corresponds to CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW in Monero

@ -34,14 +34,21 @@ if (*help_opt)
mlog_configure(mlog_get_default_log_path(""), true);
mlog_set_log("1");
string log_file = *(opts.get_option<string>("log-file"));
// setup a logger for Open Monero
el::Configurations defaultConf;
defaultConf.setToDefault();
//defaultConf.setGlobally(el::ConfigurationType::Filename, filename_base);
defaultConf.setGlobally(el::ConfigurationType::ToFile, "false");
if (!log_file.empty())
{
// setup openmonero log file
defaultConf.setGlobally(el::ConfigurationType::Filename, log_file);
defaultConf.setGlobally(el::ConfigurationType::ToFile, "true");
}
defaultConf.setGlobally(el::ConfigurationType::ToStandardOutput, "true");
el::Loggers::reconfigureLogger("openmonero", defaultConf);
@ -90,9 +97,6 @@ xmreg::MySqlConnector::username = config_json["database"]["user"];
xmreg::MySqlConnector::password = config_json["database"]["password"];
xmreg::MySqlConnector::dbname = config_json["database"]["dbname"];
// create rpc connector
// once we have all the parameters for the blockchain and our backend
// we can create and instance of CurrentBlockchainStatus class.

@ -19,18 +19,27 @@ namespace xmreg
"openmonero, Open Monero backend service");
desc.add_options()
("help,h", value<bool>()->default_value(false)->implicit_value(true),
("help,h", value<bool>()->default_value(false)
->implicit_value(true),
"produce help message")
("testnet,t", value<bool>()->default_value(false)->implicit_value(true),
("testnet,t", value<bool>()->default_value(false)
->implicit_value(true),
"use testnet blockchain")
("stagenet,s", value<bool>()->default_value(false)->implicit_value(true),
("stagenet,s", value<bool>()->default_value(false)
->implicit_value(true),
"use stagenet blockchain")
("do-not-relay", value<bool>()->default_value(false)->implicit_value(true),
"does not relay txs to other nodes. useful when testing construction and submiting txs")
("do-not-relay", value<bool>()->default_value(false)
->implicit_value(true),
"does not relay txs to other nodes. useful "
"when testing construction and submiting txs")
("port,p", value<string>()->default_value("1984"),
"default port for restbed service of Open Monero")
("config-file,c", value<string>()->default_value("./config/config.json"),
"Config file path.");
("config-file,c", value<string>()
->default_value("./config/config.json"),
"Config file path.")
("log-file,l", value<string>()
->default_value("./openmonero.log"),
"Name and path to log file. -l \"\" to disable log file.");
store(command_line_parser(acc, avv)

@ -27,8 +27,6 @@ CurrentBlockchainStatus::CurrentBlockchainStatus(
void
CurrentBlockchainStatus::start_monitor_blockchain_thread()
{
network_type net_type = bc_setup.net_type;
TxSearch::set_search_thread_life(
bc_setup.search_thread_life_in_seconds);
@ -40,8 +38,8 @@ CurrentBlockchainStatus::start_monitor_blockchain_thread()
{
update_current_blockchain_height();
read_mempool();
OMINFO << "Check block height: " << current_height
<< " no of mempool txs: " << mempool_txs.size();
OMINFO << "Current blockchain height: " << current_height
<< ", no of mempool txs: " << mempool_txs.size();
clean_search_thread_map();
std::this_thread::sleep_for(
std::chrono::seconds(
@ -284,27 +282,6 @@ CurrentBlockchainStatus::get_amount_specific_indices(
return false;
}
//bool
//CurrentBlockchainStatus::get_random_outputs(
// const vector<uint64_t>& amounts,
// const uint64_t& outs_count,
// vector<COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS
// ::outs_for_amount>& found_outputs)
//{
// rpccalls rpc {bc_setup.deamon_url};
// string error_msg;
// if (!rpc.get_random_outs_for_amounts(
// amounts, outs_count, found_outputs, error_msg))
// {
// cerr << "rpc.get_random_outs_for_amounts failed" << endl;
// return false;
// }
// return true;
//}
bool
CurrentBlockchainStatus::get_random_outputs(
const vector<uint64_t>& amounts,
@ -330,27 +307,6 @@ CurrentBlockchainStatus::get_random_outputs(
return true;
}
//bool
//CurrentBlockchainStatus::get_output(
// const uint64_t amount,
// const uint64_t global_output_index,
// COMMAND_RPC_GET_OUTPUTS_BIN::outkey& output_info)
//{
// rpccalls rpc {bc_setup.deamon_url};
// string error_msg;
// if (!rpc.get_out(amount, global_output_index, output_info))
// {
// cerr << "rpc.get_out" << endl;
// return false;
// }
// return true;
//}
bool
CurrentBlockchainStatus::get_output(
const uint64_t amount,
@ -373,27 +329,6 @@ CurrentBlockchainStatus::get_output(
return true;
}
//bool
//CurrentBlockchainStatus::get_dynamic_per_kb_fee_estimate(
// uint64_t& fee_estimated)
//{
// rpccalls rpc {bc_setup.deamon_url};
// string error_msg;
// if (!rpc.get_dynamic_per_kb_fee_estimate(
// FEE_ESTIMATE_GRACE_BLOCKS,
// fee_estimated, error_msg))
// {
// cerr << "rpc.get_dynamic_per_kb_fee_estimate failed" << endl;
// return false;
// }
// return true;
//}
uint64_t
CurrentBlockchainStatus::get_dynamic_per_kb_fee_estimate() const
{
@ -504,8 +439,7 @@ CurrentBlockchainStatus::search_if_payment_made(
block blk;
if (!get_block(blk_i, blk)) {
OMERROR << "Cant get block of height: "
+ to_string(blk_i);
OMERROR << "Cant get block of height: " << blk_i;
return false;
}
@ -514,8 +448,7 @@ CurrentBlockchainStatus::search_if_payment_made(
if (!get_block_txs(blk, blk_txs, missed_txs))
{
OMERROR << "Cant get transactions in block: "
<< to_string(blk_i);
OMERROR << "Cant get transactions from block: " << blk_i;
return false;
}
@ -552,7 +485,8 @@ CurrentBlockchainStatus::search_if_payment_made(
if (!hex_to_pod(tx_payment_id_str, encrypted_payment_id8))
{
OMERROR << "failed parsing hex to pod for encrypted_payment_id8";
OMERROR << "Failed parsing hex to pod for encrypted_payment_id8";
continue;
}
// decrypt the encrypted_payment_id8
@ -581,12 +515,13 @@ CurrentBlockchainStatus::search_if_payment_made(
if (decrypted_payment_id8 != null_hash8)
{
if (!mcore->get_device()->decrypt_payment_id(
if (!mcore->decrypt_payment_id(
decrypted_payment_id8, tx_pub_key,
bc_setup.import_payment_viewkey))
{
OMERROR << "Cant decrypt decrypted_payment_id8: "
<< pod_to_hex(decrypted_payment_id8);
OMERROR << "Cant decrypt decrypted_payment_id8: "
<< pod_to_hex(decrypted_payment_id8);
continue;
}
}
@ -663,7 +598,7 @@ CurrentBlockchainStatus::search_if_payment_made(
if (!r)
{
OMERROR << "Cant decode ringCT!";
throw TxSearchException("Cant decode ringCT!");
return false;
}
amount = rct_amount;
@ -672,14 +607,11 @@ CurrentBlockchainStatus::search_if_payment_made(
} // if (mine_output && tx.version == 2)
if (mine_output)
{
total_received += amount;
}
total_received += amount;
}
OMINFO << " - payment id check in tx: "
OMINFO << " Payment id check in tx: "
<< tx_hash_str
<< " found: " << total_received;
@ -687,6 +619,7 @@ CurrentBlockchainStatus::search_if_payment_made(
{
// the payment has been made.
tx_hash_with_payment = tx_hash_str;
OMINFO << "Import payment done";
return true;
}
}

@ -176,6 +176,17 @@ public:
virtual bool
get_tx(crypto::hash const& tx_hash, transaction& tx) const;
virtual bool
decrypt_payment_id(crypto::hash8 &payment_id,
public_key const& public_key,
secret_key const& secret_key)
{
return m_device->decrypt_payment_id(payment_id,
public_key,
secret_key);
}
virtual bool
init_success() const;

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save