Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/rpcblockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool fPri
{
Object entry;

entry.push_back(Pair("txid", tx.GetHash().GetHex()));
//entry.push_back(Pair("txid", tx.GetHash().GetHex()));
TxToJSON(tx, 0, entry);

txinfo.push_back(entry);
Expand Down Expand Up @@ -239,14 +239,25 @@ Value getblock(const Array& params, bool fHelp)
std::string strHash = params[0].get_str();
uint256 hash(strHash);

bool fVerbose = true;
if (params.size() > 1)
fVerbose = params[1].get_bool();

if (mapBlockIndex.count(hash) == 0)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");

CBlock block;
CBlockIndex* pblockindex = mapBlockIndex[hash];
block.ReadFromDisk(pblockindex, true);

return blockToJSON(block, pblockindex, params.size() > 1 ? params[1].get_bool() : false);
if (!fVerbose) {
CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION | RPCSerializationFlags());
ssBlock << block;
std::string strHex = HexStr(ssBlock.begin(), ssBlock.end());
return strHex;
}

return blockToJSON(block, pblockindex, fVerbose);
}

Value getblockbynumber(const Array& params, bool fHelp)
Expand Down
8 changes: 8 additions & 0 deletions src/rpcprotocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,11 @@ Object JSONRPCError(int code, const string& message)
error.push_back(Pair("message", message));
return error;
}

int RPCSerializationFlags()
{
int flag = 0;
if (GetArg("-rpcserialversion", DEFAULT_RPC_SERIALIZE_VERSION) == 0)
flag |= SERIALIZE_TRANSACTION_NO_WITNESS;
return flag;
}
6 changes: 6 additions & 0 deletions src/rpcprotocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,10 @@ json_spirit::Object JSONRPCReplyObj(const json_spirit::Value& result, const json
std::string JSONRPCReply(const json_spirit::Value& result, const json_spirit::Value& error, const json_spirit::Value& id);
json_spirit::Object JSONRPCError(int code, const std::string& message);

static const int DEFAULT_RPC_SERIALIZE_VERSION = 1;
static const int SERIALIZE_TRANSACTION_NO_WITNESS = 0x40000000;

// Retrieves any serialization flags requested in command line argument
int RPCSerializationFlags();

#endif