diff --git a/src/key.cpp b/src/key.cpp index 2199996cf..ac05ed254 100644 --- a/src/key.cpp +++ b/src/key.cpp @@ -509,6 +509,16 @@ bool CPubKey::IsFullyValid() const { return true; } +bool CPubKey::Compress() { + if (!IsValid()) + return false; + CECKey key; + if (!key.SetPubKey(*this)) + return false; + key.GetPubKey(*this, true); + return true; +} + bool CPubKey::Decompress() { if (!IsValid()) return false; diff --git a/src/key.h b/src/key.h index 37a06810b..56a20e15f 100644 --- a/src/key.h +++ b/src/key.h @@ -163,6 +163,9 @@ public: // Recover a public key from a compact signature. bool RecoverCompact(const uint256 &hash, const std::vector& vchSig); + // Turn this public key into a compressed public key. + bool Compress(); + // Turn this public key into an uncompressed public key. bool Decompress();