mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 07:28:59 +01:00
Merge bitcoin/bitcoin#25784: Wallet: Document expectations for AddWalletFlags (now InitWalletFlags) correctly
0cb6d2aec6Bugfix: Wallet: Document expectations for AddWalletFlags (now InitWalletFlags) correctly (Luke Dashjr) Pull request description: Includes some slight refactoring (return type changed, current status checked) ACKs for top commit: achow101: ACK0cb6d2aec6w0xlt: ACK0cb6d2aec6ryanofsky: Code review ACK0cb6d2aec6. This is a clarifying change, and should prevent the InitWalletFlags method being called incorrectly. I left a comment suggestion, but feel free to ignore it. Tree-SHA512: fa18e9471b5e89d35cbc01526e6d4dbe4eee8faa9646847248909af1751b33014a6f9a42fe70a1331c0d73adea79008b8fc3ae2b51a641eba3e36d5c631327f6
This commit is contained in:
@@ -1526,16 +1526,20 @@ bool CWallet::LoadWalletFlags(uint64_t flags)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CWallet::AddWalletFlags(uint64_t flags)
|
||||
void CWallet::InitWalletFlags(uint64_t flags)
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
|
||||
// We should never be writing unknown non-tolerable wallet flags
|
||||
assert(((flags & KNOWN_WALLET_FLAGS) >> 32) == (flags >> 32));
|
||||
// This should only be used once, when creating a new wallet - so current flags are expected to be blank
|
||||
assert(m_wallet_flags == 0);
|
||||
|
||||
if (!WalletBatch(GetDatabase()).WriteWalletFlags(flags)) {
|
||||
throw std::runtime_error(std::string(__func__) + ": writing wallet flags failed");
|
||||
}
|
||||
|
||||
return LoadWalletFlags(flags);
|
||||
if (!LoadWalletFlags(flags)) assert(false);
|
||||
}
|
||||
|
||||
// Helper for producing a max-sized low-S low-R signature (eg 71 bytes)
|
||||
@@ -2832,7 +2836,7 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
|
||||
// ensure this wallet.dat can only be opened by clients supporting HD with chain split and expects no default key
|
||||
walletInstance->SetMinVersion(FEATURE_LATEST);
|
||||
|
||||
walletInstance->AddWalletFlags(wallet_creation_flags);
|
||||
walletInstance->InitWalletFlags(wallet_creation_flags);
|
||||
|
||||
// Only create LegacyScriptPubKeyMan when not descriptor wallet
|
||||
if (!walletInstance->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) {
|
||||
|
||||
Reference in New Issue
Block a user