15#include <validation.h>
19#include <boost/test/unit_test.hpp>
24 return IsStandardTx(tx, std::nullopt, permit_bare_multisig,
CFeeRate{DUST_RELAY_TX_FEE}, reason);
35 std::vector<unsigned char> sSerialized(s.begin(), s.end());
43 txFrom.
vout.resize(1);
44 txFrom.
vout[0].scriptPubKey = scriptPubKey;
49 txTo.
vin[0].prevout.n = 0;
51 txTo.
vin[0].scriptSig = scriptSig;
52 txTo.
vout[0].nValue = 1;
69 for (
int i = 0; i < 4; i++)
83 for (
int i = 0; i < 4; i++)
91 txFrom.
vout.resize(8);
92 for (
int i = 0; i < 4; i++)
94 txFrom.
vout[i].scriptPubKey = evalScripts[i];
95 txFrom.
vout[i].nValue = COIN;
96 txFrom.
vout[i+4].scriptPubKey = standardScripts[i];
97 txFrom.
vout[i+4].nValue = COIN;
102 for (
int i = 0; i < 8; i++)
104 txTo[i].
vin.resize(1);
105 txTo[i].
vout.resize(1);
106 txTo[i].
vin[0].prevout.n = i;
107 txTo[i].
vin[0].prevout.hash = txFrom.
GetHash();
108 txTo[i].
vout[0].nValue = 1;
110 for (
int i = 0; i < 8; i++)
118 for (
int i = 0; i < 8; i++) {
120 for (
int j = 0; j < 8; j++)
123 txTo[i].
vin[0].scriptSig = txTo[j].
vin[0].scriptSig;
126 BOOST_CHECK_MESSAGE(sigOK,
strprintf(
"VerifySignature %d %d", i, j));
128 BOOST_CHECK_MESSAGE(!sigOK,
strprintf(
"VerifySignature %d %d", i, j));
129 txTo[i].
vin[0].scriptSig = sigSave;
166 std::vector<CPubKey> keys;
168 for (
int i = 0; i < 4; i++)
172 keys.push_back(key[i].GetPubKey());
182 for (
int i = 0; i < 4; i++)
190 txFrom.
vout.resize(4);
191 for (
int i = 0; i < 4; i++)
193 txFrom.
vout[i].scriptPubKey = outer[i];
194 txFrom.
vout[i].nValue = CENT;
199 for (
int i = 0; i < 4; i++)
201 txTo[i].
vin.resize(1);
202 txTo[i].
vout.resize(1);
203 txTo[i].
vin[0].prevout.n = i;
204 txTo[i].
vin[0].prevout.hash = txFrom.
GetHash();
205 txTo[i].
vout[0].nValue = 1*CENT;
206 txTo[i].
vout[0].scriptPubKey = inner[i];
208 for (
int i = 0; i < 4; i++)
214 BOOST_CHECK_MESSAGE((i == 0 ? no_pbms_is_std : !no_pbms_is_std),
strprintf(
"txTo[%d].IsStandard(permbaremulti=false)", i));
226 std::vector<unsigned char> direct = {
OP_HASH160, 20};
227 direct.insert(direct.end(), 20, 0);
233 pushdata1.insert(pushdata1.end(), 20, 0);
237 pushdata2.insert(pushdata2.end(), 20, 0);
241 pushdata4.insert(pushdata4.end(), 20, 0);
284 for (
int i = 0; i < 6; i++)
289 std::vector<CPubKey> keys;
291 for (
int i = 0; i < 3; i++)
295 txFrom.
vout.resize(7);
303 txFrom.
vout[0].nValue = 1000;
304 txFrom.
vout[1].scriptPubKey = pay1;
305 txFrom.
vout[1].nValue = 2000;
306 txFrom.
vout[2].scriptPubKey = pay1of3;
307 txFrom.
vout[2].nValue = 3000;
318 txFrom.
vout[3].nValue = 4000;
322 for (
unsigned i = 0; i < MAX_P2SH_SIGOPS; i++)
327 txFrom.
vout[4].nValue = 5000;
333 txFrom.
vout[5].nValue = 5000;
337 txFrom.
vout[6].nValue = 6000;
346 for (
int i = 0; i < 5; i++)
348 txTo.
vin[i].prevout.n = i;
361 txTo.
vin[4].scriptSig << std::vector<unsigned char>(fifteenSigops.
begin(), fifteenSigops.
end());
368 coinbase_tx_mut.
vin.resize(1);
374 txToNonStd1.
vout.resize(1);
376 txToNonStd1.
vout[0].nValue = 1000;
377 txToNonStd1.
vin.resize(1);
378 txToNonStd1.
vin[0].prevout.n = 5;
379 txToNonStd1.
vin[0].prevout.hash = txFrom.
GetHash();
380 txToNonStd1.
vin[0].scriptSig << std::vector<unsigned char>(sixteenSigops.
begin(), sixteenSigops.
end());
386 txToNonStd2.
vout.resize(1);
388 txToNonStd2.
vout[0].nValue = 1000;
389 txToNonStd2.
vin.resize(1);
390 txToNonStd2.
vin[0].prevout.n = 6;
391 txToNonStd2.
vin[0].prevout.hash = txFrom.
GetHash();
392 txToNonStd2.
vin[0].scriptSig << std::vector<unsigned char>(twentySigops.
begin(), twentySigops.
end());
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.
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac.
An encapsulated private key.
void MakeNewKey(bool fCompressed)
Generate a new private key using a cryptographic PRNG.
CPubKey GetPubKey() const
Compute the public key from a private key.
CScriptCheck(const CTxOut &outIn, const CTransaction &txToIn, SignatureCache &signature_cache, unsigned int nInIn, script_verify_flags flags, bool cacheIn, PrecomputedTransactionData *txdataIn)
Serialized script, used inside transaction inputs and outputs.
bool IsPayToScriptHash() const
The basic transaction that is broadcasted on the network and contained in blocks.
CTransaction(const CMutableTransaction &tx)
Convert a CMutableTransaction into a CTransaction.
Fillable signing provider that keeps keys in an address->secret map.
virtual bool AddCScript(const CScript &redeemScript)
virtual bool AddKey(const CKey &key)
Valid signature cache, to avoid doing expensive ECDSA signature checking twice for every transaction ...
void AddCoins(CCoinsViewCache &cache, const CTransaction &tx, int nHeight, bool check_for_overwrite)
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, script_verify_flags flags, const BaseSignatureChecker &checker, ScriptError *serror)
GenericTransactionSignatureChecker< CMutableTransaction > MutableTransactionSignatureChecker
@ ASSERT_FAIL
Abort execution through assertion failure (for consensus code).
@ SCRIPT_VERIFY_STRICTENC
BOOST_AUTO_TEST_CASE(ipc_tests)
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
bool AreInputsStandard(const CTransaction &tx, const CCoinsViewCache &mapInputs)
Check transaction inputs.
bool IsStandardTx(const CTransaction &tx, const std::optional< unsigned > &max_datacarrier_bytes, bool permit_bare_multisig, const CFeeRate &dust_relay_fee, std::string &reason)
Check for standard transaction types.
std::vector< unsigned char > ToByteVector(const T &in)
std::string ScriptErrorString(const ScriptError serror)
enum ScriptError_t ScriptError
static bool Verify(const CScript &scriptSig, const CScript &scriptPubKey, bool fStrict, ScriptError &err)
void Serialize(Stream &, V)=delete
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.
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).
unsigned int GetP2SHSigOpCount(const CTransaction &tx, const CCoinsViewCache &inputs)
Count ECDSA signature operations in pay-to-script-hash inputs.