PIVX Core  5.6.99
P2P Digital Currency
script_standard_tests.cpp
Go to the documentation of this file.
1 // Copyright (c) 2017 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or https://www.opensource.org/licenses/mit-license.php.
4 
5 #include "key.h"
6 #include "keystore.h"
7 #include "script/ismine.h"
8 #include "script/script.h"
9 #include "script/standard.h"
10 #include "test/test_pivx.h"
11 
12 #include <boost/test/unit_test.hpp>
13 
14 
15 BOOST_FIXTURE_TEST_SUITE(script_standard_tests, BasicTestingSetup)
16 
17 BOOST_AUTO_TEST_CASE(script_standard_Solver_success)
18 {
19  CKey keys[3];
20  CPubKey pubkeys[3];
21  for (int i = 0; i < 3; i++) {
22  keys[i].MakeNewKey(true);
23  pubkeys[i] = keys[i].GetPubKey();
24  }
25 
26  CScript s;
27  txnouttype whichType;
28  std::vector<std::vector<unsigned char> > solutions;
29 
30  // TX_PUBKEY
31  s.clear();
32  s << ToByteVector(pubkeys[0]) << OP_CHECKSIG;
33  BOOST_CHECK(Solver(s, whichType, solutions));
34  BOOST_CHECK_EQUAL(whichType, TX_PUBKEY);
35  BOOST_CHECK_EQUAL(solutions.size(), 1);
36  BOOST_CHECK(solutions[0] == ToByteVector(pubkeys[0]));
37 
38  // TX_PUBKEYHASH
39  s.clear();
40  s << OP_DUP << OP_HASH160 << ToByteVector(pubkeys[0].GetID()) << OP_EQUALVERIFY << OP_CHECKSIG;
41  BOOST_CHECK(Solver(s, whichType, solutions));
42  BOOST_CHECK_EQUAL(whichType, TX_PUBKEYHASH);
43  BOOST_CHECK_EQUAL(solutions.size(), 1);
44  BOOST_CHECK(solutions[0] == ToByteVector(pubkeys[0].GetID()));
45 
46  // TX_EXCHANGEADDR
47  s.clear();
48  s << OP_EXCHANGEADDR << OP_DUP << OP_HASH160 << ToByteVector(pubkeys[0].GetID()) << OP_EQUALVERIFY << OP_CHECKSIG;
49  BOOST_CHECK(Solver(s, whichType, solutions));
51  BOOST_CHECK_EQUAL(solutions.size(), 1);
52  BOOST_CHECK(solutions[0] == ToByteVector(pubkeys[0].GetID()));
53 
54  // TX_SCRIPTHASH
55  CScript redeemScript(s); // initialize with leftover P2PKH script
56  s.clear();
57  s << OP_HASH160 << ToByteVector(CScriptID(redeemScript)) << OP_EQUAL;
58  BOOST_CHECK(Solver(s, whichType, solutions));
59  BOOST_CHECK_EQUAL(whichType, TX_SCRIPTHASH);
60  BOOST_CHECK_EQUAL(solutions.size(), 1);
61  BOOST_CHECK(solutions[0] == ToByteVector(CScriptID(redeemScript)));
62 
63  // TX_MULTISIG
64  s.clear();
65  s << OP_1 <<
66  ToByteVector(pubkeys[0]) <<
67  ToByteVector(pubkeys[1]) <<
69  BOOST_CHECK(Solver(s, whichType, solutions));
70  BOOST_CHECK_EQUAL(whichType, TX_MULTISIG);
71  BOOST_CHECK_EQUAL(solutions.size(), 4);
72  BOOST_CHECK(solutions[0] == std::vector<unsigned char>({1}));
73  BOOST_CHECK(solutions[1] == ToByteVector(pubkeys[0]));
74  BOOST_CHECK(solutions[2] == ToByteVector(pubkeys[1]));
75  BOOST_CHECK(solutions[3] == std::vector<unsigned char>({2}));
76 
77  s.clear();
78  s << OP_2 <<
79  ToByteVector(pubkeys[0]) <<
80  ToByteVector(pubkeys[1]) <<
81  ToByteVector(pubkeys[2]) <<
83  BOOST_CHECK(Solver(s, whichType, solutions));
84  BOOST_CHECK_EQUAL(whichType, TX_MULTISIG);
85  BOOST_CHECK_EQUAL(solutions.size(), 5);
86  BOOST_CHECK(solutions[0] == std::vector<unsigned char>({2}));
87  BOOST_CHECK(solutions[1] == ToByteVector(pubkeys[0]));
88  BOOST_CHECK(solutions[2] == ToByteVector(pubkeys[1]));
89  BOOST_CHECK(solutions[3] == ToByteVector(pubkeys[2]));
90  BOOST_CHECK(solutions[4] == std::vector<unsigned char>({3}));
91 
92  // TX_NULL_DATA
93  s.clear();
94  s << OP_RETURN <<
95  std::vector<unsigned char>({0}) <<
96  std::vector<unsigned char>({75}) <<
97  std::vector<unsigned char>({255});
98  BOOST_CHECK(Solver(s, whichType, solutions));
99  BOOST_CHECK_EQUAL(whichType, TX_NULL_DATA);
100  BOOST_CHECK_EQUAL(solutions.size(), 0);
101 
102  // TX_NONSTANDARD
103  s.clear();
104  s << OP_9 << OP_ADD << OP_11 << OP_EQUAL;
105  BOOST_CHECK(!Solver(s, whichType, solutions));
106  BOOST_CHECK_EQUAL(whichType, TX_NONSTANDARD);
107 }
108 
109 BOOST_AUTO_TEST_CASE(script_standard_Solver_failure)
110 {
111  CKey key;
112  CPubKey pubkey;
113  key.MakeNewKey(true);
114  pubkey = key.GetPubKey();
115 
116  CScript s;
117  txnouttype whichType;
118  std::vector<std::vector<unsigned char> > solutions;
119 
120  // TX_PUBKEY with incorrectly sized pubkey
121  s.clear();
122  s << std::vector<unsigned char>(30, 0x01) << OP_CHECKSIG;
123  BOOST_CHECK(!Solver(s, whichType, solutions));
124 
125  // TX_PUBKEYHASH with incorrectly sized key hash
126  s.clear();
127  s << OP_DUP << OP_HASH160 << ToByteVector(pubkey) << OP_EQUALVERIFY << OP_CHECKSIG;
128  BOOST_CHECK(!Solver(s, whichType, solutions));
129 
130  // TX_EXCHANGEADDR with incorrectly sized key hash
131  s.clear();
133  BOOST_CHECK(!Solver(s, whichType, solutions));
134 
135  // TX_SCRIPTHASH with incorrectly sized script hash
136  s.clear();
137  s << OP_HASH160 << std::vector<unsigned char>(21, 0x01) << OP_EQUAL;
138  BOOST_CHECK(!Solver(s, whichType, solutions));
139 
140  // TX_MULTISIG 0/2
141  s.clear();
142  s << OP_0 << ToByteVector(pubkey) << OP_1 << OP_CHECKMULTISIG;
143  BOOST_CHECK(!Solver(s, whichType, solutions));
144 
145  // TX_MULTISIG 2/1
146  s.clear();
147  s << OP_2 << ToByteVector(pubkey) << OP_1 << OP_CHECKMULTISIG;
148  BOOST_CHECK(!Solver(s, whichType, solutions));
149 
150  // TX_MULTISIG n = 2 with 1 pubkey
151  s.clear();
152  s << OP_1 << ToByteVector(pubkey) << OP_2 << OP_CHECKMULTISIG;
153  BOOST_CHECK(!Solver(s, whichType, solutions));
154 
155  // TX_MULTISIG n = 1 with 0 pubkeys
156  s.clear();
157  s << OP_1 << OP_1 << OP_CHECKMULTISIG;
158  BOOST_CHECK(!Solver(s, whichType, solutions));
159 
160  // TX_NULL_DATA with other opcodes
161  s.clear();
162  s << OP_RETURN << std::vector<unsigned char>({75}) << OP_ADD;
163  BOOST_CHECK(!Solver(s, whichType, solutions));
164 
165  // TX_WITNESS with incorrect program size
166  s.clear();
167  s << OP_0 << std::vector<unsigned char>(19, 0x01);
168  BOOST_CHECK(!Solver(s, whichType, solutions));
169 }
170 
171 BOOST_AUTO_TEST_CASE(script_standard_ExtractDestination)
172 {
173  CKey key;
174  CPubKey pubkey;
175  key.MakeNewKey(true);
176  pubkey = key.GetPubKey();
177 
178  CScript s;
179  CTxDestination address;
180 
181  // TX_PUBKEY
182  s.clear();
183  s << ToByteVector(pubkey) << OP_CHECKSIG;
184  BOOST_CHECK(ExtractDestination(s, address));
185  BOOST_CHECK(boost::get<CKeyID>(&address) &&
186  *boost::get<CKeyID>(&address) == pubkey.GetID());
187 
188  // TX_PUBKEYHASH
189  s.clear();
190  s << OP_DUP << OP_HASH160 << ToByteVector(pubkey.GetID()) << OP_EQUALVERIFY << OP_CHECKSIG;
191  BOOST_CHECK(ExtractDestination(s, address));
192  BOOST_CHECK(boost::get<CKeyID>(&address) &&
193  *boost::get<CKeyID>(&address) == pubkey.GetID());
194 
195  // TX_EXCHANGEADDR
196  s.clear();
198  BOOST_CHECK(ExtractDestination(s, address));
199  BOOST_CHECK(boost::get<CExchangeKeyID>(&address) &&
200  *boost::get<CExchangeKeyID>(&address) == pubkey.GetID());
201 
202  // TX_SCRIPTHASH
203  CScript redeemScript(s); // initialize with leftover P2PKH script
204  s.clear();
205  s << OP_HASH160 << ToByteVector(CScriptID(redeemScript)) << OP_EQUAL;
206  BOOST_CHECK(ExtractDestination(s, address));
207  BOOST_CHECK(boost::get<CScriptID>(&address) &&
208  *boost::get<CScriptID>(&address) == CScriptID(redeemScript));
209 
210  // TX_MULTISIG
211  s.clear();
212  s << OP_1 << ToByteVector(pubkey) << OP_1 << OP_CHECKMULTISIG;
213  BOOST_CHECK(!ExtractDestination(s, address));
214 
215  // TX_NULL_DATA
216  s.clear();
217  s << OP_RETURN << std::vector<unsigned char>({75});
218  BOOST_CHECK(!ExtractDestination(s, address));
219 }
220 
221 BOOST_AUTO_TEST_CASE(script_standard_ExtractDestinations)
222 {
223  CKey keys[3];
224  CPubKey pubkeys[3];
225  for (int i = 0; i < 3; i++) {
226  keys[i].MakeNewKey(true);
227  pubkeys[i] = keys[i].GetPubKey();
228  }
229 
230  CScript s;
231  txnouttype whichType;
232  std::vector<CTxDestination> addresses;
233  int nRequired;
234 
235  // TX_PUBKEY
236  s.clear();
237  s << ToByteVector(pubkeys[0]) << OP_CHECKSIG;
238  BOOST_CHECK(ExtractDestinations(s, whichType, addresses, nRequired));
239  BOOST_CHECK_EQUAL(whichType, TX_PUBKEY);
240  BOOST_CHECK_EQUAL(addresses.size(), 1);
241  BOOST_CHECK_EQUAL(nRequired, 1);
242  BOOST_CHECK(boost::get<CKeyID>(&addresses[0]) &&
243  *boost::get<CKeyID>(&addresses[0]) == pubkeys[0].GetID());
244 
245  // TX_PUBKEYHASH
246  s.clear();
247  s << OP_DUP << OP_HASH160 << ToByteVector(pubkeys[0].GetID()) << OP_EQUALVERIFY << OP_CHECKSIG;
248  BOOST_CHECK(ExtractDestinations(s, whichType, addresses, nRequired));
249  BOOST_CHECK_EQUAL(whichType, TX_PUBKEYHASH);
250  BOOST_CHECK_EQUAL(addresses.size(), 1);
251  BOOST_CHECK_EQUAL(nRequired, 1);
252  BOOST_CHECK(boost::get<CKeyID>(&addresses[0]) &&
253  *boost::get<CKeyID>(&addresses[0]) == pubkeys[0].GetID());
254 
255  // TX_EXCHANGEADDR
256  s.clear();
257  s << OP_EXCHANGEADDR << OP_DUP << OP_HASH160 << ToByteVector(pubkeys[0].GetID()) << OP_EQUALVERIFY << OP_CHECKSIG;
258  BOOST_CHECK(ExtractDestinations(s, whichType, addresses, nRequired));
260  BOOST_CHECK_EQUAL(addresses.size(), 1);
261  BOOST_CHECK_EQUAL(nRequired, 1);
262  BOOST_CHECK(boost::get<CExchangeKeyID>(&addresses[0]) &&
263  *boost::get<CExchangeKeyID>(&addresses[0]) == pubkeys[0].GetID());
264 
265  // TX_SCRIPTHASH
266  CScript redeemScript(s); // initialize with leftover P2PKH script
267  s.clear();
268  s << OP_HASH160 << ToByteVector(CScriptID(redeemScript)) << OP_EQUAL;
269  BOOST_CHECK(ExtractDestinations(s, whichType, addresses, nRequired));
270  BOOST_CHECK_EQUAL(whichType, TX_SCRIPTHASH);
271  BOOST_CHECK_EQUAL(addresses.size(), 1);
272  BOOST_CHECK_EQUAL(nRequired, 1);
273  BOOST_CHECK(boost::get<CScriptID>(&addresses[0]) &&
274  *boost::get<CScriptID>(&addresses[0]) == CScriptID(redeemScript));
275 
276  // TX_MULTISIG
277  s.clear();
278  s << OP_2 <<
279  ToByteVector(pubkeys[0]) <<
280  ToByteVector(pubkeys[1]) <<
282  BOOST_CHECK(ExtractDestinations(s, whichType, addresses, nRequired));
283  BOOST_CHECK_EQUAL(whichType, TX_MULTISIG);
284  BOOST_CHECK_EQUAL(addresses.size(), 2);
285  BOOST_CHECK_EQUAL(nRequired, 2);
286  BOOST_CHECK(boost::get<CKeyID>(&addresses[0]) &&
287  *boost::get<CKeyID>(&addresses[0]) == pubkeys[0].GetID());
288  BOOST_CHECK(boost::get<CKeyID>(&addresses[1]) &&
289  *boost::get<CKeyID>(&addresses[1]) == pubkeys[1].GetID());
290 
291  // TX_NULL_DATA
292  s.clear();
293  s << OP_RETURN << std::vector<unsigned char>({75});
294  BOOST_CHECK(!ExtractDestinations(s, whichType, addresses, nRequired));
295 }
296 
297 BOOST_AUTO_TEST_CASE(script_standard_GetScriptFor_)
298 {
299  CKey keys[3];
300  CPubKey pubkeys[3];
301  for (int i = 0; i < 3; i++) {
302  keys[i].MakeNewKey(true);
303  pubkeys[i] = keys[i].GetPubKey();
304  }
305 
306  CScript expected, result;
307 
308  // CKeyID
309  expected.clear();
310  expected << OP_DUP << OP_HASH160 << ToByteVector(pubkeys[0].GetID()) << OP_EQUALVERIFY << OP_CHECKSIG;
311  result = GetScriptForDestination(pubkeys[0].GetID());
312  BOOST_CHECK(result == expected);
313 
314  // CScriptID
315  CScript redeemScript(result);
316  expected.clear();
317  expected << OP_HASH160 << ToByteVector(CScriptID(redeemScript)) << OP_EQUAL;
318  result = GetScriptForDestination(CScriptID(redeemScript));
319  BOOST_CHECK(result == expected);
320 
321  // CNoDestination
322  expected.clear();
324  BOOST_CHECK(result == expected);
325 
326  // GetScriptForRawPubKey
327  expected.clear();
328  expected << ToByteVector(pubkeys[0]) << OP_CHECKSIG;
329  result = GetScriptForRawPubKey(pubkeys[0]);
330  BOOST_CHECK(result == expected);
331 
332  // GetScriptForMultisig
333  expected.clear();
334  expected << OP_2 <<
335  ToByteVector(pubkeys[0]) <<
336  ToByteVector(pubkeys[1]) <<
337  ToByteVector(pubkeys[2]) <<
339  result = GetScriptForMultisig(2, std::vector<CPubKey>(pubkeys, pubkeys + 3));
340  BOOST_CHECK(result == expected);
341 }
342 
343 BOOST_AUTO_TEST_CASE(script_standard_IsMine)
344 {
345  CKey keys[2];
346  CPubKey pubkeys[2];
347  for (int i = 0; i < 2; i++) {
348  keys[i].MakeNewKey(true);
349  pubkeys[i] = keys[i].GetPubKey();
350  }
351 
352  CKey uncompressedKey;
353  uncompressedKey.MakeNewKey(false);
354  CPubKey uncompressedPubkey = uncompressedKey.GetPubKey();
355 
356  CScript scriptPubKey;
357  isminetype result;
358 
359  // P2PK compressed
360  {
361  CBasicKeyStore keystore;
362  scriptPubKey.clear();
363  scriptPubKey << ToByteVector(pubkeys[0]) << OP_CHECKSIG;
364 
365  // Keystore does not have key
366  result = IsMine(keystore, scriptPubKey);
367  BOOST_CHECK_EQUAL(result, ISMINE_NO);
368 
369  // Keystore has key
370  keystore.AddKey(keys[0]);
371  result = IsMine(keystore, scriptPubKey);
373  }
374 
375  // P2PK uncompressed
376  {
377  CBasicKeyStore keystore;
378  scriptPubKey.clear();
379  scriptPubKey << ToByteVector(uncompressedPubkey) << OP_CHECKSIG;
380 
381  // Keystore does not have key
382  result = IsMine(keystore, scriptPubKey);
383  BOOST_CHECK_EQUAL(result, ISMINE_NO);
384 
385  // Keystore has key
386  keystore.AddKey(uncompressedKey);
387  result = IsMine(keystore, scriptPubKey);
389  }
390 
391  // P2PKH compressed
392  {
393  CBasicKeyStore keystore;
394  scriptPubKey.clear();
395  scriptPubKey << OP_DUP << OP_HASH160 << ToByteVector(pubkeys[0].GetID()) << OP_EQUALVERIFY << OP_CHECKSIG;
396 
397  // Keystore does not have key
398  result = IsMine(keystore, scriptPubKey);
399  BOOST_CHECK_EQUAL(result, ISMINE_NO);
400 
401  // Keystore has key
402  keystore.AddKey(keys[0]);
403  result = IsMine(keystore, scriptPubKey);
405  }
406 
407  // P2PKH uncompressed
408  {
409  CBasicKeyStore keystore;
410  scriptPubKey.clear();
411  scriptPubKey << OP_DUP << OP_HASH160 << ToByteVector(uncompressedPubkey.GetID()) << OP_EQUALVERIFY << OP_CHECKSIG;
412 
413  // Keystore does not have key
414  result = IsMine(keystore, scriptPubKey);
415  BOOST_CHECK_EQUAL(result, ISMINE_NO);
416 
417  // Keystore has key
418  keystore.AddKey(uncompressedKey);
419  result = IsMine(keystore, scriptPubKey);
421  }
422 
423  // P2SH
424  {
425  CBasicKeyStore keystore;
426 
427  CScript redeemScript;
428  redeemScript << OP_DUP << OP_HASH160 << ToByteVector(pubkeys[0].GetID()) << OP_EQUALVERIFY << OP_CHECKSIG;
429 
430  scriptPubKey.clear();
431  scriptPubKey << OP_HASH160 << ToByteVector(CScriptID(redeemScript)) << OP_EQUAL;
432 
433  // Keystore does not have redeemScript or key
434  result = IsMine(keystore, scriptPubKey);
435  BOOST_CHECK_EQUAL(result, ISMINE_NO);
436 
437  // Keystore has redeemScript but no key
438  keystore.AddCScript(redeemScript);
439  result = IsMine(keystore, scriptPubKey);
440  BOOST_CHECK_EQUAL(result, ISMINE_NO);
441 
442  // Keystore has redeemScript and key
443  keystore.AddKey(keys[0]);
444  result = IsMine(keystore, scriptPubKey);
446  }
447 
448  // scriptPubKey multisig
449  {
450  CBasicKeyStore keystore;
451 
452  scriptPubKey.clear();
453  scriptPubKey << OP_2 <<
454  ToByteVector(uncompressedPubkey) <<
455  ToByteVector(pubkeys[1]) <<
457 
458  // Keystore does not have any keys
459  result = IsMine(keystore, scriptPubKey);
460  BOOST_CHECK_EQUAL(result, ISMINE_NO);
461 
462  // Keystore has 1/2 keys
463  keystore.AddKey(uncompressedKey);
464 
465  result = IsMine(keystore, scriptPubKey);
466  BOOST_CHECK_EQUAL(result, ISMINE_NO);
467 
468  // Keystore has 2/2 keys
469  keystore.AddKey(keys[1]);
470 
471  result = IsMine(keystore, scriptPubKey);
473  }
474 
475  // P2SH multisig
476  {
477  CBasicKeyStore keystore;
478  keystore.AddKey(uncompressedKey);
479  keystore.AddKey(keys[1]);
480 
481  CScript redeemScript;
482  redeemScript << OP_2 <<
483  ToByteVector(uncompressedPubkey) <<
484  ToByteVector(pubkeys[1]) <<
486 
487  scriptPubKey.clear();
488  scriptPubKey << OP_HASH160 << ToByteVector(CScriptID(redeemScript)) << OP_EQUAL;
489 
490  // Keystore has no redeemScript
491  result = IsMine(keystore, scriptPubKey);
492  BOOST_CHECK_EQUAL(result, ISMINE_NO);
493 
494  // Keystore has redeemScript
495  keystore.AddCScript(redeemScript);
496  result = IsMine(keystore, scriptPubKey);
498  }
499 
500  // OP_RETURN
501  {
502  CBasicKeyStore keystore;
503  keystore.AddKey(keys[0]);
504 
505  scriptPubKey.clear();
506  scriptPubKey << OP_RETURN << ToByteVector(pubkeys[0]);
507 
508  result = IsMine(keystore, scriptPubKey);
509  BOOST_CHECK_EQUAL(result, ISMINE_NO);
510  }
511 
512  // Nonstandard
513  {
514  CBasicKeyStore keystore;
515  keystore.AddKey(keys[0]);
516 
517  scriptPubKey.clear();
518  scriptPubKey << OP_9 << OP_ADD << OP_11 << OP_EQUAL;
519 
520  result = IsMine(keystore, scriptPubKey);
521  BOOST_CHECK_EQUAL(result, ISMINE_NO);
522  }
523 }
524 
Basic key store, that keeps keys in an address->secret map.
Definition: keystore.h:99
virtual bool AddCScript(const CScript &redeemScript)
Support for BIP 0013 : see https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki.
Definition: keystore.cpp:41
An encapsulated private key.
Definition: key.h:30
void MakeNewKey(bool fCompressed)
Generate a new private key using a cryptographic PRNG.
Definition: key.cpp:158
CPubKey GetPubKey() const
Compute the public key from a private key.
Definition: key.cpp:186
virtual bool AddKey(const CKey &key)
Definition: keystore.cpp:14
An encapsulated public key.
Definition: pubkey.h:44
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
Definition: pubkey.h:167
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:381
void clear()
Definition: script.h:659
A reference to a CScript: the Hash160 of its serialization (see script.h)
Definition: standard.h:24
BOOST_AUTO_TEST_SUITE_END()
isminetype IsMine(const CKeyStore &keystore, const CTxDestination &dest)
Definition: ismine.cpp:29
isminetype
IsMine() return codes.
Definition: ismine.h:19
@ ISMINE_SPENDABLE
Definition: ismine.h:22
@ ISMINE_NO
Definition: ismine.h:20
#define BOOST_FIXTURE_TEST_SUITE(a, b)
Definition: object.cpp:14
#define BOOST_CHECK_EQUAL(v1, v2)
Definition: object.cpp:18
#define BOOST_CHECK(expr)
Definition: object.cpp:17
std::vector< unsigned char > ToByteVector(const T &in)
Definition: script.h:43
@ OP_2
Definition: script.h:61
@ OP_CHECKMULTISIG
Definition: script.h:168
@ OP_CHECKSIG
Definition: script.h:166
@ OP_EQUAL
Definition: script.h:122
@ OP_DUP
Definition: script.h:101
@ OP_HASH160
Definition: script.h:163
@ OP_1
Definition: script.h:59
@ OP_ADD
Definition: script.h:137
@ OP_9
Definition: script.h:68
@ OP_3
Definition: script.h:62
@ OP_11
Definition: script.h:70
@ OP_0
Definition: script.h:52
@ OP_RETURN
Definition: script.h:87
@ OP_EXCHANGEADDR
Definition: script.h:194
@ OP_EQUALVERIFY
Definition: script.h:123
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.
Definition: standard.cpp:195
CScript GetScriptForMultisig(int nRequired, const std::vector< CPubKey > &keys)
Generate a multisig script.
Definition: standard.cpp:311
bool Solver(const CScript &scriptPubKey, txnouttype &typeRet, std::vector< std::vector< unsigned char > > &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
Definition: standard.cpp:90
CScript GetScriptForRawPubKey(const CPubKey &pubKey)
Generate a P2PK script for the given pubkey.
Definition: standard.cpp:286
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a PIVX scriptPubKey for the given CTxDestination.
Definition: standard.cpp:278
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet, bool fColdStake)
Parse a standard scriptPubKey for the destination address.
Definition: standard.cpp:162
boost::variant< CNoDestination, CKeyID, CScriptID, CExchangeKeyID > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:72
txnouttype
Definition: standard.h:46
@ TX_PUBKEYHASH
Definition: standard.h:50
@ TX_PUBKEY
Definition: standard.h:49
@ TX_NULL_DATA
Definition: standard.h:53
@ TX_SCRIPTHASH
Definition: standard.h:51
@ TX_NONSTANDARD
Definition: standard.h:47
@ TX_MULTISIG
Definition: standard.h:52
@ TX_EXCHANGEADDR
Definition: standard.h:55
Basic testing setup.
Definition: test_pivx.h:51