diff options
author | MarcoFalke <falke.marco@gmail.com> | 2018-06-05 11:38:03 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2018-06-05 11:38:09 -0400 |
commit | 2140f6cbc5e97fd7ab2900ae906595e9d697d669 (patch) | |
tree | 735b2737475b6c13a00696e4fb2b9b482cc65c79 | |
parent | 7c7508c268fa9dc01b2f7cff1fb3c314ad4f305f (diff) | |
parent | fa36aa79655f7ec76043976f3c1c207afa9bfd6f (diff) |
Merge #13351: wallet: Prevent segfault when sending to unspendable witness
fa36aa7965 wallet: Prevent segfault when sending to unspendable witness (MarcoFalke)
Pull request description:
Previously we wouldn't care about the `txnouttype`, but after 4e91820531889e309dc4335fe0de8229c6426040 we `switch` on the type.
Tree-SHA512: 6b597aba80cb43881671ad7b3a4ad97753864e8005a05c23fdd8ee79953483c08f241b5c392a9b494298eadc5cfba895b0480d916ef4f11d122fd6196f31b84a
-rw-r--r-- | src/script/standard.cpp | 1 | ||||
-rw-r--r-- | src/test/script_standard_tests.cpp | 26 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/script/standard.cpp b/src/script/standard.cpp index 53fcbe37de..d9269d6147 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -114,6 +114,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::v vSolutionsRet.push_back(std::move(witnessprogram)); return true; } + typeRet = TX_NONSTANDARD; return false; } diff --git a/src/test/script_standard_tests.cpp b/src/test/script_standard_tests.cpp index ff0bf6c66d..7ab0978228 100644 --- a/src/test/script_standard_tests.cpp +++ b/src/test/script_standard_tests.cpp @@ -726,6 +726,32 @@ BOOST_AUTO_TEST_CASE(script_standard_IsMine) BOOST_CHECK(!isInvalid); } + // witness unspendable + { + CBasicKeyStore keystore; + keystore.AddKey(keys[0]); + + scriptPubKey.clear(); + scriptPubKey << OP_0 << ToByteVector(ParseHex("aabb")); + + result = IsMine(keystore, scriptPubKey, isInvalid); + BOOST_CHECK_EQUAL(result, ISMINE_NO); + BOOST_CHECK(!isInvalid); + } + + // witness unknown + { + CBasicKeyStore keystore; + keystore.AddKey(keys[0]); + + scriptPubKey.clear(); + scriptPubKey << OP_16 << ToByteVector(ParseHex("aabb")); + + result = IsMine(keystore, scriptPubKey, isInvalid); + BOOST_CHECK_EQUAL(result, ISMINE_NO); + BOOST_CHECK(!isInvalid); + } + // Nonstandard { CBasicKeyStore keystore; |