Skip to content

Commit bac8c67

Browse files
committed
Add a method to CWallet to write just CKeyMetadata
1 parent e7652d3 commit bac8c67

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/wallet/wallet.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,12 @@ void CWallet::LoadScriptMetadata(const CScriptID& script_id, const CKeyMetadata
349349
m_script_metadata[script_id] = meta;
350350
}
351351

352+
// Writes a keymetadata for a public key. overwrite specifies whether to overwrite an existing metadata for that key if there exists one.
353+
bool CWallet::WriteKeyMetadata(const CKeyMetadata& meta, const CPubKey& pubkey, const bool overwrite)
354+
{
355+
return WalletBatch(*database).WriteKeyMetadata(meta, pubkey, overwrite);
356+
}
357+
352358
bool CWallet::LoadCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret)
353359
{
354360
return CCryptoKeyStore::AddCryptedKey(vchPubKey, vchCryptedSecret);

src/wallet/wallet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,8 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
776776
// Map from Script ID to key metadata (for watch-only keys).
777777
std::map<CScriptID, CKeyMetadata> m_script_metadata GUARDED_BY(cs_wallet);
778778

779+
bool WriteKeyMetadata(const CKeyMetadata& meta, const CPubKey& pubkey, bool overwrite);
780+
779781
typedef std::map<unsigned int, CMasterKey> MasterKeyMap;
780782
MasterKeyMap mapMasterKeys;
781783
unsigned int nMasterKeyMaxID = 0;

0 commit comments

Comments
 (0)