Skip to content

Commit 08f3228

Browse files
committed
Optimization: only test for witness scripts at top level
Inside P2SH scripts we already know that the P2SH script version of witness keys/scripts are acceptable, so there is no need to test for it again.
1 parent 3619735 commit 08f3228

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/script/ismine.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static isminetype IsMineInner(const CKeyStore& keystore, const CScript& scriptPu
7070
break;
7171
case TX_WITNESS_V0_KEYHASH:
7272
{
73-
if (!keystore.HaveCScript(CScriptID(CScript() << OP_0 << vSolutions[0]))) {
73+
if (sigversion == IsMineSigVersion::TOP && !keystore.HaveCScript(CScriptID(CScript() << OP_0 << vSolutions[0]))) {
7474
// We do not support bare witness outputs unless the P2SH version of it would be
7575
// acceptable as well. This protects against matching before segwit activates.
7676
// This also applies to the P2WSH case.
@@ -106,7 +106,7 @@ static isminetype IsMineInner(const CKeyStore& keystore, const CScript& scriptPu
106106
}
107107
case TX_WITNESS_V0_SCRIPTHASH:
108108
{
109-
if (!keystore.HaveCScript(CScriptID(CScript() << OP_0 << vSolutions[0]))) {
109+
if (sigversion == IsMineSigVersion::TOP && !keystore.HaveCScript(CScriptID(CScript() << OP_0 << vSolutions[0]))) {
110110
break;
111111
}
112112
uint160 hash;

0 commit comments

Comments
 (0)