mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-05 18:23:03 +01:00
Implement writing descriptorkeys, descriptorckeys, and descriptors to wallet file
This commit is contained in:
@@ -191,6 +191,31 @@ bool WalletBatch::WriteActiveScriptPubKeyMan(uint8_t type, const uint256& id, bo
|
||||
return WriteIC(make_pair(key, type), id);
|
||||
}
|
||||
|
||||
bool WalletBatch::WriteDescriptorKey(const uint256& desc_id, const CPubKey& pubkey, const CPrivKey& privkey)
|
||||
{
|
||||
// hash pubkey/privkey to accelerate wallet load
|
||||
std::vector<unsigned char> key;
|
||||
key.reserve(pubkey.size() + privkey.size());
|
||||
key.insert(key.end(), pubkey.begin(), pubkey.end());
|
||||
key.insert(key.end(), privkey.begin(), privkey.end());
|
||||
|
||||
return WriteIC(std::make_pair(DBKeys::WALLETDESCRIPTORKEY, std::make_pair(desc_id, pubkey)), std::make_pair(privkey, Hash(key.begin(), key.end())), false);
|
||||
}
|
||||
|
||||
bool WalletBatch::WriteCryptedDescriptorKey(const uint256& desc_id, const CPubKey& pubkey, const std::vector<unsigned char>& secret)
|
||||
{
|
||||
if (!WriteIC(std::make_pair(DBKeys::WALLETDESCRIPTORCKEY, std::make_pair(desc_id, pubkey)), secret, false)) {
|
||||
return false;
|
||||
}
|
||||
EraseIC(std::make_pair(DBKeys::WALLETDESCRIPTORKEY, std::make_pair(desc_id, pubkey)));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WalletBatch::WriteDescriptor(const uint256& desc_id, const WalletDescriptor& descriptor)
|
||||
{
|
||||
return WriteIC(make_pair(DBKeys::WALLETDESCRIPTOR, desc_id), descriptor);
|
||||
}
|
||||
|
||||
class CWalletScanState {
|
||||
public:
|
||||
unsigned int nKeys{0};
|
||||
|
||||
Reference in New Issue
Block a user