Skip to content

Commit e754732

Browse files
committed
[RPC][Tests] Include proTx data in json formatted transactions
1 parent 431693f commit e754732

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/rpc/rawtransaction.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#include "base58.h"
99
#include "core_io.h"
10+
#include "evo/specialtx.h"
11+
#include "evo/providertx.h"
1012
#include "init.h"
1113
#include "keystore.h"
1214
#include "validationinterface.h"
@@ -31,6 +33,27 @@
3133

3234
#include <univalue.h>
3335

36+
template <typename Payload>
37+
static void PayloadToJSON(const CTransaction& tx, Payload& pl, UniValue& entry)
38+
{
39+
if (GetTxPayload(tx, pl)) {
40+
UniValue payloadObj;
41+
pl.ToJson(payloadObj);
42+
entry.pushKV("payload", payloadObj);
43+
}
44+
}
45+
46+
static void PayloadToJSON(const CTransaction& tx, UniValue& entry)
47+
{
48+
switch(tx.nType) {
49+
case CTransaction::TxType::PROREG: {
50+
ProRegPL pl;
51+
PayloadToJSON(tx, pl, entry);
52+
break;
53+
}
54+
}
55+
}
56+
3457
void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
3558
{
3659
// Call into TxToUniv() in bitcoin-common to decode the transaction hex.
@@ -54,6 +77,11 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
5477
}
5578
}
5679

80+
// Special txes
81+
if (tx.IsSpecialTx()) {
82+
PayloadToJSON(tx, entry);
83+
}
84+
5785
if (!hashBlock.IsNull()) {
5886
entry.pushKV("blockhash", hashBlock.GetHex());
5987
BlockMap::iterator mi = mapBlockIndex.find(hashBlock);

0 commit comments

Comments
 (0)