Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPC: correctly display signblock_witness post-dynafed #1108

Merged
Merged
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
2 changes: 2 additions & 0 deletions src/core_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
class CBlock;
class CBlockHeader;
class CScript;
struct CScriptWitness;
class CTransaction;
struct CMutableTransaction;
class uint256;
Expand Down Expand Up @@ -44,6 +45,7 @@ int ParseSighashString(const UniValue& sighash);
UniValue ValueFromAmount(const CAmount& amount);
std::string FormatScript(const CScript& script);
std::string EncodeHexTx(const CTransaction& tx, const int serializeFlags = 0);
UniValue EncodeHexScriptWitness(const CScriptWitness& witness);
std::string SighashToStr(unsigned char sighash_type);
void ScriptPubKeyToUniv(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex);
void ScriptToUniv(const CScript& script, UniValue& out, bool include_address);
Expand Down
9 changes: 9 additions & 0 deletions src/core_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,15 @@ std::string EncodeHexTx(const CTransaction& tx, const int serializeFlags)
return HexStr(ssTx);
}

UniValue EncodeHexScriptWitness(const CScriptWitness& witness)
{
UniValue witness_hex(UniValue::VARR);
for (const auto &item : witness.stack) {
witness_hex.push_back(HexStr(item));
}
return witness_hex;
}

void ScriptToUniv(const CScript& script, UniValue& out, bool include_address)
{
out.pushKV("asm", ScriptToAsmStr(script));
Expand Down
9 changes: 6 additions & 3 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,11 @@ UniValue blockheaderToJSON(const CBlockIndex* tip, const CBlockIndex* blockindex
result.pushKV("difficulty", GetDifficulty(blockindex));
result.pushKV("chainwork", blockindex->nChainWork.GetHex());
} else {
result.pushKV("signblock_witness_asm", ScriptToAsmStr(blockindex->proof.solution));
result.pushKV("signblock_witness_hex", HexStr(blockindex->proof.solution));
if (!blockindex->dynafed_params.IsNull()) {
if (blockindex->dynafed_params.IsNull()) {
result.pushKV("signblock_witness_asm", ScriptToAsmStr(blockindex->proof.solution));
result.pushKV("signblock_witness_hex", HexStr(blockindex->proof.solution));
} else {
result.pushKV("signblock_witness_hex", EncodeHexScriptWitness(blockindex->m_signblock_witness));
result.pushKV("dynamic_parameters", dynaParamsToJSON(blockindex->dynafed_params));
}
}
Expand Down Expand Up @@ -218,6 +220,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIn
result.pushKV("signblock_witness_hex", HexStr(blockindex->proof.solution));
result.pushKV("signblock_challenge", HexStr(blockindex->proof.challenge));
} else {
result.pushKV("signblock_witness_hex", EncodeHexScriptWitness(blockindex->m_signblock_witness));
result.pushKV("dynamic_parameters", dynaParamsToJSON(block.m_dynafed_params));
}
}
Expand Down