aboutsummaryrefslogtreecommitdiff
path: root/src/core_write.cpp
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2023-09-07 19:16:57 +1000
committerAnthony Towns <aj@erisian.com.au>2023-11-14 08:45:30 +1000
commit6e9e4e6130797b721c8df1eabaf46ec25ebb6abe (patch)
tree6444c337cd23d1e6aabedf229a9efb1583fb7351 /src/core_write.cpp
parent5800c558eb5efb4839ed00d6967e43306d68e1c3 (diff)
downloadbitcoin-6e9e4e6130797b721c8df1eabaf46ec25ebb6abe.tar.xz
Use ParamsWrapper for witness serialization
Diffstat (limited to 'src/core_write.cpp')
-rw-r--r--src/core_write.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/core_write.cpp b/src/core_write.cpp
index 7cf019a42e..a2be17d1aa 100644
--- a/src/core_write.cpp
+++ b/src/core_write.cpp
@@ -140,10 +140,14 @@ std::string ScriptToAsmStr(const CScript& script, const bool fAttemptSighashDeco
return str;
}
-std::string EncodeHexTx(const CTransaction& tx, const int serializeFlags)
+std::string EncodeHexTx(const CTransaction& tx, const bool without_witness)
{
- CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION | serializeFlags);
- ssTx << tx;
+ DataStream ssTx;
+ if (without_witness) {
+ ssTx << TX_NO_WITNESS(tx);
+ } else {
+ ssTx << TX_WITH_WITNESS(tx);
+ }
return HexStr(ssTx);
}
@@ -168,7 +172,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, int serialize_flags, const CTxUndo* txundo, TxVerbosity verbosity)
+void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry, bool include_hex, bool without_witness, const CTxUndo* txundo, TxVerbosity verbosity)
{
CHECK_NONFATAL(verbosity >= TxVerbosity::SHOW_DETAILS);
@@ -177,7 +181,7 @@ void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry
// Transaction version is actually unsigned in consensus checks, just signed in memory,
// so cast to unsigned before giving it to the user.
entry.pushKV("version", static_cast<int64_t>(static_cast<uint32_t>(tx.nVersion)));
- entry.pushKV("size", (int)::GetSerializeSize(tx, PROTOCOL_VERSION));
+ entry.pushKV("size", tx.GetTotalSize());
entry.pushKV("vsize", (GetTransactionWeight(tx) + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR);
entry.pushKV("weight", GetTransactionWeight(tx));
entry.pushKV("locktime", (int64_t)tx.nLockTime);
@@ -264,6 +268,6 @@ void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry
}
if (include_hex) {
- entry.pushKV("hex", EncodeHexTx(tx, serialize_flags)); // The hex-encoded transaction. Used the name "hex" to be consistent with the verbose output of "getrawtransaction".
+ entry.pushKV("hex", EncodeHexTx(tx, without_witness)); // The hex-encoded transaction. Used the name "hex" to be consistent with the verbose output of "getrawtransaction".
}
}