diff options
Diffstat (limited to 'src/rpcdump.cpp')
| -rw-r--r-- | src/rpcdump.cpp | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/rpcdump.cpp b/src/rpcdump.cpp index 1bc87e921..30e504a09 100644 --- a/src/rpcdump.cpp +++ b/src/rpcdump.cpp @@ -1,25 +1,19 @@ // Copyright (c) 2009-2012 Bitcoin Developers // Distributed under the MIT/X11 software license, see the accompanying -// file license.txt or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "init.h" // for pwalletMain #include "bitcoinrpc.h" #include "ui_interface.h" +#include "base58.h" #include <boost/lexical_cast.hpp> -#include "json/json_spirit_reader_template.h" -#include "json/json_spirit_writer_template.h" -#include "json/json_spirit_utils.h" - #define printf OutputDebugStringF -// using namespace boost::asio; using namespace json_spirit; using namespace std; -extern Object JSONRPCError(int code, const string& message); - class CTxDump { public: @@ -58,8 +52,7 @@ Value importprivkey(const Array& params, bool fHelp) bool fCompressed; CSecret secret = vchSecret.GetSecret(fCompressed); key.SetSecret(secret, fCompressed); - CBitcoinAddress vchAddress = CBitcoinAddress(key.GetPubKey()); - + CKeyID vchAddress = key.GetPubKey().GetID(); { LOCK2(cs_main, pwalletMain->cs_wallet); @@ -73,8 +66,6 @@ Value importprivkey(const Array& params, bool fHelp) pwalletMain->ReacceptWalletTransactions(); } - MainFrameRepaint(); - return Value::null; } @@ -88,10 +79,13 @@ Value dumpprivkey(const Array& params, bool fHelp) string strAddress = params[0].get_str(); CBitcoinAddress address; if (!address.SetString(strAddress)) - throw JSONRPCError(-5, "Invalid bitcoin address"); + throw JSONRPCError(-5, "Invalid Bitcoin address"); + CKeyID keyID; + if (!address.GetKeyID(keyID)) + throw JSONRPCError(-3, "Address does not refer to a key"); CSecret vchSecret; bool fCompressed; - if (!pwalletMain->GetSecret(address, vchSecret, fCompressed)) + if (!pwalletMain->GetSecret(keyID, vchSecret, fCompressed)) throw JSONRPCError(-4,"Private key for address " + strAddress + " is not known"); return CBitcoinSecret(vchSecret, fCompressed).ToString(); } |