From 479d6524ab8b2e9e0c8947b7eaf859c2b07e4099 Mon Sep 17 00:00:00 2001 From: Alexander Suprunenko Date: Thu, 23 May 2019 22:59:48 +0300 Subject: [PATCH] Partial build fix --- CMakeLists.txt | 5 +- graftlets/WalletAddress.cpp | 8 ++-- src/lib/graft/connection.cpp | 2 + src/lib/graft/task.cpp | 4 +- src/rta/fullsupernodelist.cpp | 2 +- src/rta/supernode.cpp | 6 +-- .../requests/auth_sample_disqualificator.cpp | 2 +- src/supernode/requests/authorize_rta_tx.cpp | 46 +++++++++---------- .../requests/blockchain_based_list.cpp | 2 +- src/supernode/requests/debug.cpp | 2 +- src/supernode/requests/pay.cpp | 8 ++-- src/supernode/requests/sale.cpp | 6 +-- src/supernode/requests/sale_details.cpp | 24 +++++----- src/supernode/requests/sale_status.cpp | 4 +- .../requests/send_supernode_announce.cpp | 4 +- src/supernode/server.cpp | 1 + src/supernode/supernode.cpp | 2 + src/walletnode/wallet_manager.cpp | 28 +++++------ 18 files changed, 84 insertions(+), 72 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15f44567..b05f6042 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,7 +89,8 @@ ExternalProject_Add( STAMP_DIR ${PROJECT_BINARY_DIR}/STAMP/cryptonode TMP_DIR ${PROJECT_BINARY_DIR}/TMP/cryptonode INSTALL_DIR ${PROJECT_BINARY_DIR}/BUILD - CMAKE_ARGS ${ExternalProjectCMakeArgs} -DSTATIC=ON -DARCH=x86-64 -DHAVE_EVP_MD_CTX_NEW=YES -DENABLE_SYSLOG=${ENABLE_SYSLOG} -DCMAKE_ROOT_SOURCE_DIR="\"${CMAKE_ROOT_SOURCE_DIR}\"" +# CMAKE_ARGS ${ExternalProjectCMakeArgs} -DSTATIC=ON -DARCH=x86-64 -DHAVE_EVP_MD_CTX_NEW=YES -DENABLE_SYSLOG=${ENABLE_SYSLOG} -DCMAKE_ROOT_SOURCE_DIR="\"${CMAKE_ROOT_SOURCE_DIR}\"" + CMAKE_ARGS ${ExternalProjectCMakeArgs} -DARCH=x86-64 -DHAVE_EVP_MD_CTX_NEW=YES -DENABLE_SYSLOG=${ENABLE_SYSLOG} -DCMAKE_ROOT_SOURCE_DIR="\"${CMAKE_ROOT_SOURCE_DIR}\"" ) set(CMAKE_CXX_STANDARD 17) @@ -174,7 +175,7 @@ endif() include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) # cryptonode dependencies # TODO: modify cryptonode CMakeLists.txt so it installs all required headers/libs -include_directories(${CRYPTONODE_INCLUDE_DIRS} "${CMAKE_BINARY_DIR}/version") +include_directories("${CMAKE_BINARY_DIR}/version" ${CRYPTONODE_INCLUDE_DIRS}) link_directories(${CRYPTONODE_LIB_DIRS}) ### graftlet_lib diff --git a/graftlets/WalletAddress.cpp b/graftlets/WalletAddress.cpp index fa32d8bf..dc7f53fb 100644 --- a/graftlets/WalletAddress.cpp +++ b/graftlets/WalletAddress.cpp @@ -35,8 +35,8 @@ #include "rta/supernode.h" #include "lib/graft/graft_exception.h" #include "cryptonote_basic/cryptonote_basic_impl.h" -#include "cryptonote_protocol/blobdatatype.h" -#include "file_io_utils.h" +#include "cryptonote_basic/blobdatatype.h" +#include "string_tools.h" #include @@ -70,14 +70,14 @@ graft::Status WalletAddress::getWalletAddressHandler(const graft::Router::vars_t if (ctx.local.getLastStatus() != graft::Status::None) { graft::supernode::request::GetWalletAddressErrorResponse err; - err.error = string("internal error: wrong status: " + to_string((int)ctx.local.getLastStatus())); + err.error = std::string("internal error: wrong status: " + std::to_string((int)ctx.local.getLastStatus())); return graft::Status::Error; } graft::SupernodePtr supernode = ctx.global.get(CONTEXT_KEY_SUPERNODE, graft::SupernodePtr()); if (!supernode) { graft::supernode::request::GetWalletAddressErrorResponse err; - err.error = string("supernode was not setup correctly"); + err.error = std::string("supernode was not setup correctly"); return graft::Status::Error; } diff --git a/src/lib/graft/connection.cpp b/src/lib/graft/connection.cpp index 2f363404..b9471c74 100644 --- a/src/lib/graft/connection.cpp +++ b/src/lib/graft/connection.cpp @@ -4,6 +4,8 @@ #include "lib/graft/sys_info.h" #include "lib/graft/graft_exception.h" +#include + #undef MONERO_DEFAULT_LOG_CATEGORY #define MONERO_DEFAULT_LOG_CATEGORY "supernode.connection" diff --git a/src/lib/graft/task.cpp b/src/lib/graft/task.cpp index 7197eb1b..81cfe040 100644 --- a/src/lib/graft/task.cpp +++ b/src/lib/graft/task.cpp @@ -8,6 +8,8 @@ #include "lib/graft/sys_info.h" #include "lib/graft/common/utils.h" +#include + #undef MONERO_DEFAULT_LOG_CATEGORY #define MONERO_DEFAULT_LOG_CATEGORY "supernode.task" @@ -722,7 +724,7 @@ void TaskManager::postponeTask(BaseTaskPtr bt) assert(res.second.getInputPtr()); bt->getParams().input = *res.second.getInputPtr(); m_readyToResume.push_back(bt); - LOG_PRINT_RQS_BT(2,bt,"for the task with uuid '" << uuid << "' an answer found; it will be resumed."); + LOG_PRINT_RQS_BT(2,bt,"for the task with uuid '" << boost::uuids::to_string(uuid) << "' an answer found; it will be resumed."); return; } diff --git a/src/rta/fullsupernodelist.cpp b/src/rta/fullsupernodelist.cpp index de25495a..3c540338 100644 --- a/src/rta/fullsupernodelist.cpp +++ b/src/rta/fullsupernodelist.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/rta/supernode.cpp b/src/rta/supernode.cpp index d9ccdaa2..6519859c 100644 --- a/src/rta/supernode.cpp +++ b/src/rta/supernode.cpp @@ -308,17 +308,17 @@ bool Supernode::saveKeys(const string &filename, bool force) return true; } -const public_key &Supernode::idKey() const +const crypto::public_key &Supernode::idKey() const { return m_id_key; } -const secret_key &Supernode::secretKey() const +const crypto::secret_key &Supernode::secretKey() const { return m_secret_key; } -string Supernode::idKeyAsString() const +std::string Supernode::idKeyAsString() const { return epee::string_tools::pod_to_hex(m_id_key); } diff --git a/src/supernode/requests/auth_sample_disqualificator.cpp b/src/supernode/requests/auth_sample_disqualificator.cpp index c12ddb88..054f4040 100644 --- a/src/supernode/requests/auth_sample_disqualificator.cpp +++ b/src/supernode/requests/auth_sample_disqualificator.cpp @@ -349,7 +349,7 @@ class AuthSDisqualificatorImpl : public AuthSDisqualificator, public BBLDisquali //create wallet std::string addr = ctx.global["cryptonode_rpc_address"]; bool testnet = ctx.global["testnet"]; - tools::wallet2 wallet(testnet); + tools::wallet2 wallet(testnet? cryptonote::TESTNET : cryptonote::MAINNET ); wallet.init(addr); wallet.set_refresh_from_block_height(coll.di.item.block_height); wallet.set_seed_language("English"); diff --git a/src/supernode/requests/authorize_rta_tx.cpp b/src/supernode/requests/authorize_rta_tx.cpp index f8d61492..92fb9f70 100644 --- a/src/supernode/requests/authorize_rta_tx.cpp +++ b/src/supernode/requests/authorize_rta_tx.cpp @@ -139,7 +139,7 @@ void putRtaSignaturesToTx(cryptonote::transaction &tx, const std::vectorsignMessage(arg.tx_id + ":" + to_string(arg.result), sign); + supernode->signMessage(arg.tx_id + ":" + std::to_string(arg.result), sign); arg.signature.result_signature = epee::string_tools::pod_to_hex(sign); crypto::hash tx_id; epee::string_tools::hex_to_pod(arg.tx_id, tx_id); @@ -177,7 +177,7 @@ bool validateAuthResponse(const AuthorizeRtaTxResponse &arg, const SupernodePtr - std::string msg = arg.tx_id + ":" + to_string(arg.result); + std::string msg = arg.tx_id + ":" + std::to_string(arg.result); crypto::public_key id_key; epee::string_tools::hex_to_pod(arg.signature.id_key, id_key); bool r1 = supernode->verifySignature(msg, id_key, sign_result); @@ -195,7 +195,7 @@ Status storeRequestAndReplyOk(const Router::vars_t& vars, const graft::Input& in // here request parsed for the logging purposes. normally we don't need to parse it here; MulticastRequestJsonRpc req; if (!input.get(req)) { // can't parse request - return errorCustomError(string("failed to parse request: ") + input.data(), ERROR_INVALID_REQUEST, output); + return errorCustomError(std::string("failed to parse request: ") + input.data(), ERROR_INVALID_REQUEST, output); } SupernodePtr supernode = ctx.global.get(CONTEXT_KEY_SUPERNODE, SupernodePtr()); @@ -240,12 +240,12 @@ Status handleTxAuthRequest(const Router::vars_t& vars, const graft::Input& /*inp } graft::Input input; - string body = ctx.local["request"]; + std::string body = ctx.local["request"]; input.body = body; MulticastRequestJsonRpc req; if (!input.get(req)) { // can't parse request - return errorCustomError(string("failed to parse request: ") + input.data(), ERROR_INVALID_REQUEST, output); + return errorCustomError(std::string("failed to parse request: ") + input.data(), ERROR_INVALID_REQUEST, output); } SupernodePtr supernode = ctx.global.get(CONTEXT_KEY_SUPERNODE, SupernodePtr()); @@ -273,7 +273,7 @@ Status handleTxAuthRequest(const Router::vars_t& vars, const graft::Input& /*inp return errorInvalidTransaction(authReq.tx_hex, output); } - string tx_id_str = epee::string_tools::pod_to_hex(tx_hash); + std::string tx_id_str = epee::string_tools::pod_to_hex(tx_hash); MDEBUG("incoming auth req for payment: " << authReq.payment_id << ", tx_id: " << tx_id_str); // check if we already processed this tx @@ -350,7 +350,7 @@ Status handleCryptonodeMulticastStatus(const Router::vars_t& vars, const graft:: if (!input.get(resp) || resp.error.code != 0 || resp.result.status != STATUS_OK) { return errorInternalError("Error multicasting request", output); } - string payment_id_local = ctx.local["payment_id"]; + std::string payment_id_local = ctx.local["payment_id"]; MDEBUG("tx auth response multicast ask received for payment: " << payment_id_local); AuthorizeRtaTxRequestJsonRpcResponse out; @@ -379,7 +379,7 @@ Status handleRtaAuthResponseMulticast(const Router::vars_t& vars, const graft::I if (!input.get(req)) { // can't parse request LOG_ERROR("failed to parse request: " + input.data()); - return errorCustomError(string("failed to parse request: ") + input.data(), ERROR_INVALID_REQUEST, output); + return errorCustomError(std::string("failed to parse request: ") + input.data(), ERROR_INVALID_REQUEST, output); } // TODO: check if our address is listed in "receiver_addresses" @@ -403,13 +403,13 @@ Status handleRtaAuthResponseMulticast(const Router::vars_t& vars, const graft::I } - string ctx_payment_id_key = rtaAuthResp.tx_id + CONTEXT_KEY_PAYMENT_ID_BY_TXID; + std::string ctx_payment_id_key = rtaAuthResp.tx_id + CONTEXT_KEY_PAYMENT_ID_BY_TXID; if (!ctx.global.hasKey(ctx_payment_id_key)) { LOG_ERROR("no payment_id for tx: " << rtaAuthResp.tx_id); - return errorCustomError(string("unknown tx: ") + rtaAuthResp.tx_id, ERROR_INTERNAL_ERROR, output); + return errorCustomError(std::string("unknown tx: ") + rtaAuthResp.tx_id, ERROR_INTERNAL_ERROR, output); } - string payment_id = ctx.global.get(ctx_payment_id_key, std::string()); + std::string payment_id = ctx.global.get(ctx_payment_id_key, std::string()); MDEBUG("incoming tx auth response payment: " << payment_id << ", tx_id: " << rtaAuthResp.tx_id << ", from: " << rtaAuthResp.signature.id_key @@ -421,7 +421,7 @@ Status handleRtaAuthResponseMulticast(const Router::vars_t& vars, const graft::I // validate signature bool signOk = validateAuthResponse(rtaAuthResp, supernode); if (!signOk) { - string msg = "failed to validate signature for rta auth response"; + std::string msg = "failed to validate signature for rta auth response"; LOG_ERROR(msg); return errorCustomError(msg, ERROR_RTA_SIGNATURE_FAILED, @@ -429,14 +429,14 @@ Status handleRtaAuthResponseMulticast(const Router::vars_t& vars, const graft::I } // stop handling it if we already processed response RtaAuthResult authResult; - string ctx_tx_to_auth_resp = rtaAuthResp.tx_id + CONTEXT_KEY_AUTH_RESULT_BY_TXID; + std::string ctx_tx_to_auth_resp = rtaAuthResp.tx_id + CONTEXT_KEY_AUTH_RESULT_BY_TXID; if (ctx.global.hasKey(ctx_tx_to_auth_resp)) { authResult = ctx.global.get(ctx_tx_to_auth_resp, authResult); } if (authResult.alreadyApproved(rtaAuthResp.signature.id_key) || authResult.alreadyRejected(rtaAuthResp.signature.id_key)) { - return errorCustomError(string("supernode: ") + rtaAuthResp.signature.id_key + " already processed", + return errorCustomError(std::string("supernode: ") + rtaAuthResp.signature.id_key + " already processed", ERROR_ADDRESS_INVALID, output); } @@ -452,7 +452,7 @@ Status handleRtaAuthResponseMulticast(const Router::vars_t& vars, const graft::I // store result in context ctx.global.set(ctx_tx_to_auth_resp, authResult, RTA_TX_TTL); if (!ctx.global.hasKey(rtaAuthResp.tx_id + CONTEXT_KEY_AMOUNT_BY_TX_ID)) { - string msg = string("no amount found for tx id: ") + rtaAuthResp.tx_id; + std::string msg = std::string("no amount found for tx id: ") + rtaAuthResp.tx_id; LOG_ERROR(msg); return errorCustomError(msg, ERROR_INTERNAL_ERROR, output); } @@ -468,7 +468,7 @@ Status handleRtaAuthResponseMulticast(const Router::vars_t& vars, const graft::I if (!ctx.global.hasKey(rtaAuthResp.tx_id + CONTEXT_KEY_TX_BY_TXID)) { - string msg = string("rta auth response processed but no tx found for tx id: ") + rtaAuthResp.tx_id; + std::string msg = std::string("rta auth response processed but no tx found for tx id: ") + rtaAuthResp.tx_id; LOG_ERROR(msg); return errorCustomError(msg, ERROR_INTERNAL_ERROR, output); } @@ -528,11 +528,11 @@ Status handleRtaAuthResponseMulticast(const Router::vars_t& vars, const graft::I } catch (const std::exception &e) { LOG_ERROR("std::exception catched: " << e.what()); - return errorInternalError(string("exception in cryptonode/authorize_rta_tx_response handler: ") + e.what(), + return errorInternalError(std::string("exception in cryptonode/authorize_rta_tx_response handler: ") + e.what(), output); } catch (...) { LOG_ERROR("unhandled exception"); - return errorInternalError(string("unknown exception in cryptonode/authorize_rta_tx_response handler"), + return errorInternalError(std::string("unknown exception in cryptonode/authorize_rta_tx_response handler"), output); } } @@ -544,12 +544,12 @@ Status handleCryptonodeTxPushResponse(const Router::vars_t& vars, const graft::I { MDEBUG(__FUNCTION__ << " begin for task: " << boost::uuids::to_string(ctx.getId())); - string payment_id_local = ctx.local["payment_id"]; + std::string payment_id_local = ctx.local["payment_id"]; MDEBUG("processing sendrawtransaction reply for payment: " << payment_id_local); SendRawTxResponse resp; // check if we have tx_id in local context - string tx_id = ctx.local[CONTEXT_TX_ID]; + std::string tx_id = ctx.local[CONTEXT_TX_ID]; if (tx_id.empty()) { LOG_ERROR("internal erorr, tx_id key not found in local context"); @@ -557,7 +557,7 @@ Status handleCryptonodeTxPushResponse(const Router::vars_t& vars, const graft::I } // obtain payment id for given tx_id - string payment_id = ctx.global.get(tx_id + CONTEXT_KEY_PAYMENT_ID_BY_TXID, std::string()); + std::string payment_id = ctx.global.get(tx_id + CONTEXT_KEY_PAYMENT_ID_BY_TXID, std::string()); if (payment_id.empty()) { LOG_ERROR("Internal error, payment id not found for tx id: " << tx_id); } @@ -611,7 +611,7 @@ Status handleStatusBroadcastResponse(const Router::vars_t& vars, const graft::In { // TODO: check if cryptonode broadcasted status MDEBUG(__FUNCTION__ << " begin"); - string payment_id_local = ctx.local["payment_id"]; + std::string payment_id_local = ctx.local["payment_id"]; MDEBUG("received status broadcasting result for payment: " << payment_id_local); BroadcastResponseFromCryptonodeJsonRpc in; JsonRpcErrorResponse error; @@ -654,7 +654,7 @@ Status authorizeRtaTxRequestHandler(const Router::vars_t& vars, const graft::Inp MDEBUG("cyptonode reply, payload: " << input.data()); return handleCryptonodeMulticastStatus(vars, input, ctx, output); default: // internal error - return errorInternalError(string("authorize_rta_tx_request: unhandled state: ") + to_string(int(state)), + return errorInternalError(std::string("authorize_rta_tx_request: unhandled state: ") + std::to_string(int(state)), output); }; } catch (const std::exception &e) { diff --git a/src/supernode/requests/blockchain_based_list.cpp b/src/supernode/requests/blockchain_based_list.cpp index 6b3945f9..fb76d3cf 100644 --- a/src/supernode/requests/blockchain_based_list.cpp +++ b/src/supernode/requests/blockchain_based_list.cpp @@ -717,7 +717,7 @@ class BBLDisqualificator : public BBLDisqualificatorBase //create wallet std::string addr = ctx.global["cryptonode_rpc_address"]; bool testnet = ctx.global["testnet"]; - tools::wallet2 wallet(testnet); + tools::wallet2 wallet(testnet? cryptonote::TESTNET : cryptonote::MAINNET); wallet.init(addr); wallet.set_refresh_from_block_height(m_block_height); wallet.set_seed_language("English"); diff --git a/src/supernode/requests/debug.cpp b/src/supernode/requests/debug.cpp index 4e560b45..f1787ad0 100644 --- a/src/supernode/requests/debug.cpp +++ b/src/supernode/requests/debug.cpp @@ -11,7 +11,7 @@ #include "rta/fullsupernodelist.h" #include -#include +#include #include #include diff --git a/src/supernode/requests/pay.cpp b/src/supernode/requests/pay.cpp index 27d882de..34291d82 100644 --- a/src/supernode/requests/pay.cpp +++ b/src/supernode/requests/pay.cpp @@ -12,7 +12,7 @@ #include "rta/fullsupernodelist.h" #include -#include +#include #include #undef MONERO_DEFAULT_LOG_CATEGORY @@ -127,7 +127,7 @@ Status handleClientPayRequest(const Router::vars_t& vars, const graft::Input& in return errorBuildAuthSample(output); } - string tx_hex; + std::string tx_hex; if (in.Transactions.empty()) { if (in.Account.empty()) { return errorInvalidTransaction("tx empty", output); @@ -198,7 +198,7 @@ Status handleWaitingTxReply(const Router::vars_t& vars, const graft::Input& inpu PayRequest payData = ctx.local[scPayClientHandlerKey]; // TODO: !implement tx vector in every interface! - string tx_hex = res.Transactions[0]; + std::string tx_hex = res.Transactions[0]; SupernodePtr supernode = ctx.global.get(CONTEXT_KEY_SUPERNODE, SupernodePtr()); FullSupernodeListPtr fsl = ctx.global.get(CONTEXT_KEY_FULLSUPERNODELIST, FullSupernodeListPtr()); @@ -273,7 +273,7 @@ Status handleStatusBroadcastReply(const Router::vars_t& vars, const graft::Input } // prepare reply to the client - string payment_id = ctx.local["payment_id"]; + std::string payment_id = ctx.local["payment_id"]; MDEBUG("status broadcast ask received for payment: " << payment_id); PayResponseJsonRpc out; out.result.Result = STATUS_OK; diff --git a/src/supernode/requests/sale.cpp b/src/supernode/requests/sale.cpp index 2a4dd871..f4d890eb 100644 --- a/src/supernode/requests/sale.cpp +++ b/src/supernode/requests/sale.cpp @@ -29,7 +29,7 @@ GRAFT_DEFINE_IO_STRUCT(SaleDataMulticast, (SaleData, sale_data), (std::string, paymentId), (int, status), - (string, details) + (std::string, details) ); enum class SaleHandlerState : int @@ -144,7 +144,7 @@ Status handleSaleMulticastReply(const Router::vars_t& vars, const graft::Input& SupernodePtr supernode = ctx.global.get(CONTEXT_KEY_SUPERNODE, SupernodePtr()); - string payment_id = ctx.local["payment_id"]; + std::string payment_id = ctx.local["payment_id"]; int status = ctx.global.get(payment_id + CONTEXT_KEY_STATUS, static_cast((RTAStatus::Waiting))); buildBroadcastSaleStatusOutput(payment_id, status, supernode, output); @@ -170,7 +170,7 @@ Status handleSaleStatusBroadcastReply(const Router::vars_t& vars, const graft::I // prepare reply to the client SaleData data = ctx.local["sale_data"]; - string payment_id = ctx.local["payment_id"]; + std::string payment_id = ctx.local["payment_id"]; SaleResponseJsonRpc out; out.result.BlockNumber = data.BlockNumber; out.result.PaymentID = payment_id; diff --git a/src/supernode/requests/sale_details.cpp b/src/supernode/requests/sale_details.cpp index c4bd1aaa..78b2806c 100644 --- a/src/supernode/requests/sale_details.cpp +++ b/src/supernode/requests/sale_details.cpp @@ -33,7 +33,7 @@ bool prepareSaleDetailsResponse(const SaleDetailsRequest &req, graft::Context &c if (!ctx.global.hasKey(req.PaymentID + CONTEXT_KEY_SALE)) { error.code = ERROR_PAYMENT_ID_INVALID; - error.message = string("sale data missing for payment: ") + req.PaymentID; + error.message = std::string("sale data missing for payment: ") + req.PaymentID; LOG_ERROR(__FUNCTION__ << " " << error.message); return false; } @@ -97,7 +97,7 @@ Status handleClientRequest(const Router::vars_t& vars, const graft::Input& input return Status::Ok; } - vector authSample; + std::vector authSample; uint64_t auth_sample_block_number = 0; FullSupernodeListPtr fsl = ctx.global.get(CONTEXT_KEY_FULLSUPERNODELIST, FullSupernodeListPtr()); SupernodePtr supernode = ctx.global.get(CONTEXT_KEY_SUPERNODE, SupernodePtr()); @@ -131,7 +131,7 @@ Status handleClientRequest(const Router::vars_t& vars, const graft::Input& input return sn->idKeyAsString() == supernode->idKeyAsString(); }) != authSample.end()) { - ostringstream oss; oss << authSample; + std::ostringstream oss; oss << authSample; std::string msg = "Internal error: our supernode is in auth sample but no sale details found for " + in.PaymentID + ", auth_sample: " + oss.str(); LOG_ERROR(msg); @@ -178,20 +178,20 @@ Status handleSaleDetailsResponse(const Router::vars_t& vars, const graft::Input& if (ctx.local.getLastStatus() != Status::Postpone) { - string msg = string("Expected postponed status but status is : " + to_string(int(ctx.local.getLastStatus()))); + std::string msg = std::string("Expected postponed status but status is : " + std::to_string(int(ctx.local.getLastStatus()))); LOG_ERROR(msg); return errorInternalError(msg, output); } - string task_id = boost::uuids::to_string(ctx.getId()); + std::string task_id = boost::uuids::to_string(ctx.getId()); if (!ctx.global.hasKey(task_id + CONTEXT_SALE_DETAILS_RESULT)) { - string msg = "no sale details response found for id: " + task_id; + std::string msg = "no sale details response found for id: " + task_id; LOG_ERROR(msg); return errorInternalError(msg, output); } Input inputLocal; - inputLocal.load(ctx.global.get(task_id + CONTEXT_SALE_DETAILS_RESULT, string())); + inputLocal.load(ctx.global.get(task_id + CONTEXT_SALE_DETAILS_RESULT, std::string())); UnicastRequestJsonRpc in; @@ -202,12 +202,12 @@ Status handleSaleDetailsResponse(const Router::vars_t& vars, const graft::Input& UnicastRequest unicastReq = in.params; SupernodePtr supernode = ctx.global.get(CONTEXT_KEY_SUPERNODE, SupernodePtr()); - string payment_id = ctx.local["payment_id"]; + std::string payment_id = ctx.local["payment_id"]; MDEBUG("received sale details from remote supernode: " << unicastReq.sender_address << ", payment: " << payment_id); if (unicastReq.receiver_address != supernode->idKeyAsString()) { - string msg = string("wrong receiver id: " + unicastReq.receiver_address + ", expected id: " + supernode->idKeyAsString()); + std::string msg = std::string("wrong receiver id: " + unicastReq.receiver_address + ", expected id: " + supernode->idKeyAsString()); LOG_ERROR(msg); return errorInternalError(msg, output); } @@ -269,7 +269,7 @@ Status handleSaleDetailsUnicastRequest(const Router::vars_t& vars, const graft:: SupernodePtr supernode = ctx.global.get(CONTEXT_KEY_SUPERNODE, SupernodePtr()); if (unicastReq.receiver_address != supernode->idKeyAsString()) { - string msg = string("wrong receiver id: " + supernode->idKeyAsString()); + std::string msg = std::string("wrong receiver id: " + supernode->idKeyAsString()); LOG_ERROR(msg); return sendOkResponseToCryptonode(output); // cryptonode doesn't care about any errors, it's job is only deliver request } @@ -285,7 +285,7 @@ Status handleSaleDetailsUnicastRequest(const Router::vars_t& vars, const graft:: return sendOkResponseToCryptonode(output); // cryptonode doesn't care about any errors, it's job is only deliver request } - vector authSample; + std::vector authSample; uint64_t auth_sample_block_number = 0; FullSupernodeListPtr fsl = ctx.global.get(CONTEXT_KEY_FULLSUPERNODELIST, FullSupernodeListPtr()); @@ -375,7 +375,7 @@ Status saleDetailsCallbackHandler(const Router::vars_t& vars, const graft::Input { if (vars.count("id") == 0) { - string msg = string("Can't parse request id from URL"); + std::string msg = std::string("Can't parse request id from URL"); LOG_ERROR(msg); return errorInternalError(msg, output); } diff --git a/src/supernode/requests/sale_status.cpp b/src/supernode/requests/sale_status.cpp index e9d4513a..0154a12f 100644 --- a/src/supernode/requests/sale_status.cpp +++ b/src/supernode/requests/sale_status.cpp @@ -2,7 +2,9 @@ #include "supernode/requests/sale_status.h" #include "supernode/requests/broadcast.h" #include "supernode/requestdefines.h" -#include + +#include "string_tools.h" +#include "misc_log_ex.h" #undef MONERO_DEFAULT_LOG_CATEGORY #define MONERO_DEFAULT_LOG_CATEGORY "supernode.salestatusrequest" diff --git a/src/supernode/requests/send_supernode_announce.cpp b/src/supernode/requests/send_supernode_announce.cpp index b692f8a8..e56af669 100644 --- a/src/supernode/requests/send_supernode_announce.cpp +++ b/src/supernode/requests/send_supernode_announce.cpp @@ -176,7 +176,7 @@ Status sendAnnounce(const graft::Router::vars_t& vars, const graft::Input& input MDEBUG("about to refresh supernode: " << supernode->idKeyAsString()); if (!supernode->refresh()) { - return errorCustomError(string("failed to refresh supernode: ") + supernode->idKeyAsString(), + return errorCustomError(std::string("failed to refresh supernode: ") + supernode->idKeyAsString(), ERROR_INTERNAL_ERROR, output); } @@ -184,7 +184,7 @@ Status sendAnnounce(const graft::Router::vars_t& vars, const graft::Input& input SendSupernodeAnnounceJsonRpcRequest req; if (!supernode->prepareAnnounce(req.params)) { - return errorCustomError(string("failed to prepare announce: ") + supernode->idKeyAsString(), + return errorCustomError(std::string("failed to prepare announce: ") + supernode->idKeyAsString(), ERROR_INTERNAL_ERROR, output); } diff --git a/src/supernode/server.cpp b/src/supernode/server.cpp index 679a6762..c43eaf9a 100644 --- a/src/supernode/server.cpp +++ b/src/supernode/server.cpp @@ -6,6 +6,7 @@ #include "lib/graft/graft_exception.h" #include "version.h" +#include #include #include #include diff --git a/src/supernode/supernode.cpp b/src/supernode/supernode.cpp index 3b59540e..c7478b8b 100644 --- a/src/supernode/supernode.cpp +++ b/src/supernode/supernode.cpp @@ -10,6 +10,8 @@ #include "lib/graft/graft_exception.h" #include +//#include +#include #undef MONERO_DEFAULT_LOG_CATEGORY #define MONERO_DEFAULT_LOG_CATEGORY "supernode.supernode" diff --git a/src/walletnode/wallet_manager.cpp b/src/walletnode/wallet_manager.cpp index 0edf6d76..4732a20a 100644 --- a/src/walletnode/wallet_manager.cpp +++ b/src/walletnode/wallet_manager.cpp @@ -57,22 +57,22 @@ struct URL URL(const std::string& url_s) { - const string prot_end("://"); + const std::string prot_end("://"); - string::const_iterator prot_i = search(url_s.begin(), url_s.end(), prot_end.begin(), prot_end.end()); + std::string::const_iterator prot_i = search(url_s.begin(), url_s.end(), prot_end.begin(), prot_end.end()); protocol.reserve(distance(url_s.begin(), prot_i)); - transform(url_s.begin(), prot_i, back_inserter(protocol), ptr_fun(tolower)); // protocol is icase + transform(url_s.begin(), prot_i, back_inserter(protocol), std::ptr_fun(tolower)); // protocol is icase if( prot_i == url_s.end() ) return; advance(prot_i, prot_end.length()); - string::const_iterator port_i = find(prot_i, url_s.end(), ':'); + std::string::const_iterator port_i = find(prot_i, url_s.end(), ':'); - string::const_iterator path_i = find(prot_i, url_s.end(), '/'); + std::string::const_iterator path_i = find(prot_i, url_s.end(), '/'); if (port_i == url_s.end()) { @@ -80,18 +80,18 @@ struct URL port = "80"; //todo: make port based on protocol - transform(prot_i, path_i, back_inserter(host), ptr_fun(tolower)); // host is icase + transform(prot_i, path_i, back_inserter(host), std::ptr_fun(tolower)); // host is icase } else { host.reserve(distance(prot_i, port_i)); - transform(prot_i, port_i, back_inserter(host), ptr_fun(tolower)); // host is icase + std::transform(prot_i, port_i, back_inserter(host), std::ptr_fun(tolower)); // host is icase port.assign(port_i + 1, path_i); } - string::const_iterator query_i = find(path_i, url_s.end(), '?'); + std::string::const_iterator query_i = find(path_i, url_s.end(), '?'); path.assign(path_i, query_i); @@ -169,7 +169,7 @@ struct WalletManager::WalletHolder StrandX strand; WalletHolder(ThreadPoolX& thread_pool, bool testnet) - : wallet(testnet) + : wallet(testnet? cryptonote::TESTNET : cryptonote::MAINNET) , strand(thread_pool, WALLET_TRANSACTIONS_QUEUE_SIZE) { } @@ -233,7 +233,9 @@ void WalletManager::runAsyncForWallet wallet->wallet.load_cache(cache_file_name); - wallet->wallet.refresh(); +//TODO: +// wallet->wallet.refresh(); + wallet->wallet.refresh(true); WebHookCallback callback(callback_url.c_str()); @@ -309,7 +311,7 @@ void WalletManager::createAccount(Context& context, const std::string& password, crypto::secret_key secret_key = wallet->wallet.generateFromData(password); std::string account_data = wallet->wallet.getAccountData(password); const cryptonote::account_base& account = wallet->wallet.get_account(); - std::string public_address = account.get_public_address_str(m_testnet); + std::string public_address = account.get_public_address_str(m_testnet? cryptonote::TESTNET : cryptonote::MAINNET); std::string view_key (&account.get_keys().m_view_secret_key.data[0], sizeof(account.get_keys().m_view_secret_key.data)); std::string seed; @@ -369,7 +371,7 @@ void WalletManager::restoreAccount(Context& context, const std::string& password crypto::secret_key secret_key = wallet->wallet.generateFromData(password, recovery_key, true); const cryptonote::account_base& account = wallet->wallet.get_account(); - std::string public_address = account.get_public_address_str(m_testnet); + std::string public_address = account.get_public_address_str(m_testnet? cryptonote::TESTNET : cryptonote::MAINNET); std::string account_data = wallet->wallet.getAccountData(password); std::string view_key (&account.get_keys().m_view_secret_key.data[0], sizeof(account.get_keys().m_view_secret_key.data)); std::string seed; @@ -546,7 +548,7 @@ void WalletManager::requestTransactionHistory Transfer transfer; transfer.Amount = d.amount; - transfer.Address = get_account_address_as_str(wallet.testnet(), d.addr); + transfer.Address = cryptonote::get_account_address_as_str(wallet.testnet()? cryptonote::TESTNET : cryptonote::MAINNET, d.addr); info.Transfers.emplace_back(std::move(transfer)); }