MCPcopy Create free account
hub / github.com/ElementsProject/elements / UseHInsteadOfApostrophe

Function UseHInsteadOfApostrophe

src/test/descriptor_tests.cpp:61–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61std::string UseHInsteadOfApostrophe(const std::string& desc)
62{
63 std::string ret = desc;
64 while (true) {
65 auto it = ret.find('\'');
66 if (it == std::string::npos) break;
67 ret[it] = 'h';
68 }
69
70 // GetDescriptorChecksum returns "" if the checksum exists but is bad.
71 // Switching apostrophes with 'h' breaks the checksum if it exists - recalculate it and replace the broken one.
72 if (GetDescriptorChecksum(ret) == "") {
73 ret = ret.substr(0, desc.size() - 9);
74 ret += std::string("#") + GetDescriptorChecksum(ret);
75 }
76 return ret;
77}
78
79// Count the number of times the string "xpub" appears in a descriptor string
80static size_t CountXpubs(const std::string& desc)

Callers 1

DoCheckFunction · 0.85

Calls 3

GetDescriptorChecksumFunction · 0.85
findMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected