Skip to content

Commit

Permalink
Change error handling in /sendrawtransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
aivve committed Dec 27, 2023
1 parent c704f99 commit 6fd2345
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/Rpc/RpcServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2211,8 +2211,7 @@ bool RpcServer::on_send_raw_transaction(const COMMAND_RPC_SEND_RAW_TRANSACTION::
if (!Common::fromHex(req.tx_as_hex, tx_blob))
{
logger(Logging::INFO) << "[on_send_raw_tx]: Failed to parse transaction from hexbuff: " << req.tx_as_hex;
res.status = "Failed";
return true;
throw JsonRpc::JsonRpcError{ CORE_RPC_ERROR_CODE_WRONG_PARAM, "Failed to parse transaction from hexbuff" };
}

Crypto::Hash transactionHash = Crypto::cn_fast_hash(tx_blob.data(), tx_blob.size());
Expand All @@ -2222,15 +2221,13 @@ bool RpcServer::on_send_raw_transaction(const COMMAND_RPC_SEND_RAW_TRANSACTION::
if (!m_core.handle_incoming_tx(tx_blob, tvc, false))
{
logger(Logging::INFO) << "[on_send_raw_tx]: Failed to process tx";
res.status = "Failed";
return true;
throw JsonRpc::JsonRpcError{ CORE_RPC_ERROR_CODE_INTERNAL_ERROR, "Failed to process tx" };
}

if (tvc.m_verification_failed)
{
logger(Logging::INFO) << "[on_send_raw_tx]: transaction verification failed";
res.status = "Failed";
return true;
logger(Logging::INFO) << "[on_send_raw_tx]: Transaction verification failed";
throw JsonRpc::JsonRpcError{ CORE_RPC_ERROR_CODE_WRONG_PARAM, "Transaction verification failed" };
}

if (!tvc.m_should_be_relayed)
Expand Down

0 comments on commit 6fd2345

Please sign in to comment.