mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-02 03:46:01 +02:00
Add option to return non-segwit serialization via rpc
This commit is contained in:
@@ -751,7 +751,7 @@ UniValue getblock(const JSONRPCRequest& request)
|
||||
|
||||
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;
|
||||
|
||||
@@ -223,7 +223,7 @@ UniValue getrawtransaction(const JSONRPCRequest& request)
|
||||
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;
|
||||
|
||||
@@ -497,4 +497,12 @@ void RPCRunLater(const std::string& name, boost::function<void(void)> func, int6
|
||||
deadlineTimers.emplace(name, std::unique_ptr<RPCTimerBase>(timerInterface->NewTimer(func, nSeconds*1000)));
|
||||
}
|
||||
|
||||
int RPCSerializationFlags()
|
||||
{
|
||||
int flag = 0;
|
||||
if (GetArg("-rpcserialversion", DEFAULT_RPC_SERIALIZE_VERSION) == 0)
|
||||
flag |= SERIALIZE_TRANSACTION_NO_WITNESS;
|
||||
return flag;
|
||||
}
|
||||
|
||||
CRPCTable tableRPC;
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include <univalue.h>
|
||||
|
||||
static const unsigned int DEFAULT_RPC_SERIALIZE_VERSION = 1;
|
||||
|
||||
class CRPCCommand;
|
||||
|
||||
namespace RPCServer
|
||||
@@ -198,4 +200,7 @@ void StopRPC();
|
||||
std::string JSONRPCExecBatch(const UniValue& vReq);
|
||||
void RPCNotifyBlockChange(bool ibd, const CBlockIndex *);
|
||||
|
||||
// Retrieves any serialization flags requested in command line argument
|
||||
int RPCSerializationFlags();
|
||||
|
||||
#endif // BITCOIN_RPCSERVER_H
|
||||
|
||||
Reference in New Issue
Block a user