18 #include <boost/test/unit_test.hpp> 29 for (
const CKey &key : keys)
31 std::vector<unsigned char> vchSig;
46 for (
int i = 0; i < 4; i++)
47 key[i].MakeNewKey(
true);
59 txFrom.
vout.resize(3);
60 txFrom.
vout[0].scriptPubKey = a_and_b;
61 txFrom.
vout[1].scriptPubKey = a_or_b;
62 txFrom.
vout[2].scriptPubKey = escrow;
65 for (
int i = 0; i < 3; i++)
67 txTo[i].
vin.resize(1);
68 txTo[i].
vout.resize(1);
69 txTo[i].
vin[0].prevout.n = i;
70 txTo[i].
vin[0].prevout.hash = txFrom.
GetHash();
71 txTo[i].
vout[0].nValue = 1;
74 std::vector<CKey> keys;
78 keys.assign(1,key[0]);
79 keys.push_back(key[1]);
84 for (
int i = 0; i < 4; i++)
86 keys.assign(1,key[i]);
88 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));
91 keys.assign(1,key[1]);
92 keys.push_back(key[i]);
94 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));
99 for (
int i = 0; i < 4; i++)
101 keys.assign(1,key[i]);
103 if (i == 0 || i == 1)
105 BOOST_CHECK_MESSAGE(
VerifyScript(
s, a_or_b,
nullptr,
flags,
MutableTransactionSignatureChecker(&txTo[1], 0, amount,
MissingDataBehavior::ASSERT_FAIL), &err),
strprintf(
"a|b: %d", i));
110 BOOST_CHECK_MESSAGE(!
VerifyScript(
s, a_or_b,
nullptr,
flags,
MutableTransactionSignatureChecker(&txTo[1], 0, amount,
MissingDataBehavior::ASSERT_FAIL), &err),
strprintf(
"a|b: %d", i));
120 for (
int i = 0; i < 4; i++)
121 for (
int j = 0; j < 4; j++)
123 keys.assign(1,key[i]);
124 keys.push_back(key[j]);
126 if (i < j && i < 3 && j < 3)
128 BOOST_CHECK_MESSAGE(
VerifyScript(
s, escrow,
nullptr,
flags,
MutableTransactionSignatureChecker(&txTo[2], 0, amount,
MissingDataBehavior::ASSERT_FAIL), &err),
strprintf(
"escrow 1: %d %d", i, j));
133 BOOST_CHECK_MESSAGE(!
VerifyScript(
s, escrow,
nullptr,
flags,
MutableTransactionSignatureChecker(&txTo[2], 0, amount,
MissingDataBehavior::ASSERT_FAIL), &err),
strprintf(
"escrow 2: %d %d", i, j));
142 for (
int i = 0; i < 4; i++)
143 key[i].MakeNewKey(
true);
145 const auto is_standard{[](
const CScript& spk) {
178 for (
int i = 0; i < 6; i++) {
188 for (
int i = 0; i < 4; i++)
204 txFrom.
vout.resize(3);
205 txFrom.
vout[0].scriptPubKey = a_and_b;
206 txFrom.
vout[1].scriptPubKey = a_or_b;
207 txFrom.
vout[2].scriptPubKey = escrow;
210 for (
int i = 0; i < 3; i++)
212 txTo[i].
vin.resize(1);
213 txTo[i].
vout.resize(1);
214 txTo[i].
vin[0].prevout.n = i;
215 txTo[i].
vin[0].prevout.hash = txFrom.
GetHash();
216 txTo[i].
vout[0].nValue = 1;
219 for (
int i = 0; i < 3; i++)
enum ScriptError_t ScriptError
static CScript sign_multisig(const CScript &scriptPubKey, const std::vector< CKey > &keys, const CTransaction &transaction, int whichIn)
bool VerifyScript(const CScript &scriptSig, const CScript &scriptPubKey, const CScriptWitness *witness, unsigned int flags, const BaseSignatureChecker &checker, ScriptError *serror)
Bare scripts and BIP16 P2SH-wrapped redeemscripts.
bool IsStandard(const CScript &scriptPubKey, const std::optional< unsigned > &max_datacarrier_bytes, TxoutType &whichType)
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)
uint256 SignatureHash(const CScript &scriptCode, const T &txTo, unsigned int nIn, int32_t nHashType, const CAmount &amount, SigVersion sigversion, const PrecomputedTransactionData *cache)
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. ...
virtual bool AddKey(const CKey &key)
#define BOOST_CHECK(expr)