[bitcoin/bitcoin] Add createwallet «disableprivatekeys» option: a sane mode for watchonly-wallets (#9662)

promag commented on this pull request.

> @@ -1513,6 +1513,25 @@ bool CWallet::IsHDEnabled() const
return !hdChain.seed_id.IsNull();
}

+void CWallet::AddWalletFlag(uint64_t flags)
+{
+ m_wallet_flags |= flags;

Commit «Add facility to store wallet flags (64 bits)»

Missing `LOCK(cs_wallet);`?

> @@ -4183,18 +4205,34 @@ std::shared_ptr CWallet::CreateWalletFromFile(const std::string& name,
}
walletInstance->SetMinVersion(FEATURE_LATEST);

— // generate a new seed
— CPubKey seed = walletInstance->GenerateNewSeed();
— if (!walletInstance->SetHDSeed(seed))
— throw std::runtime_error(std::string(__func__) + «: Storing HD seed failed»);
+ if ((wallet_creation_flags & WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
+ //selective allow to set flags
+ walletInstance->AddWalletFlag(WALLET_FLAG_DISABLE_PRIVATE_KEYS);
+ }

Commit «Add per option to disable private keys during internal wallet creation»

nit `} else {`.

Добавить комментарий