Skip to content

Commit 6bbdafc

Browse files
committed
Pass serialization flags and whether to include hex to TxToUniv
1 parent e029c6e commit 6bbdafc

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

src/core_io.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ UniValue ValueFromAmount(const CAmount& amount);
3131
std::string FormatScript(const CScript& script);
3232
std::string EncodeHexTx(const CTransaction& tx, const int serializeFlags = 0);
3333
void ScriptPubKeyToUniv(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex);
34-
void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry);
34+
void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry, bool include_hex = true, int serialize_flags = 0);
3535

3636
#endif // BITCOIN_CORE_IO_H

src/core_write.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ void ScriptPubKeyToUniv(const CScript& scriptPubKey,
153153
out.pushKV("addresses", a);
154154
}
155155

156-
void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry)
156+
void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry, bool include_hex, int serialize_flags)
157157
{
158158
entry.pushKV("txid", tx.GetHash().GetHex());
159159
entry.pushKV("hash", tx.GetWitnessHash().GetHex());
@@ -207,5 +207,7 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry)
207207
if (!hashBlock.IsNull())
208208
entry.pushKV("blockhash", hashBlock.GetHex());
209209

210-
entry.pushKV("hex", EncodeHexTx(tx)); // the hex-encoded transaction. used the name "hex" to be consistent with the verbose output of "getrawtransaction".
210+
if (include_hex) {
211+
entry.pushKV("hex", EncodeHexTx(tx, serialize_flags)); // the hex-encoded transaction. used the name "hex" to be consistent with the verbose output of "getrawtransaction".
212+
}
211213
}

src/rpc/blockchain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx
125125
if(txDetails)
126126
{
127127
UniValue objTx(UniValue::VOBJ);
128-
TxToUniv(*tx, uint256(), objTx);
128+
TxToUniv(*tx, uint256(), objTx, true, RPCSerializationFlags());
129129
txs.push_back(objTx);
130130
}
131131
else

src/rpc/rawtransaction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
4141
// Blockchain contextual information (confirmations and blocktime) is not
4242
// available to code in bitcoin-common, so we query them here and push the
4343
// data into the returned UniValue.
44-
TxToUniv(tx, uint256(), entry);
44+
TxToUniv(tx, uint256(), entry, true, RPCSerializationFlags());
4545

4646
if (!hashBlock.IsNull()) {
4747
entry.push_back(Pair("blockhash", hashBlock.GetHex()));
@@ -480,7 +480,7 @@ UniValue decoderawtransaction(const JSONRPCRequest& request)
480480
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
481481

482482
UniValue result(UniValue::VOBJ);
483-
TxToUniv(CTransaction(std::move(mtx)), uint256(), result);
483+
TxToUniv(CTransaction(std::move(mtx)), uint256(), result, false);
484484

485485
return result;
486486
}

0 commit comments

Comments
 (0)