Skip to content

Commit fa1f7f2

Browse files
author
MarcoFalke
committed
rpc: Style fixups in gettxoutproof
1 parent 40a0481 commit fa1f7f2

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/rpc/rawtransaction.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,11 @@ static UniValue gettxoutproof(const JSONRPCRequest& request)
245245
for (unsigned int idx = 0; idx < txids.size(); idx++) {
246246
const UniValue& txid = txids[idx];
247247
uint256 hash(ParseHashV(txid, "txid"));
248-
if (setTxids.count(hash))
249-
throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated txid: ")+txid.get_str());
250-
setTxids.insert(hash);
251-
oneTxid = hash;
248+
if (setTxids.count(hash)) {
249+
throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated txid: ") + txid.get_str());
250+
}
251+
setTxids.insert(hash);
252+
oneTxid = hash;
252253
}
253254

254255
CBlockIndex* pblockindex = nullptr;
@@ -281,8 +282,7 @@ static UniValue gettxoutproof(const JSONRPCRequest& request)
281282

282283
LOCK(cs_main);
283284

284-
if (pblockindex == nullptr)
285-
{
285+
if (pblockindex == nullptr) {
286286
CTransactionRef tx;
287287
if (!GetTransaction(oneTxid, tx, Params().GetConsensus(), hashBlock) || hashBlock.IsNull())
288288
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not yet in block");
@@ -293,15 +293,19 @@ static UniValue gettxoutproof(const JSONRPCRequest& request)
293293
}
294294

295295
CBlock block;
296-
if(!ReadBlockFromDisk(block, pblockindex, Params().GetConsensus()))
296+
if (!ReadBlockFromDisk(block, pblockindex, Params().GetConsensus())) {
297297
throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk");
298+
}
298299

299300
unsigned int ntxFound = 0;
300-
for (const auto& tx : block.vtx)
301-
if (setTxids.count(tx->GetHash()))
301+
for (const auto& tx : block.vtx) {
302+
if (setTxids.count(tx->GetHash())) {
302303
ntxFound++;
303-
if (ntxFound != setTxids.size())
304+
}
305+
}
306+
if (ntxFound != setTxids.size()) {
304307
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Not all transactions found in specified or retrieved block");
308+
}
305309

306310
CDataStream ssMB(SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
307311
CMerkleBlock mb(block, setTxids);

0 commit comments

Comments
 (0)