Skip to content

Commit 362fbe7

Browse files
committed
validation: Apply fixes for Bitcoin backport compliance
- Remove unnecessary std::string() conversions in ParseHashO and ParseHexO - Change ParseHashV variable declaration to match Bitcoin's const reference style - Add missing blank line after #include <tuple> These changes ensure the backport matches Bitcoin commit 9b68c9b exactly.
1 parent b452bd0 commit 362fbe7

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎pyenv‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 61d869f67e2b4c1d05c532821c5166a9ed40b0aa

‎src/rpc/util.cpp‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <string_view>
2121
#include <tuple>
22+
2223
const std::string UNIX_EPOCH_TIME = "UNIX epoch time";
2324
const std::string EXAMPLE_ADDRESS[2] = {"XunLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPw0", "XwQQkwA4FYkq2XERzMY2CiAZhJTEDAbtc0"};
2425

@@ -101,7 +102,7 @@ CAmount AmountFromValue(const UniValue& value, int decimals)
101102

102103
uint256 ParseHashV(const UniValue& v, std::string_view name)
103104
{
104-
std::string strHex{v.get_str()};
105+
const std::string& strHex(v.get_str());
105106
if (64 != strHex.length())
106107
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("%s must be of length %d (not %d, for '%s')", name, 64, strHex.length(), strHex));
107108
if (!IsHex(strHex)) // Note: IsHex("") is false
@@ -110,7 +111,7 @@ uint256 ParseHashV(const UniValue& v, std::string_view name)
110111
}
111112
uint256 ParseHashO(const UniValue& o, std::string_view strKey)
112113
{
113-
return ParseHashV(o.find_value(std::string(strKey)), strKey);
114+
return ParseHashV(o.find_value(strKey), strKey);
114115
}
115116
std::vector<unsigned char> ParseHexV(const UniValue& v, std::string_view name)
116117
{
@@ -123,7 +124,7 @@ std::vector<unsigned char> ParseHexV(const UniValue& v, std::string_view name)
123124
}
124125
std::vector<unsigned char> ParseHexO(const UniValue& o, std::string_view strKey)
125126
{
126-
return ParseHexV(o.find_value(std::string(strKey)), strKey);
127+
return ParseHexV(o.find_value(strKey), strKey);
127128
}
128129

129130
int32_t ParseInt32V(const UniValue& v, const std::string &strName)

0 commit comments

Comments
 (0)