diff --git a/src/masternodes/rpc_tokens.cpp b/src/masternodes/rpc_tokens.cpp index 6941e3c0d9a..04ee86e3aa7 100644 --- a/src/masternodes/rpc_tokens.cpp +++ b/src/masternodes/rpc_tokens.cpp @@ -765,11 +765,10 @@ UniValue decodecustomtx(const JSONRPCRequest& request) RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL}); - CMutableTransaction mtx; - bool try_witness = request.params[1].isNull() ? true : request.params[1].get_bool(); bool try_no_witness = request.params[1].isNull() ? true : !request.params[1].get_bool(); + CMutableTransaction mtx; if (!DecodeHexTx(mtx, request.params[0].get_str(), try_no_witness, try_witness)) { throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed"); } @@ -802,13 +801,12 @@ UniValue decodecustomtx(const JSONRPCRequest& request) result.pushKV("txid", tx->GetHash().GetHex()); result.pushKV("type", ToString(guess)); result.pushKV("valid", res.ok ? true : false); // no actual block height - if (!res.ok) { result.pushKV("error", res.msg); } else { result.pushKV("results", txResults); } - + return result; } else { // Should not get here without prior failure. diff --git a/src/validation.cpp b/src/validation.cpp index 311285da533..be6e98c5161 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1009,51 +1009,6 @@ bool GetTransaction(const uint256& hash, CTransactionRef& txOut, const Consensus return false; } -/** - * If the transaction hash is found inside a block, the block hash is placed in hashBlock. - * If blockIndex is provided, the transaction is fetched from the corresponding block and its hash is placed in hashBlock. - */ -bool GetBlockHash(const uint256& hash, const Consensus::Params& consensusParams, uint256& hashBlock, const CBlockIndex* const blockIndex) -{ - CTransactionRef txOut; - //try the genesis block - for (auto && genesisTx : Params().GenesisBlock().vtx) { - if (genesisTx->GetHash() == hash) { - // Return genesis tx - hashBlock = consensusParams.hashGenesisBlock; - txOut = genesisTx; - return true; - } - } - - LOCK(cs_main); - if (!blockIndex) { - //try mempool and txindex - CTransactionRef ptx = mempool.get(hash); - if (ptx) { - txOut = ptx; - } - - if (g_txindex) { - return g_txindex->FindTx(hash, hashBlock, txOut); - } - } else { - //Load from disk - CBlock block; - if (ReadBlockFromDisk(block, blockIndex, consensusParams)) { - for (const auto& tx : block.vtx) { - if (tx->GetHash() == hash) { - txOut = tx; - hashBlock = blockIndex->GetBlockHash(); - return true; - } - } - } - } - - return false; -} - ////////////////////////////////////////////////////////////////////////////// // // CBlock and CBlockIndex diff --git a/src/validation.h b/src/validation.h index a08c9dc7bfb..9ab8bbfe649 100644 --- a/src/validation.h +++ b/src/validation.h @@ -262,8 +262,6 @@ void UnloadBlockIndex(); void ThreadScriptCheck(int worker_num); /** Retrieve a transaction (from memory pool, or from disk, if possible) */ bool GetTransaction(const uint256& hash, CTransactionRef& tx, const Consensus::Params& params, uint256& hashBlock, const CBlockIndex* const blockIndex = nullptr); -/** Retrieve a block hash which includes the transaction hash (from memory pool, or from disk, if possible)*/ -bool GetBlockHash(const uint256& hash, const Consensus::Params& params, uint256& hashBlock, const CBlockIndex* const blockIndex = nullptr); /** * Find the best known block, and make it the tip of the block chain *