Skip to content

Commit

Permalink
[RPC][Tests] Include proTx data in json formatted transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
random-zebra committed May 4, 2021
1 parent 431693f commit e754732
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/rpc/rawtransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include "base58.h"
#include "core_io.h"
#include "evo/specialtx.h"
#include "evo/providertx.h"
#include "init.h"
#include "keystore.h"
#include "validationinterface.h"
Expand All @@ -31,6 +33,27 @@

#include <univalue.h>

template <typename Payload>
static void PayloadToJSON(const CTransaction& tx, Payload& pl, UniValue& entry)
{
if (GetTxPayload(tx, pl)) {
UniValue payloadObj;
pl.ToJson(payloadObj);
entry.pushKV("payload", payloadObj);
}
}

static void PayloadToJSON(const CTransaction& tx, UniValue& entry)
{
switch(tx.nType) {
case CTransaction::TxType::PROREG: {
ProRegPL pl;
PayloadToJSON(tx, pl, entry);
break;
}
}
}

void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
{
// Call into TxToUniv() in bitcoin-common to decode the transaction hex.
Expand All @@ -54,6 +77,11 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
}
}

// Special txes
if (tx.IsSpecialTx()) {
PayloadToJSON(tx, entry);
}

if (!hashBlock.IsNull()) {
entry.pushKV("blockhash", hashBlock.GetHex());
BlockMap::iterator mi = mapBlockIndex.find(hashBlock);
Expand Down

0 comments on commit e754732

Please sign in to comment.