diff --git a/src/merkleblock.h b/src/merkleblock.h --- a/src/merkleblock.h +++ b/src/merkleblock.h @@ -162,7 +162,7 @@ CMerkleBlock(const CBlock &block, CBloomFilter &filter); // Create from a CBlock, matching the txids in the set. - CMerkleBlock(const CBlock &block, const std::set &txids); + CMerkleBlock(const CBlock &block, const std::set &txids); CMerkleBlock() {} diff --git a/src/merkleblock.cpp b/src/merkleblock.cpp --- a/src/merkleblock.cpp +++ b/src/merkleblock.cpp @@ -34,8 +34,7 @@ txn = CPartialMerkleTree(vHashes, vMatch); } -CMerkleBlock::CMerkleBlock(const CBlock &block, - const std::set &txids) { +CMerkleBlock::CMerkleBlock(const CBlock &block, const std::set &txids) { header = block.GetBlockHeader(); std::vector vMatch; @@ -45,7 +44,7 @@ vHashes.reserve(block.vtx.size()); for (const auto &tx : block.vtx) { - const uint256 &txid = tx->GetId(); + const TxId &txid = tx->GetId(); vMatch.push_back(txids.count(txid)); vHashes.push_back(txid); } diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -286,26 +286,26 @@ "hex-encoded data for the proof.\n"); } - std::set setTxids; - uint256 oneTxid; + std::set setTxIds; + TxId oneTxId; UniValue txids = request.params[0].get_array(); for (unsigned int idx = 0; idx < txids.size(); idx++) { - const UniValue &txid = txids[idx]; - if (txid.get_str().length() != 64 || !IsHex(txid.get_str())) { + const UniValue &utxid = txids[idx]; + if (utxid.get_str().length() != 64 || !IsHex(utxid.get_str())) { throw JSONRPCError(RPC_INVALID_PARAMETER, - std::string("Invalid txid ") + txid.get_str()); + std::string("Invalid txid ") + utxid.get_str()); } - uint256 hash(uint256S(txid.get_str())); - if (setTxids.count(hash)) { + TxId txid(uint256S(utxid.get_str())); + if (setTxIds.count(txid)) { throw JSONRPCError( RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated txid: ") + - txid.get_str()); + utxid.get_str()); } - setTxids.insert(hash); - oneTxid = hash; + setTxIds.insert(txid); + oneTxId = txid; } LOCK(cs_main); @@ -321,8 +321,8 @@ } else { // Loop through txids and try to find which block they're in. Exit loop // once a block is found. - for (const auto &tx : setTxids) { - const Coin &coin = AccessByTxid(*pcoinsTip, tx); + for (const auto &txid : setTxIds) { + const Coin &coin = AccessByTxid(*pcoinsTip, txid); if (!coin.IsSpent()) { pblockindex = chainActive[coin.GetHeight()]; break; @@ -332,7 +332,7 @@ if (pblockindex == nullptr) { CTransactionRef tx; - if (!GetTransaction(config, oneTxid, tx, hashBlock, false) || + if (!GetTransaction(config, oneTxId, tx, hashBlock, false) || hashBlock.IsNull()) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not yet in block"); @@ -352,19 +352,19 @@ unsigned int ntxFound = 0; for (const auto &tx : block.vtx) { - if (setTxids.count(tx->GetId())) { + if (setTxIds.count(tx->GetId())) { ntxFound++; } } - if (ntxFound != setTxids.size()) { + if (ntxFound != setTxIds.size()) { throw JSONRPCError( RPC_INVALID_ADDRESS_OR_KEY, "Not all transactions found in specified or retrieved block"); } CDataStream ssMB(SER_NETWORK, PROTOCOL_VERSION); - CMerkleBlock mb(block, setTxids); + CMerkleBlock mb(block, setTxIds); ssMB << mb; std::string strHex = HexStr(ssMB.begin(), ssMB.end()); return strHex;