Deserialize CFinalCommitmentTxPayload instead of CFinalCommitment in TxToJSON (#2510)

* Deserialize CFinalCommitmentTxPayload instead of CFinalCommitment in TxToJSON

* Implement ToJson for CFinalCommitmentTxPayload and use it in TxToJSON

Otherwise the nVersion and nHeight members of it are not shown.
This commit is contained in:
Alexander Block 2018-11-29 19:51:04 +01:00 committed by UdjinM6
parent 5da4c97284
commit 5a3f64310b
3 changed files with 14 additions and 1 deletions

View File

@ -144,6 +144,17 @@ void CFinalCommitment::ToJson(UniValue& obj) const
obj.push_back(Pair("quorumPublicKey", quorumPublicKey.ToString()));
}
void CFinalCommitmentTxPayload::ToJson(UniValue& obj) const
{
obj.setObject();
obj.push_back(Pair("version", (int)nVersion));
obj.push_back(Pair("height", (int)nHeight));
UniValue qcObj;
commitment.ToJson(qcObj);
obj.push_back(Pair("commitment", qcObj));
}
bool CheckLLMQCommitment(const CTransaction& tx, const CBlockIndex* pindexPrev, CValidationState& state)
{
CFinalCommitmentTxPayload qcTx;

View File

@ -108,6 +108,8 @@ public:
READWRITE(nHeight);
READWRITE(commitment);
}
void ToJson(UniValue& obj) const;
};
bool CheckLLMQCommitment(const CTransaction& tx, const CBlockIndex* pindexPrev, CValidationState& state);

View File

@ -168,7 +168,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
entry.push_back(Pair("cbTx", obj));
}
} else if (tx.nType == TRANSACTION_QUORUM_COMMITMENT) {
llmq::CFinalCommitment qcTx;
llmq::CFinalCommitmentTxPayload qcTx;
if (GetTxPayload(tx, qcTx)) {
UniValue obj;
qcTx.ToJson(obj);