X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=blobdiff_plain;f=src%2Fbase58.cpp;h=a524be6819248a7b7522ac18ee2354822de33b08;hp=184285322b984568bab2e4a2f887a28e670a6bd0;hb=fbd44e84d5841867d36d295d4f347fd5e55d293f;hpb=90d203d2e37a06a368a5ebc3af03c1d3af7ec04e diff --git a/src/base58.cpp b/src/base58.cpp index 1842853..a524be6 100644 --- a/src/base58.cpp +++ b/src/base58.cpp @@ -183,6 +183,11 @@ bool DecodeBase58Check(const std::string& str, std::vector& vchRe if (!vchData.empty()) memcpy(&vchData[0], pdata, nSize); } + + const std::vector &CBase58Data::GetData() const + { + return vchData; + } void CBase58Data::SetData(int nVersionIn, const unsigned char *pbegin, const unsigned char *pend) { @@ -243,12 +248,22 @@ bool DecodeBase58Check(const std::string& str, std::vector& vchRe return boost::apply_visitor(CBitcoinAddressVisitor(this), dest); } + bool CBitcoinAddress::Set(const CMalleablePubKey &mpk) { + std::vector vchPubkeyPair = mpk.Raw(); + SetData(fTestNet ? PUBKEY_PAIR_ADDRESS_TEST : PUBKEY_PAIR_ADDRESS, &vchPubkeyPair[0], 68); + return true; + } + bool CBitcoinAddress::IsValid() const { unsigned int nExpectedSize = 20; bool fExpectTestNet = false; switch(nVersion) { + case PUBKEY_PAIR_ADDRESS: + nExpectedSize = 68; // Serialized pair of public keys + fExpectTestNet = false; + break; case PUBKEY_ADDRESS: nExpectedSize = 20; // Hash of public key fExpectTestNet = false; @@ -258,6 +273,10 @@ bool DecodeBase58Check(const std::string& str, std::vector& vchRe fExpectTestNet = false; break; + case PUBKEY_PAIR_ADDRESS_TEST: + nExpectedSize = 68; + fExpectTestNet = true; + break; case PUBKEY_ADDRESS_TEST: nExpectedSize = 20; fExpectTestNet = true; @@ -304,6 +323,13 @@ bool DecodeBase58Check(const std::string& str, std::vector& vchRe keyID = CKeyID(id); return true; } + case PUBKEY_PAIR_ADDRESS: + case PUBKEY_PAIR_ADDRESS_TEST: + { + CMalleablePubKey mPubKey; + mPubKey.setvch(vchData); + keyID = mPubKey.GetID(); + } default: return false; } } @@ -319,6 +345,18 @@ bool DecodeBase58Check(const std::string& str, std::vector& vchRe default: return false; } } + + bool CBitcoinAddress::IsPair() const { + if (!IsValid()) + return false; + switch (nVersion) { + case PUBKEY_PAIR_ADDRESS: + case PUBKEY_PAIR_ADDRESS_TEST: { + return true; + } + default: return false; + } + } void CBitcoinSecret::SetSecret(const CSecret& vchSecret, bool fCompressed) {