19 #include <boost/test/unit_test.hpp> 22 static 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++)
55 keys.push_back(
k.GetPubKey());
91 creationTx.
vin.resize(1);
92 creationTx.
vin[0].prevout.SetNull();
94 creationTx.
vout.resize(1);
95 creationTx.
vout[0].nValue = 1;
96 creationTx.
vout[0].scriptPubKey = scriptPubKey;
99 spendingTx.
vin.resize(1);
100 spendingTx.
vin[0].prevout.hash = creationTx.
GetHash();
101 spendingTx.
vin[0].prevout.n = 0;
102 spendingTx.
vin[0].scriptSig = scriptSig;
103 spendingTx.
vin[0].scriptWitness = witness;
104 spendingTx.
vout.resize(1);
105 spendingTx.
vout[0].nValue = 1;
163 scriptWitness.
stack.emplace_back(0);
164 scriptWitness.
stack.emplace_back(0);
167 BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, scriptWitness);
174 assert(scriptPubKey[0] == 0x00);
175 scriptPubKey[0] = 0x51;
176 BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, scriptWitness);
178 scriptPubKey[0] = 0x00;
179 BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, scriptWitness);
182 spendingTx.
vin[0].prevout.SetNull();
192 scriptWitness.
stack.emplace_back(0);
193 scriptWitness.
stack.emplace_back(0);
195 BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, scriptWitness);
206 scriptWitness.
stack.emplace_back(0);
207 scriptWitness.
stack.emplace_back(0);
208 scriptWitness.
stack.emplace_back(witnessScript.
begin(), witnessScript.
end());
210 BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, scriptWitness);
223 scriptWitness.
stack.emplace_back(0);
224 scriptWitness.
stack.emplace_back(0);
225 scriptWitness.
stack.emplace_back(witnessScript.
begin(), witnessScript.
end());
227 BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, scriptWitness);
unsigned int GetSigOpCount(bool fAccurate) const
Pre-version-0.6, Bitcoin always counted CHECKMULTISIGs as 20 sigops.
CScript GetScriptForMultisig(int nRequired, const std::vector< CPubKey > &keys)
Generate a multisig script.
BOOST_AUTO_TEST_CASE(GetSigOpCount)
static const int WITNESS_SCALE_FACTOR
enum ScriptError_t ScriptError
CPubKey GetPubKey() const
Compute the public key from a private key.
bool VerifyScript(const CScript &scriptSig, const CScript &scriptPubKey, const CScriptWitness *witness, unsigned int flags, const BaseSignatureChecker &checker, ScriptError *serror)
static std::vector< unsigned char > Serialize(const CScript &s)
std::vector< std::vector< unsigned char > > stack
static const int MAX_PUBKEYS_PER_MULTISIG
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.
Abort execution through assertion failure (for consensus code)
int64_t GetTransactionSigOpCost(const CTransaction &tx, const CCoinsViewCache &inputs, uint32_t flags)
Compute total signature operation cost of a transaction.
Abstract view on the open txout dataset.
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...
BOOST_AUTO_TEST_SUITE_END()
An encapsulated public key.
void MakeNewKey(bool fCompressed)
Generate a new private key using a cryptographic PRNG.
const std::vector< CTxOut > vout
std::vector< CTxOut > vout
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
std::vector< unsigned char > ToByteVector(const T &in)
uint256 GetHash() const
Compute the hash of this CMutableTransaction.
#define BOOST_CHECK_EQUAL(v1, v2)
bool error(const char *fmt, const Args &... args)
Serialized script, used inside transaction inputs and outputs.
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...
A mutable version of CTransaction.
An encapsulated private key.
The basic transaction that is broadcasted on the network and contained in blocks. ...
CCoinsView that adds a memory cache for transactions to another CCoinsView.
#define BOOST_CHECK(expr)