 |
Bitcoin Core
22.99.0
P2P Digital Currency
|
Go to the documentation of this file.
17 #include <boost/test/unit_test.hpp>
28 for (
const CKey &key : keys)
30 std::vector<unsigned char> vchSig;
45 for (
int i = 0; i < 4; i++)
46 key[i].MakeNewKey(
true);
58 txFrom.
vout.resize(3);
59 txFrom.
vout[0].scriptPubKey = a_and_b;
60 txFrom.
vout[1].scriptPubKey = a_or_b;
61 txFrom.
vout[2].scriptPubKey = escrow;
64 for (
int i = 0; i < 3; i++)
66 txTo[i].
vin.resize(1);
67 txTo[i].
vout.resize(1);
68 txTo[i].
vin[0].prevout.n = i;
69 txTo[i].
vin[0].prevout.hash = txFrom.
GetHash();
70 txTo[i].
vout[0].nValue = 1;
73 std::vector<CKey> keys;
78 keys.push_back(key[1]);
83 for (
int i = 0; i < 4; i++)
85 keys.assign(1,key[i]);
87 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));
90 keys.assign(1,key[1]);
91 keys.push_back(key[i]);
93 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));
98 for (
int i = 0; i < 4; i++)
100 keys.assign(1,key[i]);
102 if (i == 0 || i == 1)
104 BOOST_CHECK_MESSAGE(
VerifyScript(s, a_or_b,
nullptr,
flags,
MutableTransactionSignatureChecker(&txTo[1], 0, amount,
MissingDataBehavior::ASSERT_FAIL), &err),
strprintf(
"a|b: %d", i));
109 BOOST_CHECK_MESSAGE(!
VerifyScript(s, a_or_b,
nullptr,
flags,
MutableTransactionSignatureChecker(&txTo[1], 0, amount,
MissingDataBehavior::ASSERT_FAIL), &err),
strprintf(
"a|b: %d", i));
119 for (
int i = 0; i < 4; i++)
120 for (
int j = 0; j < 4; j++)
122 keys.assign(1,key[i]);
123 keys.push_back(key[j]);
125 if (i < j && i < 3 && j < 3)
127 BOOST_CHECK_MESSAGE(
VerifyScript(s, escrow,
nullptr,
flags,
MutableTransactionSignatureChecker(&txTo[2], 0, amount,
MissingDataBehavior::ASSERT_FAIL), &err),
strprintf(
"escrow 1: %d %d", i, j));
132 BOOST_CHECK_MESSAGE(!
VerifyScript(s, escrow,
nullptr,
flags,
MutableTransactionSignatureChecker(&txTo[2], 0, amount,
MissingDataBehavior::ASSERT_FAIL), &err),
strprintf(
"escrow 2: %d %d", i, j));
141 for (
int i = 0; i < 4; i++)
142 key[i].MakeNewKey(
true);
170 for (
int i = 0; i < 6; i++)
179 for (
int i = 0; i < 4; i++)
195 txFrom.
vout.resize(3);
196 txFrom.
vout[0].scriptPubKey = a_and_b;
197 txFrom.
vout[1].scriptPubKey = a_or_b;
198 txFrom.
vout[2].scriptPubKey = escrow;
201 for (
int i = 0; i < 3; i++)
203 txTo[i].
vin.resize(1);
204 txTo[i].
vout.resize(1);
205 txTo[i].
vin[0].prevout.n = i;
206 txTo[i].
vin[0].prevout.hash = txFrom.
GetHash();
207 txTo[i].
vout[0].nValue = 1;
210 for (
int i = 0; i < 3; i++)
std::string ScriptErrorString(const ScriptError serror)
void MakeNewKey(bool fCompressed)
Generate a new private key using a cryptographic PRNG.
@ BASE
Bare scripts and BIP16 P2SH-wrapped redeemscripts.
bool IsStandard(const CScript &scriptPubKey, TxoutType &whichType)
Fillable signing provider that keeps keys in an address->secret map.
#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
BOOST_AUTO_TEST_CASE(multisig_verify)
std::vector< unsigned char > ToByteVector(const T &in)
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.
int64_t CAmount
Amount in satoshis (Can be negative)
@ SCRIPT_ERR_INVALID_STACK_OPERATION
@ ASSERT_FAIL
Abort execution through assertion failure (for consensus code)
Serialized script, used inside transaction inputs and outputs.
std::vector< CTxOut > vout
void assign(size_type n, const T &val)
An encapsulated private key.
uint256 SignatureHash(const CScript &scriptCode, const T &txTo, unsigned int nIn, int nHashType, const CAmount &amount, SigVersion sigversion, const PrecomputedTransactionData *cache)
GenericTransactionSignatureChecker< CMutableTransaction > MutableTransactionSignatureChecker
uint256 GetHash() const
Compute the hash of this CMutableTransaction.
A mutable version of CTransaction.
static CScript sign_multisig(const CScript &scriptPubKey, const std::vector< CKey > &keys, const CTransaction &transaction, int whichIn)
static bool GetPubKey(const SigningProvider &provider, const SignatureData &sigdata, const CKeyID &address, CPubKey &pubkey)
#define BOOST_CHECK(expr)
@ SCRIPT_VERIFY_STRICTENC