diff options
Diffstat (limited to 'src/core_write.cpp')
-rw-r--r-- | src/core_write.cpp | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/core_write.cpp b/src/core_write.cpp index a2be17d1aa..3a2bf865fc 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -140,14 +140,10 @@ std::string ScriptToAsmStr(const CScript& script, const bool fAttemptSighashDeco return str; } -std::string EncodeHexTx(const CTransaction& tx, const bool without_witness) +std::string EncodeHexTx(const CTransaction& tx) { DataStream ssTx; - if (without_witness) { - ssTx << TX_NO_WITNESS(tx); - } else { - ssTx << TX_WITH_WITNESS(tx); - } + ssTx << TX_WITH_WITNESS(tx); return HexStr(ssTx); } @@ -172,7 +168,7 @@ void ScriptToUniv(const CScript& script, UniValue& out, bool include_hex, bool i out.pushKV("type", GetTxnOutputType(type)); } -void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry, bool include_hex, bool without_witness, const CTxUndo* txundo, TxVerbosity verbosity) +void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry, bool include_hex, const CTxUndo* txundo, TxVerbosity verbosity) { CHECK_NONFATAL(verbosity >= TxVerbosity::SHOW_DETAILS); @@ -205,14 +201,14 @@ void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry UniValue o(UniValue::VOBJ); o.pushKV("asm", ScriptToAsmStr(txin.scriptSig, true)); o.pushKV("hex", HexStr(txin.scriptSig)); - in.pushKV("scriptSig", o); + in.pushKV("scriptSig", std::move(o)); } if (!tx.vin[i].scriptWitness.IsNull()) { UniValue txinwitness(UniValue::VARR); for (const auto& item : tx.vin[i].scriptWitness.stack) { txinwitness.push_back(HexStr(item)); } - in.pushKV("txinwitness", txinwitness); + in.pushKV("txinwitness", std::move(txinwitness)); } if (have_undo) { const Coin& prev_coin = txundo->vprevout[i]; @@ -228,14 +224,14 @@ void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry p.pushKV("generated", bool(prev_coin.fCoinBase)); p.pushKV("height", uint64_t(prev_coin.nHeight)); p.pushKV("value", ValueFromAmount(prev_txout.nValue)); - p.pushKV("scriptPubKey", o_script_pub_key); - in.pushKV("prevout", p); + p.pushKV("scriptPubKey", std::move(o_script_pub_key)); + in.pushKV("prevout", std::move(p)); } } in.pushKV("sequence", (int64_t)txin.nSequence); - vin.push_back(in); + vin.push_back(std::move(in)); } - entry.pushKV("vin", vin); + entry.pushKV("vin", std::move(vin)); UniValue vout(UniValue::VARR); for (unsigned int i = 0; i < tx.vout.size(); i++) { @@ -248,14 +244,14 @@ void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry UniValue o(UniValue::VOBJ); ScriptToUniv(txout.scriptPubKey, /*out=*/o, /*include_hex=*/true, /*include_address=*/true); - out.pushKV("scriptPubKey", o); - vout.push_back(out); + out.pushKV("scriptPubKey", std::move(o)); + vout.push_back(std::move(out)); if (have_undo) { amt_total_out += txout.nValue; } } - entry.pushKV("vout", vout); + entry.pushKV("vout", std::move(vout)); if (have_undo) { const CAmount fee = amt_total_in - amt_total_out; @@ -268,6 +264,6 @@ void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry } if (include_hex) { - entry.pushKV("hex", EncodeHexTx(tx, without_witness)); // The hex-encoded transaction. Used the name "hex" to be consistent with the verbose output of "getrawtransaction". + entry.pushKV("hex", EncodeHexTx(tx)); // The hex-encoded transaction. Used the name "hex" to be consistent with the verbose output of "getrawtransaction". } } |