This variable is unchanged after this line, can capture it in make_output and avoid passing the third variable there.
diff --git a/src/rpc/mempool.cpp b/src/rpc/mempool.cpp
index 69366eed8a..6ae6a071f6 100644
--- a/src/rpc/mempool.cpp
+++ b/src/rpc/mempool.cpp
@@ -970,13 +970,13 @@ static RPCHelpMan gettxspendingprevout()
prevouts_to_process.emplace_back(txid, static_cast<uint32_t>(nOutput));
}
- auto make_output = [](const COutPoint& prevout, const CTransaction* spending_tx = nullptr, const bool add_spending_tx_hex = false) {
+ auto make_output = [return_spending_tx](const COutPoint& prevout, const CTransaction* spending_tx = nullptr) {
UniValue o{UniValue::VOBJ};
o.pushKV("txid", prevout.hash.GetHex());
o.pushKV("vout", static_cast<int>(prevout.n));
if (spending_tx) {
o.pushKV("spendingtxid", spending_tx->GetHash().ToString());
- if (add_spending_tx_hex) {
+ if (return_spending_tx) {
o.pushKV("spendingtx", EncodeHexTx(*spending_tx));
}
}
@@ -1002,7 +1002,7 @@ static RPCHelpMan gettxspendingprevout()
continue;
}
- result.push_back(make_output(prevout, spendingTx, return_spending_tx));
+ result.push_back(make_output(prevout, spendingTx));
it = prevouts_to_process.erase(it);
}
}
@@ -1032,7 +1032,7 @@ static RPCHelpMan gettxspendingprevout()
continue;
}
- UniValue o{make_output(prevout, op_info->tx.get(), return_spending_tx)};
+ UniValue o{make_output(prevout, op_info->tx.get())};
o.pushKV("blockhash", op_info->block_hash.GetHex());
result.push_back(std::move(o));
}