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)
383
383
return str;
384
384
}
385
385
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
+
386
405
std::optional<uint64_t > ParseByteUnits (std::string_view str, ByteUnit default_multiplier)
387
406
{
388
407
if (str.empty ()) {
Original file line number Diff line number Diff line change @@ -311,6 +311,11 @@ std::string ToUpper(std::string_view str);
311
311
*/
312
312
std::string Capitalize (std::string str);
313
313
314
+ /* *
315
+ * Converts a signet_challenge to std::string
316
+ */
317
+ std::string ChallengeToStdString (const std::vector<uint8_t >& v);
318
+
314
319
/* *
315
320
* Parse a string with suffix unit [k|K|m|M|g|G|t|T].
316
321
* 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