Changeset View
Changeset View
Standalone View
Standalone View
src/base58.cpp
Show First 20 Lines • Show All 251 Lines • ▼ Show 20 Lines | const std::vector<uint8_t> &script_prefix = | ||||
params.Base58Prefix(CChainParams::SCRIPT_ADDRESS); | params.Base58Prefix(CChainParams::SCRIPT_ADDRESS); | ||||
if (data.size() == 20 + script_prefix.size() && | if (data.size() == 20 + script_prefix.size() && | ||||
std::equal(script_prefix.begin(), script_prefix.end(), data.begin())) { | std::equal(script_prefix.begin(), script_prefix.end(), data.begin())) { | ||||
memcpy(hash.begin(), &data[script_prefix.size()], 20); | memcpy(hash.begin(), &data[script_prefix.size()], 20); | ||||
return CScriptID(hash); | return CScriptID(hash); | ||||
} | } | ||||
return CNoDestination(); | return CNoDestination(); | ||||
} | } | ||||
} // namespace | |||||
} // namespace | } // namespace | ||||
void CBitcoinSecret::SetKey(const CKey &vchSecret) { | void CBitcoinSecret::SetKey(const CKey &vchSecret) { | ||||
assert(vchSecret.IsValid()); | assert(vchSecret.IsValid()); | ||||
SetData(Params().Base58Prefix(CChainParams::SECRET_KEY), vchSecret.begin(), | SetData(Params().Base58Prefix(CChainParams::SECRET_KEY), vchSecret.begin(), | ||||
vchSecret.size()); | vchSecret.size()); | ||||
if (vchSecret.IsCompressed()) vchData.push_back(1); | if (vchSecret.IsCompressed()) vchData.push_back(1); | ||||
Show All 18 Lines | |||||
bool CBitcoinSecret::SetString(const char *pszSecret) { | bool CBitcoinSecret::SetString(const char *pszSecret) { | ||||
return CBase58Data::SetString(pszSecret) && IsValid(); | return CBase58Data::SetString(pszSecret) && IsValid(); | ||||
} | } | ||||
bool CBitcoinSecret::SetString(const std::string &strSecret) { | bool CBitcoinSecret::SetString(const std::string &strSecret) { | ||||
return SetString(strSecret.c_str()); | return SetString(strSecret.c_str()); | ||||
} | } | ||||
std::string EncodeDestination(const CTxDestination &dest) { | std::string EncodeLegacyAddr(const CTxDestination &dest, | ||||
return boost::apply_visitor(DestinationEncoder(Params()), dest); | |||||
} | |||||
CTxDestination DecodeDestination(const std::string &str) { | |||||
return DecodeDestination(str, Params()); | |||||
} | |||||
bool IsValidDestinationString(const std::string &str, | |||||
const CChainParams ¶ms) { | const CChainParams ¶ms) { | ||||
return IsValidDestination(DecodeDestination(str, params)); | return boost::apply_visitor(DestinationEncoder(params), dest); | ||||
} | } | ||||
bool IsValidDestinationString(const std::string &str) { | CTxDestination DecodeLegacyAddr(const std::string &str, | ||||
return IsValidDestination(DecodeDestination(str, Params())); | const CChainParams ¶ms) { | ||||
return DecodeDestination(str, params); | |||||
} | } |