diff --git a/src/crypto/zarcanum.h b/src/crypto/zarcanum.h index 3fe4b5c1..55e6b202 100644 --- a/src/crypto/zarcanum.h +++ b/src/crypto/zarcanum.h @@ -123,6 +123,15 @@ namespace crypto return generate_schnorr_sig(m, point_t(A), scalar_t(secret_a), result); } + inline bool generate_schnorr_sig(const hash& m, const secret_key& secret_a, generic_schnorr_sig& result) + { + scalar_t secret_a_s(secret_a); + if (!secret_a_s.is_reduced()) + return false; + point_t A = secret_a_s * c_point_G; + return generate_schnorr_sig_custom_generator(m, A, secret_a_s, result, c_point_G); + } + template inline bool verify_schnorr_sig(const hash& m, const public_key& A, const generic_schnorr_sig& sig) noexcept; diff --git a/src/currency_core/currency_basic.h b/src/currency_core/currency_basic.h index 9e25b396..0b68379b 100644 --- a/src/currency_core/currency_basic.h +++ b/src/currency_core/currency_basic.h @@ -843,7 +843,7 @@ namespace currency struct asset_operation_ownership_proof_eth { - crypto::eth_signature eth_sig; + crypto::eth_signature eth_sig; // 64 bytes uint8_t version = 0; BEGIN_VERSIONED_SERIALIZE(0, version) diff --git a/src/currency_core/currency_format_utils.h b/src/currency_core/currency_format_utils.h index 0aa22de2..c654aee6 100644 --- a/src/currency_core/currency_format_utils.h +++ b/src/currency_core/currency_format_utils.h @@ -950,6 +950,12 @@ namespace currency } } //--------------------------------------------------------------- + template + typename std::enable_if_t, std::ostream&> operator<<(std::ostream& o, invocable_t callee) + { + callee(o); + return o; + } //--------------------------------------------------------------- std::ostream& operator <<(std::ostream& o, const ref_by_id& r); std::ostream& operator <<(std::ostream& o, const std::type_info& ti); diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index ee76e1ac..cc81a19e 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -75,7 +75,8 @@ namespace currency return true; } #define check_core_ready() check_core_ready_(LOCAL_FUNCTION_DEF__) -#define CHECK_CORE_READY() if(!check_core_ready()){res.status = API_RETURN_CODE_BUSY;return true;} +#define CHECK_CORE_READY() if (!check_core_ready()) {res.status = API_RETURN_CODE_BUSY; return true; } +#define CHECK_CORE_READY_WE() if (!check_core_ready()) {error_resp.code = CORE_RPC_ERROR_CODE_CORE_BUSY; error_resp.message = "Core is busy."; return false; } //------------------------------------------------------------------------------------------------------------------------------ bool core_rpc_server::on_get_height(const COMMAND_RPC_GET_HEIGHT::request& req, COMMAND_RPC_GET_HEIGHT::response& res, connection_context& cntx) { @@ -1001,7 +1002,7 @@ namespace currency //------------------------------------------------------------------------------------------------------------------------------ bool core_rpc_server::on_submitblock(const COMMAND_RPC_SUBMITBLOCK::request& req, COMMAND_RPC_SUBMITBLOCK::response& res, epee::json_rpc::error& error_resp, connection_context& cntx) { - CHECK_CORE_READY(); + CHECK_CORE_READY_WE(); if(req.size()!=1) { error_resp.code = CORE_RPC_ERROR_CODE_WRONG_PARAM; @@ -1044,8 +1045,7 @@ namespace currency //------------------------------------------------------------------------------------------------------------------------------ bool core_rpc_server::on_submitblock2(const COMMAND_RPC_SUBMITBLOCK2::request& req, COMMAND_RPC_SUBMITBLOCK2::response& res, epee::json_rpc::error& error_resp, connection_context& cntx) { - CHECK_CORE_READY(); - + CHECK_CORE_READY_WE(); block b = AUTO_VAL_INIT(b); if (!parse_and_validate_block_from_blob(req.b, b)) diff --git a/src/serialization/serialization.h b/src/serialization/serialization.h index bb61001e..02eee4b1 100644 --- a/src/serialization/serialization.h +++ b/src/serialization/serialization.h @@ -238,8 +238,7 @@ bool t_unserializable_object_from_blob(t_object& to, const std::string& blob) ss << blob; binary_archive ba(ss); bool r = ::serialization::serialize(ba, to); - CHECK_AND_ASSERT_MES(r, false, "Failed to parse block from blob"); - return true; + return r; } //--------------------------------------------------------------- template