Add option to return non-segwit serialization via rpc
This commit is contained in:
committed by
lateminer
parent
552ef391d7
commit
ab2332461b
@@ -25,7 +25,7 @@ extern std::vector<unsigned char> ParseHexUV(const UniValue& v, const std::strin
|
||||
|
||||
// core_write.cpp
|
||||
extern std::string FormatScript(const CScript& script);
|
||||
extern std::string EncodeHexTx(const CTransaction& tx);
|
||||
extern std::string EncodeHexTx(const CTransaction& tx, const int serializeFlags = 0);
|
||||
extern void ScriptPubKeyToUniv(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex);
|
||||
extern void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry);
|
||||
|
||||
|
||||
@@ -116,9 +116,9 @@ string ScriptToAsmStr(const CScript& script, const bool fAttemptSighashDecode)
|
||||
return str;
|
||||
}
|
||||
|
||||
string EncodeHexTx(const CTransaction& tx)
|
||||
string EncodeHexTx(const CTransaction& tx, const int serialFlags)
|
||||
{
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION | serialFlags);
|
||||
ssTx << tx;
|
||||
return HexStr(ssTx.begin(), ssTx.end());
|
||||
}
|
||||
|
||||
@@ -486,7 +486,7 @@ UniValue getblock(const UniValue& params, bool fHelp)
|
||||
|
||||
if (!fVerbose)
|
||||
{
|
||||
CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION);
|
||||
CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION | RPCSerializationFlags());
|
||||
ssBlock << block;
|
||||
std::string strHex = HexStr(ssBlock.begin(), ssBlock.end());
|
||||
return strHex;
|
||||
|
||||
@@ -197,7 +197,7 @@ UniValue getrawtransaction(const UniValue& params, bool fHelp)
|
||||
if (!GetTransaction(hash, tx, Params().GetConsensus(), hashBlock, true))
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available about transaction");
|
||||
|
||||
string strHex = EncodeHexTx(tx);
|
||||
string strHex = EncodeHexTx(tx, RPCSerializationFlags());
|
||||
|
||||
if (!fVerbose)
|
||||
return strHex;
|
||||
|
||||
@@ -523,4 +523,9 @@ void RPCRunLater(const std::string& name, boost::function<void(void)> func, int6
|
||||
deadlineTimers.insert(std::make_pair(name, std::shared_ptr<RPCTimerBase>(timerInterface->NewTimer(func, nSeconds*1000))));
|
||||
}
|
||||
|
||||
int RPCSerializationFlags()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
CRPCTable tableRPC;
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include <univalue.h>
|
||||
|
||||
static const unsigned int DEFAULT_RPC_SERIALIZE_VERSION = 1;
|
||||
|
||||
class CRPCCommand;
|
||||
|
||||
namespace RPCServer
|
||||
@@ -196,4 +198,7 @@ void InterruptRPC();
|
||||
void StopRPC();
|
||||
std::string JSONRPCExecBatch(const UniValue& vReq);
|
||||
|
||||
// Retrieves any serialization flags requested in command line argument
|
||||
int RPCSerializationFlags();
|
||||
|
||||
#endif // BITCOIN_RPCSERVER_H
|
||||
|
||||
@@ -1775,7 +1775,7 @@ UniValue gettransaction(const UniValue& params, bool fHelp)
|
||||
ListTransactions(wtx, "*", 0, false, details, filter);
|
||||
entry.push_back(Pair("details", details));
|
||||
|
||||
string strHex = EncodeHexTx(static_cast<CTransaction>(wtx));
|
||||
string strHex = EncodeHexTx(static_cast<CTransaction>(wtx), RPCSerializationFlags());
|
||||
entry.push_back(Pair("hex", strHex));
|
||||
|
||||
return entry;
|
||||
|
||||
Reference in New Issue
Block a user