aboutsummaryrefslogtreecommitdiff
path: root/src/keystore.cpp
diff options
context:
space:
mode:
authorPieter Wuille <[email protected]>2011-06-18 17:36:25 -0700
committerPieter Wuille <[email protected]>2011-06-18 17:36:25 -0700
commita6b211596323a8f2de20f8ab97e38969bece30fb (patch)
treeab08fe8b2a13873284dce843fb39ee3b8ccdeaf1 /src/keystore.cpp
parentdoc/release-process.txt: minor updates (diff)
parentCWallet class (diff)
downloaddiscoin-a6b211596323a8f2de20f8ab97e38969bece30fb.tar.xz
discoin-a6b211596323a8f2de20f8ab97e38969bece30fb.zip
Merge pull request #288 from sipa/walletclass
CWallet class
Diffstat (limited to 'src/keystore.cpp')
-rw-r--r--src/keystore.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/keystore.cpp b/src/keystore.cpp
new file mode 100644
index 000000000..7dd045fe5
--- /dev/null
+++ b/src/keystore.cpp
@@ -0,0 +1,33 @@
+// Copyright (c) 2009-2011 Satoshi Nakamoto & Bitcoin developers
+// Distributed under the MIT/X11 software license, see the accompanying
+// file license.txt or http://www.opensource.org/licenses/mit-license.php.
+
+#include "headers.h"
+#include "db.h"
+
+
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// mapKeys
+//
+
+std::vector<unsigned char> CKeyStore::GenerateNewKey()
+{
+ RandAddSeedPerfmon();
+ CKey key;
+ key.MakeNewKey();
+ if (!AddKey(key))
+ throw std::runtime_error("GenerateNewKey() : AddKey failed");
+ return key.GetPubKey();
+}
+
+bool CKeyStore::AddKey(const CKey& key)
+{
+ CRITICAL_BLOCK(cs_mapKeys)
+ {
+ mapKeys[key.GetPubKey()] = key.GetPrivKey();
+ mapPubKeys[Hash160(key.GetPubKey())] = key.GetPubKey();
+ }
+}
+