MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / Encrypt

Method Encrypt

src/wallet/scriptpubkeyman.cpp:951–972  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

949}
950
951bool DescriptorScriptPubKeyMan::Encrypt(const CKeyingMaterial& master_key, WalletBatch* batch)
952{
953 LOCK(cs_desc_man);
954 if (!m_map_crypted_keys.empty()) {
955 return false;
956 }
957
958 for (const KeyMap::value_type& key_in : m_map_keys)
959 {
960 const CKey &key = key_in.second;
961 CPubKey pubkey = key.GetPubKey();
962 CKeyingMaterial secret{UCharCast(key.begin()), UCharCast(key.end())};
963 std::vector<unsigned char> crypted_secret;
964 if (!EncryptSecret(master_key, secret, pubkey.GetHash(), crypted_secret)) {
965 return false;
966 }
967 m_map_crypted_keys[pubkey.GetID()] = make_pair(pubkey, crypted_secret);
968 batch->WriteCryptedDescriptorKey(GetID(), pubkey, crypted_secret);
969 }
970 m_map_keys.clear();
971 return true;
972}
973
974util::Result<CTxDestination> DescriptorScriptPubKeyMan::GetReservedDestination(const OutputType type, bool internal, int64_t& index)
975{

Callers

nothing calls this directly

Calls 10

UCharCastFunction · 0.85
EncryptSecretFunction · 0.85
emptyMethod · 0.45
GetPubKeyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
GetHashMethod · 0.45
GetIDMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected