File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -383,6 +383,25 @@ std::string Capitalize(std::string str)
383383 return str;
384384}
385385
386+ std::string ChallengeToStdString (const std::vector<uint8_t >& v)
387+ {
388+ std::string result;
389+ result.reserve (v.size () * 2 );
390+
391+ static constexpr char hex[] = " 0123456789ABCDEF" ;
392+
393+ for (uint8_t c : v)
394+ {
395+ result.push_back (hex[c / 16 ]);
396+ result.push_back (hex[c % 16 ]);
397+ }
398+ if (IsHex (result)) {
399+ return result;
400+ } else {
401+ return " Invalid signet_challenge" ;
402+ }
403+ }
404+
386405std::optional<uint64_t > ParseByteUnits (std::string_view str, ByteUnit default_multiplier)
387406{
388407 if (str.empty ()) {
Original file line number Diff line number Diff line change @@ -311,6 +311,11 @@ std::string ToUpper(std::string_view str);
311311 */
312312std::string Capitalize (std::string str);
313313
314+ /* *
315+ * Converts a signet_challenge to std::string
316+ */
317+ std::string ChallengeToStdString (const std::vector<uint8_t >& v);
318+
314319/* *
315320 * Parse a string with suffix unit [k|K|m|M|g|G|t|T].
316321 * Must be a whole integer, fractions not allowed (0.5t), no whitespace or +-
You can’t perform that action at this time.
0 commit comments