Commit 175faeca authored by Pierre Kim's avatar Pierre Kim

Add RPC call 'getaddress'

parent 084e456a
......@@ -88,7 +88,11 @@ void wallet_rpc_server::processRequest(const CryptoNote::HttpRequest& request, C
jsonRequest.parseRequest(request.getBody());
jsonResponse.setId(jsonRequest.getId());
//Simplewallet API calls list
static std::unordered_map<std::string, JsonMemberMethod> s_methods = {
{ "getaddress", makeMemberMethod(&wallet_rpc_server::on_getaddress) },
{ "getbalance", makeMemberMethod(&wallet_rpc_server::on_getbalance) },
{ "transfer", makeMemberMethod(&wallet_rpc_server::on_transfer) },
{ "store", makeMemberMethod(&wallet_rpc_server::on_store) },
......@@ -114,6 +118,11 @@ void wallet_rpc_server::processRequest(const CryptoNote::HttpRequest& request, C
response.setBody(jsonResponse.getBody());
}
//------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server::on_getaddress(const wallet_rpc::COMMAND_RPC_GET_ADDRESS::request& req, wallet_rpc::COMMAND_RPC_GET_ADDRESS::response& res) {
res.address = m_wallet.getAddress();
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server::on_getbalance(const wallet_rpc::COMMAND_RPC_GET_BALANCE::request& req, wallet_rpc::COMMAND_RPC_GET_BALANCE::response& res) {
res.locked_amount = m_wallet.pendingBalance();
......
......@@ -46,6 +46,7 @@ namespace Tools
virtual void processRequest(const CryptoNote::HttpRequest& request, CryptoNote::HttpResponse& response) override;
//json_rpc
bool on_getaddress(const wallet_rpc::COMMAND_RPC_GET_ADDRESS::request& req, wallet_rpc::COMMAND_RPC_GET_ADDRESS::response& res);
bool on_getbalance(const wallet_rpc::COMMAND_RPC_GET_BALANCE::request& req, wallet_rpc::COMMAND_RPC_GET_BALANCE::response& res);
bool on_transfer(const wallet_rpc::COMMAND_RPC_TRANSFER::request& req, wallet_rpc::COMMAND_RPC_TRANSFER::response& res);
bool on_store(const wallet_rpc::COMMAND_RPC_STORE::request& req, wallet_rpc::COMMAND_RPC_STORE::response& res);
......
......@@ -19,6 +19,20 @@ using CryptoNote::ISerializer;
#define WALLET_RPC_STATUS_OK "OK"
#define WALLET_RPC_STATUS_BUSY "BUSY"
struct COMMAND_RPC_GET_ADDRESS
{
typedef CryptoNote::EMPTY_STRUCT request;
struct response
{
std::string address;
void serialize(ISerializer& s) {
KV_MEMBER(address)
}
};
};
struct COMMAND_RPC_GET_BALANCE
{
typedef CryptoNote::EMPTY_STRUCT request;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment