Skip to content

Commit 2140f6c

Browse files
author
MarcoFalke
committed
Merge #13351: wallet: Prevent segfault when sending to unspendable witness
fa36aa7 wallet: Prevent segfault when sending to unspendable witness (MarcoFalke) Pull request description: Previously we wouldn't care about the `txnouttype`, but after 4e91820 we `switch` on the type. Tree-SHA512: 6b597aba80cb43881671ad7b3a4ad97753864e8005a05c23fdd8ee79953483c08f241b5c392a9b494298eadc5cfba895b0480d916ef4f11d122fd6196f31b84a
2 parents 7c7508c + fa36aa7 commit 2140f6c

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)