Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/walletdb.cpp
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | |||||
bool WalletBatch::WriteTx(const CWalletTx &wtx) { | bool WalletBatch::WriteTx(const CWalletTx &wtx) { | ||||
return WriteIC(std::make_pair(std::string("tx"), wtx.GetId()), wtx); | return WriteIC(std::make_pair(std::string("tx"), wtx.GetId()), wtx); | ||||
} | } | ||||
bool WalletBatch::EraseTx(uint256 hash) { | bool WalletBatch::EraseTx(uint256 hash) { | ||||
return EraseIC(std::make_pair(std::string("tx"), hash)); | return EraseIC(std::make_pair(std::string("tx"), hash)); | ||||
} | } | ||||
bool WalletBatch::WriteKeyMetadata(const CKeyMetadata &meta, | |||||
const CPubKey &pubkey, | |||||
const bool overwrite) { | |||||
return WriteIC(std::make_pair(std::string("keymeta"), pubkey), meta, | |||||
overwrite); | |||||
} | |||||
bool WalletBatch::WriteKey(const CPubKey &vchPubKey, const CPrivKey &vchPrivKey, | bool WalletBatch::WriteKey(const CPubKey &vchPubKey, const CPrivKey &vchPrivKey, | ||||
const CKeyMetadata &keyMeta) { | const CKeyMetadata &keyMeta) { | ||||
if (!WriteIC(std::make_pair(std::string("keymeta"), vchPubKey), keyMeta, | if (!WriteKeyMetadata(keyMeta, vchPubKey, true)) { | ||||
Fabien: No overwrite | |||||
false)) { | |||||
return false; | return false; | ||||
} | } | ||||
// hash pubkey/privkey to accelerate wallet load | // hash pubkey/privkey to accelerate wallet load | ||||
std::vector<uint8_t> vchKey; | std::vector<uint8_t> vchKey; | ||||
vchKey.reserve(vchPubKey.size() + vchPrivKey.size()); | vchKey.reserve(vchPubKey.size() + vchPrivKey.size()); | ||||
vchKey.insert(vchKey.end(), vchPubKey.begin(), vchPubKey.end()); | vchKey.insert(vchKey.end(), vchPubKey.begin(), vchPubKey.end()); | ||||
vchKey.insert(vchKey.end(), vchPrivKey.begin(), vchPrivKey.end()); | vchKey.insert(vchKey.end(), vchPrivKey.begin(), vchPrivKey.end()); | ||||
return WriteIC( | return WriteIC( | ||||
std::make_pair(std::string("key"), vchPubKey), | std::make_pair(std::string("key"), vchPubKey), | ||||
std::make_pair(vchPrivKey, Hash(vchKey.begin(), vchKey.end())), false); | std::make_pair(vchPrivKey, Hash(vchKey.begin(), vchKey.end())), false); | ||||
} | } | ||||
bool WalletBatch::WriteCryptedKey(const CPubKey &vchPubKey, | bool WalletBatch::WriteCryptedKey(const CPubKey &vchPubKey, | ||||
const std::vector<uint8_t> &vchCryptedSecret, | const std::vector<uint8_t> &vchCryptedSecret, | ||||
const CKeyMetadata &keyMeta) { | const CKeyMetadata &keyMeta) { | ||||
if (!WriteIC(std::make_pair(std::string("keymeta"), vchPubKey), keyMeta)) { | if (!WriteKeyMetadata(keyMeta, vchPubKey, true)) { | ||||
return false; | return false; | ||||
} | } | ||||
if (!WriteIC(std::make_pair(std::string("ckey"), vchPubKey), | if (!WriteIC(std::make_pair(std::string("ckey"), vchPubKey), | ||||
vchCryptedSecret, false)) { | vchCryptedSecret, false)) { | ||||
return false; | return false; | ||||
} | } | ||||
EraseIC(std::make_pair(std::string("key"), vchPubKey)); | EraseIC(std::make_pair(std::string("key"), vchPubKey)); | ||||
▲ Show 20 Lines • Show All 688 Lines • Show Last 20 Lines |
No overwrite