X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=blobdiff_plain;f=src%2Fkey.cpp;h=9503f958972a08a7b4ef97734634542c8cca0d92;hp=eb4f5c4520b1121bfce17cdf4105d13685d72460;hb=e5e4c598dc43bb5e01b3a30aaeb2dfc9376bd7b4;hpb=bd4a1340b19f76cbb4e0507a30621d0be37394af diff --git a/src/key.cpp b/src/key.cpp index eb4f5c4..9503f95 100644 --- a/src/key.cpp +++ b/src/key.cpp @@ -1004,6 +1004,14 @@ CMalleableKeyView::CMalleableKeyView(const CMalleableKey &b) vchPubKeyH = H.GetPubKey().Raw(); } +CMalleableKeyView::CMalleableKeyView(const CMalleableKeyView &b) +{ + assert(b.nVersion == CURRENT_VERSION); + vchSecretL = b.vchSecretL; + vchPubKeyH = b.vchPubKeyH; + nVersion = CURRENT_VERSION; +} + CMalleableKeyView::CMalleableKeyView(const CSecret &L, const CPubKey &pvchPubKeyH) { vchSecretL = L; @@ -1095,6 +1103,33 @@ bool CMalleableKeyView::CheckKeyVariant(const CPubKey &R, const CPubKey &vchPubK return true; } +std::string CMalleableKeyView::ToString() +{ + CDataStream ssKey(SER_NETWORK, PROTOCOL_VERSION); + ssKey << *this; + std::vector vch(ssKey.begin(), ssKey.end()); + + return EncodeBase58Check(vch); +} + +bool CMalleableKeyView::SetString(const std::string& strMutableKey) +{ + std::vector vchTemp; + if (!DecodeBase58Check(strMutableKey, vchTemp)) { + throw key_error("CMalleableKeyView::SetString() : Provided key data seems corrupted."); + } + + CDataStream ssKey(vchTemp, SER_NETWORK, PROTOCOL_VERSION); + ssKey >> *this; + + return IsNull(); +} + +bool CMalleableKeyView::IsNull() const +{ + return nVersion != CURRENT_VERSION; +} + //// Asymmetric encryption void CPubKey::EncryptData(const std::vector& data, std::vector& encrypted)