Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/walletdb.cpp
Show All 26 Lines | |||||
// | // | ||||
// CWalletDB | // CWalletDB | ||||
// | // | ||||
bool CWalletDB::WriteName(const std::string &strAddress, | bool CWalletDB::WriteName(const std::string &strAddress, | ||||
const std::string &strName) { | const std::string &strName) { | ||||
nWalletDBUpdateCounter++; | nWalletDBUpdateCounter++; | ||||
return Write(make_pair(std::string("name"), strAddress), strName); | return Write(std::make_pair(std::string("name"), strAddress), strName); | ||||
} | } | ||||
bool CWalletDB::EraseName(const std::string &strAddress) { | bool CWalletDB::EraseName(const std::string &strAddress) { | ||||
// This should only be used for sending addresses, never for receiving | // This should only be used for sending addresses, never for receiving | ||||
// addresses, receiving addresses must always have an address book entry if | // addresses, receiving addresses must always have an address book entry if | ||||
// they're not change return. | // they're not change return. | ||||
nWalletDBUpdateCounter++; | nWalletDBUpdateCounter++; | ||||
return Erase(make_pair(std::string("name"), strAddress)); | return Erase(std::make_pair(std::string("name"), strAddress)); | ||||
} | } | ||||
bool CWalletDB::WritePurpose(const std::string &strAddress, | bool CWalletDB::WritePurpose(const std::string &strAddress, | ||||
const std::string &strPurpose) { | const std::string &strPurpose) { | ||||
nWalletDBUpdateCounter++; | nWalletDBUpdateCounter++; | ||||
return Write(make_pair(std::string("purpose"), strAddress), strPurpose); | return Write(std::make_pair(std::string("purpose"), strAddress), | ||||
strPurpose); | |||||
} | } | ||||
bool CWalletDB::ErasePurpose(const std::string &strPurpose) { | bool CWalletDB::ErasePurpose(const std::string &strPurpose) { | ||||
nWalletDBUpdateCounter++; | nWalletDBUpdateCounter++; | ||||
return Erase(make_pair(std::string("purpose"), strPurpose)); | return Erase(std::make_pair(std::string("purpose"), strPurpose)); | ||||
} | } | ||||
bool CWalletDB::WriteTx(const CWalletTx &wtx) { | bool CWalletDB::WriteTx(const CWalletTx &wtx) { | ||||
nWalletDBUpdateCounter++; | nWalletDBUpdateCounter++; | ||||
return Write(std::make_pair(std::string("tx"), wtx.GetId()), wtx); | return Write(std::make_pair(std::string("tx"), wtx.GetId()), wtx); | ||||
} | } | ||||
bool CWalletDB::EraseTx(uint256 hash) { | bool CWalletDB::EraseTx(uint256 hash) { | ||||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
bool CWalletDB::WriteMinVersion(int nVersion) { | bool CWalletDB::WriteMinVersion(int nVersion) { | ||||
return Write(std::string("minversion"), nVersion); | return Write(std::string("minversion"), nVersion); | ||||
} | } | ||||
bool CWalletDB::ReadAccount(const std::string &strAccount, CAccount &account) { | bool CWalletDB::ReadAccount(const std::string &strAccount, CAccount &account) { | ||||
account.SetNull(); | account.SetNull(); | ||||
return Read(make_pair(std::string("acc"), strAccount), account); | return Read(std::make_pair(std::string("acc"), strAccount), account); | ||||
} | } | ||||
bool CWalletDB::WriteAccount(const std::string &strAccount, | bool CWalletDB::WriteAccount(const std::string &strAccount, | ||||
const CAccount &account) { | const CAccount &account) { | ||||
return Write(make_pair(std::string("acc"), strAccount), account); | return Write(std::make_pair(std::string("acc"), strAccount), account); | ||||
} | } | ||||
bool CWalletDB::WriteAccountingEntry(const uint64_t nAccEntryNum, | bool CWalletDB::WriteAccountingEntry(const uint64_t nAccEntryNum, | ||||
const CAccountingEntry &acentry) { | const CAccountingEntry &acentry) { | ||||
return Write( | return Write( | ||||
std::make_pair(std::string("acentry"), | std::make_pair(std::string("acentry"), | ||||
std::make_pair(acentry.strAccount, nAccEntryNum)), | std::make_pair(acentry.strAccount, nAccEntryNum)), | ||||
acentry); | acentry); | ||||
▲ Show 20 Lines • Show All 394 Lines • ▼ Show 20 Lines | DBErrors CWalletDB::LoadWallet(CWallet *pwallet) { | ||||
if (wss.nFileVersion < CLIENT_VERSION) // Update | if (wss.nFileVersion < CLIENT_VERSION) // Update | ||||
WriteVersion(CLIENT_VERSION); | WriteVersion(CLIENT_VERSION); | ||||
if (wss.fAnyUnordered) result = pwallet->ReorderTransactions(); | if (wss.fAnyUnordered) result = pwallet->ReorderTransactions(); | ||||
pwallet->laccentries.clear(); | pwallet->laccentries.clear(); | ||||
ListAccountCreditDebit("*", pwallet->laccentries); | ListAccountCreditDebit("*", pwallet->laccentries); | ||||
for (CAccountingEntry &entry : pwallet->laccentries) { | for (CAccountingEntry &entry : pwallet->laccentries) { | ||||
pwallet->wtxOrdered.insert(make_pair( | pwallet->wtxOrdered.insert(std::make_pair( | ||||
entry.nOrderPos, CWallet::TxPair((CWalletTx *)0, &entry))); | entry.nOrderPos, CWallet::TxPair((CWalletTx *)0, &entry))); | ||||
} | } | ||||
return result; | return result; | ||||
} | } | ||||
DBErrors CWalletDB::FindWalletTx(CWallet *pwallet, | DBErrors CWalletDB::FindWalletTx(CWallet *pwallet, | ||||
std::vector<uint256> &vTxHash, | std::vector<uint256> &vTxHash, | ||||
▲ Show 20 Lines • Show All 278 Lines • Show Last 20 Lines |