Skip to content

Commit 208fda6

Browse files
committed
CCrypter: move relevant implementation out of the header
1 parent 3155fd2 commit 208fda6

File tree

2 files changed

+41
-40
lines changed

2 files changed

+41
-40
lines changed

src/wallet/crypter.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,18 @@ bool CCryptoKeyStore::SetCrypted()
153153
return true;
154154
}
155155

156+
bool CCryptoKeyStore::IsLocked() const
157+
{
158+
if (!IsCrypted())
159+
return false;
160+
bool result;
161+
{
162+
LOCK(cs_KeyStore);
163+
result = vMasterKey.empty();
164+
}
165+
return result;
166+
}
167+
156168
bool CCryptoKeyStore::Lock()
157169
{
158170
if (!SetCrypted())
@@ -239,6 +251,18 @@ bool CCryptoKeyStore::AddCryptedKey(const CPubKey &vchPubKey, const std::vector<
239251
return true;
240252
}
241253

254+
bool CCryptoKeyStore::HaveKey(const CKeyID &address) const
255+
{
256+
{
257+
LOCK(cs_KeyStore);
258+
if (!IsCrypted()) {
259+
return CBasicKeyStore::HaveKey(address);
260+
}
261+
return mapCryptedKeys.count(address) > 0;
262+
}
263+
return false;
264+
}
265+
242266
bool CCryptoKeyStore::GetKey(const CKeyID &address, CKey& keyOut) const
243267
{
244268
{
@@ -275,6 +299,19 @@ bool CCryptoKeyStore::GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) co
275299
}
276300
}
277301

302+
std::set<CKeyID> CCryptoKeyStore::GetKeys() const
303+
{
304+
LOCK(cs_KeyStore);
305+
if (!IsCrypted()) {
306+
return CBasicKeyStore::GetKeys();
307+
}
308+
std::set<CKeyID> set_address;
309+
for (const auto& mi : mapCryptedKeys) {
310+
set_address.insert(mi.first);
311+
}
312+
return set_address;
313+
}
314+
278315
bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn)
279316
{
280317
{

src/wallet/crypter.h

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -137,52 +137,16 @@ class CCryptoKeyStore : public CBasicKeyStore
137137
{
138138
}
139139

140-
bool IsCrypted() const
141-
{
142-
return fUseCrypto;
143-
}
144-
145-
bool IsLocked() const
146-
{
147-
if (!IsCrypted())
148-
return false;
149-
bool result;
150-
{
151-
LOCK(cs_KeyStore);
152-
result = vMasterKey.empty();
153-
}
154-
return result;
155-
}
156-
140+
bool IsCrypted() const { return fUseCrypto; }
141+
bool IsLocked() const;
157142
bool Lock();
158143

159144
virtual bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret);
160145
bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey) override;
161-
bool HaveKey(const CKeyID &address) const override
162-
{
163-
{
164-
LOCK(cs_KeyStore);
165-
if (!IsCrypted()) {
166-
return CBasicKeyStore::HaveKey(address);
167-
}
168-
return mapCryptedKeys.count(address) > 0;
169-
}
170-
return false;
171-
}
146+
bool HaveKey(const CKeyID &address) const override;
172147
bool GetKey(const CKeyID &address, CKey& keyOut) const override;
173148
bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const override;
174-
std::set<CKeyID> GetKeys() const override
175-
{
176-
LOCK(cs_KeyStore);
177-
if (!IsCrypted()) {
178-
return CBasicKeyStore::GetKeys();
179-
}
180-
std::set<CKeyID> set_address;
181-
for (const auto& mi : mapCryptedKeys) {
182-
set_address.insert(mi.first);
183-
}
184-
return set_address;
185-
}
149+
std::set<CKeyID> GetKeys() const override;
186150

187151
/**
188152
* Wallet status (encrypted, locked) changed.

0 commit comments

Comments
 (0)