19#include <boost/test/unit_test.hpp>
22static std::vector<unsigned char>
25 std::vector<unsigned char> sSerialized(
s.begin(),
s.end());
50 std::vector<CPubKey> keys;
51 for (
int i = 0; i < 3; i++)
54 keys.push_back(
k.GetPubKey());
90 creationTx.
vin.resize(1);
91 creationTx.
vin[0].prevout.SetNull();
93 creationTx.
vout.resize(1);
94 creationTx.
vout[0].nValue = 1;
95 creationTx.
vout[0].scriptPubKey = scriptPubKey;
98 spendingTx.
vin.resize(1);
99 spendingTx.
vin[0].prevout.hash = creationTx.
GetHash();
100 spendingTx.
vin[0].prevout.n = 0;
101 spendingTx.
vin[0].scriptSig = scriptSig;
102 spendingTx.
vin[0].scriptWitness = witness;
103 spendingTx.
vout.resize(1);
104 spendingTx.
vout[0].nValue = 1;
161 scriptWitness.
stack.emplace_back(0);
162 scriptWitness.
stack.emplace_back(0);
165 BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, scriptWitness);
172 assert(scriptPubKey[0] == 0x00);
173 scriptPubKey[0] = 0x51;
174 BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, scriptWitness);
176 scriptPubKey[0] = 0x00;
177 BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, scriptWitness);
180 spendingTx.
vin[0].prevout.SetNull();
190 scriptWitness.
stack.emplace_back(0);
191 scriptWitness.
stack.emplace_back(0);
193 BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, scriptWitness);
204 scriptWitness.
stack.emplace_back(0);
205 scriptWitness.
stack.emplace_back(0);
206 scriptWitness.
stack.emplace_back(witnessScript.
begin(), witnessScript.
end());
208 BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, scriptWitness);
221 scriptWitness.
stack.emplace_back(0);
222 scriptWitness.
stack.emplace_back(0);
223 scriptWitness.
stack.emplace_back(witnessScript.
begin(), witnessScript.
end());
225 BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, scriptWitness);
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Abstract view on the open txout dataset.
An encapsulated private key.
CPubKey GetPubKey() const
Compute the public key from a private key.
An encapsulated public key.
Serialized script, used inside transaction inputs and outputs.
unsigned int GetSigOpCount(bool fAccurate) const
Pre-version-0.6, Bitcoin always counted CHECKMULTISIGs as 20 sigops.
The basic transaction that is broadcasted on the network and contained in blocks.
const std::vector< CTxOut > vout
const std::vector< CTxIn > vin
void AddCoins(CCoinsViewCache &cache, const CTransaction &tx, int nHeight, bool check_for_overwrite)
Utility function to add all of a transaction's outputs to a cache.
static const int WITNESS_SCALE_FACTOR
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
bool VerifyScript(const CScript &scriptSig, const CScript &scriptPubKey, const CScriptWitness *witness, unsigned int flags, const BaseSignatureChecker &checker, ScriptError *serror)
@ ASSERT_FAIL
Abort execution through assertion failure (for consensus code)
CKey GenerateRandomKey(bool compressed) noexcept
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
static const int MAX_PUBKEYS_PER_MULTISIG
std::vector< unsigned char > ToByteVector(const T &in)
enum ScriptError_t ScriptError
@ SCRIPT_ERR_CHECKMULTISIGVERIFY
static ScriptError VerifyWithFlag(const CTransaction &output, const CMutableTransaction &input, uint32_t flags)
Verifies script execution of the zeroth scriptPubKey of tx output and zeroth scriptSig and witness of...
static void BuildTxs(CMutableTransaction &spendingTx, CCoinsViewCache &coins, CMutableTransaction &creationTx, const CScript &scriptPubKey, const CScript &scriptSig, const CScriptWitness &witness)
Builds a creationTx from scriptPubKey and a spendingTx from scriptSig and witness such that spendingT...
static std::vector< unsigned char > Serialize(const CScript &s)
BOOST_AUTO_TEST_CASE(GetSigOpCount)
CScript GetScriptForMultisig(int nRequired, const std::vector< CPubKey > &keys)
Generate a multisig script.
A mutable version of CTransaction.
std::vector< CTxOut > vout
Txid GetHash() const
Compute the hash of this CMutableTransaction.
std::vector< std::vector< unsigned char > > stack
int64_t GetTransactionSigOpCost(const CTransaction &tx, const CCoinsViewCache &inputs, uint32_t flags)
Compute total signature operation cost of a transaction.