Skip to content

Latest commit

 

History

History
69 lines (58 loc) · 2.55 KB

walletdb.h.adoc

File metadata and controls

69 lines (58 loc) · 2.55 KB

比特币源码分析

实现了访问钱包数据库wallet.dat

1. 山寨开发关注度:五星

基本上每个客户都会要求修改钱包地址首字母

2. 全局变量

2.1. DBErrors-- 钱包数据库的错误状态

  • DB_LOAD_OK,

  • DB_CORRUPT,

  • DB_NONCRITICAL_ERROR,

  • DB_TOO_NEW,

  • DB_LOAD_FAIL,

  • DB_NEED_REWRITE

3. CWalletDB类

访问钱包数据库,继承CDB

3.1. 成员变量

  • nVersion,版本号

  • vchData,被base58编码的数据.

3.2. 成员函数

方法名 说明

CWalletDB(std::string strFilename, const char* pszMode="r+")

…​

bool WriteName(const std::string& strAddress, const std::string& strName);

…​

bool EraseName(const std::string& strAddress);

…​

bool WriteTx(uint256 hash, const CWalletTx& wtx)

…​

bool EraseTx(uint256 hash)

…​

bool WriteKey(const CPubKey& vchPubKey, const CPrivKey& vchPrivKey)

…​

bool WriteCryptedKey(const CPubKey& vchPubKey, const std::vector<unsigned char>& vchCryptedSecret, bool fEraseUnencryptedKey = true)

…​

bool WriteMasterKey(unsigned int nID, const CMasterKey& kMasterKey)

…​

bool WriteCScript(const uint160& hash, const CScript& redeemScript)

…​

bool WriteBestBlock(const CBlockLocator& locator)

…​

bool ReadBestBlock(CBlockLocator& locator)

…​

bool WriteOrderPosNext(int64 nOrderPosNext)

…​

bool WriteDefaultKey(const CPubKey& vchPubKey)

…​

bool ReadPool(int64 nPool, CKeyPool& keypool)

…​

bool WritePool(int64 nPool, const CKeyPool& keypool)

…​

bool ErasePool(int64 nPool)

…​

bool ReadSetting(const std::string& strKey, T& value)

…​

bool WriteSetting(const std::string& strKey, const T& value)

…​

bool EraseSetting(const std::string& strKey)

…​

bool WriteMinVersion(int nVersion)

…​

bool ReadAccount(const std::string& strAccount, CAccount& account);

…​

bool WriteAccount(const std::string& strAccount, const CAccount& account);

…​

bool WriteAccountingEntry(const uint64 nAccEntryNum, const CAccountingEntry& acentry);

…​

bool WriteAccountingEntry(const CAccountingEntry& acentry);

…​

int64 GetAccountCreditDebit(const std::string& strAccount);

…​

void ListAccountCreditDebit(const std::string& strAccount, std::list<CAccountingEntry>& acentries);

…​

DBErrors ReorderTransactions(CWallet*);

…​

DBErrors LoadWallet(CWallet* pwallet);

…​

static bool Recover(CDBEnv& dbenv, std::string filename, bool fOnlyKeys);

…​

static bool Recover(CDBEnv& dbenv, std::string filename);

…​