Make IsSegWitOutput return true for taproot outputs

This commit is contained in:
Pieter Wuille committed 2021-07-15 17:08:52 -07:00
1 parent a88fa1a555
commit 8465978f23
1 file changed
+12 -9
+12 -9
View File
@@ -612,15 +612,18 @@ bool IsSolvable(const SigningProvider& provider, const CScript& script)
bool IsSegWitOutput(const SigningProvider& provider, const CScript& script) bool IsSegWitOutput(const SigningProvider& provider, const CScript& script)
{ {
std::vector<valtype> solutions; int version;
auto whichtype = Solver(script, solutions); valtype program;
if (whichtype == TxoutType::WITNESS_V0_SCRIPTHASH || whichtype == TxoutType::WITNESS_V0_KEYHASH || whichtype == TxoutType::WITNESS_UNKNOWN) return true; if (script.IsWitnessProgram(version, program)) return true;
if (whichtype == TxoutType::SCRIPTHASH) { if (script.IsPayToScriptHash()) {
auto h160 = uint160(solutions[0]); std::vector<valtype> solutions;
CScript subscript; auto whichtype = Solver(script, solutions);
if (provider.GetCScript(CScriptID{h160}, subscript)) { if (whichtype == TxoutType::SCRIPTHASH) {
whichtype = Solver(subscript, solutions); auto h160 = uint160(solutions[0]);
if (whichtype == TxoutType::WITNESS_V0_SCRIPTHASH || whichtype == TxoutType::WITNESS_V0_KEYHASH || whichtype == TxoutType::WITNESS_UNKNOWN) return true; CScript subscript;
if (provider.GetCScript(CScriptID{h160}, subscript)) {
if (subscript.IsWitnessProgram(version, program)) return true;
}
} }
} }
return false; return false;