mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
Merge #19739: refactor: remove c-string interfaces for DecodeBase58{Check}
d3e8adfada889a3c9fba930086eda609509aca07 util: remove c-string interfaces for DecodeBase58{Check} (Sebastian Falbesoner) Pull request description: This micro-PR gets rid of base58 function interfaces that are redundant in terms of c-string / std::string variants; the c-string interface for `DecodeBase58Check` is completely unused outside the base58 module, while the c-string interface for `DecodeBase58` is only used in unit tests, where an implicit conversion to std::string is not problematic. ACKs for top commit: practicalswift: ACK d3e8adfada889a3c9fba930086eda609509aca07 -- patch looks correct laanwj: Code review ACK d3e8adfada889a3c9fba930086eda609509aca07 Tree-SHA512: 006a4a1e23b11385f60820c188b8e6b1634a182ca36e29a6580f72150214c65a3fdb273ec439165f26ba88a42d2bf5bab1cf3666a9eaee222fb4e1c00aeba433
This commit is contained in:
parent
feb636352a
commit
fb274b16da
@ -35,7 +35,7 @@ static const int8_t mapBase58[256] = {
|
|||||||
-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,
|
-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
};
|
};
|
||||||
|
|
||||||
bool DecodeBase58(const char* psz, std::vector<unsigned char>& vch, int max_ret_len)
|
[[nodiscard]] static bool DecodeBase58(const char* psz, std::vector<unsigned char>& vch, int max_ret_len)
|
||||||
{
|
{
|
||||||
// Skip leading spaces.
|
// Skip leading spaces.
|
||||||
while (*psz && IsSpace(*psz))
|
while (*psz && IsSpace(*psz))
|
||||||
@ -141,7 +141,7 @@ std::string EncodeBase58Check(Span<const unsigned char> input)
|
|||||||
return EncodeBase58(vch);
|
return EncodeBase58(vch);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet, int max_ret_len)
|
[[nodiscard]] static bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet, int max_ret_len)
|
||||||
{
|
{
|
||||||
if (!DecodeBase58(psz, vchRet, max_ret_len > std::numeric_limits<int>::max() - 4 ? std::numeric_limits<int>::max() : max_ret_len + 4) ||
|
if (!DecodeBase58(psz, vchRet, max_ret_len > std::numeric_limits<int>::max() - 4 ? std::numeric_limits<int>::max() : max_ret_len + 4) ||
|
||||||
(vchRet.size() < 4)) {
|
(vchRet.size() < 4)) {
|
||||||
|
13
src/base58.h
13
src/base58.h
@ -25,13 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
std::string EncodeBase58(Span<const unsigned char> input);
|
std::string EncodeBase58(Span<const unsigned char> input);
|
||||||
|
|
||||||
/**
|
|
||||||
* Decode a base58-encoded string (psz) into a byte vector (vchRet).
|
|
||||||
* return true if decoding is successful.
|
|
||||||
* psz cannot be nullptr.
|
|
||||||
*/
|
|
||||||
[[nodiscard]] bool DecodeBase58(const char* psz, std::vector<unsigned char>& vchRet, int max_ret_len);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decode a base58-encoded string (str) into a byte vector (vchRet).
|
* Decode a base58-encoded string (str) into a byte vector (vchRet).
|
||||||
* return true if decoding is successful.
|
* return true if decoding is successful.
|
||||||
@ -43,12 +36,6 @@ std::string EncodeBase58(Span<const unsigned char> input);
|
|||||||
*/
|
*/
|
||||||
std::string EncodeBase58Check(Span<const unsigned char> input);
|
std::string EncodeBase58Check(Span<const unsigned char> input);
|
||||||
|
|
||||||
/**
|
|
||||||
* Decode a base58-encoded string (psz) that includes a checksum into a byte
|
|
||||||
* vector (vchRet), return true if decoding is successful
|
|
||||||
*/
|
|
||||||
[[nodiscard]] bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet, int max_ret_len);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decode a base58-encoded string (str) that includes a checksum into a byte
|
* Decode a base58-encoded string (str) that includes a checksum into a byte
|
||||||
* vector (vchRet), return true if decoding is successful
|
* vector (vchRet), return true if decoding is successful
|
||||||
|
Loading…
Reference in New Issue
Block a user