diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h --- a/src/wallet/walletdb.h +++ b/src/wallet/walletdb.h @@ -170,6 +170,8 @@ bool WriteTx(const CWalletTx &wtx); bool EraseTx(uint256 hash); + bool WriteKeyMetadata(const CKeyMetadata &meta, const CPubKey &pubkey, + const bool overwrite); bool WriteKey(const CPubKey &vchPubKey, const CPrivKey &vchPrivKey, const CKeyMetadata &keyMeta); bool WriteCryptedKey(const CPubKey &vchPubKey, diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -72,10 +72,16 @@ return EraseIC(std::make_pair(std::string("tx"), hash)); } +bool WalletBatch::WriteKeyMetadata(const CKeyMetadata &meta, + const CPubKey &pubkey, + const bool overwrite) { + return WriteIC(std::make_pair(std::string("keymeta"), pubkey), meta, + overwrite); +} + bool WalletBatch::WriteKey(const CPubKey &vchPubKey, const CPrivKey &vchPrivKey, const CKeyMetadata &keyMeta) { - if (!WriteIC(std::make_pair(std::string("keymeta"), vchPubKey), keyMeta, - false)) { + if (!WriteKeyMetadata(keyMeta, vchPubKey, false)) { return false; } @@ -93,7 +99,7 @@ bool WalletBatch::WriteCryptedKey(const CPubKey &vchPubKey, const std::vector &vchCryptedSecret, const CKeyMetadata &keyMeta) { - if (!WriteIC(std::make_pair(std::string("keymeta"), vchPubKey), keyMeta)) { + if (!WriteKeyMetadata(keyMeta, vchPubKey, true)) { return false; }