mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-05 21:24:47 +02:00
Add CWallet::IsInternalScriptPubKeyMan
This commit is contained in:
@ -3265,6 +3265,30 @@ DescriptorScriptPubKeyMan* CWallet::GetDescriptorScriptPubKeyMan(const WalletDes
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::optional<bool> CWallet::IsInternalScriptPubKeyMan(ScriptPubKeyMan* spk_man) const
|
||||
{
|
||||
// Legacy script pubkey man can't be either external or internal
|
||||
if (IsLegacy()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// only active ScriptPubKeyMan can be internal
|
||||
if (!GetActiveScriptPubKeyMans().count(spk_man)) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
const auto desc_spk_man = dynamic_cast<DescriptorScriptPubKeyMan*>(spk_man);
|
||||
if (!desc_spk_man) {
|
||||
throw std::runtime_error(std::string(__func__) + ": unexpected ScriptPubKeyMan type.");
|
||||
}
|
||||
|
||||
LOCK(desc_spk_man->cs_desc_man);
|
||||
const auto& type = desc_spk_man->GetWalletDescriptor().descriptor->GetOutputType();
|
||||
assert(type.has_value());
|
||||
|
||||
return GetScriptPubKeyMan(*type, /* internal= */ true) == desc_spk_man;
|
||||
}
|
||||
|
||||
ScriptPubKeyMan* CWallet::AddWalletDescriptor(WalletDescriptor& desc, const FlatSigningProvider& signing_provider, const std::string& label, bool internal)
|
||||
{
|
||||
AssertLockHeld(cs_wallet);
|
||||
|
Reference in New Issue
Block a user