Add option to return non-segwit serialization via rpc

This commit is contained in:
Gregory Sanders
2016-11-20 09:54:51 -05:00
committed by lateminer
parent 552ef391d7
commit ab2332461b
7 changed files with 16 additions and 6 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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