mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-17 13:07:54 +02:00
getblockheader: properly display 'signblock_witness_hex' field and remove irrelevant 'signblock_witness_asm' field in post-dynafed RPC response
This commit is contained in:
parent
cf2eb09bc5
commit
79f5a000a8
3 changed files with 16 additions and 3 deletions
|
|
@ -15,6 +15,7 @@
|
|||
class CBlock;
|
||||
class CBlockHeader;
|
||||
class CScript;
|
||||
struct CScriptWitness;
|
||||
class CTransaction;
|
||||
struct CMutableTransaction;
|
||||
class uint256;
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue