Skip to content

Commit

Permalink
wallet: Write hd{c}key when HAS_HDKEY_RECORDS is set
Browse files Browse the repository at this point in the history
If WALLET_FLAG_HAS_HDKEY_RECORDS is already set, then it's okay to just
use the hd{c}key records.
  • Loading branch information
achow101 committed Nov 28, 2023
1 parent 06fa375 commit 9024317
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4464,8 +4464,16 @@ bool CWallet::SetActiveHDKey(const CExtKey& xprv)
if (!EncryptSecret(GetEncryptionKey(), secret, xprv.key.GetPubKey().GetHash(), crypted_key)) {
return false;
}
// Write the key if HAS_HDKEY_RECORDS is set
if (IsWalletFlagSet(WALLET_FLAG_HAS_HDKEY_RECORDS) && !WalletBatch(GetDatabase()).WriteHDCryptedKey(xprv.Neuter(), crypted_key)) {
return false;
}
} else {
key = xprv.key;
// Write the key if HAS_HDKEY_RECORDS is set
if (IsWalletFlagSet(WALLET_FLAG_HAS_HDKEY_RECORDS) && !WalletBatch(GetDatabase()).WriteHDKey(xprv)) {
return false;
}
}
return SetActiveHDKey(xprv.Neuter(), key, crypted_key);
}
Expand Down

0 comments on commit 9024317

Please sign in to comment.