Changeset View
Changeset View
Standalone View
Standalone View
src/base58.cpp
Show First 20 Lines • Show All 224 Lines • ▼ Show 20 Lines | public: | ||||
bool IsValid(const CChainParams ¶ms) const; | bool IsValid(const CChainParams ¶ms) const; | ||||
CBitcoinAddress() {} | CBitcoinAddress() {} | ||||
CBitcoinAddress(const CTxDestination &dest) { Set(dest); } | CBitcoinAddress(const CTxDestination &dest) { Set(dest); } | ||||
CBitcoinAddress(const std::string &strAddress) { SetString(strAddress); } | CBitcoinAddress(const std::string &strAddress) { SetString(strAddress); } | ||||
CBitcoinAddress(const char *pszAddress) { SetString(pszAddress); } | CBitcoinAddress(const char *pszAddress) { SetString(pszAddress); } | ||||
CTxDestination Get() const; | CTxDestination Get() const; | ||||
bool GetKeyID(CKeyID &keyID) const; | |||||
bool IsScript() const; | |||||
}; | }; | ||||
class CBitcoinAddressVisitor : public boost::static_visitor<bool> { | class CBitcoinAddressVisitor : public boost::static_visitor<bool> { | ||||
private: | private: | ||||
CBitcoinAddress *addr; | CBitcoinAddress *addr; | ||||
public: | public: | ||||
CBitcoinAddressVisitor(CBitcoinAddress *addrIn) : addr(addrIn) {} | CBitcoinAddressVisitor(CBitcoinAddress *addrIn) : addr(addrIn) {} | ||||
Show All 40 Lines | CTxDestination CBitcoinAddress::Get() const { | ||||
} else if (vchVersion == | } else if (vchVersion == | ||||
Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS)) { | Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS)) { | ||||
return CScriptID(id); | return CScriptID(id); | ||||
} else { | } else { | ||||
return CNoDestination(); | return CNoDestination(); | ||||
} | } | ||||
} | } | ||||
bool CBitcoinAddress::GetKeyID(CKeyID &keyID) const { | |||||
if (!IsValid() || | |||||
vchVersion != Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS)) { | |||||
return false; | |||||
} | |||||
uint160 id; | |||||
memcpy(&id, &vchData[0], 20); | |||||
keyID = CKeyID(id); | |||||
return true; | |||||
} | |||||
bool CBitcoinAddress::IsScript() const { | |||||
return IsValid() && | |||||
vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS); | |||||
} | |||||
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); | ||||
} | } | ||||
CKey CBitcoinSecret::GetKey() { | CKey CBitcoinSecret::GetKey() { | ||||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |