Skip to content

Commit 228aba2

Browse files
committed
Merge bitcoin#31555: descriptor: remove unreachable verification for pkh
366ae00 descriptor: Assume `ParseScript` is not being called with a P2WPKH context (brunoerg) e366408 descriptor: remove unreachable verification for `pkh` (brunoerg) Pull request description: This PR removes an unreachable verification in the `ParseScript` function. It returns an error if `pkh` is not being used at top level, sh, wsh or tr. However, any usage of `pkh` without these contexts will not reach this verification but other ones like "invalid keys" (e.g. `wpkh(pkh(L4gM1FBdyHNpkzsFh9ipnofLhpZRp2mwobpeULy1a6dBTvw8Ywtd))`). ACKs for top commit: davidgumberg: crACK bitcoin@366ae00 achow101: ACK 366ae00 tdb3: cr ACK 366ae00 sipa: crACK 366ae00 Tree-SHA512: b954221a77eed623aeed5eb54f14e82c49540a151d3388831924caa7a784e48a2a975e418af1e13d491e4f8cded3b1797aa39e0e4e39e302a991105df09cdec0
2 parents 9b97522 + 366ae00 commit 228aba2

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/script/descriptor.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -1761,7 +1761,7 @@ struct KeyParser {
17611761
std::vector<std::unique_ptr<DescriptorImpl>> ParseScript(uint32_t& key_exp_index, Span<const char>& sp, ParseScriptContext ctx, FlatSigningProvider& out, std::string& error)
17621762
{
17631763
using namespace script;
1764-
1764+
Assume(ctx == ParseScriptContext::TOP || ctx == ParseScriptContext::P2SH || ctx == ParseScriptContext::P2WSH || ctx == ParseScriptContext::P2TR);
17651765
std::vector<std::unique_ptr<DescriptorImpl>> ret;
17661766
auto expr = Expr(sp);
17671767
if (Func("pk", expr)) {
@@ -1787,10 +1787,6 @@ std::vector<std::unique_ptr<DescriptorImpl>> ParseScript(uint32_t& key_exp_index
17871787
ret.emplace_back(std::make_unique<PKHDescriptor>(std::move(pubkey)));
17881788
}
17891789
return ret;
1790-
} else if (ctx != ParseScriptContext::P2TR && Func("pkh", expr)) {
1791-
// Under Taproot, always the Miniscript parser deal with it.
1792-
error = "Can only have pkh at top level, in sh(), wsh(), or in tr()";
1793-
return {};
17941790
}
17951791
if (ctx == ParseScriptContext::TOP && Func("combo", expr)) {
17961792
auto pubkeys = ParsePubkey(key_exp_index, expr, ctx, out, error);

0 commit comments

Comments
 (0)