aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet_rpc_server.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-11-28 14:07:25 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-11-28 17:54:22 +0000
commit82ba2108e98ab3f2695232fd45101bdc257e525a (patch)
tree68d2fcf0d962172f7012636fe6cd257d052a979a /src/wallet/wallet_rpc_server.cpp
parentepee: add functions to convert from URL format (ie, %XX values) (diff)
downloadmonero-82ba2108e98ab3f2695232fd45101bdc257e525a.tar.xz
wallet: add API and RPC to create/parse monero: URIs
Diffstat (limited to '')
-rw-r--r--src/wallet/wallet_rpc_server.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index f1c3faa3e..fb0bf36a6 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -1075,6 +1075,33 @@ namespace tools
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
+ bool wallet_rpc_server::on_make_uri(const wallet_rpc::COMMAND_RPC_MAKE_URI::request& req, wallet_rpc::COMMAND_RPC_MAKE_URI::response& res, epee::json_rpc::error& er)
+ {
+ std::string error;
+ std::string uri = m_wallet.make_uri(req.address, req.payment_id, req.amount, req.tx_description, req.recipient_name, error);
+ if (uri.empty())
+ {
+ er.code = WALLET_RPC_ERROR_CODE_WRONG_URI;
+ er.message = std::string("Cannot make URI from supplied parameters: ") + error;
+ return false;
+ }
+
+ res.uri = uri;
+ return true;
+ }
+ //------------------------------------------------------------------------------------------------------------------------------
+ bool wallet_rpc_server::on_parse_uri(const wallet_rpc::COMMAND_RPC_PARSE_URI::request& req, wallet_rpc::COMMAND_RPC_PARSE_URI::response& res, epee::json_rpc::error& er)
+ {
+ std::string error;
+ if (!m_wallet.parse_uri(req.uri, res.uri.address, res.uri.payment_id, res.uri.amount, res.uri.tx_description, res.uri.recipient_name, res.unknown_parameters, error))
+ {
+ er.code = WALLET_RPC_ERROR_CODE_WRONG_URI;
+ er.message = "Error parsing URI: " + error;
+ return false;
+ }
+ return true;
+ }
+ //------------------------------------------------------------------------------------------------------------------------------
}
int main(int argc, char** argv) {