From 00e56272e8a598fc9909ecc3df0a54c0df580676 Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Tue, 4 Oct 2016 02:53:55 +0100 Subject: [PATCH] CBitcoinAddress should use nVersionBytes == 2. Signed-off-by: Daira Hopwood --- src/base58.cpp | 16 +++++++++++++--- src/base58.h | 6 ++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/base58.cpp b/src/base58.cpp index a6152e692..12e2496da 100644 --- a/src/base58.cpp +++ b/src/base58.cpp @@ -179,9 +179,9 @@ bool CBase58Data::SetString(const char* psz, unsigned int nVersionBytes) return true; } -bool CBase58Data::SetString(const std::string& str) +bool CBase58Data::SetString(const std::string& str, unsigned int nVersionBytes) { - return SetString(str.c_str()); + return SetString(str.c_str(), nVersionBytes); } std::string CBase58Data::ToString() const @@ -251,6 +251,16 @@ bool CBitcoinAddress::IsValid(const CChainParams& params) const return fCorrectSize && fKnownVersion; } +bool CBitcoinAddress::SetString(const char* pszAddress) +{ + return CBase58Data::SetString(pszAddress, 2); +} + +bool CBitcoinAddress::SetString(const std::string& strAddress) +{ + return SetString(strAddress.c_str()); +} + CTxDestination CBitcoinAddress::Get() const { if (!IsValid()) @@ -305,7 +315,7 @@ bool CBitcoinSecret::IsValid() const bool CBitcoinSecret::SetString(const char* pszSecret) { - return CBase58Data::SetString(pszSecret) && IsValid(); + return CBase58Data::SetString(pszSecret, 1) && IsValid(); } bool CBitcoinSecret::SetString(const std::string& strSecret) diff --git a/src/base58.h b/src/base58.h index 8a442b1bc..d3967ec4e 100644 --- a/src/base58.h +++ b/src/base58.h @@ -84,8 +84,8 @@ protected: void SetData(const std::vector &vchVersionIn, const unsigned char *pbegin, const unsigned char *pend); public: - bool SetString(const char* psz, unsigned int nVersionBytes = 1); - bool SetString(const std::string& str); + bool SetString(const char* psz, unsigned int nVersionBytes); + bool SetString(const std::string& str, unsigned int nVersionBytes); std::string ToString() const; int CompareTo(const CBase58Data& b58) const; @@ -131,6 +131,8 @@ public: bool Set(const CTxDestination &dest); bool IsValid() const; bool IsValid(const CChainParams ¶ms) const; + bool SetString(const char* pszSecret); + bool SetString(const std::string& strSecret); CBitcoinAddress() {} CBitcoinAddress(const CTxDestination &dest) { Set(dest); }