From 9f98a70fcf4a9a43402722de2d2e6a00393d44c1 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Wed, 18 Jan 2017 18:18:46 +0800 Subject: [PATCH] changed get to post requests in decoding outputs and prove sending --- main.cpp | 38 +++++++++++++++++++------- src/templates/partials/tx_details.html | 8 +++--- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/main.cpp b/main.cpp index 0bf260d..92b6c06 100644 --- a/main.cpp +++ b/main.cpp @@ -181,27 +181,45 @@ int main(int ac, const char* av[]) { return xmrblocks.show_tx(tx_hash, with_ring_signatures); }); - CROW_ROUTE(app, "/myoutputs").methods("GET"_method) + CROW_ROUTE(app, "/myoutputs").methods("POST"_method) ([&](const crow::request& req) { - string tx_hash = string(req.url_params.get("tx_hash")); - string xmr_address = string(req.url_params.get("xmr_address")); - string viewkey = string(req.url_params.get("viewkey")); + map post_body = xmreg::parse_crow_post_data(req.body); + + if (post_body.count("xmr_address") == 0 + || post_body.count("viewkey") == 0 + || post_body.count("tx_hash") == 0) + { + return string("xmr_address, viewkey or tx_hash not provided"); + } + + string tx_hash = post_body["tx_hash"]; + string xmr_address = post_body["xmr_address"]; + string viewkey = post_body["viewkey"]; return xmrblocks.show_my_outputs(tx_hash, xmr_address, viewkey); }); + CROW_ROUTE(app, "/prove").methods("POST"_method) + ([&](const crow::request& req) { - CROW_ROUTE(app, "/prove").methods("GET"_method) - ([&](const crow::request& req) { + map post_body = xmreg::parse_crow_post_data(req.body); - string tx_hash = string(req.url_params.get("txhash")); - string tx_prv_key = string(req.url_params.get("txprvkey")); - string xmr_address = string(req.url_params.get("xmraddress")); + if (post_body.count("xmr_address") == 0 + || post_body.count("txprvkey") == 0 + || post_body.count("tx_hash") == 0) + { + return string("xmr_address, txprvkey or tx_hash not provided"); + } - return xmrblocks.show_prove(tx_hash, xmr_address, tx_prv_key); + string tx_hash = post_body["tx_hash"];; + string tx_prv_key = post_body["txprvkey"];; + string xmr_address = post_body["xmr_address"];; + + return xmrblocks.show_prove(tx_hash, xmr_address, tx_prv_key); }); + CROW_ROUTE(app, "/rawtx") ([&](const crow::request& req) { return xmrblocks.show_rawtx(); diff --git a/src/templates/partials/tx_details.html b/src/templates/partials/tx_details.html index 26cf08f..65ffbe1 100644 --- a/src/templates/partials/tx_details.html +++ b/src/templates/partials/tx_details.html @@ -88,7 +88,7 @@
Note: these calculations are done on the server side, because there is no javascript -
+


@@ -109,10 +109,10 @@
Note: these calculations are done on the server side, because there is no javascript - -
+ +

-
+