tree checksum vpatch file split hunks
all signers: mircea_popescu trinque asciilifeform ben_vulpes mod6
antecedents: bitcoin-asciilifeform.1 genesis asciilifeform_lets_lose_testnet
press order:
patch:
(18 . 6)(18 . 7)- EDE2E19DD0CE3D03F54689CBEDA30B4B36152F7E532B3D34F0F8C55BB292F7D25C149B88162D96A8208997237A32566D0E555AA7105BFED8175983D80AD892E6
5 #include <string>
6 #include <vector>
7 #include "bignum.h"
8 #include "key.h"
9
10 static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
11
(313 . 6)(314 . 53)
13 memcpy(&hash160, &vchData[0], 20);
14 return hash160;
15 }
16
17 };
18
19 /** A base58-encoded secret key */
20 class CBitcoinSecret : public CBase58Data
21 {
22 public:
23 void SetSecret(const CSecret& vchSecret)
24 {
25 assert(vchSecret.size() == 32);
26 SetData(128, &vchSecret[0], vchSecret.size());
27 }
28
29 CSecret GetSecret()
30 {
31 CSecret vchSecret;
32 vchSecret.resize(32);
33 memcpy(&vchSecret[0], &vchData[0], 32);
34 return vchSecret;
35 }
36
37 bool IsValid() const
38 {
39 bool fExpectTestNet = false;
40 switch(nVersion)
41 {
42 case 128:
43 break;
44
45 case 239:
46 fExpectTestNet = true;
47 break;
48
49 default:
50 return false;
51 }
52 return (vchData.size() == 32 || (vchData.size() == 33 && vchData[32] == 1));
53 }
54
55 CBitcoinSecret(const CSecret& vchSecret)
56 {
57 SetSecret(vchSecret);
58 }
59
60 CBitcoinSecret()
61 {
62 }
63 };
64
65 #endif
(7 . 6)(7 . 7)- 6B2389129DEC411D013D754EAEBC169A23F60B2169DC41CCED21248A603CED46DFDC64E016C082A154AF87784049333BE75C91FB08265306A3BDC2BC0AF2E6C5
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
(14 . 7)(14 . 6)- D11A428A6FD4D8431CCE1195406DFF39B0A585A0F44C6156A07A33E02C61D711220747B25BF9C341E88DEAE60719C1DDEB03DF016F7374B966B3A0B830E6F98A
162
163 #include "serialize.h"
164 #include "uint256.h"
165 #include "base58.h"
166
167 // secp160k1
168 // const unsigned int PRIVATE_KEY_SIZE = 192;
(385 . 12)(384 . 6)
170 return true;
171 }
172
173 // Get the address corresponding to this key
174 CBitcoinAddress GetAddress() const
175 {
176 return CBitcoinAddress(GetPubKey());
177 }
178
179 bool IsValid()
180 {
181 if (!fSet)
(29 . 7)(29 . 7)
186 bool CBasicKeyStore::AddKey(const CKey& key)
187 {
188 CRITICAL_BLOCK(cs_KeyStore)
189 mapKeys[key.GetAddress()] = key.GetSecret();
190 mapKeys[CBitcoinAddress(key.GetPubKey())] = key.GetSecret();
191 return true;
192 }
193
- 247C94EA309F95DDC3B90DCD41DD9212BD5269E8772816BB272A1152422CC1C50BEAD6370495043A9ABC924E119C926D55ECD7F39D1022C7D4EB50718188A641(28 . 6)(28 . 15)
198 // This may succeed even if GetKey fails (e.g., encrypted wallets)
199 virtual bool GetPubKey(const CBitcoinAddress &address, std::vector<unsigned char>& vchPubKeyOut) const;
200
201 virtual bool GetSecret(const CBitcoinAddress &address, CSecret& vchSecret) const
202 {
203 CKey key;
204 if (!GetKey(address, key))
205 return false;
206 vchSecret = key.GetSecret();
207 return true;
208 }
209
210 // Generate a new key, and add it to the store
211 virtual std::vector<unsigned char> GenerateNewKey();
212 };
- BDC4FC472BE4A86FB91FA69368FAACE04414FDEEE5B8C82795E31D37E21581B973CAF7F3E9CCC27D487944A5782E3B59615180EAB87C8B3E81242901F3039E4D(224 . 6)(224 . 15)
217 }
218 }
219
220 void CWallet::MarkDirty()
221 {
222 CRITICAL_BLOCK(cs_wallet)
223 {
224 BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet)
225 item.second.MarkDirty();
226 }
227 }
228
229 bool CWallet::AddToWallet(const CWalletTx& wtxIn)
230 {
231 uint256 hash = wtxIn.GetHash();
- 86F5E1CA584E6AA01B956278EA06EFF4F79B58CA386C490FE605384923F90FCC710FD6BF2F14926D5DFD43E17FC5655A0150B32BC750F05506BAF439255C8E30(73 . 6)(73 . 7)
236 bool Unlock(const SecureString& strWalletPassphrase);
237 bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase);
238 bool EncryptWallet(const SecureString& strWalletPassphrase);
239 void MarkDirty();
240
241 bool AddToWallet(const CWalletTx& wtxIn);
242 bool AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate = false);