diff options
| author | Pieter Wuille <[email protected]> | 2013-05-01 06:52:05 +0200 |
|---|---|---|
| committer | Pieter Wuille <[email protected]> | 2013-05-30 05:20:21 +0200 |
| commit | dfa23b94c24aae6466152fccbe896ba5dc0e97b4 (patch) | |
| tree | a1f7f856577b2223bae9351c960b595b4032ce7a /src/base58.h | |
| parent | Make CPubKey statically allocated (diff) | |
| download | discoin-dfa23b94c24aae6466152fccbe896ba5dc0e97b4.tar.xz discoin-dfa23b94c24aae6466152fccbe896ba5dc0e97b4.zip | |
CSecret/CKey -> CKey/CPubKey split/refactor
Diffstat (limited to 'src/base58.h')
| -rw-r--r-- | src/base58.h | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/base58.h b/src/base58.h index be8a541f6..efe3a95eb 100644 --- a/src/base58.h +++ b/src/base58.h @@ -398,21 +398,19 @@ bool inline CBitcoinAddressVisitor::operator()(const CNoDestination &id) const { class CBitcoinSecret : public CBase58Data { public: - void SetSecret(const CSecret& vchSecret, bool fCompressed) + void SetKey(const CKey& vchSecret) { - assert(vchSecret.size() == 32); - SetData(fTestNet ? 239 : 128, &vchSecret[0], vchSecret.size()); - if (fCompressed) + assert(vchSecret.IsValid()); + SetData(fTestNet ? 239 : 128, vchSecret.begin(), vchSecret.size()); + if (vchSecret.IsCompressed()) vchData.push_back(1); } - CSecret GetSecret(bool &fCompressedOut) + CKey GetKey() { - CSecret vchSecret; - vchSecret.resize(32); - memcpy(&vchSecret[0], &vchData[0], 32); - fCompressedOut = vchData.size() == 33; - return vchSecret; + CKey ret; + ret.Set(&vchData[0], &vchData[32], vchData.size() > 32 && vchData[32] == 1); + return ret; } bool IsValid() const @@ -443,9 +441,9 @@ public: return SetString(strSecret.c_str()); } - CBitcoinSecret(const CSecret& vchSecret, bool fCompressed) + CBitcoinSecret(const CKey& vchSecret) { - SetSecret(vchSecret, fCompressed); + SetKey(vchSecret); } CBitcoinSecret() |