Skip to content

Commit fa36aa7

Browse files
author
MarcoFalke
committed
wallet: Prevent segfault when sending to unspendable witness
1 parent 61fcef0 commit fa36aa7

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/script/standard.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::v
114114
vSolutionsRet.push_back(std::move(witnessprogram));
115115
return true;
116116
}
117+
typeRet = TX_NONSTANDARD;
117118
return false;
118119
}
119120

src/test/script_standard_tests.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,32 @@ BOOST_AUTO_TEST_CASE(script_standard_IsMine)
726726
BOOST_CHECK(!isInvalid);
727727
}
728728

729+
// witness unspendable
730+
{
731+
CBasicKeyStore keystore;
732+
keystore.AddKey(keys[0]);
733+
734+
scriptPubKey.clear();
735+
scriptPubKey << OP_0 << ToByteVector(ParseHex("aabb"));
736+
737+
result = IsMine(keystore, scriptPubKey, isInvalid);
738+
BOOST_CHECK_EQUAL(result, ISMINE_NO);
739+
BOOST_CHECK(!isInvalid);
740+
}
741+
742+
// witness unknown
743+
{
744+
CBasicKeyStore keystore;
745+
keystore.AddKey(keys[0]);
746+
747+
scriptPubKey.clear();
748+
scriptPubKey << OP_16 << ToByteVector(ParseHex("aabb"));
749+
750+
result = IsMine(keystore, scriptPubKey, isInvalid);
751+
BOOST_CHECK_EQUAL(result, ISMINE_NO);
752+
BOOST_CHECK(!isInvalid);
753+
}
754+
729755
// Nonstandard
730756
{
731757
CBasicKeyStore keystore;

0 commit comments

Comments
 (0)