Skip to content

Commit

Permalink
script: add BracketStr helper fn
Browse files Browse the repository at this point in the history
wrap a pushed value in angle brackets
  • Loading branch information
willcl-ark committed Nov 15, 2023
1 parent ce1de6c commit 70fd568
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/core_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ std::string SighashToStr(unsigned char sighash_type)
return it->second;
}

/**
* Wrap a string in angle brackets for ASM
*/
std::string BracketStr(std::string h)
{
std::string s = "<" + h + ">";
return s;
}

/**
* Create the assembly string representation of a CScript object.
* @param[in] script CScript object to convert into the asm string representation.
Expand Down Expand Up @@ -129,18 +138,14 @@ std::string ScriptToAsmStr(const CScript& script)
str += strprintf("%lld", n.GetInt64());
} else {
// Otherwise display the push as LE hex enclosed in angle brackets
str += "<";
str += HexStr(vch);
str += ">";
str += BracketStr(HexStr(vch));
}
continue;
}
// If push not minimally-encoded prepend with opcode name and enclose in angle brackets
// TODO: There are no tests for this currently
str += GetOpNameAsm(opcode);
str += "<";
str += HexStr(vch);
str += ">";
str += BracketStr(HexStr(vch));
continue;
}
// Handle unknown opcodes
Expand Down

0 comments on commit 70fd568

Please sign in to comment.