X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fbase58.cpp;h=b077a0b44c0368a504ed54da7f660c4607290fcd;hb=HEAD;hp=82893b1a394df7067d3f6ba1d7d5bce52881a0b3;hpb=08f00ae20145913f9c33b4a61aa16c6add80fcb7;p=novacoin.git diff --git a/src/base58.cpp b/src/base58.cpp index 82893b1..b077a0b 100644 --- a/src/base58.cpp +++ b/src/base58.cpp @@ -13,11 +13,8 @@ // - Double-clicking selects the whole number as one word if it's all alphanumeric. // -#include -#include -#include "key.h" -#include "script.h" #include "base58.h" +#include "hash.h" static const std::array digits = { '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', @@ -261,7 +258,7 @@ bool DecodeBase58Check(const std::string& str, std::vector& vchRe std::string CBase58Data::ToString() const { - std::vector vch(1, nVersion); + std::vector vch{nVersion}; vch.insert(vch.end(), vchData.begin(), vchData.end()); return EncodeBase58Check(vch); } @@ -275,6 +272,20 @@ bool DecodeBase58Check(const std::string& str, std::vector& vchRe return 0; } + namespace { + class CBitcoinAddressVisitor { + private: + CBitcoinAddress *addr; + public: + explicit CBitcoinAddressVisitor(CBitcoinAddress *addrIn) : addr(addrIn) { } + + bool operator()(const CKeyID &id) const { return addr->Set(id); } + bool operator()(const CScriptID &id) const { return addr->Set(id); } + bool operator()(const CMalleablePubKey &mpk) const { return addr->Set(mpk); } + bool operator()([[maybe_unused]] const CNoDestination &no) const { return false; } + }; + } // namespace + bool CBitcoinAddress::Set(const CKeyID &id) { SetData(fTestNet ? PUBKEY_ADDRESS_TEST : PUBKEY_ADDRESS, &id, 20); return true; @@ -287,7 +298,7 @@ bool DecodeBase58Check(const std::string& str, std::vector& vchRe bool CBitcoinAddress::Set(const CTxDestination &dest) { - return boost::apply_visitor(CBitcoinAddressVisitor(this), dest); + return std::visit(CBitcoinAddressVisitor(this), dest); } bool CBitcoinAddress::Set(const CMalleablePubKey &mpk) { @@ -347,7 +358,7 @@ bool DecodeBase58Check(const std::string& str, std::vector& vchRe if (fSeemsSane && !fSimple) { - // Perform dditional checking + // Perform additional checking // for pubkey pair addresses CMalleablePubKey mpk; mpk.setvch(vchData); @@ -485,5 +496,3 @@ bool DecodeBase58Check(const std::string& str, std::vector& vchRe { SetSecret(vchSecret, fCompressed); } - -