aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cryptonote_core/miner.cpp19
-rw-r--r--src/cryptonote_core/miner.h6
-rw-r--r--src/rpc/core_rpc_server.cpp18
-rw-r--r--src/rpc/core_rpc_server.h2
-rw-r--r--src/rpc/core_rpc_server_commands_defs.h29
-rw-r--r--src/simplewallet/simplewallet.cpp6
-rw-r--r--src/wallet/wallet_rpc_server.cpp15
-rw-r--r--src/wallet/wallet_rpc_server.h2
-rw-r--r--src/wallet/wallet_rpc_server_commans_defs.h18
9 files changed, 106 insertions, 9 deletions
diff --git a/src/cryptonote_core/miner.cpp b/src/cryptonote_core/miner.cpp
index 56b459d6e..2055bb15d 100644
--- a/src/cryptonote_core/miner.cpp
+++ b/src/cryptonote_core/miner.cpp
@@ -188,10 +188,19 @@ namespace cryptonote
return true;
}
//-----------------------------------------------------------------------------------------------------
- bool miner::is_mining()
+ bool miner::is_mining() const
{
return !m_stop;
}
+ //-----------------------------------------------------------------------------------------------------
+ const account_public_address& miner::get_mining_address() const
+ {
+ return m_mine_address;
+ }
+ //-----------------------------------------------------------------------------------------------------
+ uint32_t miner::get_threads_count() const {
+ return m_threads_total;
+ }
//-----------------------------------------------------------------------------------------------------
bool miner::start(const account_public_address& adr, size_t threads_count, const boost::thread::attributes& attrs)
{
@@ -226,12 +235,14 @@ namespace cryptonote
return true;
}
//-----------------------------------------------------------------------------------------------------
- uint64_t miner::get_speed()
+ uint64_t miner::get_speed() const
{
- if(is_mining())
+ if(is_mining()) {
return m_current_hash_rate;
- else
+ }
+ else {
return 0;
+ }
}
//-----------------------------------------------------------------------------------------------------
void miner::send_stop_signal()
diff --git a/src/cryptonote_core/miner.h b/src/cryptonote_core/miner.h
index 61c063ddf..d9ac5a501 100644
--- a/src/cryptonote_core/miner.h
+++ b/src/cryptonote_core/miner.h
@@ -35,10 +35,12 @@ namespace cryptonote
bool set_block_template(const block& bl, const difficulty_type& diffic, uint64_t height);
bool on_block_chain_update();
bool start(const account_public_address& adr, size_t threads_count, const boost::thread::attributes& attrs);
- uint64_t get_speed();
+ uint64_t get_speed() const;
+ uint32_t get_threads_count() const;
void send_stop_signal();
bool stop();
- bool is_mining();
+ bool is_mining() const;
+ const account_public_address& get_mining_address() const;
bool on_idle();
void on_synchronized();
//synchronous analog (for fast calls)
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index 8779f73d8..a724246f1 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -275,6 +275,24 @@ namespace cryptonote
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
+ bool core_rpc_server::on_mining_status(const COMMAND_RPC_MINING_STATUS::request& req, COMMAND_RPC_MINING_STATUS::response& res, connection_context& cntx)
+ {
+ CHECK_CORE_READY();
+
+ const miner& lMiner = m_core.get_miner();
+ res.active = lMiner.is_mining();
+
+ if ( lMiner.is_mining() ) {
+ res.speed = lMiner.get_speed();
+ res.threads_count = lMiner.get_threads_count();
+ const account_public_address& lMiningAdr = lMiner.get_mining_address();
+ res.address = get_account_address_as_str(lMiningAdr);
+ }
+
+ res.status = CORE_RPC_STATUS_OK;
+ return true;
+ }
+ //------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_save_bc(const COMMAND_RPC_SAVE_BC::request& req, COMMAND_RPC_SAVE_BC::response& res, connection_context& cntx)
{
CHECK_CORE_READY();
diff --git a/src/rpc/core_rpc_server.h b/src/rpc/core_rpc_server.h
index ad0016c94..0f8f69b9d 100644
--- a/src/rpc/core_rpc_server.h
+++ b/src/rpc/core_rpc_server.h
@@ -40,6 +40,7 @@ namespace cryptonote
MAP_URI_AUTO_JON2("/sendrawtransaction", on_send_raw_tx, COMMAND_RPC_SEND_RAW_TX)
MAP_URI_AUTO_JON2("/start_mining", on_start_mining, COMMAND_RPC_START_MINING)
MAP_URI_AUTO_JON2("/stop_mining", on_stop_mining, COMMAND_RPC_STOP_MINING)
+ MAP_URI_AUTO_JON2("/mining_status", on_mining_status, COMMAND_RPC_MINING_STATUS)
MAP_URI_AUTO_JON2("/save_bc", on_save_bc, COMMAND_RPC_SAVE_BC)
MAP_URI_AUTO_JON2("/getinfo", on_get_info, COMMAND_RPC_GET_INFO)
BEGIN_JSON_RPC_MAP("/json_rpc")
@@ -60,6 +61,7 @@ namespace cryptonote
bool on_send_raw_tx(const COMMAND_RPC_SEND_RAW_TX::request& req, COMMAND_RPC_SEND_RAW_TX::response& res, connection_context& cntx);
bool on_start_mining(const COMMAND_RPC_START_MINING::request& req, COMMAND_RPC_START_MINING::response& res, connection_context& cntx);
bool on_stop_mining(const COMMAND_RPC_STOP_MINING::request& req, COMMAND_RPC_STOP_MINING::response& res, connection_context& cntx);
+ bool on_mining_status(const COMMAND_RPC_MINING_STATUS::request& req, COMMAND_RPC_MINING_STATUS::response& res, connection_context& cntx);
bool on_get_random_outs(const COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::request& req, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::response& res, connection_context& cntx);
bool on_get_info(const COMMAND_RPC_GET_INFO::request& req, COMMAND_RPC_GET_INFO::response& res, connection_context& cntx);
bool on_save_bc(const COMMAND_RPC_SAVE_BC::request& req, COMMAND_RPC_SAVE_BC::response& res, connection_context& cntx);
diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h
index 1e8ebe8ff..48df16e59 100644
--- a/src/rpc/core_rpc_server_commands_defs.h
+++ b/src/rpc/core_rpc_server_commands_defs.h
@@ -261,6 +261,35 @@ namespace cryptonote
};
//-----------------------------------------------
+ struct COMMAND_RPC_MINING_STATUS
+ {
+ struct request
+ {
+
+ BEGIN_KV_SERIALIZE_MAP()
+ END_KV_SERIALIZE_MAP()
+ };
+
+
+ struct response
+ {
+ std::string status;
+ bool active;
+ uint64_t speed;
+ uint32_t threads_count;
+ std::string address;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(status)
+ KV_SERIALIZE(active)
+ KV_SERIALIZE(speed)
+ KV_SERIALIZE(threads_count)
+ KV_SERIALIZE(address)
+ END_KV_SERIALIZE_MAP()
+ };
+ };
+
+ //-----------------------------------------------
struct COMMAND_RPC_SAVE_BC
{
struct request
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 9053dde1f..dc45d9d74 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -944,7 +944,7 @@ int main(int argc, char* argv[])
if (command_line::get_arg(vm, command_line::arg_help))
{
- success_msg_writer() << "bytecoin wallet v" << PROJECT_VERSION_LONG;
+ success_msg_writer() << CRYPTONOTE_NAME << " wallet v" << PROJECT_VERSION_LONG;
success_msg_writer() << "Usage: simplewallet [--wallet-file=<file>|--generate-new-wallet=<file>] [--daemon-address=<host>:<port>] [<COMMAND>]";
success_msg_writer() << desc_all << '\n' << w.get_commands_str();
return false;
@@ -961,7 +961,7 @@ int main(int argc, char* argv[])
return true;
});
if (!r)
- return 1;
+ return 0;
//set up logging options
log_space::get_set_log_detalisation_level(true, LOG_LEVEL_2);
@@ -1069,6 +1069,6 @@ int main(int argc, char* argv[])
w.deinit();
}
}
- return 1;
+ return 0;
//CATCH_ENTRY_L0("main", 1);
}
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index f1766c3b4..55f81aacc 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -71,6 +71,21 @@ namespace tools
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
+ bool wallet_rpc_server::on_getaddress(const wallet_rpc::COMMAND_RPC_GET_ADDRESS::request& req, wallet_rpc::COMMAND_RPC_GET_ADDRESS::response& res, epee::json_rpc::error& er, connection_context& cntx)
+ {
+ try
+ {
+ res.address = m_wallet.get_account().get_public_address_str();
+ }
+ catch (std::exception& e)
+ {
+ er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
+ er.message = e.what();
+ return false;
+ }
+ return true;
+ }
+ //------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server::on_transfer(const wallet_rpc::COMMAND_RPC_TRANSFER::request& req, wallet_rpc::COMMAND_RPC_TRANSFER::response& res, epee::json_rpc::error& er, connection_context& cntx)
{
diff --git a/src/wallet/wallet_rpc_server.h b/src/wallet/wallet_rpc_server.h
index db49df574..ec29e0932 100644
--- a/src/wallet/wallet_rpc_server.h
+++ b/src/wallet/wallet_rpc_server.h
@@ -36,6 +36,7 @@ namespace tools
BEGIN_URI_MAP2()
BEGIN_JSON_RPC_MAP("/json_rpc")
MAP_JON_RPC_WE("getbalance", on_getbalance, wallet_rpc::COMMAND_RPC_GET_BALANCE)
+ MAP_JON_RPC_WE("getaddress", on_getaddress, wallet_rpc::COMMAND_RPC_GET_ADDRESS)
MAP_JON_RPC_WE("transfer", on_transfer, wallet_rpc::COMMAND_RPC_TRANSFER)
MAP_JON_RPC_WE("store", on_store, wallet_rpc::COMMAND_RPC_STORE)
MAP_JON_RPC_WE("get_payments", on_get_payments, wallet_rpc::COMMAND_RPC_GET_PAYMENTS)
@@ -44,6 +45,7 @@ namespace tools
//json_rpc
bool on_getbalance(const wallet_rpc::COMMAND_RPC_GET_BALANCE::request& req, wallet_rpc::COMMAND_RPC_GET_BALANCE::response& res, epee::json_rpc::error& er, connection_context& cntx);
+ bool on_getaddress(const wallet_rpc::COMMAND_RPC_GET_ADDRESS::request& req, wallet_rpc::COMMAND_RPC_GET_ADDRESS::response& res, epee::json_rpc::error& er, connection_context& cntx);
bool on_transfer(const wallet_rpc::COMMAND_RPC_TRANSFER::request& req, wallet_rpc::COMMAND_RPC_TRANSFER::response& res, epee::json_rpc::error& er, connection_context& cntx);
bool on_store(const wallet_rpc::COMMAND_RPC_STORE::request& req, wallet_rpc::COMMAND_RPC_STORE::response& res, epee::json_rpc::error& er, connection_context& cntx);
bool on_get_payments(const wallet_rpc::COMMAND_RPC_GET_PAYMENTS::request& req, wallet_rpc::COMMAND_RPC_GET_PAYMENTS::response& res, epee::json_rpc::error& er, connection_context& cntx);
diff --git a/src/wallet/wallet_rpc_server_commans_defs.h b/src/wallet/wallet_rpc_server_commans_defs.h
index b99d92ca2..cc005b29c 100644
--- a/src/wallet/wallet_rpc_server_commans_defs.h
+++ b/src/wallet/wallet_rpc_server_commans_defs.h
@@ -34,6 +34,24 @@ namespace wallet_rpc
};
};
+ struct COMMAND_RPC_GET_ADDRESS
+ {
+ struct request
+ {
+ BEGIN_KV_SERIALIZE_MAP()
+ END_KV_SERIALIZE_MAP()
+ };
+
+ struct response
+ {
+ std::string address;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(address)
+ END_KV_SERIALIZE_MAP()
+ };
+ };
+
struct trnsfer_destination
{
uint64_t amount;