tree checksum vpatch file split hunks
all signers: mod6
antecedents: bitcoin-asciilifeform.1 genesis mod6_der_high_low_s asciilifeform_lets_lose_testnet
press order:
patch:
(18 . 6)(18 . 7)- CA28A67C52B37D372E22B124EECB4E136925110DB1132AE122A1F47B20E60BFC7ABDD76ABCBB03ABF026E6900FD377CED5A983026F1B7B6C9CB26EF3FAADE0EF
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)- 36DDD67BA47C3860BA5747A2388B11E4CB3ED91AE1BC54A051F773E7958D3EC08CBD029607D1878661D644D34910098027600CD7E1BD08ACA059452CF03FD0E8
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)- 8E9AABB0569D092A6B1BFF5015211A38475530B28614A7163ADE52496314094BC00FD443EAFB66F1285EAA1C69A680233A3E6044058598D2E2CFFCF8797E0CC0
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
- 5E302C824B6802E5AC88277F9DCCA66B645A2E6932713EF817B6E3352CEF123BB4492FDB19ACAE7236A090715770D9D623C209218BCD2745C1277D3172EF30D5(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 };
- C95A36390729D1D846DC7036D5489178A361AF69D310DCC250096DEAE764729550AC117096ADF54084FD0F9A7798228C8282656441CBA93351D810001F4D311B(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();
- DF93B83C3880E14D890FE853D8556EEC6377B90D5E83BD696F4C5800042C2CD04C5242B69B8886E22DFCEB5B9B16E790FB526E9039CC130C9FB0F12CC8BB19D2(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);