MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / GetDescriptor

Method GetDescriptor

src/test/fuzz/util/descriptor.cpp:59–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59std::optional<std::string> MockedDescriptorConverter::GetDescriptor(std::string_view mocked_desc) const {
60 // The smallest fragment would be "pk(%00)"
61 if (mocked_desc.size() < 7) return {};
62
63 // The actual descriptor string to be returned.
64 std::string desc;
65 desc.reserve(mocked_desc.size());
66
67 // Replace all occurrences of '%' followed by two hex characters with the corresponding key.
68 for (size_t i = 0; i < mocked_desc.size();) {
69 if (mocked_desc[i] == '%') {
70 if (i + 3 >= mocked_desc.size()) return {};
71 if (const auto idx = IdxFromHex(mocked_desc.substr(i + 1, 2))) {
72 desc += keys_str[*idx];
73 i += 3;
74 } else {
75 return {};
76 }
77 } else {
78 desc += mocked_desc[i++];
79 }
80 }
81
82 return desc;
83}
84
85bool HasDeepDerivPath(std::span<const uint8_t> buff, const int max_depth)
86{

Callers 2

CreateWalletDescriptorFunction · 0.80

Calls 2

sizeMethod · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected