|
|
@ -13,6 +13,21 @@ using boost::filesystem::path;
|
|
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace myxmr
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
struct jsonresponse: crow::response
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
jsonresponse(const nlohmann::json& _body) : crow::response {_body.dump()}
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
add_header("Access-Control-Allow-Origin", "*");
|
|
|
|
|
|
|
|
add_header("Access-Control-Allow-Headers", "Content-Type");
|
|
|
|
|
|
|
|
add_header("Content-Type", "application/json");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main(int ac, const char* av[]) {
|
|
|
|
int main(int ac, const char* av[]) {
|
|
|
|
|
|
|
|
|
|
|
|
// get command line options
|
|
|
|
// get command line options
|
|
|
@ -343,11 +358,7 @@ int main(int ac, const char* av[]) {
|
|
|
|
CROW_ROUTE(app, "/api/transaction/<string>")
|
|
|
|
CROW_ROUTE(app, "/api/transaction/<string>")
|
|
|
|
([&](const crow::request &req, string tx_hash) {
|
|
|
|
([&](const crow::request &req, string tx_hash) {
|
|
|
|
|
|
|
|
|
|
|
|
crow::response r{xmrblocks.json_transaction(tx_hash).dump()};
|
|
|
|
myxmr::jsonresponse r{xmrblocks.json_transaction(tx_hash)};
|
|
|
|
|
|
|
|
|
|
|
|
r.add_header("Access-Control-Allow-Origin", "*");
|
|
|
|
|
|
|
|
r.add_header("Access-Control-Allow-Headers", "Content-Type");
|
|
|
|
|
|
|
|
r.add_header("Content-Type", "application/json");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return r;
|
|
|
|
return r;
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -355,11 +366,7 @@ int main(int ac, const char* av[]) {
|
|
|
|
CROW_ROUTE(app, "/api/block/<string>")
|
|
|
|
CROW_ROUTE(app, "/api/block/<string>")
|
|
|
|
([&](const crow::request &req, string block_no_or_hash) {
|
|
|
|
([&](const crow::request &req, string block_no_or_hash) {
|
|
|
|
|
|
|
|
|
|
|
|
crow::response r{xmrblocks.json_block(block_no_or_hash).dump()};
|
|
|
|
myxmr::jsonresponse r{xmrblocks.json_block(block_no_or_hash)};
|
|
|
|
|
|
|
|
|
|
|
|
r.add_header("Access-Control-Allow-Origin", "*");
|
|
|
|
|
|
|
|
r.add_header("Access-Control-Allow-Headers", "Content-Type");
|
|
|
|
|
|
|
|
r.add_header("Content-Type", "application/json");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return r;
|
|
|
|
return r;
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -374,11 +381,7 @@ int main(int ac, const char* av[]) {
|
|
|
|
string limit = regex_search(req.raw_url, regex {"limit=\\d+"}) ?
|
|
|
|
string limit = regex_search(req.raw_url, regex {"limit=\\d+"}) ?
|
|
|
|
req.url_params.get("limit") : "25";
|
|
|
|
req.url_params.get("limit") : "25";
|
|
|
|
|
|
|
|
|
|
|
|
crow::response r{xmrblocks.json_transactions(page, limit).dump()};
|
|
|
|
myxmr::jsonresponse r{xmrblocks.json_transactions(page, limit)};
|
|
|
|
|
|
|
|
|
|
|
|
r.add_header("Access-Control-Allow-Origin", "*");
|
|
|
|
|
|
|
|
r.add_header("Access-Control-Allow-Headers", "Content-Type");
|
|
|
|
|
|
|
|
r.add_header("Content-Type", "application/json");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return r;
|
|
|
|
return r;
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -386,11 +389,7 @@ int main(int ac, const char* av[]) {
|
|
|
|
CROW_ROUTE(app, "/api/mempool")
|
|
|
|
CROW_ROUTE(app, "/api/mempool")
|
|
|
|
([&](const crow::request &req) {
|
|
|
|
([&](const crow::request &req) {
|
|
|
|
|
|
|
|
|
|
|
|
crow::response r{xmrblocks.json_mempool().dump()};
|
|
|
|
myxmr::jsonresponse r{xmrblocks.json_mempool()};
|
|
|
|
|
|
|
|
|
|
|
|
r.add_header("Access-Control-Allow-Origin", "*");
|
|
|
|
|
|
|
|
r.add_header("Access-Control-Allow-Headers", "Content-Type");
|
|
|
|
|
|
|
|
r.add_header("Content-Type", "application/json");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return r;
|
|
|
|
return r;
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -398,11 +397,7 @@ int main(int ac, const char* av[]) {
|
|
|
|
CROW_ROUTE(app, "/api/search/<string>")
|
|
|
|
CROW_ROUTE(app, "/api/search/<string>")
|
|
|
|
([&](const crow::request &req, string search_value) {
|
|
|
|
([&](const crow::request &req, string search_value) {
|
|
|
|
|
|
|
|
|
|
|
|
crow::response r{xmrblocks.json_search(search_value).dump()};
|
|
|
|
myxmr::jsonresponse r{xmrblocks.json_search(search_value)};
|
|
|
|
|
|
|
|
|
|
|
|
r.add_header("Access-Control-Allow-Origin", "*");
|
|
|
|
|
|
|
|
r.add_header("Access-Control-Allow-Headers", "Content-Type");
|
|
|
|
|
|
|
|
r.add_header("Content-Type", "application/json");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return r;
|
|
|
|
return r;
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -421,21 +416,18 @@ int main(int ac, const char* av[]) {
|
|
|
|
|
|
|
|
|
|
|
|
bool tx_prove{false};
|
|
|
|
bool tx_prove{false};
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
tx_prove = regex_search(req.raw_url, regex {"txprove=[01]"}) ?
|
|
|
|
tx_prove = regex_search(req.raw_url, regex {"txprove=[01]"}) ?
|
|
|
|
boost::lexical_cast<bool>(req.url_params.get("txprove")) :
|
|
|
|
boost::lexical_cast<bool>(req.url_params.get("txprove")) :
|
|
|
|
false;
|
|
|
|
false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (const boost::bad_lexical_cast &e) {
|
|
|
|
catch (const boost::bad_lexical_cast &e)
|
|
|
|
|
|
|
|
{
|
|
|
|
cerr << "Cant parse tx_prove as bool. Using default value" << endl;
|
|
|
|
cerr << "Cant parse tx_prove as bool. Using default value" << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
crow::response r{xmrblocks.json_outputs(
|
|
|
|
myxmr::jsonresponse r{xmrblocks.json_outputs(tx_hash, address, viewkey, tx_prove)};
|
|
|
|
tx_hash, address, viewkey, tx_prove).dump()};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
r.add_header("Access-Control-Allow-Origin", "*");
|
|
|
|
|
|
|
|
r.add_header("Access-Control-Allow-Headers", "Content-Type");
|
|
|
|
|
|
|
|
r.add_header("Content-Type", "application/json");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return r;
|
|
|
|
return r;
|
|
|
|
});
|
|
|
|
});
|
|
|
|