12 #include <boost/test/unit_test.hpp>
21 for (
int i = 0; i < 3; i++) {
28 std::vector<std::vector<unsigned char> > solutions;
72 BOOST_CHECK(solutions[0] == std::vector<unsigned char>({1}));
75 BOOST_CHECK(solutions[3] == std::vector<unsigned char>({2}));
86 BOOST_CHECK(solutions[0] == std::vector<unsigned char>({2}));
90 BOOST_CHECK(solutions[4] == std::vector<unsigned char>({3}));
95 std::vector<unsigned char>({0}) <<
96 std::vector<unsigned char>({75}) <<
97 std::vector<unsigned char>({255});
118 std::vector<std::vector<unsigned char> > solutions;
122 s << std::vector<unsigned char>(30, 0x01) <<
OP_CHECKSIG;
137 s << OP_HASH160 << std::vector<unsigned char>(21, 0x01) <<
OP_EQUAL;
162 s << OP_RETURN << std::vector<unsigned char>({75}) <<
OP_ADD;
167 s << OP_0 << std::vector<unsigned char>(19, 0x01);
186 *boost::get<CKeyID>(&address) == pubkey.
GetID());
193 *boost::get<CKeyID>(&address) == pubkey.
GetID());
199 BOOST_CHECK(boost::get<CExchangeKeyID>(&address) &&
200 *boost::get<CExchangeKeyID>(&address) == pubkey.
GetID());
208 *boost::get<CScriptID>(&address) ==
CScriptID(redeemScript));
217 s << OP_RETURN << std::vector<unsigned char>({75});
225 for (
int i = 0; i < 3; i++) {
232 std::vector<CTxDestination> addresses;
243 *boost::get<CKeyID>(&addresses[0]) == pubkeys[0].GetID());
253 *boost::get<CKeyID>(&addresses[0]) == pubkeys[0].GetID());
262 BOOST_CHECK(boost::get<CExchangeKeyID>(&addresses[0]) &&
263 *boost::get<CExchangeKeyID>(&addresses[0]) == pubkeys[0].GetID());
273 BOOST_CHECK(boost::get<CScriptID>(&addresses[0]) &&
274 *boost::get<CScriptID>(&addresses[0]) ==
CScriptID(redeemScript));
287 *boost::get<CKeyID>(&addresses[0]) == pubkeys[0].GetID());
289 *boost::get<CKeyID>(&addresses[1]) == pubkeys[1].GetID());
293 s << OP_RETURN << std::vector<unsigned char>({75});
301 for (
int i = 0; i < 3; i++) {
347 for (
int i = 0; i < 2; i++) {
352 CKey uncompressedKey;
362 scriptPubKey.
clear();
366 result =
IsMine(keystore, scriptPubKey);
371 result =
IsMine(keystore, scriptPubKey);
378 scriptPubKey.
clear();
382 result =
IsMine(keystore, scriptPubKey);
386 keystore.
AddKey(uncompressedKey);
387 result =
IsMine(keystore, scriptPubKey);
394 scriptPubKey.
clear();
398 result =
IsMine(keystore, scriptPubKey);
403 result =
IsMine(keystore, scriptPubKey);
410 scriptPubKey.
clear();
414 result =
IsMine(keystore, scriptPubKey);
418 keystore.
AddKey(uncompressedKey);
419 result =
IsMine(keystore, scriptPubKey);
430 scriptPubKey.
clear();
434 result =
IsMine(keystore, scriptPubKey);
439 result =
IsMine(keystore, scriptPubKey);
444 result =
IsMine(keystore, scriptPubKey);
452 scriptPubKey.
clear();
453 scriptPubKey <<
OP_2 <<
459 result =
IsMine(keystore, scriptPubKey);
463 keystore.
AddKey(uncompressedKey);
465 result =
IsMine(keystore, scriptPubKey);
471 result =
IsMine(keystore, scriptPubKey);
478 keystore.
AddKey(uncompressedKey);
482 redeemScript <<
OP_2 <<
487 scriptPubKey.
clear();
491 result =
IsMine(keystore, scriptPubKey);
496 result =
IsMine(keystore, scriptPubKey);
505 scriptPubKey.
clear();
508 result =
IsMine(keystore, scriptPubKey);
517 scriptPubKey.
clear();
520 result =
IsMine(keystore, scriptPubKey);
Basic key store, that keeps keys in an address->secret map.
virtual bool AddCScript(const CScript &redeemScript)
Support for BIP 0013 : see https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki.
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)
An encapsulated public key.
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
Serialized script, used inside transaction inputs and outputs.
A reference to a CScript: the Hash160 of its serialization (see script.h)
BOOST_AUTO_TEST_SUITE_END()
isminetype IsMine(const CKeyStore &keystore, const CTxDestination &dest)
isminetype
IsMine() return codes.
#define BOOST_FIXTURE_TEST_SUITE(a, b)
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
std::vector< unsigned char > ToByteVector(const T &in)
BOOST_AUTO_TEST_CASE(script_standard_Solver_success)
bool ExtractDestinations(const CScript &scriptPubKey, txnouttype &typeRet, std::vector< CTxDestination > &addressRet, int &nRequiredRet)
Parse a standard scriptPubKey with one or more destination addresses.
CScript GetScriptForMultisig(int nRequired, const std::vector< CPubKey > &keys)
Generate a multisig script.
bool Solver(const CScript &scriptPubKey, txnouttype &typeRet, std::vector< std::vector< unsigned char > > &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
CScript GetScriptForRawPubKey(const CPubKey &pubKey)
Generate a P2PK script for the given pubkey.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a PIVX scriptPubKey for the given CTxDestination.
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.