all signers:
antecedents:
press order:
patch:
(337 . 16)(337 . 6)- 1A4B9BD666180ACF944D189FFD5B89DA0F1C0D7B60223FE7F16F73A7D90BDD2A75B7D46805738EA3DA36AE766B0AA4A5D29283B5F4EF8A77AAE991CF990AE0CC
5 return Write(make_pair(string("tx"), hash), txindex);
6 }
7
8 bool CTxDB::AddTxIndex(const CTransaction& tx, const CDiskTxPos& pos, int nHeight)
9 {
10 assert(!fClient);
11
12 // Add to tx index
13 uint256 hash = tx.GetHash();
14 CTxIndex txindex(pos, tx.vout.size());
15 return Write(make_pair(string("tx"), hash), txindex);
16 }
17
18 bool CTxDB::EraseTxIndex(const CTransaction& tx)
19 {
20 assert(!fClient);
(361 . 60)(351 . 6)
22 return Exists(make_pair(string("tx"), hash));
23 }
24
25 bool CTxDB::ReadOwnerTxes(uint160 hash160, int nMinHeight, vector<CTransaction>& vtx)
26 {
27 assert(!fClient);
28 vtx.clear();
29
30 // Get cursor
31 Dbc* pcursor = GetCursor();
32 if (!pcursor)
33 return false;
34
35 unsigned int fFlags = DB_SET_RANGE;
36 loop
37 {
38 // Read next record
39 CDataStream ssKey;
40 if (fFlags == DB_SET_RANGE)
41 ssKey << string("owner") << hash160 << CDiskTxPos(0, 0, 0);
42 CDataStream ssValue;
43 int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags);
44 fFlags = DB_NEXT;
45 if (ret == DB_NOTFOUND)
46 break;
47 else if (ret != 0)
48 {
49 pcursor->close();
50 return false;
51 }
52
53 // Unserialize
54 string strType;
55 uint160 hashItem;
56 CDiskTxPos pos;
57 ssKey >> strType >> hashItem >> pos;
58 int nItemHeight;
59 ssValue >> nItemHeight;
60
61 // Read transaction
62 if (strType != "owner" || hashItem != hash160)
63 break;
64 if (nItemHeight >= nMinHeight)
65 {
66 vtx.resize(vtx.size()+1);
67 if (!vtx.back().ReadFromDisk(pos))
68 {
69 pcursor->close();
70 return false;
71 }
72 }
73 }
74
75 pcursor->close();
76 return true;
77 }
78
79 bool CTxDB::ReadDiskTx(uint256 hash, CTransaction& tx, CTxIndex& txindex)
80 {
81 assert(!fClient);
(446 . 11)(382 . 6)
83 return Write(make_pair(string("blockindex"), blockindex.GetBlockHash()), blockindex);
84 }
85
86 bool CTxDB::EraseBlockIndex(uint256 hash)
87 {
88 return Erase(make_pair(string("blockindex"), hash));
89 }
90
91 bool CTxDB::ReadHashBestChain(uint256& hashBestChain)
92 {
93 return Read(string("hashBestChain"), hashBestChain);
(684 . 14)(615 . 6)
95 return Write(make_pair(string("name"), strAddress), strName);
96 }
97
98 bool CWalletDB::EraseName(const string& strAddress)
99 {
100 // This should only be used for sending addresses, never for receiving addresses,
101 // receiving addresses must always have an address book entry if they're not change return.
102 nWalletDBUpdated++;
103 return Erase(make_pair(string("name"), strAddress));
104 }
105
106 bool CWalletDB::ReadAccount(const string& strAccount, CAccount& account)
107 {
108 account.SetNull();
(276 . 16)(276 . 13)- 738EA5D28C72B586790716C124D219B8B132C5224CE07CC3B47EAB4495E2C9009EAE1A7D7FA3FAAA24DE465D5A46201DC1C4A468AB5A891CB59811D328B82084
113 public:
114 bool ReadTxIndex(uint256 hash, CTxIndex& txindex);
115 bool UpdateTxIndex(uint256 hash, const CTxIndex& txindex);
116 bool AddTxIndex(const CTransaction& tx, const CDiskTxPos& pos, int nHeight);
117 bool EraseTxIndex(const CTransaction& tx);
118 bool ContainsTx(uint256 hash);
119 bool ReadOwnerTxes(uint160 hash160, int nHeight, std::vector<CTransaction>& vtx);
120 bool ReadDiskTx(uint256 hash, CTransaction& tx, CTxIndex& txindex);
121 bool ReadDiskTx(uint256 hash, CTransaction& tx);
122 bool ReadDiskTx(COutPoint outpoint, CTransaction& tx, CTxIndex& txindex);
123 bool ReadDiskTx(COutPoint outpoint, CTransaction& tx);
124 bool WriteBlockIndex(const CDiskBlockIndex& blockindex);
125 bool EraseBlockIndex(uint256 hash);
126 bool ReadHashBestChain(uint256& hashBestChain);
127 bool WriteHashBestChain(uint256 hashBestChain);
128 bool ReadBestInvalidWork(CBigNum& bnBestInvalidWork);
(370 . 8)(367 . 6)
130
131 bool WriteName(const std::string& strAddress, const std::string& strName);
132
133 bool EraseName(const std::string& strAddress);
134
135 bool ReadTx(uint256 hash, CWalletTx& wtx)
136 {
137 return Read(std::make_pair(std::string("tx"), hash), wtx);
(700 . 12)(700 . 6)
142 return true;
143 }
144
145 // Return maximum amount of blocks that other nodes claim to have
146 int GetNumBlocksOfPeers()
147 {
148 return std::max(cPeerBlockCounts.median(), Checkpoints::GetTotalBlocksEstimate());
149 }
150
151 bool IsInitialBlockDownload()
152 {
153 if (pindexBest == NULL || nBestHeight < Checkpoints::GetTotalBlocksEstimate())
- 854E85A8217F8386FA7EC13775FDF7271A41A0132816F1A64ACD40904B4B8300491DD368A26648AFB11AF019F0BDCC535CA327C19EACA698803F3AFDD57B76D8(96 . 7)(96 . 6)
158 bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey);
159 bool CheckProofOfWork(uint256 hash, unsigned int nBits);
160 unsigned int ComputeMinWork(unsigned int nBase, int64 nTime);
161 int GetNumBlocksOfPeers();
162 bool IsInitialBlockDownload();
163 std::string GetWarnings(std::string strFor);
164
- 264576D0885CFB6145807D8920B7DCC3AFFEF23FF3E45CE7138C156106C80D47D76C9485285203E5570926E51B98C8D0ABE2142160E2F5016A8E24C81773DA35(325 . 39)(325 . 6)
169 }
170 }
171
172
173
174
175
176 void AbandonRequests(void (*fn)(void*, CDataStream&), void* param1)
177 {
178 // If the dialog might get closed before the reply comes back,
179 // call this in the destructor so it doesn't get called after it's deleted.
180 CRITICAL_BLOCK(cs_vNodes)
181 {
182 BOOST_FOREACH(CNode* pnode, vNodes)
183 {
184 CRITICAL_BLOCK(pnode->cs_mapRequests)
185 {
186 for (map<uint256, CRequestTracker>::iterator mi = pnode->mapRequests.begin(); mi != pnode->mapRequests.end();)
187 {
188 CRequestTracker& tracker = (*mi).second;
189 if (tracker.fn == fn && tracker.param1 == param1)
190 pnode->mapRequests.erase(mi++);
191 else
192 mi++;
193 }
194 }
195 }
196 }
197 }
198
199
200
201
202
203
204
205 //
206 // Subscription methods for the broadcast and subscription system.
207 // Channel numbers are message numbers, i.e. MSG_TABLE and MSG_PRODUCT.
- 77EDE4A59510C44C7167144C78CC0608430C50FF25B28201EB39EE69B0D4ACBCCE7374C4EFD254304732C409B5799BC59557C3CB69A29C9F7C29DDD3D9E3A4A6(32 . 7)(32 . 6)
212 void AddressCurrentlyConnected(const CAddress& addr);
213 CNode* FindNode(unsigned int ip);
214 CNode* ConnectNode(CAddress addrConnect, int64 nTimeout=0);
215 void AbandonRequests(void (*fn)(void*, CDataStream&), void* param1);
216 bool AnySubscribed(unsigned int nChannel);
217 void MapPort(bool fMapPort);
218 bool BindListenPort(std::string& strError=REF(std::string()));
- 35EFFBC7F73CDBDA92148BE58171B2337C090A7997EB3B02DAF9A88287B4315C80D7FA5EDF403BE9CF958969C0C7E0C1B578C10F146EE0EA9B2965A1F97971BF(235 . 11)(235 . 6)
223 return strprintf("%u.%u.%u.%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0));
224 }
225
226 std::string CAddress::ToStringPort() const
227 {
228 return strprintf("%u", ntohs(port));
229 }
230
231 std::string CAddress::ToString() const
232 {
233 return strprintf("%u.%u.%u.%u:%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0), ntohs(port));
- CCE0473250E39DD85773246EA0CD40584C77DAA7FCBA7FF98836D8B9BDBFF2F3E229F385C43C73503CA9E244219708B2299600DB28D1D7DF442C92F22ED74485(102 . 7)(102 . 6)
238 unsigned char GetByte(int n) const;
239 std::string ToStringIPPort() const;
240 std::string ToStringIP() const;
241 std::string ToStringPort() const;
242 std::string ToString() const;
243 void print() const;
244
- 568CA27A4F90DC47F125880F64EE42DFEB0493A5E0EF79E314C3DF1702920C21D7AEA35CF197916A9881B569500C815D09E932F4668DEEF84507A26D7557B1CF(251 . 27)(251 . 6)- B171F0824811472EDB2E309537B772583A32B678550080F257D4B535BB62F46C04AAF0047D29500DF6CA77A7E2C01D729B4536B7B7869061863012E39B6C026F
249 return false;
250 }
251
252
253 void ParseString(const string& str, char c, vector<string>& v)
254 {
255 if (str.empty())
256 return;
257 string::size_type i1 = 0;
258 string::size_type i2;
259 loop
260 {
261 i2 = str.find(c, i1);
262 if (i2 == str.npos)
263 {
264 v.push_back(str.substr(i1));
265 return;
266 }
267 v.push_back(str.substr(i1, i2-i1));
268 i1 = i2+1;
269 }
270 }
271
272
273 string FormatMoney(int64 n, bool fPlus)
274 {
275 // Note: not using straight sprintf here because we do NOT want
(612 . 13)(591 . 6)
277 "UNKNOWN EXCEPTION \n%s in %s \n", pszModule, pszThread);
278 }
279
280 void LogException(std::exception* pex, const char* pszThread)
281 {
282 char pszMessage[10000];
283 FormatException(pszMessage, pex, pszThread);
284 printf("\n%s", pszMessage);
285 }
286
287 void PrintException(std::exception* pex, const char* pszThread)
288 {
289 char pszMessage[10000];
(132 . 10)(132 . 8)
294 int my_snprintf(char* buffer, size_t limit, const char* format, ...);
295 std::string strprintf(const std::string &format, ...);
296 bool error(const std::string &format, ...);
297 void LogException(std::exception* pex, const char* pszThread);
298 void PrintException(std::exception* pex, const char* pszThread);
299 void PrintExceptionContinue(std::exception* pex, const char* pszThread);
300 void ParseString(const std::string& str, char c, std::vector<std::string>& v);
301 std::string FormatMoney(int64 n, bool fPlus=false);
302 bool ParseMoney(const std::string& str, int64& nRet);
303 bool ParseMoney(const char* pszIn, int64& nRet);
- BDC4FC472BE4A86FB91FA69368FAACE04414FDEEE5B8C82795E31D37E21581B973CAF7F3E9CCC27D487944A5782E3B59615180EAB87C8B3E81242901F3039E4D(368 . 45)(368 . 6)- 86F5E1CA584E6AA01B956278EA06EFF4F79B58CA386C490FE605384923F90FCC710FD6BF2F14926D5DFD43E17FC5655A0150B32BC750F05506BAF439255C8E30
308 return nTimeReceived;
309 }
310
311 int CWalletTx::GetRequestCount() const
312 {
313 // Returns -1 if it wasn't being tracked
314 int nRequests = -1;
315 CRITICAL_BLOCK(pwallet->cs_wallet)
316 {
317 if (IsCoinBase())
318 {
319 // Generated block
320 if (hashBlock != 0)
321 {
322 map<uint256, int>::const_iterator mi = pwallet->mapRequestCount.find(hashBlock);
323 if (mi != pwallet->mapRequestCount.end())
324 nRequests = (*mi).second;
325 }
326 }
327 else
328 {
329 // Did anyone request this transaction?
330 map<uint256, int>::const_iterator mi = pwallet->mapRequestCount.find(GetHash());
331 if (mi != pwallet->mapRequestCount.end())
332 {
333 nRequests = (*mi).second;
334
335 // How about the block it's in?
336 if (nRequests == 0 && hashBlock != 0)
337 {
338 map<uint256, int>::const_iterator mi = pwallet->mapRequestCount.find(hashBlock);
339 if (mi != pwallet->mapRequestCount.end())
340 nRequests = (*mi).second;
341 else
342 nRequests = 1; // If it's in someone else's block it must have got out
343 }
344 }
345 }
346 }
347 return nRequests;
348 }
349
350 void CWalletTx::GetAmounts(int64& nGeneratedImmature, int64& nGeneratedMature, list<pair<CBitcoinAddress, int64> >& listReceived,
351 list<pair<CBitcoinAddress, int64> >& listSent, int64& nFee, string& strSentAccount) const
352 {
(739 . 22)(700 . 6)
354 return nTotal;
355 }
356
357 int64 CWallet::GetUnconfirmedBalance() const
358 {
359 int64 nTotal = 0;
360 CRITICAL_BLOCK(cs_wallet)
361 {
362 for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
363 {
364 const CWalletTx* pcoin = &(*it).second;
365 if (pcoin->IsFinal() && pcoin->IsConfirmed())
366 continue;
367 nTotal += pcoin->GetAvailableCredit();
368 }
369 }
370 return nTotal;
371 }
372
373 bool CWallet::SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfTheirs, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64& nValueRet) const
374 {
375 setCoinsRet.clear();
(1189 . 15)(1134 . 6)
377 return CWalletDB(strWalletFile).WriteName(address.ToString(), strName);
378 }
379
380 bool CWallet::DelAddressBookName(const CBitcoinAddress& address)
381 {
382 mapAddressBook.erase(address);
383 if (!fFileBacked)
384 return false;
385 return CWalletDB(strWalletFile).EraseName(address.ToString());
386 }
387
388
389 void CWallet::PrintWallet(const CBlock& block)
390 {
391 CRITICAL_BLOCK(cs_wallet)
(82 . 7)(82 . 6)
396 void ReacceptWalletTransactions();
397 void ResendWalletTransactions();
398 int64 GetBalance() const;
399 int64 GetUnconfirmedBalance() const;
400 bool CreateTransaction(const std::vector<std::pair<CScript, int64> >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet);
401 bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet);
402 bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey);
(179 . 8)(178 . 6)
404
405 bool SetAddressBookName(const CBitcoinAddress& address, const std::string& strName);
406
407 bool DelAddressBookName(const CBitcoinAddress& address);
408
409 void UpdatedTransaction(const uint256 &hashTx)
410 {
411 CRITICAL_BLOCK(cs_wallet)
(525 . 7)(522 . 6)
413 bool WriteToDisk();
414
415 int64 GetTxTime() const;
416 int GetRequestCount() const;
417
418 void AddSupportingTransactions(CTxDB& txdb);
419