19 #include <boost/test/unit_test.hpp> 30 for (
const CKey &key : keys)
32 std::vector<unsigned char> vchSig;
47 for (
int i = 0; i < 4; i++)
48 key[i].MakeNewKey(
true);
60 txFrom.
vout.resize(3);
61 txFrom.
vout[0].scriptPubKey = a_and_b;
62 txFrom.
vout[1].scriptPubKey = a_or_b;
63 txFrom.
vout[2].scriptPubKey = escrow;
66 for (
int i = 0; i < 3; i++)
68 txTo[i].
vin.resize(1);
69 txTo[i].
vout.resize(1);
70 txTo[i].
vin[0].prevout.n = i;
71 txTo[i].
vin[0].prevout.hash = txFrom.
GetHash();
72 txTo[i].
vout[0].nValue = 1;
75 std::vector<CKey> keys;
79 keys.assign(1,key[0]);
80 keys.push_back(key[1]);
85 for (
int i = 0; i < 4; i++)
87 keys.assign(1,key[i]);
89 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));
92 keys.assign(1,key[1]);
93 keys.push_back(key[i]);
95 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));
100 for (
int i = 0; i < 4; i++)
102 keys.assign(1,key[i]);
104 if (i == 0 || i == 1)
106 BOOST_CHECK_MESSAGE(
VerifyScript(
s, a_or_b,
nullptr,
flags,
MutableTransactionSignatureChecker(&txTo[1], 0, amount,
MissingDataBehavior::ASSERT_FAIL), &err),
strprintf(
"a|b: %d", i));
111 BOOST_CHECK_MESSAGE(!
VerifyScript(
s, a_or_b,
nullptr,
flags,
MutableTransactionSignatureChecker(&txTo[1], 0, amount,
MissingDataBehavior::ASSERT_FAIL), &err),
strprintf(
"a|b: %d", i));
121 for (
int i = 0; i < 4; i++)
122 for (
int j = 0; j < 4; j++)
124 keys.assign(1,key[i]);
125 keys.push_back(key[j]);
127 if (i < j && i < 3 && j < 3)
129 BOOST_CHECK_MESSAGE(
VerifyScript(
s, escrow,
nullptr,
flags,
MutableTransactionSignatureChecker(&txTo[2], 0, amount,
MissingDataBehavior::ASSERT_FAIL), &err),
strprintf(
"escrow 1: %d %d", i, j));
134 BOOST_CHECK_MESSAGE(!
VerifyScript(
s, escrow,
nullptr,
flags,
MutableTransactionSignatureChecker(&txTo[2], 0, amount,
MissingDataBehavior::ASSERT_FAIL), &err),
strprintf(
"escrow 2: %d %d", i, j));
143 for (
int i = 0; i < 4; i++)
144 key[i].MakeNewKey(
true);
146 const auto is_standard{[](
const CScript& spk) {
179 for (
int i = 0; i < 6; i++) {
189 for (
int i = 0; i < 4; i++)
205 txFrom.
vout.resize(3);
206 txFrom.
vout[0].scriptPubKey = a_and_b;
207 txFrom.
vout[1].scriptPubKey = a_or_b;
208 txFrom.
vout[2].scriptPubKey = escrow;
211 for (
int i = 0; i < 3; i++)
213 txTo[i].
vin.resize(1);
214 txTo[i].
vout.resize(1);
215 txTo[i].
vin[0].prevout.n = i;
216 txTo[i].
vin[0].prevout.hash = txFrom.
GetHash();
217 txTo[i].
vout[0].nValue = 1;
220 for (
int i = 0; i < 3; i++)
uint256 SignatureHash(const CScript &scriptCode, const T &txTo, unsigned int nIn, int32_t nHashType, const CAmount &amount, SigVersion sigversion, const PrecomputedTransactionData *cache, SigHashCache *sighash_cache)
enum ScriptError_t ScriptError
static CScript sign_multisig(const CScript &scriptPubKey, const std::vector< CKey > &keys, const CTransaction &transaction, int whichIn)
Bare scripts and BIP16 P2SH-wrapped redeemscripts.
bool VerifyScript(const CScript &scriptSig, const CScript &scriptPubKey, const CScriptWitness *witness, script_verify_flags flags, const BaseSignatureChecker &checker, ScriptError *serror)
int64_t CAmount
Amount in satoshis (Can be negative)
Abort execution through assertion failure (for consensus code)
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
Fillable signing provider that keeps keys in an address->secret map.
std::string ScriptErrorString(const ScriptError serror)
void MakeNewKey(bool fCompressed)
Generate a new private key using a cryptographic PRNG.
GenericTransactionSignatureChecker< CMutableTransaction > MutableTransactionSignatureChecker
Txid GetHash() const
Compute the hash of this CMutableTransaction.
std::vector< CTxOut > vout
bool SignSignature(const SigningProvider &provider, const CScript &fromPubKey, CMutableTransaction &txTo, unsigned int nIn, const CAmount &amount, int nHashType, SignatureData &sig_data)
Produce a satisfying script (scriptSig or witness).
std::vector< unsigned char > ToByteVector(const T &in)
#define BOOST_CHECK_EQUAL(v1, v2)
Serialized script, used inside transaction inputs and outputs.
static bool GetPubKey(const SigningProvider &provider, const SignatureData &sigdata, const CKeyID &address, CPubKey &pubkey)
BOOST_AUTO_TEST_CASE(multisig_verify)
A mutable version of CTransaction.
An encapsulated private key.
The basic transaction that is broadcasted on the network and contained in blocks. ...
bool IsStandard(const CScript &scriptPubKey, TxoutType &whichType)
virtual bool AddKey(const CKey &key)
#define BOOST_CHECK(expr)