aboutsummaryrefslogtreecommitdiff
path: root/src/base58.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2019-11-18 15:16:50 -0800
committerPieter Wuille <pieter.wuille@gmail.com>2019-11-19 15:38:27 -0800
commit2bcf1fc444d5c4b8efa879e54e7b6134b7e6b986 (patch)
tree333cb13784c3cd48d5ade305246212ddbd590386 /src/base58.h
parentb4a1da9ef8e4b673c290d5b882527e627ae1b43a (diff)
downloadbitcoin-2bcf1fc444d5c4b8efa879e54e7b6134b7e6b986.tar.xz
Pass a maximum output length to DecodeBase58 and DecodeBase58Check
Also remove a needless loop in DecodeBase58 to prune zeroes in the base256 output of the conversion. The number of zeroes is implied by keeping track explicitly of the length during the loop.
Diffstat (limited to 'src/base58.h')
-rw-r--r--src/base58.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/base58.h b/src/base58.h
index d6e0299a1e..cfdab511b6 100644
--- a/src/base58.h
+++ b/src/base58.h
@@ -16,6 +16,7 @@
#include <attributes.h>
+#include <limits>
#include <string>
#include <vector>
@@ -35,13 +36,13 @@ std::string EncodeBase58(const std::vector<unsigned char>& vch);
* return true if decoding is successful.
* psz cannot be nullptr.
*/
-NODISCARD bool DecodeBase58(const char* psz, std::vector<unsigned char>& vchRet);
+NODISCARD bool DecodeBase58(const char* psz, std::vector<unsigned char>& vchRet, int max_ret_len = std::numeric_limits<int>::max());
/**
* Decode a base58-encoded string (str) into a byte vector (vchRet).
* return true if decoding is successful.
*/
-NODISCARD bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet);
+NODISCARD bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet, int max_ret_len = std::numeric_limits<int>::max());
/**
* Encode a byte vector into a base58-encoded string, including checksum
@@ -52,12 +53,12 @@ std::string EncodeBase58Check(const std::vector<unsigned char>& vchIn);
* 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);
+NODISCARD bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet, int max_ret_len = std::numeric_limits<int>::max());
/**
* Decode a base58-encoded string (str) that includes a checksum into a byte
* vector (vchRet), return true if decoding is successful
*/
-NODISCARD bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet);
+NODISCARD bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet, int max_ret_len = std::numeric_limits<int>::max());
#endif // BITCOIN_BASE58_H