mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
Implement writing descriptorkeys, descriptorckeys, and descriptors to wallet file
This commit is contained in:
@@ -1553,6 +1553,30 @@ void DescriptorScriptPubKeyMan::MarkUnusedAddresses(const CScript& script)
|
||||
}
|
||||
}
|
||||
|
||||
bool DescriptorScriptPubKeyMan::AddDescriptorKeyWithDB(WalletBatch& batch, const CKey& key, const CPubKey &pubkey)
|
||||
{
|
||||
AssertLockHeld(cs_desc_man);
|
||||
assert(!m_storage.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS));
|
||||
|
||||
if (m_storage.HasEncryptionKeys()) {
|
||||
if (m_storage.IsLocked()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<unsigned char> crypted_secret;
|
||||
CKeyingMaterial secret(key.begin(), key.end());
|
||||
if (!EncryptSecret(m_storage.GetEncryptionKey(), secret, pubkey.GetHash(), crypted_secret)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_map_crypted_keys[pubkey.GetID()] = make_pair(pubkey, crypted_secret);
|
||||
return batch.WriteCryptedDescriptorKey(GetID(), pubkey, crypted_secret);
|
||||
} else {
|
||||
m_map_keys[pubkey.GetID()] = key;
|
||||
return batch.WriteDescriptorKey(GetID(), pubkey, key.GetPrivKey());
|
||||
}
|
||||
}
|
||||
|
||||
bool DescriptorScriptPubKeyMan::IsHDEnabled() const
|
||||
{
|
||||
LOCK(cs_desc_man);
|
||||
|
||||
Reference in New Issue
Block a user