18 #include <boost/test/unit_test.hpp>
21 typedef std::vector<unsigned char>
valtype;
32 for (
const CKey &key : keys)
34 std::vector<unsigned char> vchSig;
49 for (
int i = 0; i < 4; i++)
50 key[i].MakeNewKey(
true);
62 txFrom.
vout.resize(3);
63 txFrom.
vout[0].scriptPubKey = a_and_b;
64 txFrom.
vout[1].scriptPubKey = a_or_b;
65 txFrom.
vout[2].scriptPubKey = escrow;
68 for (
int i = 0; i < 3; i++)
70 txTo[i].
vin.resize(1);
71 txTo[i].
vout.resize(1);
72 txTo[i].
vin[0].prevout.n = i;
73 txTo[i].
vin[0].prevout.hash = txFrom.
GetHash();
74 txTo[i].
vout[0].nValue = 1;
77 std::vector<CKey> keys;
82 keys.push_back(key[0]);
83 keys.push_back(key[1]);
88 for (
int i = 0; i < 4; i++)
91 keys.push_back(key[i]);
97 keys.push_back(key[1]);
98 keys.push_back(key[i]);
105 for (
int i = 0; i < 4; i++)
108 keys.push_back(key[i]);
110 if (i == 0 || i == 1)
127 for (
int i = 0; i < 4; i++)
128 for (
int j = 0; j < 4; j++)
131 keys.push_back(key[i]);
132 keys.push_back(key[j]);
134 if (i < j && i < 3 && j < 3)
136 BOOST_CHECK_MESSAGE(
VerifyScript(s, escrow,
flags,
MutableTransactionSignatureChecker(&txTo[2], 0, amount),
SIGVERSION_BASE, &err),
strprintf(
"escrow 1: %d %d", i, j));
141 BOOST_CHECK_MESSAGE(!
VerifyScript(s, escrow,
flags,
MutableTransactionSignatureChecker(&txTo[2], 0, amount),
SIGVERSION_BASE, &err),
strprintf(
"escrow 2: %d %d", i, j));
150 for (
int i = 0; i < 4; i++)
151 key[i].MakeNewKey(
true);
179 for (
int i = 0; i < 6; i++)
198 for (
int i = 0; i < 3; i++)
204 partialkeystore.
AddKey(key[0]);
207 std::vector<valtype> solutions;
220 std::vector<valtype> solutions;
233 std::vector<valtype> solutions;
246 std::vector<valtype> solutions;
252 std::vector<CTxDestination> addrs;
263 std::vector<valtype> solutions;
277 for (
int i = 0; i < 4; i++)
293 txFrom.
vout.resize(3);
294 txFrom.
vout[0].scriptPubKey = a_and_b;
295 txFrom.
vout[1].scriptPubKey = a_or_b;
296 txFrom.
vout[2].scriptPubKey = escrow;
299 for (
int i = 0; i < 3; i++)
301 txTo[i].
vin.resize(1);
302 txTo[i].
vout.resize(1);
303 txTo[i].
vin[0].prevout.n = i;
304 txTo[i].
vin[0].prevout.hash = txFrom.
GetHash();
305 txTo[i].
vout[0].nValue = 1;
308 for (
int i = 0; i < 3; i++)
int64_t CAmount
Amount in PIV (Can be negative)
Basic key store, that keeps keys in an address->secret map.
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.
virtual bool AddKey(const CKey &key)
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
Serialized script, used inside transaction inputs and outputs.
The basic transaction that is broadcasted on the network and contained in blocks.
BOOST_AUTO_TEST_SUITE_END()
bool VerifyScript(const CScript &scriptSig, const CScript &scriptPubKey, unsigned int flags, const BaseSignatureChecker &checker, SigVersion sigversion, ScriptError *serror)
uint256 SignatureHash(const CScript &scriptCode, const CTransaction &txTo, unsigned int nIn, int nHashType, const CAmount &amount, SigVersion sigversion, const PrecomputedTransactionData *cache)
@ SCRIPT_VERIFY_STRICTENC
isminetype IsMine(const CKeyStore &keystore, const CTxDestination &dest)
BOOST_AUTO_TEST_CASE(multisig_verify)
std::vector< unsigned char > valtype
CScript sign_multisig(const CScript &scriptPubKey, const std::vector< CKey > &keys, const CTransaction &transaction, int whichIn)
#define BOOST_FIXTURE_TEST_SUITE(a, b)
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
bool IsStandard(const CScript &scriptPubKey, txnouttype &whichType)
Check transaction inputs to mitigate two potential denial-of-service attacks:
std::vector< unsigned char > ToByteVector(const T &in)
const char * ScriptErrorString(const ScriptError serror)
enum ScriptError_t ScriptError
@ SCRIPT_ERR_INVALID_STACK_OPERATION
bool SignSignature(const CKeyStore &keystore, const CScript &fromPubKey, CMutableTransaction &txTo, unsigned int nIn, const CAmount &amount, int nHashType, bool fColdStake)
Produce a script signature for a transaction.
bool ExtractDestinations(const CScript &scriptPubKey, txnouttype &typeRet, std::vector< CTxDestination > &addressRet, int &nRequiredRet)
Parse a standard scriptPubKey with one or more destination addresses.
bool Solver(const CScript &scriptPubKey, txnouttype &typeRet, std::vector< std::vector< unsigned char > > &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet, bool fColdStake)
Parse a standard scriptPubKey for the destination address.
boost::variant< CNoDestination, CKeyID, CScriptID, CExchangeKeyID > CTxDestination
A txout script template with a specific destination.
A mutable version of CTransaction.
uint256 GetHash() const
Compute the hash of this CMutableTransaction.
std::vector< CTxOut > vout