aboutsummaryrefslogtreecommitdiff
path: root/src/wallet.cpp
diff options
context:
space:
mode:
authorJeff Garzik <[email protected]>2013-05-30 07:55:25 -0700
committerJeff Garzik <[email protected]>2013-05-30 07:55:25 -0700
commite2f42142a03fa817a7fe6529fc1d55ef2d016352 (patch)
treea298361e95260b418a2bf82665390441e954954e /src/wallet.cpp
parentMerge pull request #2693 from jgarzik/checkpoint-bool (diff)
parentMake signature cache store CPubKeys (diff)
downloaddiscoin-e2f42142a03fa817a7fe6529fc1d55ef2d016352.tar.xz
discoin-e2f42142a03fa817a7fe6529fc1d55ef2d016352.zip
Merge pull request #2600 from sipa/keyrefactor
Refactor key.cpp/.h
Diffstat (limited to 'src/wallet.cpp')
-rw-r--r--src/wallet.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp
index c70ea20e8..5efc45583 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -32,26 +32,28 @@ CPubKey CWallet::GenerateNewKey()
bool fCompressed = CanSupportFeature(FEATURE_COMPRPUBKEY); // default to compressed public keys if we want 0.6.0 wallets
RandAddSeedPerfmon();
- CKey key;
- key.MakeNewKey(fCompressed);
+ CKey secret;
+ secret.MakeNewKey(fCompressed);
// Compressed public keys were introduced in version 0.6.0
if (fCompressed)
SetMinVersion(FEATURE_COMPRPUBKEY);
- if (!AddKey(key))
+ CPubKey pubkey = secret.GetPubKey();
+ if (!AddKeyPubKey(secret, pubkey))
throw std::runtime_error("CWallet::GenerateNewKey() : AddKey failed");
- return key.GetPubKey();
+ return pubkey;
}
-bool CWallet::AddKey(const CKey& key)
+bool CWallet::AddKeyPubKey(const CKey& secret, const CPubKey &pubkey)
{
- if (!CCryptoKeyStore::AddKey(key))
+ if (!CCryptoKeyStore::AddKeyPubKey(secret, pubkey))
return false;
if (!fFileBacked)
return true;
- if (!IsCrypted())
- return CWalletDB(strWalletFile).WriteKey(key.GetPubKey(), key.GetPrivKey());
+ if (!IsCrypted()) {
+ return CWalletDB(strWalletFile).WriteKey(pubkey, secret.GetPrivKey());
+ }
return true;
}