 |
Bitcoin Core
22.99.0
P2P Digital Currency
|
Go to the documentation of this file.
14 #include <validation.h>
18 #include <boost/test/unit_test.hpp>
21 static std::vector<unsigned char>
24 std::vector<unsigned char> sSerialized(s.
begin(), s.
end());
33 txFrom.
vout.resize(1);
34 txFrom.
vout[0].scriptPubKey = scriptPubKey;
39 txTo.
vin[0].prevout.n = 0;
41 txTo.
vin[0].scriptSig = scriptSig;
42 txTo.
vout[0].nValue = 1;
60 for (
int i = 0; i < 4; i++)
74 for (
int i = 0; i < 4; i++)
82 txFrom.
vout.resize(8);
83 for (
int i = 0; i < 4; i++)
85 txFrom.
vout[i].scriptPubKey = evalScripts[i];
87 txFrom.
vout[i+4].scriptPubKey = standardScripts[i];
93 for (
int i = 0; i < 8; i++)
95 txTo[i].
vin.resize(1);
96 txTo[i].
vout.resize(1);
97 txTo[i].
vin[0].prevout.n = i;
98 txTo[i].
vin[0].prevout.hash = txFrom.
GetHash();
99 txTo[i].
vout[0].nValue = 1;
101 for (
int i = 0; i < 8; i++)
107 for (
int i = 0; i < 8; i++) {
109 for (
int j = 0; j < 8; j++)
112 txTo[i].
vin[0].scriptSig = txTo[j].
vin[0].scriptSig;
115 BOOST_CHECK_MESSAGE(sigOK,
strprintf(
"VerifySignature %d %d", i, j));
117 BOOST_CHECK_MESSAGE(!sigOK,
strprintf(
"VerifySignature %d %d", i, j));
118 txTo[i].
vin[0].scriptSig = sigSave;
156 std::vector<CPubKey> keys;
157 for (
int i = 0; i < 4; i++)
171 for (
int i = 0; i < 4; i++)
179 txFrom.
vout.resize(4);
180 for (
int i = 0; i < 4; i++)
182 txFrom.
vout[i].scriptPubKey = outer[i];
188 for (
int i = 0; i < 4; i++)
190 txTo[i].
vin.resize(1);
191 txTo[i].
vout.resize(1);
192 txTo[i].
vin[0].prevout.n = i;
193 txTo[i].
vin[0].prevout.hash = txFrom.
GetHash();
195 txTo[i].
vout[0].scriptPubKey = inner[i];
197 for (
int i = 0; i < 4; i++)
212 std::vector<unsigned char> direct = {
OP_HASH160, 20};
213 direct.insert(direct.end(), 20, 0);
219 pushdata1.insert(pushdata1.end(), 20, 0);
223 pushdata2.insert(pushdata2.end(), 20, 0);
227 pushdata4.insert(pushdata4.end(), 20, 0);
271 std::vector<CPubKey> keys;
272 for (
int i = 0; i < 6; i++)
277 for (
int i = 0; i < 3; i++)
281 txFrom.
vout.resize(7);
289 txFrom.
vout[0].nValue = 1000;
290 txFrom.
vout[1].scriptPubKey = pay1;
291 txFrom.
vout[1].nValue = 2000;
292 txFrom.
vout[2].scriptPubKey = pay1of3;
293 txFrom.
vout[2].nValue = 3000;
304 txFrom.
vout[3].nValue = 4000;
313 txFrom.
vout[4].nValue = 5000;
319 txFrom.
vout[5].nValue = 5000;
323 txFrom.
vout[6].nValue = 6000;
332 for (
int i = 0; i < 5; i++)
334 txTo.
vin[i].prevout.n = i;
343 txTo.
vin[3].scriptSig << OP_11 << OP_11 << std::vector<unsigned char>(oneAndTwo.
begin(), oneAndTwo.
end());
344 txTo.
vin[4].scriptSig << std::vector<unsigned char>(fifteenSigops.
begin(), fifteenSigops.
end());
351 txToNonStd1.
vout.resize(1);
353 txToNonStd1.
vout[0].nValue = 1000;
354 txToNonStd1.
vin.resize(1);
355 txToNonStd1.
vin[0].prevout.n = 5;
356 txToNonStd1.
vin[0].prevout.hash = txFrom.
GetHash();
357 txToNonStd1.
vin[0].scriptSig << std::vector<unsigned char>(sixteenSigops.
begin(), sixteenSigops.
end());
363 txToNonStd2.
vout.resize(1);
365 txToNonStd2.
vout[0].nValue = 1000;
366 txToNonStd2.
vin.resize(1);
367 txToNonStd2.
vin[0].prevout.n = 6;
368 txToNonStd2.
vin[0].prevout.hash = txFrom.
GetHash();
369 txToNonStd2.
vin[0].scriptSig << std::vector<unsigned char>(twentySigops.
begin(), twentySigops.
end());
std::string ScriptErrorString(const ScriptError serror)
void MakeNewKey(bool fCompressed)
Generate a new private key using a cryptographic PRNG.
Fillable signing provider that keeps keys in an address->secret map.
static bool Verify(const CScript &scriptSig, const CScript &scriptPubKey, bool fStrict, ScriptError &err)
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
bool IsStandardTx(const CTransaction &tx, bool permit_bare_multisig, const CFeeRate &dust_relay_fee, std::string &reason)
Check for standard transaction types.
unsigned int GetP2SHSigOpCount(const CTransaction &tx, const CCoinsViewCache &inputs)
Count ECDSA signature operations in pay-to-script-hash inputs.
bool IsPayToScriptHash() const
bool AreInputsStandard(const CTransaction &tx, const CCoinsViewCache &mapInputs)
Check transaction inputs to mitigate two potential denial-of-service attacks:
#define BOOST_FIXTURE_TEST_SUITE(a, b)
BOOST_AUTO_TEST_SUITE_END()
bool VerifyScript(const CScript &scriptSig, const CScript &scriptPubKey, const CScriptWitness *witness, unsigned int flags, const BaseSignatureChecker &checker, ScriptError *serror)
virtual bool AddKey(const CKey &key)
The basic transaction that is broadcasted on the network and contained in blocks.
enum ScriptError_t ScriptError
Abstract view on the open txout dataset.
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.
std::vector< unsigned char > ToByteVector(const T &in)
static const unsigned int MAX_P2SH_SIGOPS
Maximum number of signature check operations in an IsStandard() P2SH script.
bool SignSignature(const SigningProvider &provider, const CScript &fromPubKey, CMutableTransaction &txTo, unsigned int nIn, const CAmount &amount, int nHashType)
Produce a script signature for a transaction.
CScript GetScriptForMultisig(int nRequired, const std::vector< CPubKey > &keys)
Generate a multisig script.
static constexpr CAmount CENT
static std::vector< unsigned char > Serialize(const CScript &s)
CPubKey GetPubKey() const
Compute the public key from a private key.
@ ASSERT_FAIL
Abort execution through assertion failure (for consensus code)
Serialized script, used inside transaction inputs and outputs.
std::vector< CTxOut > vout
An encapsulated private key.
CCoinsView that adds a memory cache for transactions to another CCoinsView.
GenericTransactionSignatureChecker< CMutableTransaction > MutableTransactionSignatureChecker
BOOST_AUTO_TEST_CASE(sign)
Closure representing one script verification Note that this stores references to the spending transac...
virtual bool AddCScript(const CScript &redeemScript)
uint256 GetHash() const
Compute the hash of this CMutableTransaction.
static constexpr CAmount COIN
The amount of satoshis in one BTC.
A mutable version of CTransaction.
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
static bool GetPubKey(const SigningProvider &provider, const SignatureData &sigdata, const CKeyID &address, CPubKey &pubkey)
#define BOOST_CHECK(expr)
#define BOOST_CHECK_EQUAL(v1, v2)
@ SCRIPT_VERIFY_STRICTENC