17#include <boost/test/unit_test.hpp> 
   28    for (
const CKey &key : keys)
 
   30        std::vector<unsigned char> vchSig;
 
   45    for (
int i = 0; i < 4; i++)
 
   46        key[i].MakeNewKey(
true);
 
   58    txFrom.
vout.resize(3);
 
   59    txFrom.
vout[0].scriptPubKey = a_and_b;
 
   60    txFrom.
vout[1].scriptPubKey = a_or_b;
 
   61    txFrom.
vout[2].scriptPubKey = escrow;
 
   64    for (
int i = 0; i < 3; i++)
 
   66        txTo[i].
vin.resize(1);
 
   67        txTo[i].
vout.resize(1);
 
   68        txTo[i].
vin[0].prevout.n = i;
 
   69        txTo[i].
vin[0].prevout.hash = txFrom.
GetHash();
 
   70        txTo[i].
vout[0].nValue = 1;
 
   73    std::vector<CKey> keys;
 
   78    keys.push_back(key[1]);
 
   83    for (
int i = 0; i < 4; i++)
 
   85        keys.assign(1,key[i]);
 
   87        BOOST_CHECK_MESSAGE(!
VerifyScript(s, a_and_b, 
nullptr, 
flags, 
MutableTransactionSignatureChecker(&txTo[0], 0, amount, 
MissingDataBehavior::ASSERT_FAIL), &err), 
strprintf(
"a&b 1: %d", i));
 
   90        keys.assign(1,key[1]);
 
   91        keys.push_back(key[i]);
 
   93        BOOST_CHECK_MESSAGE(!
VerifyScript(s, a_and_b, 
nullptr, 
flags, 
MutableTransactionSignatureChecker(&txTo[0], 0, amount, 
MissingDataBehavior::ASSERT_FAIL), &err), 
strprintf(
"a&b 2: %d", i));
 
   98    for (
int i = 0; i < 4; i++)
 
  100        keys.assign(1,key[i]);
 
  102        if (i == 0 || i == 1)
 
  104            BOOST_CHECK_MESSAGE(
VerifyScript(s, a_or_b, 
nullptr, 
flags, 
MutableTransactionSignatureChecker(&txTo[1], 0, amount, 
MissingDataBehavior::ASSERT_FAIL), &err), 
strprintf(
"a|b: %d", i));
 
  109            BOOST_CHECK_MESSAGE(!
VerifyScript(s, a_or_b, 
nullptr, 
flags, 
MutableTransactionSignatureChecker(&txTo[1], 0, amount, 
MissingDataBehavior::ASSERT_FAIL), &err), 
strprintf(
"a|b: %d", i));
 
  119    for (
int i = 0; i < 4; i++)
 
  120        for (
int j = 0; j < 4; j++)
 
  122            keys.assign(1,key[i]);
 
  123            keys.push_back(key[j]);
 
  125            if (i < j && i < 3 && j < 3)
 
  127                BOOST_CHECK_MESSAGE(
VerifyScript(s, escrow, 
nullptr, 
flags, 
MutableTransactionSignatureChecker(&txTo[2], 0, amount, 
MissingDataBehavior::ASSERT_FAIL), &err), 
strprintf(
"escrow 1: %d %d", i, j));
 
  132                BOOST_CHECK_MESSAGE(!
VerifyScript(s, escrow, 
nullptr, 
flags, 
MutableTransactionSignatureChecker(&txTo[2], 0, amount, 
MissingDataBehavior::ASSERT_FAIL), &err), 
strprintf(
"escrow 2: %d %d", i, j));
 
  141    for (
int i = 0; i < 4; i++)
 
  142        key[i].MakeNewKey(
true);
 
  170    for (
int i = 0; i < 6; i++)
 
  179    for (
int i = 0; i < 4; i++)
 
  195    txFrom.
vout.resize(3);
 
  196    txFrom.
vout[0].scriptPubKey = a_and_b;
 
  197    txFrom.
vout[1].scriptPubKey = a_or_b;
 
  198    txFrom.
vout[2].scriptPubKey = escrow;
 
  201    for (
int i = 0; i < 3; i++)
 
  203        txTo[i].
vin.resize(1);
 
  204        txTo[i].
vout.resize(1);
 
  205        txTo[i].
vin[0].prevout.n = i;
 
  206        txTo[i].
vin[0].prevout.hash = txFrom.
GetHash();
 
  207        txTo[i].
vout[0].nValue = 1;
 
  210    for (
int i = 0; i < 3; i++)
 
int64_t CAmount
Amount in satoshis (Can be negative)
An encapsulated private key.
void MakeNewKey(bool fCompressed)
Generate a new private key using a cryptographic PRNG.
Serialized script, used inside transaction inputs and outputs.
The basic transaction that is broadcasted on the network and contained in blocks.
Fillable signing provider that keeps keys in an address->secret map.
virtual bool AddKey(const CKey &key)
void assign(size_type n, const T &val)
BOOST_AUTO_TEST_SUITE_END()
uint256 SignatureHash(const CScript &scriptCode, const T &txTo, unsigned int nIn, int nHashType, const CAmount &amount, SigVersion sigversion, const PrecomputedTransactionData *cache)
bool VerifyScript(const CScript &scriptSig, const CScript &scriptPubKey, const CScriptWitness *witness, unsigned int flags, const BaseSignatureChecker &checker, ScriptError *serror)
@ BASE
Bare scripts and BIP16 P2SH-wrapped redeemscripts.
@ SCRIPT_VERIFY_STRICTENC
GenericTransactionSignatureChecker< CMutableTransaction > MutableTransactionSignatureChecker
@ ASSERT_FAIL
Abort execution through assertion failure (for consensus code)
BOOST_AUTO_TEST_CASE(multisig_verify)
static CScript sign_multisig(const CScript &scriptPubKey, const std::vector< CKey > &keys, const CTransaction &transaction, int whichIn)
#define BOOST_FIXTURE_TEST_SUITE(a, b)
#define BOOST_CHECK(expr)
bool IsStandard(const CScript &scriptPubKey, TxoutType &whichType)
std::vector< unsigned char > ToByteVector(const T &in)
std::string ScriptErrorString(const ScriptError serror)
enum ScriptError_t ScriptError
@ SCRIPT_ERR_INVALID_STACK_OPERATION
bool SignSignature(const SigningProvider &provider, const CScript &fromPubKey, CMutableTransaction &txTo, unsigned int nIn, const CAmount &amount, int nHashType)
Produce a script signature for a transaction.
static bool GetPubKey(const SigningProvider &provider, const SignatureData &sigdata, const CKeyID &address, CPubKey &pubkey)
A mutable version of CTransaction.
uint256 GetHash() const
Compute the hash of this CMutableTransaction.
std::vector< CTxOut > vout