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 d96be59 commit 00c22ba
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 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 @@ -128,17 +137,13 @@ std::string ScriptToAsmStr(const CScript& script)
str += strprintf("%lld", LittleEndianBytesToDecimal(vch));
} 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
// If push not minimally-encoded prepend with opcode name and enclose in angle brackets
str += GetOpNameAsm(opcode);
str += "<";
str += HexStr(vch);
str += ">";
str += BracketStr(HexStr(vch));
continue;
}
// Handle unknown opcodes
Expand Down

0 comments on commit 00c22ba

Please sign in to comment.