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