| 123 | } |
| 124 | |
| 125 | bool WalletBatch::WriteCryptedKey(const CPubKey& vchPubKey, |
| 126 | const std::vector<unsigned char>& vchCryptedSecret, |
| 127 | const CKeyMetadata &keyMeta) |
| 128 | { |
| 129 | if (!WriteKeyMetadata(keyMeta, vchPubKey, true)) { |
| 130 | return false; |
| 131 | } |
| 132 | |
| 133 | // Compute a checksum of the encrypted key |
| 134 | uint256 checksum = Hash(vchCryptedSecret); |
| 135 | |
| 136 | const auto key = std::make_pair(DBKeys::CRYPTED_KEY, vchPubKey); |
| 137 | if (!WriteIC(key, std::make_pair(vchCryptedSecret, checksum), false)) { |
| 138 | // It may already exist, so try writing just the checksum |
| 139 | std::vector<unsigned char> val; |
| 140 | if (!m_batch->Read(key, val)) { |
| 141 | return false; |
| 142 | } |
| 143 | if (!WriteIC(key, std::make_pair(val, checksum), true)) { |
| 144 | return false; |
| 145 | } |
| 146 | } |
| 147 | EraseIC(std::make_pair(DBKeys::KEY, vchPubKey)); |
| 148 | return true; |
| 149 | } |
| 150 | |
| 151 | bool WalletBatch::WriteMasterKey(unsigned int nID, const CMasterKey& kMasterKey) |
| 152 | { |
no test coverage detected