Changeset View
Changeset View
Standalone View
Standalone View
src/test/base58_tests.cpp
Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
// Visitor to check address type | // Visitor to check address type | ||||
class TestAddrTypeVisitor : public boost::static_visitor<bool> { | class TestAddrTypeVisitor : public boost::static_visitor<bool> { | ||||
private: | private: | ||||
std::string exp_addrType; | std::string exp_addrType; | ||||
public: | public: | ||||
TestAddrTypeVisitor(const std::string &_exp_addrType) | explicit TestAddrTypeVisitor(const std::string &_exp_addrType) | ||||
: exp_addrType(_exp_addrType) {} | : exp_addrType(_exp_addrType) {} | ||||
bool operator()(const CKeyID &id) const { | bool operator()(const CKeyID &id) const { | ||||
return (exp_addrType == "pubkey"); | return (exp_addrType == "pubkey"); | ||||
} | } | ||||
bool operator()(const CScriptID &id) const { | bool operator()(const CScriptID &id) const { | ||||
return (exp_addrType == "script"); | return (exp_addrType == "script"); | ||||
} | } | ||||
bool operator()(const CNoDestination &no) const { | bool operator()(const CNoDestination &no) const { | ||||
return (exp_addrType == "none"); | return (exp_addrType == "none"); | ||||
} | } | ||||
}; | }; | ||||
// Visitor to check address payload | // Visitor to check address payload | ||||
class TestPayloadVisitor : public boost::static_visitor<bool> { | class TestPayloadVisitor : public boost::static_visitor<bool> { | ||||
private: | private: | ||||
std::vector<uint8_t> exp_payload; | std::vector<uint8_t> exp_payload; | ||||
public: | public: | ||||
TestPayloadVisitor(std::vector<uint8_t> &_exp_payload) | explicit TestPayloadVisitor(std::vector<uint8_t> &_exp_payload) | ||||
: exp_payload(_exp_payload) {} | : exp_payload(_exp_payload) {} | ||||
bool operator()(const CKeyID &id) const { | bool operator()(const CKeyID &id) const { | ||||
uint160 exp_key(exp_payload); | uint160 exp_key(exp_payload); | ||||
return exp_key == id; | return exp_key == id; | ||||
} | } | ||||
bool operator()(const CScriptID &id) const { | bool operator()(const CScriptID &id) const { | ||||
uint160 exp_key(exp_payload); | uint160 exp_key(exp_payload); | ||||
return exp_key == id; | return exp_key == id; | ||||
▲ Show 20 Lines • Show All 160 Lines • Show Last 20 Lines |