|
|
|
@ -1,4 +1,4 @@
@@ -1,4 +1,4 @@
|
|
|
|
|
// Copyright (c) 2011-2015 The Bitcoin Core developers
|
|
|
|
|
// Copyright (c) 2011-2016 The Bitcoin Core developers
|
|
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
|
@ -55,7 +55,8 @@ static std::map<string, unsigned int> mapFlagNames = boost::assign::map_list_of
@@ -55,7 +55,8 @@ static std::map<string, unsigned int> mapFlagNames = boost::assign::map_list_of
|
|
|
|
|
(string("CHECKLOCKTIMEVERIFY"), (unsigned int)SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY) |
|
|
|
|
(string("CHECKSEQUENCEVERIFY"), (unsigned int)SCRIPT_VERIFY_CHECKSEQUENCEVERIFY) |
|
|
|
|
(string("WITNESS"), (unsigned int)SCRIPT_VERIFY_WITNESS) |
|
|
|
|
(string("DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM"), (unsigned int)SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM); |
|
|
|
|
(string("DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM"), (unsigned int)SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM) |
|
|
|
|
(string("WITNESS_PUBKEYTYPE"), (unsigned int)SCRIPT_VERIFY_WITNESS_PUBKEYTYPE); |
|
|
|
|
|
|
|
|
|
unsigned int ParseScriptFlags(string strFlags) |
|
|
|
|
{ |
|
|
|
@ -429,7 +430,7 @@ BOOST_AUTO_TEST_CASE(test_big_witness_transaction) {
@@ -429,7 +430,7 @@ BOOST_AUTO_TEST_CASE(test_big_witness_transaction) {
|
|
|
|
|
mtx.nVersion = 1; |
|
|
|
|
|
|
|
|
|
CKey key; |
|
|
|
|
key.MakeNewKey(false); |
|
|
|
|
key.MakeNewKey(true); // Need to use compressed keys in segwit or the signing will fail
|
|
|
|
|
CBasicKeyStore keystore; |
|
|
|
|
keystore.AddKeyPubKey(key, key.GetPubKey()); |
|
|
|
|
CKeyID hash = key.GetPubKey().GetID(); |
|
|
|
@ -625,30 +626,13 @@ BOOST_AUTO_TEST_CASE(test_witness)
@@ -625,30 +626,13 @@ BOOST_AUTO_TEST_CASE(test_witness)
|
|
|
|
|
CheckWithFlag(output1, input2, SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2SH, false); |
|
|
|
|
CheckWithFlag(output1, input2, STANDARD_SCRIPT_VERIFY_FLAGS, false); |
|
|
|
|
|
|
|
|
|
// Witness pay-to-uncompressed-pubkey (v1).
|
|
|
|
|
CreateCreditAndSpend(keystore, GetScriptForWitness(scriptPubkey1L), output1, input1); |
|
|
|
|
CreateCreditAndSpend(keystore, GetScriptForWitness(scriptPubkey2L), output2, input2); |
|
|
|
|
CheckWithFlag(output1, input1, 0, true); |
|
|
|
|
CheckWithFlag(output1, input1, SCRIPT_VERIFY_P2SH, true); |
|
|
|
|
CheckWithFlag(output1, input1, SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2SH, true); |
|
|
|
|
CheckWithFlag(output1, input1, STANDARD_SCRIPT_VERIFY_FLAGS, true); |
|
|
|
|
CheckWithFlag(output1, input2, 0, true); |
|
|
|
|
CheckWithFlag(output1, input2, SCRIPT_VERIFY_P2SH, true); |
|
|
|
|
CheckWithFlag(output1, input2, SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2SH, false); |
|
|
|
|
CheckWithFlag(output1, input2, STANDARD_SCRIPT_VERIFY_FLAGS, false); |
|
|
|
|
// Signing disabled for witness pay-to-uncompressed-pubkey (v1).
|
|
|
|
|
CreateCreditAndSpend(keystore, GetScriptForWitness(scriptPubkey1L), output1, input1, false); |
|
|
|
|
CreateCreditAndSpend(keystore, GetScriptForWitness(scriptPubkey2L), output2, input2, false); |
|
|
|
|
|
|
|
|
|
// P2SH witness pay-to-uncompressed-pubkey (v1).
|
|
|
|
|
CreateCreditAndSpend(keystore, GetScriptForDestination(CScriptID(GetScriptForWitness(scriptPubkey1L))), output1, input1); |
|
|
|
|
CreateCreditAndSpend(keystore, GetScriptForDestination(CScriptID(GetScriptForWitness(scriptPubkey2L))), output2, input2); |
|
|
|
|
ReplaceRedeemScript(input2.vin[0].scriptSig, GetScriptForWitness(scriptPubkey1L)); |
|
|
|
|
CheckWithFlag(output1, input1, 0, true); |
|
|
|
|
CheckWithFlag(output1, input1, SCRIPT_VERIFY_P2SH, true); |
|
|
|
|
CheckWithFlag(output1, input1, SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2SH, true); |
|
|
|
|
CheckWithFlag(output1, input1, STANDARD_SCRIPT_VERIFY_FLAGS, true); |
|
|
|
|
CheckWithFlag(output1, input2, 0, true); |
|
|
|
|
CheckWithFlag(output1, input2, SCRIPT_VERIFY_P2SH, true); |
|
|
|
|
CheckWithFlag(output1, input2, SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2SH, false); |
|
|
|
|
CheckWithFlag(output1, input2, STANDARD_SCRIPT_VERIFY_FLAGS, false); |
|
|
|
|
// Signing disabled for P2SH witness pay-to-uncompressed-pubkey (v1).
|
|
|
|
|
CreateCreditAndSpend(keystore, GetScriptForDestination(CScriptID(GetScriptForWitness(scriptPubkey1L))), output1, input1, false); |
|
|
|
|
CreateCreditAndSpend(keystore, GetScriptForDestination(CScriptID(GetScriptForWitness(scriptPubkey2L))), output2, input2, false); |
|
|
|
|
|
|
|
|
|
// Normal 2-of-2 multisig
|
|
|
|
|
CreateCreditAndSpend(keystore, scriptMulti, output1, input1, false); |
|
|
|
|