- EDE2E19DD0CE3D03F54689CBEDA30B4B36152F7E532B3D34F0F8C55BB292F7D25C149B88162D96A8208997237A32566D0E555AA7105BFED8175983D80AD892E6
+ 6F22E42948D63D0887BEC91DC3A25A22C06A53F398426351B6AF18F57207CC815ED7D74BDA204AD404A16F1C56144B68137000166C72075A326C1CB6532577CF
bitcoin/src/bitcoinrpc.cpp
(7 . 6)(7 . 7)
70 #include "db.h"
71 #include "net.h"
72 #include "init.h"
73 #include "util.h"
74 #undef printf
75 #include <boost/asio.hpp>
76 #include <boost/iostreams/concepts.hpp>
(584 . 7)(585 . 7)
78 if (!key.SetCompactSignature(Hash(ss.begin(), ss.end()), vchSig))
79 return false;
80
81 return (key.GetAddress() == addr);
82 return (CBitcoinAddress(key.GetPubKey()) == addr);
83 }
84
85
(1838 . 6)(1839 . 62)
87 } // ... but will return 'false' if we already have the block.
88
89
90 Value importprivkey(const Array& params, bool fHelp)
91 {
92 if (fHelp || params.size() < 1 || params.size() > 2)
93 throw runtime_error(
94 "importprivkey <bitcoinprivkey> [label]\n"
95 "Adds a private key (as returned by dumpprivkey) to your wallet.");
96
97 string strSecret = params[0].get_str();
98 string strLabel = "";
99 if (params.size() > 1)
100 strLabel = params[1].get_str();
101 CBitcoinSecret vchSecret;
102 bool fGood = vchSecret.SetString(strSecret);
103
104 if (!fGood) throw JSONRPCError(-5,"Invalid private key");
105
106 CKey key;
107 CSecret secret = vchSecret.GetSecret();
108 key.SetSecret(secret);
109 CBitcoinAddress vchAddress = CBitcoinAddress(key.GetPubKey());
110
111 CRITICAL_BLOCK(cs_main)
112 CRITICAL_BLOCK(pwalletMain->cs_wallet)
113 {
114 pwalletMain->MarkDirty();
115 pwalletMain->SetAddressBookName(vchAddress, strLabel);
116
117 if (!pwalletMain->AddKey(key))
118 throw JSONRPCError(-4,"Error adding key to wallet");
119
120 pwalletMain->ScanForWalletTransactions(pindexGenesisBlock, true);
121 pwalletMain->ReacceptWalletTransactions();
122 }
123
124 MainFrameRepaint();
125
126 return Value::null;
127 }
128
129 Value dumpprivkey(const Array& params, bool fHelp)
130 {
131 if (fHelp || params.size() != 1)
132 throw runtime_error(
133 "dumpprivkey <bitcoinaddress>\n"
134 "Reveals the private key corresponding to <bitcoinaddress>.");
135
136 string strAddress = params[0].get_str();
137 CBitcoinAddress address;
138 if (!address.SetString(strAddress))
139 throw JSONRPCError(-5, "Invalid bitcoin address");
140 CSecret vchSecret;
141 if (!pwalletMain->GetSecret(address, vchSecret))
142 throw JSONRPCError(-4,"Private key for address " + strAddress + " is not known");
143 return CBitcoinSecret(vchSecret).ToString();
144 }
145
146
147 //
148 // Call Table
(1887 . 6)(1944 . 8)
150 make_pair("listsinceblock", &listsinceblock),
151 make_pair("dumpblock", &dumpblock),
152 make_pair("eatblock", &eatblock),
153 make_pair("importprivkey", &importprivkey),
154 make_pair("dumpprivkey", &dumpprivkey),
155 };
156 map<string, rpcfn_type> mapCallTable(pCallTable, pCallTable + sizeof(pCallTable)/sizeof(pCallTable[0]));
157