mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 13:03:17 +01:00
Fix subscript[0] in base58.cpp
This commit is contained in:
parent
6896dbf169
commit
361d95265a
@ -110,7 +110,7 @@ std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend)
|
|||||||
|
|
||||||
std::string EncodeBase58(const std::vector<unsigned char>& vch)
|
std::string EncodeBase58(const std::vector<unsigned char>& vch)
|
||||||
{
|
{
|
||||||
return EncodeBase58(&vch[0], &vch[0] + vch.size());
|
return EncodeBase58(vch.data(), vch.data() + vch.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet)
|
bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet)
|
||||||
@ -160,7 +160,7 @@ void CBase58Data::SetData(const std::vector<unsigned char>& vchVersionIn, const
|
|||||||
vchVersion = vchVersionIn;
|
vchVersion = vchVersionIn;
|
||||||
vchData.resize(nSize);
|
vchData.resize(nSize);
|
||||||
if (!vchData.empty())
|
if (!vchData.empty())
|
||||||
memcpy(&vchData[0], pdata, nSize);
|
memcpy(vchData.data(), pdata, nSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBase58Data::SetData(const std::vector<unsigned char>& vchVersionIn, const unsigned char* pbegin, const unsigned char* pend)
|
void CBase58Data::SetData(const std::vector<unsigned char>& vchVersionIn, const unsigned char* pbegin, const unsigned char* pend)
|
||||||
@ -180,8 +180,8 @@ bool CBase58Data::SetString(const char* psz, unsigned int nVersionBytes)
|
|||||||
vchVersion.assign(vchTemp.begin(), vchTemp.begin() + nVersionBytes);
|
vchVersion.assign(vchTemp.begin(), vchTemp.begin() + nVersionBytes);
|
||||||
vchData.resize(vchTemp.size() - nVersionBytes);
|
vchData.resize(vchTemp.size() - nVersionBytes);
|
||||||
if (!vchData.empty())
|
if (!vchData.empty())
|
||||||
memcpy(&vchData[0], &vchTemp[nVersionBytes], vchData.size());
|
memcpy(vchData.data(), vchTemp.data() + nVersionBytes, vchData.size());
|
||||||
memory_cleanse(&vchTemp[0], vchTemp.size());
|
memory_cleanse(vchTemp.data(), vchTemp.size());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,7 +262,7 @@ CTxDestination CBitcoinAddress::Get() const
|
|||||||
if (!IsValid())
|
if (!IsValid())
|
||||||
return CNoDestination();
|
return CNoDestination();
|
||||||
uint160 id;
|
uint160 id;
|
||||||
memcpy(&id, &vchData[0], 20);
|
memcpy(&id, vchData.data(), 20);
|
||||||
if (vchVersion == Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS))
|
if (vchVersion == Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS))
|
||||||
return CKeyID(id);
|
return CKeyID(id);
|
||||||
else if (vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS))
|
else if (vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS))
|
||||||
@ -276,7 +276,7 @@ bool CBitcoinAddress::GetKeyID(CKeyID& keyID) const
|
|||||||
if (!IsValid() || vchVersion != Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS))
|
if (!IsValid() || vchVersion != Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS))
|
||||||
return false;
|
return false;
|
||||||
uint160 id;
|
uint160 id;
|
||||||
memcpy(&id, &vchData[0], 20);
|
memcpy(&id, vchData.data(), 20);
|
||||||
keyID = CKeyID(id);
|
keyID = CKeyID(id);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ public:
|
|||||||
K ret;
|
K ret;
|
||||||
if (vchData.size() == Size) {
|
if (vchData.size() == Size) {
|
||||||
// If base58 encoded data does not hold an ext key, return a !IsValid() key
|
// If base58 encoded data does not hold an ext key, return a !IsValid() key
|
||||||
ret.Decode(&vchData[0]);
|
ret.Decode(vchData.data());
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user