Skip to content

Commit bfb9b94

Browse files
committed
wallet: remove duplicate descriptor type check in GetNewDestination
1 parent 76b982a commit bfb9b94

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/wallet/scriptpubkeyman.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,7 +1676,7 @@ util::Result<CTxDestination> DescriptorScriptPubKeyMan::GetNewDestination(const
16761676
std::optional<OutputType> desc_addr_type = m_wallet_descriptor.descriptor->GetOutputType();
16771677
assert(desc_addr_type);
16781678
if (type != *desc_addr_type) {
1679-
throw std::runtime_error(std::string(__func__) + ": Types are inconsistent");
1679+
throw std::runtime_error(std::string(__func__) + ": Types are inconsistent. Stored type does not match type of newly generated address");
16801680
}
16811681

16821682
TopUp();
@@ -1694,11 +1694,8 @@ util::Result<CTxDestination> DescriptorScriptPubKeyMan::GetNewDestination(const
16941694
}
16951695

16961696
CTxDestination dest;
1697-
std::optional<OutputType> out_script_type = m_wallet_descriptor.descriptor->GetOutputType();
1698-
if (out_script_type && out_script_type == type) {
1699-
ExtractDestination(scripts_temp[0], dest);
1700-
} else {
1701-
throw std::runtime_error(std::string(__func__) + ": Types are inconsistent. Stored type does not match type of newly generated address");
1697+
if (!ExtractDestination(scripts_temp[0], dest)) {
1698+
return util::Error{_("Error: Cannot extract destination from the generated scriptpubkey")}; // shouldn't happen
17021699
}
17031700
m_wallet_descriptor.next_index++;
17041701
WalletBatch(m_storage.GetDatabase()).WriteDescriptor(GetID(), m_wallet_descriptor);

0 commit comments

Comments
 (0)