tree checksum vpatch file split hunks
all signers: mircea_popescu trinque asciilifeform ben_vulpes mod6
antecedents: bitcoin-asciilifeform.1 genesis mod6_der_high_low_s 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
(315 . 4)(316 . 32)
13 }
14 };
15
16 /** A base58-encoded secret key */
17 class CBitcoinSecret : public CBase58Data
18 {
19 public:
20 void SetSecret(const CSecret& vchSecret)
21 {
22 assert(vchSecret.size() == 32);
23 SetData(128, &vchSecret[0], vchSecret.size());
24 }
25
26 CSecret GetSecret()
27 {
28 CSecret vchSecret;
29 vchSecret.resize(32);
30 memcpy(&vchSecret[0], &vchData[0], 32);
31 return vchSecret;
32 }
33
34 CBitcoinSecret(const CSecret& vchSecret)
35 {
36 SetSecret(vchSecret);
37 }
38
39 CBitcoinSecret()
40 {
41 }
42 };
43
44 #endif
(7 . 6)(7 . 7)- AFE71ADE56FAE65B970FF3DFB3F14EDACEE0AF497AE57E2D2502C9A4B4F49F3336F9D3794B72A87D185B92FC01F1A5077E1CCD63A61AC4FA9C4464C6224FD1E4
49 #include "db.h"
50 #include "net.h"
51 #include "init.h"
52 #include "util.h"
53 #undef printf
54 #include <boost/asio.hpp>
55 #include <boost/iostreams/concepts.hpp>
(584 . 7)(585 . 7)
57 if (!key.SetCompactSignature(Hash(ss.begin(), ss.end()), vchSig))
58 return false;
59
60 return (key.GetAddress() == addr);
61 return (CBitcoinAddress(key.GetPubKey()) == addr);
62 }
63
64
(1838 . 6)(1839 . 60)
66 } // ... but will return 'false' if we already have the block.
67
68
69 Value importprivkey(const Array& params, bool fHelp)
70 {
71 if (fHelp || params.size() < 1 || params.size() > 2)
72 throw runtime_error(
73 "importprivkey <bitcoinprivkey> [label]\n"
74 "Adds a private key (as returned by dumpprivkey) to your wallet.");
75
76 string strSecret = params[0].get_str();
77 string strLabel = "";
78 if (params.size() > 1)
79 strLabel = params[1].get_str();
80 CBitcoinSecret vchSecret;
81 bool fGood = vchSecret.SetString(strSecret);
82
83 if (!fGood) throw JSONRPCError(-5,"Invalid private key");
84
85 CKey key;
86 CSecret secret = vchSecret.GetSecret();
87 key.SetSecret(secret);
88 CBitcoinAddress vchAddress = CBitcoinAddress(key.GetPubKey());
89
90 CRITICAL_BLOCK(cs_main)
91 CRITICAL_BLOCK(pwalletMain->cs_wallet)
92 {
93 pwalletMain->MarkDirty();
94 pwalletMain->SetAddressBookName(vchAddress, strLabel);
95
96 if (!pwalletMain->AddKey(key))
97 throw JSONRPCError(-4,"Error adding key to wallet");
98
99 pwalletMain->ScanForWalletTransactions(pindexGenesisBlock, true);
100 pwalletMain->ReacceptWalletTransactions();
101 }
102
103 return Value::null;
104 }
105
106 Value dumpprivkey(const Array& params, bool fHelp)
107 {
108 if (fHelp || params.size() != 1)
109 throw runtime_error(
110 "dumpprivkey <bitcoinaddress>\n"
111 "Reveals the private key corresponding to <bitcoinaddress>.");
112
113 string strAddress = params[0].get_str();
114 CBitcoinAddress address;
115 if (!address.SetString(strAddress))
116 throw JSONRPCError(-5, "Invalid bitcoin address");
117 CSecret vchSecret;
118 if (!pwalletMain->GetSecret(address, vchSecret))
119 throw JSONRPCError(-4,"Private key for address " + strAddress + " is not known");
120 return CBitcoinSecret(vchSecret).ToString();
121 }
122
123
124 //
125 // Call Table
(1887 . 6)(1942 . 8)
127 make_pair("listsinceblock", &listsinceblock),
128 make_pair("dumpblock", &dumpblock),
129 make_pair("eatblock", &eatblock),
130 make_pair("importprivkey", &importprivkey),
131 make_pair("dumpprivkey", &dumpprivkey),
132 };
133 map<string, rpcfn_type> mapCallTable(pCallTable, pCallTable + sizeof(pCallTable)/sizeof(pCallTable[0]));
134
(14 . 7)(14 . 6)- D11A428A6FD4D8431CCE1195406DFF39B0A585A0F44C6156A07A33E02C61D711220747B25BF9C341E88DEAE60719C1DDEB03DF016F7374B966B3A0B830E6F98A
139
140 #include "serialize.h"
141 #include "uint256.h"
142 #include "base58.h"
143
144 // secp160k1
145 // const unsigned int PRIVATE_KEY_SIZE = 192;
(419 . 12)(418 . 6)
147 return true;
148 }
149
150 // Get the address corresponding to this key
151 CBitcoinAddress GetAddress() const
152 {
153 return CBitcoinAddress(GetPubKey());
154 }
155
156 bool IsValid()
157 {
158 if (!fSet)
(29 . 7)(29 . 7)
163 bool CBasicKeyStore::AddKey(const CKey& key)
164 {
165 CRITICAL_BLOCK(cs_KeyStore)
166 mapKeys[key.GetAddress()] = key.GetSecret();
167 mapKeys[CBitcoinAddress(key.GetPubKey())] = key.GetSecret();
168 return true;
169 }
170
- 247C94EA309F95DDC3B90DCD41DD9212BD5269E8772816BB272A1152422CC1C50BEAD6370495043A9ABC924E119C926D55ECD7F39D1022C7D4EB50718188A641(28 . 6)(28 . 15)
175 // This may succeed even if GetKey fails (e.g., encrypted wallets)
176 virtual bool GetPubKey(const CBitcoinAddress &address, std::vector<unsigned char>& vchPubKeyOut) const;
177
178 virtual bool GetSecret(const CBitcoinAddress &address, CSecret& vchSecret) const
179 {
180 CKey key;
181 if (!GetKey(address, key))
182 return false;
183 vchSecret = key.GetSecret();
184 return true;
185 }
186
187 // Generate a new key, and add it to the store
188 virtual std::vector<unsigned char> GenerateNewKey();
189 };
- BDC4FC472BE4A86FB91FA69368FAACE04414FDEEE5B8C82795E31D37E21581B973CAF7F3E9CCC27D487944A5782E3B59615180EAB87C8B3E81242901F3039E4D(224 . 6)(224 . 15)
194 }
195 }
196
197 void CWallet::MarkDirty()
198 {
199 CRITICAL_BLOCK(cs_wallet)
200 {
201 BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet)
202 item.second.MarkDirty();
203 }
204 }
205
206 bool CWallet::AddToWallet(const CWalletTx& wtxIn)
207 {
208 uint256 hash = wtxIn.GetHash();
- 86F5E1CA584E6AA01B956278EA06EFF4F79B58CA386C490FE605384923F90FCC710FD6BF2F14926D5DFD43E17FC5655A0150B32BC750F05506BAF439255C8E30(73 . 6)(73 . 7)
213 bool Unlock(const SecureString& strWalletPassphrase);
214 bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase);
215 bool EncryptWallet(const SecureString& strWalletPassphrase);
216 void MarkDirty();
217
218 bool AddToWallet(const CWalletTx& wtxIn);
219 bool AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate = false);