use 'byte'/'bytes' for bech32(m) validation error

changed from std::string -> std::string_view

applied snake case to byteStr -> byte_str
This commit is contained in:
Reese Russell
2023-05-25 01:23:04 +00:00
parent a13f3746dc
commit 3d0a5c37e9
3 changed files with 11 additions and 8 deletions

View File

@@ -146,6 +146,9 @@ CTxDestination DecodeDestination(const std::string& str, const CChainParams& par
// The rest of the symbols are converted witness program bytes.
data.reserve(((dec.data.size() - 1) * 5) / 8);
if (ConvertBits<5, 8, false>([&](unsigned char c) { data.push_back(c); }, dec.data.begin() + 1, dec.data.end())) {
std::string_view byte_str{data.size() == 1 ? "byte" : "bytes"};
if (version == 0) {
{
WitnessV0KeyHash keyid;
@@ -162,7 +165,7 @@ CTxDestination DecodeDestination(const std::string& str, const CChainParams& par
}
}
error_str = strprintf("Invalid Bech32 v0 address program size (%s byte), per BIP141", data.size());
error_str = strprintf("Invalid Bech32 v0 address program size (%d %s), per BIP141", data.size(), byte_str);
return CNoDestination();
}
@@ -179,7 +182,7 @@ CTxDestination DecodeDestination(const std::string& str, const CChainParams& par
}
if (data.size() < 2 || data.size() > BECH32_WITNESS_PROG_MAX_LEN) {
error_str = strprintf("Invalid Bech32 address program size (%s byte)", data.size());
error_str = strprintf("Invalid Bech32 address program size (%d %s)", data.size(), byte_str);
return CNoDestination();
}