wallet: remove duplicate descriptor type check in GetNewDestination

This commit is contained in:
furszy
2022-07-01 16:56:51 -03:00
parent 76b982a4a5
commit bfb9b94ebe

View File

@@ -1676,7 +1676,7 @@ util::Result<CTxDestination> DescriptorScriptPubKeyMan::GetNewDestination(const
std::optional<OutputType> desc_addr_type = m_wallet_descriptor.descriptor->GetOutputType(); std::optional<OutputType> desc_addr_type = m_wallet_descriptor.descriptor->GetOutputType();
assert(desc_addr_type); assert(desc_addr_type);
if (type != *desc_addr_type) { if (type != *desc_addr_type) {
throw std::runtime_error(std::string(__func__) + ": Types are inconsistent"); throw std::runtime_error(std::string(__func__) + ": Types are inconsistent. Stored type does not match type of newly generated address");
} }
TopUp(); TopUp();
@@ -1694,11 +1694,8 @@ util::Result<CTxDestination> DescriptorScriptPubKeyMan::GetNewDestination(const
} }
CTxDestination dest; CTxDestination dest;
std::optional<OutputType> out_script_type = m_wallet_descriptor.descriptor->GetOutputType(); if (!ExtractDestination(scripts_temp[0], dest)) {
if (out_script_type && out_script_type == type) { return util::Error{_("Error: Cannot extract destination from the generated scriptpubkey")}; // shouldn't happen
ExtractDestination(scripts_temp[0], dest);
} else {
throw std::runtime_error(std::string(__func__) + ": Types are inconsistent. Stored type does not match type of newly generated address");
} }
m_wallet_descriptor.next_index++; m_wallet_descriptor.next_index++;
WalletBatch(m_storage.GetDatabase()).WriteDescriptor(GetID(), m_wallet_descriptor); WalletBatch(m_storage.GetDatabase()).WriteDescriptor(GetID(), m_wallet_descriptor);