Skip to content

Commit 9632b7e

Browse files
committed
Merge bitcoin#19739: refactor: remove c-string interfaces for DecodeBase58{Check}
d3e8adf 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 d3e8adf -- patch looks correct laanwj: Code review ACK d3e8adf Tree-SHA512: 006a4a1e23b11385f60820c188b8e6b1634a182ca36e29a6580f72150214c65a3fdb273ec439165f26ba88a42d2bf5bab1cf3666a9eaee222fb4e1c00aeba433
2 parents 22acd36 + d3e8adf commit 9632b7e

File tree

2 files changed

+2
-15
lines changed

2 files changed

+2
-15
lines changed

src/base58.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static const int8_t mapBase58[256] = {
3535
-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,
3636
};
3737

38-
bool DecodeBase58(const char* psz, std::vector<unsigned char>& vch, int max_ret_len)
38+
NODISCARD static bool DecodeBase58(const char* psz, std::vector<unsigned char>& vch, int max_ret_len)
3939
{
4040
// Skip leading spaces.
4141
while (*psz && IsSpace(*psz))
@@ -141,7 +141,7 @@ std::string EncodeBase58Check(Span<const unsigned char> input)
141141
return EncodeBase58(vch);
142142
}
143143

144-
bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet, int max_ret_len)
144+
NODISCARD static bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet, int max_ret_len)
145145
{
146146
if (!DecodeBase58(psz, vchRet, max_ret_len > std::numeric_limits<int>::max() - 4 ? std::numeric_limits<int>::max() : max_ret_len + 4) ||
147147
(vchRet.size() < 4)) {

src/base58.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@
2525
*/
2626
std::string EncodeBase58(Span<const unsigned char> input);
2727

28-
/**
29-
* Decode a base58-encoded string (psz) into a byte vector (vchRet).
30-
* return true if decoding is successful.
31-
* psz cannot be nullptr.
32-
*/
33-
NODISCARD bool DecodeBase58(const char* psz, std::vector<unsigned char>& vchRet, int max_ret_len);
34-
3528
/**
3629
* Decode a base58-encoded string (str) into a byte vector (vchRet).
3730
* return true if decoding is successful.
@@ -43,12 +36,6 @@ NODISCARD bool DecodeBase58(const std::string& str, std::vector<unsigned char>&
4336
*/
4437
std::string EncodeBase58Check(Span<const unsigned char> input);
4538

46-
/**
47-
* Decode a base58-encoded string (psz) that includes a checksum into a byte
48-
* vector (vchRet), return true if decoding is successful
49-
*/
50-
NODISCARD bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet, int max_ret_len);
51-
5239
/**
5340
* Decode a base58-encoded string (str) that includes a checksum into a byte
5441
* vector (vchRet), return true if decoding is successful

0 commit comments

Comments
 (0)