Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/scriptpubkeyman.cpp
Show First 20 Lines • Show All 1,568 Lines • ▼ Show 20 Lines | if (IsMine(script)) { | ||||
} | } | ||||
if (!TopUp()) { | if (!TopUp()) { | ||||
WalletLogPrintf("%s: Topping up keypool failed (locked wallet)\n", | WalletLogPrintf("%s: Topping up keypool failed (locked wallet)\n", | ||||
__func__); | __func__); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
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<uint8_t> 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 { | bool DescriptorScriptPubKeyMan::IsHDEnabled() const { | ||||
LOCK(cs_desc_man); | LOCK(cs_desc_man); | ||||
return m_wallet_descriptor.descriptor->IsRange(); | return m_wallet_descriptor.descriptor->IsRange(); | ||||
} | } | ||||
bool DescriptorScriptPubKeyMan::CanGetAddresses(bool internal) const { | bool DescriptorScriptPubKeyMan::CanGetAddresses(bool internal) const { | ||||
// We can only give out addresses from descriptors that are single type (not | // We can only give out addresses from descriptors that are single type (not | ||||
// combo), ranged, and either have cached keys or can generate more keys | // combo), ranged, and either have cached keys or can generate more keys | ||||
▲ Show 20 Lines • Show All 126 Lines • Show Last 20 Lines |