raw
experimental-genesis    1 //  /****************************\
experimental-genesis 2 // * EXPERIMENTAL BRANCH. *
experimental-genesis 3 // * FOR LABORATORY USE ONLY. *
experimental-genesis 4 // ********************************
experimental-genesis 5 // ************
experimental-genesis 6 // **************
experimental-genesis 7 // ****************
experimental-genesis 8 // **** **** ****
experimental-genesis 9 // *** *** ***
experimental-genesis 10 // *** *** ***
experimental-genesis 11 // *** * * **
experimental-genesis 12 // ******** ********
experimental-genesis 13 // ******* ******
experimental-genesis 14 // *** **
experimental-genesis 15 // * ******* **
experimental-genesis 16 // ** * * * * *
experimental-genesis 17 // ** * * ***
experimental-genesis 18 // **** * * * * ****
experimental-genesis 19 // **** *** * * ** ***
experimental-genesis 20 // **** ********* ******
experimental-genesis 21 // ******* ***** *******
experimental-genesis 22 // ********* ****** **
experimental-genesis 23 // ** ****** ******
experimental-genesis 24 // ** ******* **
experimental-genesis 25 // ** ******* ***
experimental-genesis 26 // **** ******** ************
experimental-genesis 27 // ************ ************
experimental-genesis 28 // ******** *******
experimental-genesis 29 // ****** ****
experimental-genesis 30 // *** ***
experimental-genesis 31 // ********************************
experimental-genesis 32 // Copyright (c) 2009-2010 Satoshi Nakamoto
experimental-genesis 33 // Copyright (c) 2011 The Bitcoin developers
experimental-genesis 34 // Distributed under the MIT/X11 software license, see the accompanying
experimental-genesis 35 // file license.txt or http://www.opensource.org/licenses/mit-license.php.
experimental-genesis 36 #ifndef BITCOIN_DB_H
experimental-genesis 37 #define BITCOIN_DB_H
experimental-genesis 38
experimental-genesis 39 #include "key.h"
experimental-genesis 40
experimental-genesis 41 #include <map>
experimental-genesis 42 #include <string>
experimental-genesis 43 #include <vector>
experimental-genesis 44
experimental-genesis 45 #include <db_cxx.h>
experimental-genesis 46
experimental-genesis 47 class CTxIndex;
experimental-genesis 48 class CDiskBlockIndex;
experimental-genesis 49 class CDiskTxPos;
experimental-genesis 50 class COutPoint;
experimental-genesis 51 class CAddress;
experimental-genesis 52 class CWalletTx;
experimental-genesis 53 class CWallet;
experimental-genesis 54 class CAccount;
experimental-genesis 55 class CAccountingEntry;
experimental-genesis 56 class CBlockLocator;
experimental-genesis 57
experimental-genesis 58
experimental-genesis 59 extern unsigned int nWalletDBUpdated;
experimental-genesis 60 extern DbEnv dbenv;
experimental-genesis 61
experimental-genesis 62 extern void DBFlush(bool fShutdown);
experimental-genesis 63 void ThreadFlushWalletDB(void* parg);
experimental-genesis 64 bool BackupWallet(const CWallet& wallet, const std::string& strDest);
experimental-genesis 65
experimental-genesis 66
experimental-genesis 67
experimental-genesis 68 class CDB
experimental-genesis 69 {
experimental-genesis 70 protected:
experimental-genesis 71 Db* pdb;
experimental-genesis 72 std::string strFile;
experimental-genesis 73 std::vector<DbTxn*> vTxn;
experimental-genesis 74 bool fReadOnly;
experimental-genesis 75
experimental-genesis 76 explicit CDB(const char* pszFile, const char* pszMode="r+");
experimental-genesis 77 ~CDB() { Close(); }
experimental-genesis 78 public:
experimental-genesis 79 void Close();
experimental-genesis 80 private:
experimental-genesis 81 CDB(const CDB&);
experimental-genesis 82 void operator=(const CDB&);
experimental-genesis 83
experimental-genesis 84 protected:
experimental-genesis 85 template<typename K, typename T>
experimental-genesis 86 bool Read(const K& key, T& value)
experimental-genesis 87 {
experimental-genesis 88 if (!pdb)
experimental-genesis 89 return false;
experimental-genesis 90
experimental-genesis 91 // Key
experimental-genesis 92 CDataStream ssKey(SER_DISK);
experimental-genesis 93 ssKey.reserve(1000);
experimental-genesis 94 ssKey << key;
experimental-genesis 95 Dbt datKey(&ssKey[0], ssKey.size());
experimental-genesis 96
experimental-genesis 97 // Read
experimental-genesis 98 Dbt datValue;
experimental-genesis 99 datValue.set_flags(DB_DBT_MALLOC);
experimental-genesis 100 int ret = pdb->get(GetTxn(), &datKey, &datValue, 0);
experimental-genesis 101 memset(datKey.get_data(), 0, datKey.get_size());
experimental-genesis 102 if (datValue.get_data() == NULL)
experimental-genesis 103 return false;
experimental-genesis 104
experimental-genesis 105 // Unserialize value
experimental-genesis 106 CDataStream ssValue((char*)datValue.get_data(), (char*)datValue.get_data() + datValue.get_size(), SER_DISK);
experimental-genesis 107 ssValue >> value;
experimental-genesis 108
experimental-genesis 109 // Clear and free memory
experimental-genesis 110 memset(datValue.get_data(), 0, datValue.get_size());
experimental-genesis 111 free(datValue.get_data());
experimental-genesis 112 return (ret == 0);
experimental-genesis 113 }
experimental-genesis 114
experimental-genesis 115 template<typename K, typename T>
experimental-genesis 116 bool Write(const K& key, const T& value, bool fOverwrite=true)
experimental-genesis 117 {
experimental-genesis 118 if (!pdb)
experimental-genesis 119 return false;
experimental-genesis 120 if (fReadOnly)
experimental-genesis 121 assert(!"Write called on database in read-only mode");
experimental-genesis 122
experimental-genesis 123 // Key
experimental-genesis 124 CDataStream ssKey(SER_DISK);
experimental-genesis 125 ssKey.reserve(1000);
experimental-genesis 126 ssKey << key;
experimental-genesis 127 Dbt datKey(&ssKey[0], ssKey.size());
experimental-genesis 128
experimental-genesis 129 // Value
experimental-genesis 130 CDataStream ssValue(SER_DISK);
experimental-genesis 131 ssValue.reserve(10000);
experimental-genesis 132 ssValue << value;
experimental-genesis 133 Dbt datValue(&ssValue[0], ssValue.size());
experimental-genesis 134
experimental-genesis 135 // Write
experimental-genesis 136 int ret = pdb->put(GetTxn(), &datKey, &datValue, (fOverwrite ? 0 : DB_NOOVERWRITE));
experimental-genesis 137
experimental-genesis 138 // Clear memory in case it was a private key
experimental-genesis 139 memset(datKey.get_data(), 0, datKey.get_size());
experimental-genesis 140 memset(datValue.get_data(), 0, datValue.get_size());
experimental-genesis 141 return (ret == 0);
experimental-genesis 142 }
experimental-genesis 143
experimental-genesis 144 template<typename K>
experimental-genesis 145 bool Erase(const K& key)
experimental-genesis 146 {
experimental-genesis 147 if (!pdb)
experimental-genesis 148 return false;
experimental-genesis 149 if (fReadOnly)
experimental-genesis 150 assert(!"Erase called on database in read-only mode");
experimental-genesis 151
experimental-genesis 152 // Key
experimental-genesis 153 CDataStream ssKey(SER_DISK);
experimental-genesis 154 ssKey.reserve(1000);
experimental-genesis 155 ssKey << key;
experimental-genesis 156 Dbt datKey(&ssKey[0], ssKey.size());
experimental-genesis 157
experimental-genesis 158 // Erase
experimental-genesis 159 int ret = pdb->del(GetTxn(), &datKey, 0);
experimental-genesis 160
experimental-genesis 161 // Clear memory
experimental-genesis 162 memset(datKey.get_data(), 0, datKey.get_size());
experimental-genesis 163 return (ret == 0 || ret == DB_NOTFOUND);
experimental-genesis 164 }
experimental-genesis 165
experimental-genesis 166 template<typename K>
experimental-genesis 167 bool Exists(const K& key)
experimental-genesis 168 {
experimental-genesis 169 if (!pdb)
experimental-genesis 170 return false;
experimental-genesis 171
experimental-genesis 172 // Key
experimental-genesis 173 CDataStream ssKey(SER_DISK);
experimental-genesis 174 ssKey.reserve(1000);
experimental-genesis 175 ssKey << key;
experimental-genesis 176 Dbt datKey(&ssKey[0], ssKey.size());
experimental-genesis 177
experimental-genesis 178 // Exists
experimental-genesis 179 int ret = pdb->exists(GetTxn(), &datKey, 0);
experimental-genesis 180
experimental-genesis 181 // Clear memory
experimental-genesis 182 memset(datKey.get_data(), 0, datKey.get_size());
experimental-genesis 183 return (ret == 0);
experimental-genesis 184 }
experimental-genesis 185
experimental-genesis 186 Dbc* GetCursor()
experimental-genesis 187 {
experimental-genesis 188 if (!pdb)
experimental-genesis 189 return NULL;
experimental-genesis 190 Dbc* pcursor = NULL;
experimental-genesis 191 int ret = pdb->cursor(NULL, &pcursor, 0);
experimental-genesis 192 if (ret != 0)
experimental-genesis 193 return NULL;
experimental-genesis 194 return pcursor;
experimental-genesis 195 }
experimental-genesis 196
experimental-genesis 197 int ReadAtCursor(Dbc* pcursor, CDataStream& ssKey, CDataStream& ssValue, unsigned int fFlags=DB_NEXT)
experimental-genesis 198 {
experimental-genesis 199 // Read at cursor
experimental-genesis 200 Dbt datKey;
experimental-genesis 201 if (fFlags == DB_SET || fFlags == DB_SET_RANGE || fFlags == DB_GET_BOTH || fFlags == DB_GET_BOTH_RANGE)
experimental-genesis 202 {
experimental-genesis 203 datKey.set_data(&ssKey[0]);
experimental-genesis 204 datKey.set_size(ssKey.size());
experimental-genesis 205 }
experimental-genesis 206 Dbt datValue;
experimental-genesis 207 if (fFlags == DB_GET_BOTH || fFlags == DB_GET_BOTH_RANGE)
experimental-genesis 208 {
experimental-genesis 209 datValue.set_data(&ssValue[0]);
experimental-genesis 210 datValue.set_size(ssValue.size());
experimental-genesis 211 }
experimental-genesis 212 datKey.set_flags(DB_DBT_MALLOC);
experimental-genesis 213 datValue.set_flags(DB_DBT_MALLOC);
experimental-genesis 214 int ret = pcursor->get(&datKey, &datValue, fFlags);
experimental-genesis 215 if (ret != 0)
experimental-genesis 216 return ret;
experimental-genesis 217 else if (datKey.get_data() == NULL || datValue.get_data() == NULL)
experimental-genesis 218 return 99999;
experimental-genesis 219
experimental-genesis 220 // Convert to streams
experimental-genesis 221 ssKey.SetType(SER_DISK);
experimental-genesis 222 ssKey.clear();
experimental-genesis 223 ssKey.write((char*)datKey.get_data(), datKey.get_size());
experimental-genesis 224 ssValue.SetType(SER_DISK);
experimental-genesis 225 ssValue.clear();
experimental-genesis 226 ssValue.write((char*)datValue.get_data(), datValue.get_size());
experimental-genesis 227
experimental-genesis 228 // Clear and free memory
experimental-genesis 229 memset(datKey.get_data(), 0, datKey.get_size());
experimental-genesis 230 memset(datValue.get_data(), 0, datValue.get_size());
experimental-genesis 231 free(datKey.get_data());
experimental-genesis 232 free(datValue.get_data());
experimental-genesis 233 return 0;
experimental-genesis 234 }
experimental-genesis 235
experimental-genesis 236 DbTxn* GetTxn()
experimental-genesis 237 {
experimental-genesis 238 if (!vTxn.empty())
experimental-genesis 239 return vTxn.back();
experimental-genesis 240 else
experimental-genesis 241 return NULL;
experimental-genesis 242 }
experimental-genesis 243
experimental-genesis 244 public:
experimental-genesis 245 bool TxnBegin()
experimental-genesis 246 {
experimental-genesis 247 if (!pdb)
experimental-genesis 248 return false;
experimental-genesis 249 DbTxn* ptxn = NULL;
experimental-genesis 250 int ret = dbenv.txn_begin(GetTxn(), &ptxn, DB_TXN_NOSYNC);
experimental-genesis 251 if (!ptxn || ret != 0)
experimental-genesis 252 return false;
experimental-genesis 253 vTxn.push_back(ptxn);
experimental-genesis 254 return true;
experimental-genesis 255 }
experimental-genesis 256
experimental-genesis 257 bool TxnCommit()
experimental-genesis 258 {
experimental-genesis 259 if (!pdb)
experimental-genesis 260 return false;
experimental-genesis 261 if (vTxn.empty())
experimental-genesis 262 return false;
experimental-genesis 263 int ret = vTxn.back()->commit(0);
experimental-genesis 264 vTxn.pop_back();
experimental-genesis 265 return (ret == 0);
experimental-genesis 266 }
experimental-genesis 267
experimental-genesis 268 bool TxnAbort()
experimental-genesis 269 {
experimental-genesis 270 if (!pdb)
experimental-genesis 271 return false;
experimental-genesis 272 if (vTxn.empty())
experimental-genesis 273 return false;
experimental-genesis 274 int ret = vTxn.back()->abort();
experimental-genesis 275 vTxn.pop_back();
experimental-genesis 276 return (ret == 0);
experimental-genesis 277 }
experimental-genesis 278
experimental-genesis 279 bool ReadVersion(int& nVersion)
experimental-genesis 280 {
experimental-genesis 281 nVersion = 0;
experimental-genesis 282 return Read(std::string("version"), nVersion);
experimental-genesis 283 }
experimental-genesis 284
experimental-genesis 285 bool WriteVersion(int nVersion)
experimental-genesis 286 {
experimental-genesis 287 return Write(std::string("version"), nVersion);
experimental-genesis 288 }
experimental-genesis 289
experimental-genesis 290 bool static Rewrite(const std::string& strFile, const char* pszSkip = NULL);
experimental-genesis 291 };
experimental-genesis 292
experimental-genesis 293
experimental-genesis 294
experimental-genesis 295
experimental-genesis 296
experimental-genesis 297
experimental-genesis 298
experimental-genesis 299
experimental-genesis 300 class CTxDB : public CDB
experimental-genesis 301 {
experimental-genesis 302 public:
experimental-genesis 303 CTxDB(const char* pszMode="r+") : CDB("blkindex.dat", pszMode) { }
experimental-genesis 304 private:
experimental-genesis 305 CTxDB(const CTxDB&);
experimental-genesis 306 void operator=(const CTxDB&);
experimental-genesis 307 public:
experimental-genesis 308 bool ReadTxIndex(uint256 hash, CTxIndex& txindex);
experimental-genesis 309 bool UpdateTxIndex(uint256 hash, const CTxIndex& txindex);
experimental-genesis 310 bool AddTxIndex(const CTransaction& tx, const CDiskTxPos& pos, int nHeight);
experimental-genesis 311 bool EraseTxIndex(const CTransaction& tx);
experimental-genesis 312 bool ContainsTx(uint256 hash);
experimental-genesis 313 bool ReadOwnerTxes(uint160 hash160, int nHeight, std::vector<CTransaction>& vtx);
experimental-genesis 314 bool ReadDiskTx(uint256 hash, CTransaction& tx, CTxIndex& txindex);
experimental-genesis 315 bool ReadDiskTx(uint256 hash, CTransaction& tx);
experimental-genesis 316 bool ReadDiskTx(COutPoint outpoint, CTransaction& tx, CTxIndex& txindex);
experimental-genesis 317 bool ReadDiskTx(COutPoint outpoint, CTransaction& tx);
experimental-genesis 318 bool WriteBlockIndex(const CDiskBlockIndex& blockindex);
experimental-genesis 319 bool EraseBlockIndex(uint256 hash);
experimental-genesis 320 bool ReadHashBestChain(uint256& hashBestChain);
experimental-genesis 321 bool WriteHashBestChain(uint256 hashBestChain);
experimental-genesis 322 bool ReadBestInvalidWork(CBigNum& bnBestInvalidWork);
experimental-genesis 323 bool WriteBestInvalidWork(CBigNum bnBestInvalidWork);
experimental-genesis 324 bool LoadBlockIndex();
experimental-genesis 325 };
experimental-genesis 326
experimental-genesis 327
experimental-genesis 328
experimental-genesis 329
experimental-genesis 330
experimental-genesis 331 class CAddrDB : public CDB
experimental-genesis 332 {
experimental-genesis 333 public:
experimental-genesis 334 CAddrDB(const char* pszMode="r+") : CDB("addr.dat", pszMode) { }
experimental-genesis 335 private:
experimental-genesis 336 CAddrDB(const CAddrDB&);
experimental-genesis 337 void operator=(const CAddrDB&);
experimental-genesis 338 public:
experimental-genesis 339 bool WriteAddress(const CAddress& addr);
experimental-genesis 340 bool EraseAddress(const CAddress& addr);
experimental-genesis 341 bool LoadAddresses();
experimental-genesis 342 };
experimental-genesis 343
experimental-genesis 344 bool LoadAddresses();
experimental-genesis 345
experimental-genesis 346
experimental-genesis 347
experimental-genesis 348 class CKeyPool
experimental-genesis 349 {
experimental-genesis 350 public:
experimental-genesis 351 int64 nTime;
experimental-genesis 352 std::vector<unsigned char> vchPubKey;
experimental-genesis 353
experimental-genesis 354 CKeyPool()
experimental-genesis 355 {
experimental-genesis 356 nTime = GetTime();
experimental-genesis 357 }
experimental-genesis 358
experimental-genesis 359 CKeyPool(const std::vector<unsigned char>& vchPubKeyIn)
experimental-genesis 360 {
experimental-genesis 361 nTime = GetTime();
experimental-genesis 362 vchPubKey = vchPubKeyIn;
experimental-genesis 363 }
experimental-genesis 364
experimental-genesis 365 IMPLEMENT_SERIALIZE
experimental-genesis 366 (
experimental-genesis 367 if (!(nType & SER_GETHASH))
experimental-genesis 368 READWRITE(nVersion);
experimental-genesis 369 READWRITE(nTime);
experimental-genesis 370 READWRITE(vchPubKey);
experimental-genesis 371 )
experimental-genesis 372 };
experimental-genesis 373
experimental-genesis 374
experimental-genesis 375
experimental-genesis 376
experimental-genesis 377 enum DBErrors
experimental-genesis 378 {
experimental-genesis 379 DB_LOAD_OK,
experimental-genesis 380 DB_CORRUPT,
experimental-genesis 381 DB_TOO_NEW,
experimental-genesis 382 DB_LOAD_FAIL,
experimental-genesis 383 DB_NEED_REWRITE
experimental-genesis 384 };
experimental-genesis 385
experimental-genesis 386 class CWalletDB : public CDB
experimental-genesis 387 {
experimental-genesis 388 public:
experimental-genesis 389 CWalletDB(std::string strFilename, const char* pszMode="r+") : CDB(strFilename.c_str(), pszMode)
experimental-genesis 390 {
experimental-genesis 391 }
experimental-genesis 392 private:
experimental-genesis 393 CWalletDB(const CWalletDB&);
experimental-genesis 394 void operator=(const CWalletDB&);
experimental-genesis 395 public:
experimental-genesis 396 bool ReadName(const std::string& strAddress, std::string& strName)
experimental-genesis 397 {
experimental-genesis 398 strName = "";
experimental-genesis 399 return Read(std::make_pair(std::string("name"), strAddress), strName);
experimental-genesis 400 }
experimental-genesis 401
experimental-genesis 402 bool WriteName(const std::string& strAddress, const std::string& strName);
experimental-genesis 403
experimental-genesis 404 bool EraseName(const std::string& strAddress);
experimental-genesis 405
experimental-genesis 406 bool ReadTx(uint256 hash, CWalletTx& wtx)
experimental-genesis 407 {
experimental-genesis 408 return Read(std::make_pair(std::string("tx"), hash), wtx);
experimental-genesis 409 }
experimental-genesis 410
experimental-genesis 411 bool WriteTx(uint256 hash, const CWalletTx& wtx)
experimental-genesis 412 {
experimental-genesis 413 nWalletDBUpdated++;
experimental-genesis 414 return Write(std::make_pair(std::string("tx"), hash), wtx);
experimental-genesis 415 }
experimental-genesis 416
experimental-genesis 417 bool EraseTx(uint256 hash)
experimental-genesis 418 {
experimental-genesis 419 nWalletDBUpdated++;
experimental-genesis 420 return Erase(std::make_pair(std::string("tx"), hash));
experimental-genesis 421 }
experimental-genesis 422
experimental-genesis 423 bool ReadKey(const std::vector<unsigned char>& vchPubKey, CPrivKey& vchPrivKey)
experimental-genesis 424 {
experimental-genesis 425 vchPrivKey.clear();
experimental-genesis 426 return Read(std::make_pair(std::string("key"), vchPubKey), vchPrivKey);
experimental-genesis 427 }
experimental-genesis 428
experimental-genesis 429 bool WriteKey(const std::vector<unsigned char>& vchPubKey, const CPrivKey& vchPrivKey)
experimental-genesis 430 {
experimental-genesis 431 nWalletDBUpdated++;
experimental-genesis 432 return Write(std::make_pair(std::string("key"), vchPubKey), vchPrivKey, false);
experimental-genesis 433 }
experimental-genesis 434
experimental-genesis 435 bool WriteCryptedKey(const std::vector<unsigned char>& vchPubKey, const std::vector<unsigned char>& vchCryptedSecret, bool fEraseUnencryptedKey = true)
experimental-genesis 436 {
experimental-genesis 437 nWalletDBUpdated++;
experimental-genesis 438 if (!Write(std::make_pair(std::string("ckey"), vchPubKey), vchCryptedSecret, false))
experimental-genesis 439 return false;
experimental-genesis 440 if (fEraseUnencryptedKey)
experimental-genesis 441 {
experimental-genesis 442 Erase(std::make_pair(std::string("key"), vchPubKey));
experimental-genesis 443 Erase(std::make_pair(std::string("wkey"), vchPubKey));
experimental-genesis 444 }
experimental-genesis 445 return true;
experimental-genesis 446 }
experimental-genesis 447
experimental-genesis 448 bool WriteMasterKey(unsigned int nID, const CMasterKey& kMasterKey)
experimental-genesis 449 {
experimental-genesis 450 nWalletDBUpdated++;
experimental-genesis 451 return Write(std::make_pair(std::string("mkey"), nID), kMasterKey, true);
experimental-genesis 452 }
experimental-genesis 453
experimental-genesis 454 bool WriteBestBlock(const CBlockLocator& locator)
experimental-genesis 455 {
experimental-genesis 456 nWalletDBUpdated++;
experimental-genesis 457 return Write(std::string("bestblock"), locator);
experimental-genesis 458 }
experimental-genesis 459
experimental-genesis 460 bool ReadBestBlock(CBlockLocator& locator)
experimental-genesis 461 {
experimental-genesis 462 return Read(std::string("bestblock"), locator);
experimental-genesis 463 }
experimental-genesis 464
experimental-genesis 465 bool ReadDefaultKey(std::vector<unsigned char>& vchPubKey)
experimental-genesis 466 {
experimental-genesis 467 vchPubKey.clear();
experimental-genesis 468 return Read(std::string("defaultkey"), vchPubKey);
experimental-genesis 469 }
experimental-genesis 470
experimental-genesis 471 bool WriteDefaultKey(const std::vector<unsigned char>& vchPubKey)
experimental-genesis 472 {
experimental-genesis 473 nWalletDBUpdated++;
experimental-genesis 474 return Write(std::string("defaultkey"), vchPubKey);
experimental-genesis 475 }
experimental-genesis 476
experimental-genesis 477 bool ReadPool(int64 nPool, CKeyPool& keypool)
experimental-genesis 478 {
experimental-genesis 479 return Read(std::make_pair(std::string("pool"), nPool), keypool);
experimental-genesis 480 }
experimental-genesis 481
experimental-genesis 482 bool WritePool(int64 nPool, const CKeyPool& keypool)
experimental-genesis 483 {
experimental-genesis 484 nWalletDBUpdated++;
experimental-genesis 485 return Write(std::make_pair(std::string("pool"), nPool), keypool);
experimental-genesis 486 }
experimental-genesis 487
experimental-genesis 488 bool ErasePool(int64 nPool)
experimental-genesis 489 {
experimental-genesis 490 nWalletDBUpdated++;
experimental-genesis 491 return Erase(std::make_pair(std::string("pool"), nPool));
experimental-genesis 492 }
experimental-genesis 493
experimental-genesis 494 template<typename T>
experimental-genesis 495 bool ReadSetting(const std::string& strKey, T& value)
experimental-genesis 496 {
experimental-genesis 497 return Read(std::make_pair(std::string("setting"), strKey), value);
experimental-genesis 498 }
experimental-genesis 499
experimental-genesis 500 template<typename T>
experimental-genesis 501 bool WriteSetting(const std::string& strKey, const T& value)
experimental-genesis 502 {
experimental-genesis 503 nWalletDBUpdated++;
experimental-genesis 504 return Write(std::make_pair(std::string("setting"), strKey), value);
experimental-genesis 505 }
experimental-genesis 506
experimental-genesis 507 bool ReadAccount(const std::string& strAccount, CAccount& account);
experimental-genesis 508 bool WriteAccount(const std::string& strAccount, const CAccount& account);
experimental-genesis 509 bool WriteAccountingEntry(const CAccountingEntry& acentry);
experimental-genesis 510 int64 GetAccountCreditDebit(const std::string& strAccount);
experimental-genesis 511 void ListAccountCreditDebit(const std::string& strAccount, std::list<CAccountingEntry>& acentries);
experimental-genesis 512
experimental-genesis 513 int LoadWallet(CWallet* pwallet);
experimental-genesis 514 };
experimental-genesis 515
experimental-genesis 516 #endif