wallet: Prevent segfault when sending to unspendable witness

This commit is contained in:
MarcoFalke 2018-05-30 15:47:20 -04:00
parent 61fcef0f89
commit fa36aa7965
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548
2 changed files with 27 additions and 0 deletions

View File

@ -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;
}

View File

@ -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;