9 #include <test/util/setup_common.h>
13 #include <boost/test/unit_test.hpp>
22 for (
int i = 0; i < 2; i++) {
23 keys[i].MakeNewKey(
true);
24 pubkeys[i] = keys[i].GetPubKey();
28 uncompressedKey.MakeNewKey(
false);
29 CPubKey uncompressedPubkey = uncompressedKey.GetPubKey();
40 LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
44 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
48 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
49 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
57 LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
61 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
65 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(uncompressedKey));
66 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
74 LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
78 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
82 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
83 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
91 LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
95 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
99 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(uncompressedKey));
100 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
108 LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
114 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
118 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(redeemScript));
119 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
123 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
124 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
132 LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
138 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(redeemscript));
139 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(redeemscript_inner));
140 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(scriptPubKey));
141 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
142 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
150 LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
156 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(witnessscript));
157 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(redeemscript));
158 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(scriptPubKey));
159 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
160 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
168 LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
173 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(witnessscript));
174 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(scriptPubKey));
175 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
176 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
184 LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
190 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(witnessscript_inner));
191 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(witnessscript));
192 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(scriptPubKey));
193 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
194 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
202 LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
203 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
208 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(scriptPubKey));
209 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
217 LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
218 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(uncompressedKey));
223 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
227 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(scriptPubKey));
228 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
236 LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
241 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
245 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(uncompressedKey));
247 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
251 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[1]));
253 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
257 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(scriptPubKey));
259 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
267 LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
268 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(uncompressedKey));
269 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[1]));
275 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
279 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(redeemScript));
280 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
288 LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
289 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
290 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[1]));
296 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
300 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(witnessScript));
301 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
305 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(scriptPubKey));
306 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
314 LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
315 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(uncompressedKey));
316 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[1]));
322 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
326 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(witnessScript));
327 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
331 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(scriptPubKey));
332 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
340 LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
347 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
351 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(redeemScript));
352 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(witnessScript));
353 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
357 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
358 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[1]));
359 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
367 LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
368 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
370 scriptPubKey.
clear();
373 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
381 LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
382 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
384 scriptPubKey.
clear();
387 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
395 LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
396 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
398 scriptPubKey.
clear();
401 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
409 LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
410 BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
412 scriptPubKey.
clear();
415 result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
void SetupLegacyScriptPubKeyMan()
Make a LegacyScriptPubKeyMan and set it for all types, internal, and external.
std::vector< unsigned char > ParseHex(const char *psz)
CScript GetScriptForRawPubKey(const CPubKey &pubKey)
Generate a P2PK script for the given pubkey.
std::unique_ptr< Chain > MakeChain(NodeContext &node)
Return implementation of Chain interface.
NodeContext struct containing references to chain state and connection state.
BOOST_AUTO_TEST_CASE(ismine_standard)
An encapsulated public key.
isminetype
IsMine() return codes.
std::unique_ptr< WalletDatabase > CreateDummyWalletDatabase()
Return object for accessing dummy database with no read/write capabilities.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
#define BOOST_FIXTURE_TEST_SUITE(a, b)
#define BOOST_CHECK_EQUAL(v1, v2)
Serialized script, used inside transaction inputs and outputs.
#define BOOST_AUTO_TEST_SUITE_END()
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
CScript GetScriptForMultisig(int nRequired, const std::vector< CPubKey > &keys)
Generate a multisig script.
An encapsulated private key.
#define BOOST_CHECK(expr)
std::vector< unsigned char > ToByteVector(const T &in)