src: add net type and daemon address to wallet rpc
This commit is contained in:
parent
caa62bc9ea
commit
56ca0a3227
|
@ -845,6 +845,26 @@ namespace tools
|
|||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool wallet_rpc_server::on_getinfo(const wallet_rpc::COMMAND_RPC_GET_INFO::request& req, wallet_rpc::COMMAND_RPC_GET_INFO::response& res, epee::json_rpc::error& er, const connection_context *ctx)
|
||||
{
|
||||
try
|
||||
{
|
||||
cryptonote::network_type net_type = nettype();
|
||||
|
||||
res.mainnet = net_type == cryptonote::MAINNET;
|
||||
res.testnet = net_type == cryptonote::TESTNET;
|
||||
res.stagenet = net_type == cryptonote::STAGENET;
|
||||
res.nettype = net_type == cryptonote::MAINNET ? "mainnet" : net_type == cryptonote::TESTNET ? "testnet" : net_type == cryptonote::STAGENET ? "stagenet" : "fakechain";
|
||||
res.daemon_address = get_daemon_address();
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
handle_rpc_exception(std::current_exception(), er, WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool wallet_rpc_server::on_freeze(const wallet_rpc::COMMAND_RPC_FREEZE::request& req, wallet_rpc::COMMAND_RPC_FREEZE::response& res, epee::json_rpc::error& er, const connection_context *ctx)
|
||||
|
|
|
@ -61,6 +61,20 @@ namespace tools
|
|||
void stop();
|
||||
void set_wallet(wallet2 *cr);
|
||||
|
||||
cryptonote::network_type nettype() const {
|
||||
if (tools::wallet2::has_testnet_option(m_vm))
|
||||
return cryptonote::TESTNET;
|
||||
if (tools::wallet2::has_stagenet_option(m_vm))
|
||||
return cryptonote::STAGENET;
|
||||
return cryptonote::MAINNET;
|
||||
}
|
||||
|
||||
std::string get_daemon_address() const {
|
||||
if (m_wallet)
|
||||
return m_wallet->get_daemon_address();
|
||||
return "";
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
CHAIN_HTTP_TO_MAP2(connection_context); //forward http requests to uri map
|
||||
|
@ -83,6 +97,7 @@ namespace tools
|
|||
MAP_JON_RPC_WE("set_account_tag_description", on_set_account_tag_description, wallet_rpc::COMMAND_RPC_SET_ACCOUNT_TAG_DESCRIPTION)
|
||||
MAP_JON_RPC_WE("get_height", on_getheight, wallet_rpc::COMMAND_RPC_GET_HEIGHT)
|
||||
MAP_JON_RPC_WE("getheight", on_getheight, wallet_rpc::COMMAND_RPC_GET_HEIGHT)
|
||||
MAP_JON_RPC_WE("get_info", on_getinfo, wallet_rpc::COMMAND_RPC_GET_INFO)
|
||||
MAP_JON_RPC_WE("freeze", on_freeze, wallet_rpc::COMMAND_RPC_FREEZE)
|
||||
MAP_JON_RPC_WE("thaw", on_thaw, wallet_rpc::COMMAND_RPC_THAW)
|
||||
MAP_JON_RPC_WE("frozen", on_frozen, wallet_rpc::COMMAND_RPC_FROZEN)
|
||||
|
@ -180,6 +195,7 @@ namespace tools
|
|||
bool on_untag_accounts(const wallet_rpc::COMMAND_RPC_UNTAG_ACCOUNTS::request& req, wallet_rpc::COMMAND_RPC_UNTAG_ACCOUNTS::response& res, epee::json_rpc::error& er, const connection_context *ctx = NULL);
|
||||
bool on_set_account_tag_description(const wallet_rpc::COMMAND_RPC_SET_ACCOUNT_TAG_DESCRIPTION::request& req, wallet_rpc::COMMAND_RPC_SET_ACCOUNT_TAG_DESCRIPTION::response& res, epee::json_rpc::error& er, const connection_context *ctx = NULL);
|
||||
bool on_getheight(const wallet_rpc::COMMAND_RPC_GET_HEIGHT::request& req, wallet_rpc::COMMAND_RPC_GET_HEIGHT::response& res, epee::json_rpc::error& er, const connection_context *ctx = NULL);
|
||||
bool on_getinfo(const wallet_rpc::COMMAND_RPC_GET_INFO::request& req, wallet_rpc::COMMAND_RPC_GET_INFO::response& res, epee::json_rpc::error& er, const connection_context *ctx = NULL);
|
||||
bool on_freeze(const wallet_rpc::COMMAND_RPC_FREEZE::request& req, wallet_rpc::COMMAND_RPC_FREEZE::response& res, epee::json_rpc::error& er, const connection_context *ctx = NULL);
|
||||
bool on_thaw(const wallet_rpc::COMMAND_RPC_THAW::request& req, wallet_rpc::COMMAND_RPC_THAW::response& res, epee::json_rpc::error& er, const connection_context *ctx = NULL);
|
||||
bool on_frozen(const wallet_rpc::COMMAND_RPC_FROZEN::request& req, wallet_rpc::COMMAND_RPC_FROZEN::response& res, epee::json_rpc::error& er, const connection_context *ctx = NULL);
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
// advance which version they will stop working with
|
||||
// Don't go over 32767 for any of these
|
||||
#define WALLET_RPC_VERSION_MAJOR 1
|
||||
#define WALLET_RPC_VERSION_MINOR 27
|
||||
#define WALLET_RPC_VERSION_MINOR 28
|
||||
#define MAKE_WALLET_RPC_VERSION(major,minor) (((major)<<16)|(minor))
|
||||
#define WALLET_RPC_VERSION MAKE_WALLET_RPC_VERSION(WALLET_RPC_VERSION_MAJOR, WALLET_RPC_VERSION_MINOR)
|
||||
namespace tools
|
||||
|
@ -447,7 +447,34 @@ namespace wallet_rpc
|
|||
};
|
||||
typedef epee::misc_utils::struct_init<response_t> response;
|
||||
};
|
||||
|
||||
struct COMMAND_RPC_GET_INFO
|
||||
{
|
||||
struct request_t
|
||||
{
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
typedef epee::misc_utils::struct_init<request_t> request;
|
||||
|
||||
struct response_t
|
||||
{
|
||||
std::string daemon_address;
|
||||
std::string nettype;
|
||||
bool mainnet;
|
||||
bool testnet;
|
||||
bool stagenet;
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(daemon_address)
|
||||
KV_SERIALIZE(nettype)
|
||||
KV_SERIALIZE(mainnet)
|
||||
KV_SERIALIZE(testnet)
|
||||
KV_SERIALIZE(stagenet)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
typedef epee::misc_utils::struct_init<response_t> response;
|
||||
};
|
||||
|
||||
struct transfer_destination
|
||||
{
|
||||
uint64_t amount;
|
||||
|
|
Loading…
Reference in New Issue