| 1909 | } |
| 1910 | |
| 1911 | bool DescriptorScriptPubKeyMan::AddDescriptorKeyWithDB(WalletBatch& batch, const CKey& key, const CPubKey &pubkey) |
| 1912 | { |
| 1913 | AssertLockHeld(cs_desc_man); |
| 1914 | assert(!m_storage.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)); |
| 1915 | |
| 1916 | // Check if provided key already exists |
| 1917 | if (m_map_keys.find(pubkey.GetID()) != m_map_keys.end() || |
| 1918 | m_map_crypted_keys.find(pubkey.GetID()) != m_map_crypted_keys.end()) { |
| 1919 | return true; |
| 1920 | } |
| 1921 | |
| 1922 | if (m_storage.HasEncryptionKeys()) { |
| 1923 | if (m_storage.IsLocked()) { |
| 1924 | return false; |
| 1925 | } |
| 1926 | |
| 1927 | std::vector<unsigned char> crypted_secret; |
| 1928 | CKeyingMaterial secret(key.begin(), key.end()); |
| 1929 | if (!EncryptSecret(m_storage.GetEncryptionKey(), secret, pubkey.GetHash(), crypted_secret)) { |
| 1930 | return false; |
| 1931 | } |
| 1932 | |
| 1933 | m_map_crypted_keys[pubkey.GetID()] = make_pair(pubkey, crypted_secret); |
| 1934 | return batch.WriteCryptedDescriptorKey(GetID(), pubkey, crypted_secret); |
| 1935 | } else { |
| 1936 | m_map_keys[pubkey.GetID()] = key; |
| 1937 | return batch.WriteDescriptorKey(GetID(), pubkey, key.GetPrivKey()); |
| 1938 | } |
| 1939 | } |
| 1940 | |
| 1941 | bool DescriptorScriptPubKeyMan::SetupDescriptorGeneration(const CExtKey& master_key, OutputType addr_type, bool internal) |
| 1942 | { |
nothing calls this directly
no test coverage detected