Bitcoin Core  29.1.0
P2P Digital Currency
script_standard_tests.cpp
Go to the documentation of this file.
1 // Copyright (c) 2017-2022 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <test/data/bip341_wallet_vectors.json.h>
6 
7 #include <key.h>
8 #include <key_io.h>
9 #include <script/script.h>
10 #include <script/signingprovider.h>
11 #include <script/solver.h>
12 #include <test/util/setup_common.h>
13 #include <util/strencodings.h>
14 
15 #include <boost/test/unit_test.hpp>
16 
17 #include <univalue.h>
18 
19 using namespace util::hex_literals;
20 
21 BOOST_FIXTURE_TEST_SUITE(script_standard_tests, BasicTestingSetup)
22 
23 BOOST_AUTO_TEST_CASE(dest_default_is_no_dest)
24 {
25  CTxDestination dest;
27 }
28 
29 BOOST_AUTO_TEST_CASE(script_standard_Solver_success)
30 {
31  CKey keys[3];
32  CPubKey pubkeys[3];
33  for (int i = 0; i < 3; i++) {
34  keys[i].MakeNewKey(true);
35  pubkeys[i] = keys[i].GetPubKey();
36  }
37 
38  CScript s;
39  std::vector<std::vector<unsigned char> > solutions;
40 
41  // TxoutType::PUBKEY
42  s.clear();
43  s << ToByteVector(pubkeys[0]) << OP_CHECKSIG;
45  BOOST_CHECK_EQUAL(solutions.size(), 1U);
46  BOOST_CHECK(solutions[0] == ToByteVector(pubkeys[0]));
47 
48  // TxoutType::PUBKEYHASH
49  s.clear();
50  s << OP_DUP << OP_HASH160 << ToByteVector(pubkeys[0].GetID()) << OP_EQUALVERIFY << OP_CHECKSIG;
52  BOOST_CHECK_EQUAL(solutions.size(), 1U);
53  BOOST_CHECK(solutions[0] == ToByteVector(pubkeys[0].GetID()));
54 
55  // TxoutType::SCRIPTHASH
56  CScript redeemScript(s); // initialize with leftover P2PKH script
57  s.clear();
58  s << OP_HASH160 << ToByteVector(CScriptID(redeemScript)) << OP_EQUAL;
60  BOOST_CHECK_EQUAL(solutions.size(), 1U);
61  BOOST_CHECK(solutions[0] == ToByteVector(CScriptID(redeemScript)));
62 
63  // TxoutType::MULTISIG
64  s.clear();
65  s << OP_1 <<
66  ToByteVector(pubkeys[0]) <<
67  ToByteVector(pubkeys[1]) <<
70  BOOST_CHECK_EQUAL(solutions.size(), 4U);
71  BOOST_CHECK(solutions[0] == std::vector<unsigned char>({1}));
72  BOOST_CHECK(solutions[1] == ToByteVector(pubkeys[0]));
73  BOOST_CHECK(solutions[2] == ToByteVector(pubkeys[1]));
74  BOOST_CHECK(solutions[3] == std::vector<unsigned char>({2}));
75 
76  s.clear();
77  s << OP_2 <<
78  ToByteVector(pubkeys[0]) <<
79  ToByteVector(pubkeys[1]) <<
80  ToByteVector(pubkeys[2]) <<
83  BOOST_CHECK_EQUAL(solutions.size(), 5U);
84  BOOST_CHECK(solutions[0] == std::vector<unsigned char>({2}));
85  BOOST_CHECK(solutions[1] == ToByteVector(pubkeys[0]));
86  BOOST_CHECK(solutions[2] == ToByteVector(pubkeys[1]));
87  BOOST_CHECK(solutions[3] == ToByteVector(pubkeys[2]));
88  BOOST_CHECK(solutions[4] == std::vector<unsigned char>({3}));
89 
90  // TxoutType::NULL_DATA
91  s.clear();
92  s << OP_RETURN <<
93  std::vector<unsigned char>({0}) <<
94  std::vector<unsigned char>({75}) <<
95  std::vector<unsigned char>({255});
97  BOOST_CHECK_EQUAL(solutions.size(), 0U);
98 
99  // TxoutType::WITNESS_V0_KEYHASH
100  s.clear();
101  s << OP_0 << ToByteVector(pubkeys[0].GetID());
103  BOOST_CHECK_EQUAL(solutions.size(), 1U);
104  BOOST_CHECK(solutions[0] == ToByteVector(pubkeys[0].GetID()));
105 
106  // TxoutType::WITNESS_V0_SCRIPTHASH
107  uint256 scriptHash;
108  CSHA256().Write(redeemScript.data(), redeemScript.size())
109  .Finalize(scriptHash.begin());
110 
111  s.clear();
112  s << OP_0 << ToByteVector(scriptHash);
114  BOOST_CHECK_EQUAL(solutions.size(), 1U);
115  BOOST_CHECK(solutions[0] == ToByteVector(scriptHash));
116 
117  // TxoutType::WITNESS_V1_TAPROOT
118  s.clear();
121  BOOST_CHECK_EQUAL(solutions.size(), 1U);
122  BOOST_CHECK(solutions[0] == ToByteVector(uint256::ZERO));
123 
124  // TxoutType::WITNESS_UNKNOWN
125  s.clear();
128  BOOST_CHECK_EQUAL(solutions.size(), 2U);
129  BOOST_CHECK(solutions[0] == std::vector<unsigned char>{16});
130  BOOST_CHECK(solutions[1] == ToByteVector(uint256::ONE));
131 
132  // TxoutType::ANCHOR
133  std::vector<unsigned char> anchor_bytes{0x4e, 0x73};
134  s.clear();
135  s << OP_1 << anchor_bytes;
137  BOOST_CHECK(solutions.empty());
138 
139  // Sanity-check IsPayToAnchor
140  int version{-1};
141  std::vector<unsigned char> witness_program;
142  BOOST_CHECK(s.IsPayToAnchor());
143  BOOST_CHECK(s.IsWitnessProgram(version, witness_program));
144  BOOST_CHECK(CScript::IsPayToAnchor(version, witness_program));
145 
146  // TxoutType::NONSTANDARD
147  s.clear();
148  s << OP_9 << OP_ADD << OP_11 << OP_EQUAL;
150 }
151 
152 BOOST_AUTO_TEST_CASE(script_standard_Solver_failure)
153 {
154  CKey key = GenerateRandomKey();
155  CPubKey pubkey = key.GetPubKey();
156 
157  CScript s;
158  std::vector<std::vector<unsigned char> > solutions;
159 
160  // TxoutType::PUBKEY with incorrectly sized pubkey
161  s.clear();
162  s << std::vector<unsigned char>(30, 0x01) << OP_CHECKSIG;
164 
165  // TxoutType::PUBKEYHASH with incorrectly sized key hash
166  s.clear();
167  s << OP_DUP << OP_HASH160 << ToByteVector(pubkey) << OP_EQUALVERIFY << OP_CHECKSIG;
169 
170  // TxoutType::SCRIPTHASH with incorrectly sized script hash
171  s.clear();
172  s << OP_HASH160 << std::vector<unsigned char>(21, 0x01) << OP_EQUAL;
174 
175  // TxoutType::MULTISIG 0/2
176  s.clear();
177  s << OP_0 << ToByteVector(pubkey) << OP_1 << OP_CHECKMULTISIG;
179 
180  // TxoutType::MULTISIG 2/1
181  s.clear();
182  s << OP_2 << ToByteVector(pubkey) << OP_1 << OP_CHECKMULTISIG;
184 
185  // TxoutType::MULTISIG n = 2 with 1 pubkey
186  s.clear();
187  s << OP_1 << ToByteVector(pubkey) << OP_2 << OP_CHECKMULTISIG;
189 
190  // TxoutType::MULTISIG n = 1 with 0 pubkeys
191  s.clear();
192  s << OP_1 << OP_1 << OP_CHECKMULTISIG;
194 
195  // TxoutType::NULL_DATA with other opcodes
196  s.clear();
197  s << OP_RETURN << std::vector<unsigned char>({75}) << OP_ADD;
199 
200  // TxoutType::WITNESS_UNKNOWN with incorrect program size
201  s.clear();
202  s << OP_0 << std::vector<unsigned char>(19, 0x01);
204 
205  // TxoutType::ANCHOR but wrong witness version
206  s.clear();
207  s << OP_2 << std::vector<unsigned char>{0x4e, 0x73};
208  BOOST_CHECK(!s.IsPayToAnchor());
210 
211  // TxoutType::ANCHOR but wrong 2-byte data push
212  s.clear();
213  s << OP_1 << std::vector<unsigned char>{0xff, 0xff};
214  BOOST_CHECK(!s.IsPayToAnchor());
216 }
217 
218 BOOST_AUTO_TEST_CASE(script_standard_ExtractDestination)
219 {
220  CKey key = GenerateRandomKey();
221  CPubKey pubkey = key.GetPubKey();
222 
223  CScript s;
224  CTxDestination address;
225 
226  // TxoutType::PUBKEY
227  s.clear();
228  s << ToByteVector(pubkey) << OP_CHECKSIG;
229  BOOST_CHECK(!ExtractDestination(s, address));
230  BOOST_CHECK(std::get<PubKeyDestination>(address) == PubKeyDestination(pubkey));
231 
232  // TxoutType::PUBKEYHASH
233  s.clear();
235  BOOST_CHECK(ExtractDestination(s, address));
236  BOOST_CHECK(std::get<PKHash>(address) == PKHash(pubkey));
237 
238  // TxoutType::SCRIPTHASH
239  CScript redeemScript(s); // initialize with leftover P2PKH script
240  s.clear();
241  s << OP_HASH160 << ToByteVector(CScriptID(redeemScript)) << OP_EQUAL;
242  BOOST_CHECK(ExtractDestination(s, address));
243  BOOST_CHECK(std::get<ScriptHash>(address) == ScriptHash(redeemScript));
244 
245  // TxoutType::MULTISIG
246  s.clear();
247  s << OP_1 << ToByteVector(pubkey) << OP_1 << OP_CHECKMULTISIG;
248  BOOST_CHECK(!ExtractDestination(s, address));
249 
250  // TxoutType::NULL_DATA
251  s.clear();
252  s << OP_RETURN << std::vector<unsigned char>({75});
253  BOOST_CHECK(!ExtractDestination(s, address));
254 
255  // TxoutType::WITNESS_V0_KEYHASH
256  s.clear();
257  s << OP_0 << ToByteVector(pubkey.GetID());
258  BOOST_CHECK(ExtractDestination(s, address));
259  WitnessV0KeyHash keyhash;
260  CHash160().Write(pubkey).Finalize(keyhash);
261  BOOST_CHECK(std::get<WitnessV0KeyHash>(address) == keyhash);
262 
263  // TxoutType::WITNESS_V0_SCRIPTHASH
264  s.clear();
265  WitnessV0ScriptHash scripthash;
266  CSHA256().Write(redeemScript.data(), redeemScript.size()).Finalize(scripthash.begin());
267  s << OP_0 << ToByteVector(scripthash);
268  BOOST_CHECK(ExtractDestination(s, address));
269  BOOST_CHECK(std::get<WitnessV0ScriptHash>(address) == scripthash);
270 
271  // TxoutType::WITNESS_UNKNOWN with unknown version
272  s.clear();
273  s << OP_1 << ToByteVector(pubkey);
274  BOOST_CHECK(ExtractDestination(s, address));
275  WitnessUnknown unk{1, ToByteVector(pubkey)};
276  BOOST_CHECK(std::get<WitnessUnknown>(address) == unk);
277 }
278 
279 BOOST_AUTO_TEST_CASE(script_standard_GetScriptFor_)
280 {
281  CKey keys[3];
282  CPubKey pubkeys[3];
283  for (int i = 0; i < 3; i++) {
284  keys[i].MakeNewKey(true);
285  pubkeys[i] = keys[i].GetPubKey();
286  }
287 
288  CScript expected, result;
289 
290  // PKHash
291  expected.clear();
292  expected << OP_DUP << OP_HASH160 << ToByteVector(pubkeys[0].GetID()) << OP_EQUALVERIFY << OP_CHECKSIG;
293  result = GetScriptForDestination(PKHash(pubkeys[0]));
294  BOOST_CHECK(result == expected);
295 
296  // CScriptID
297  CScript redeemScript(result);
298  expected.clear();
299  expected << OP_HASH160 << ToByteVector(CScriptID(redeemScript)) << OP_EQUAL;
300  result = GetScriptForDestination(ScriptHash(redeemScript));
301  BOOST_CHECK(result == expected);
302 
303  // CNoDestination
304  expected.clear();
306  BOOST_CHECK(result == expected);
307 
308  // GetScriptForRawPubKey
309  expected.clear();
310  expected << ToByteVector(pubkeys[0]) << OP_CHECKSIG;
311  result = GetScriptForRawPubKey(pubkeys[0]);
312  BOOST_CHECK(result == expected);
313 
314  // GetScriptForMultisig
315  expected.clear();
316  expected << OP_2 <<
317  ToByteVector(pubkeys[0]) <<
318  ToByteVector(pubkeys[1]) <<
319  ToByteVector(pubkeys[2]) <<
321  result = GetScriptForMultisig(2, std::vector<CPubKey>(pubkeys, pubkeys + 3));
322  BOOST_CHECK(result == expected);
323 
324  // WitnessV0KeyHash
325  expected.clear();
326  expected << OP_0 << ToByteVector(pubkeys[0].GetID());
328  BOOST_CHECK(result == expected);
329  result = GetScriptForDestination(WitnessV0KeyHash(pubkeys[0].GetID()));
330  BOOST_CHECK(result == expected);
331 
332  // WitnessV0ScriptHash (multisig)
333  CScript witnessScript;
334  witnessScript << OP_1 << ToByteVector(pubkeys[0]) << OP_1 << OP_CHECKMULTISIG;
335 
336  uint256 scriptHash;
337  CSHA256().Write(witnessScript.data(), witnessScript.size())
338  .Finalize(scriptHash.begin());
339 
340  expected.clear();
341  expected << OP_0 << ToByteVector(scriptHash);
343  BOOST_CHECK(result == expected);
344 }
345 
346 BOOST_AUTO_TEST_CASE(script_standard_taproot_builder)
347 {
388  BOOST_CHECK_EQUAL(TaprootBuilder::ValidDepths({2,2,2,3,4,5,6,7,8,9,10,11,12,14,14,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,31,31,31,31,31,31,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,128}), true);
389  BOOST_CHECK_EQUAL(TaprootBuilder::ValidDepths({128,128,127,126,125,124,123,122,121,120,119,118,117,116,115,114,113,112,111,110,109,108,107,106,105,104,103,102,101,100,99,98,97,96,95,94,93,92,91,90,89,88,87,86,85,84,83,82,81,80,79,78,77,76,75,74,73,72,71,70,69,68,67,66,65,64,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}), true);
390  BOOST_CHECK_EQUAL(TaprootBuilder::ValidDepths({129,129,128,127,126,125,124,123,122,121,120,119,118,117,116,115,114,113,112,111,110,109,108,107,106,105,104,103,102,101,100,99,98,97,96,95,94,93,92,91,90,89,88,87,86,85,84,83,82,81,80,79,78,77,76,75,74,73,72,71,70,69,68,67,66,65,64,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}), false);
391 
392  XOnlyPubKey key_inner{"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"_hex_u8};
393  XOnlyPubKey key_1{"c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5"_hex_u8};
394  XOnlyPubKey key_2{"f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"_hex_u8};
395  CScript script_1 = CScript() << ToByteVector(key_1) << OP_CHECKSIG;
396  CScript script_2 = CScript() << ToByteVector(key_2) << OP_CHECKSIG;
397  constexpr uint256 hash_3{"31fe7061656bea2a36aa60a2f7ef940578049273746935d296426dc0afd86b68"};
398 
399  TaprootBuilder builder;
400  BOOST_CHECK(builder.IsValid() && builder.IsComplete());
401  builder.Add(2, script_2, 0xc0);
402  BOOST_CHECK(builder.IsValid() && !builder.IsComplete());
403  builder.AddOmitted(2, hash_3);
404  BOOST_CHECK(builder.IsValid() && !builder.IsComplete());
405  builder.Add(1, script_1, 0xc0);
406  BOOST_CHECK(builder.IsValid() && builder.IsComplete());
407  builder.Finalize(key_inner);
408  BOOST_CHECK(builder.IsValid() && builder.IsComplete());
409  BOOST_CHECK_EQUAL(EncodeDestination(builder.GetOutput()), "bc1pj6gaw944fy0xpmzzu45ugqde4rz7mqj5kj0tg8kmr5f0pjq8vnaqgynnge");
410 }
411 
412 BOOST_AUTO_TEST_CASE(bip341_spk_test_vectors)
413 {
414  using control_set = decltype(TaprootSpendData::scripts)::mapped_type;
415 
416  UniValue tests;
417  tests.read(json_tests::bip341_wallet_vectors);
418 
419  const auto& vectors = tests["scriptPubKey"];
420 
421  for (const auto& vec : vectors.getValues()) {
422  TaprootBuilder spktest;
423  std::map<std::pair<std::vector<unsigned char>, int>, int> scriptposes;
424  std::function<void (const UniValue&, int)> parse_tree = [&](const UniValue& node, int depth) {
425  if (node.isNull()) return;
426  if (node.isObject()) {
427  auto script = ParseHex(node["script"].get_str());
428  int idx = node["id"].getInt<int>();
429  int leaf_version = node["leafVersion"].getInt<int>();
430  scriptposes[{script, leaf_version}] = idx;
431  spktest.Add(depth, script, leaf_version);
432  } else {
433  parse_tree(node[0], depth + 1);
434  parse_tree(node[1], depth + 1);
435  }
436  };
437  parse_tree(vec["given"]["scriptTree"], 0);
438  spktest.Finalize(XOnlyPubKey(ParseHex(vec["given"]["internalPubkey"].get_str())));
439  BOOST_CHECK_EQUAL(HexStr(GetScriptForDestination(spktest.GetOutput())), vec["expected"]["scriptPubKey"].get_str());
440  BOOST_CHECK_EQUAL(EncodeDestination(spktest.GetOutput()), vec["expected"]["bip350Address"].get_str());
441  auto spend_data = spktest.GetSpendData();
442  BOOST_CHECK_EQUAL(vec["intermediary"]["merkleRoot"].isNull(), spend_data.merkle_root.IsNull());
443  if (!spend_data.merkle_root.IsNull()) {
444  BOOST_CHECK_EQUAL(vec["intermediary"]["merkleRoot"].get_str(), HexStr(spend_data.merkle_root));
445  }
446  BOOST_CHECK_EQUAL(spend_data.scripts.size(), scriptposes.size());
447  for (const auto& scriptpos : scriptposes) {
448  BOOST_CHECK(spend_data.scripts[scriptpos.first] == control_set{ParseHex(vec["expected"]["scriptPathControlBlocks"][scriptpos.second].get_str())});
449  }
450  }
451 }
452 
CSHA256 & Write(const unsigned char *data, size_t len)
Definition: sha256.cpp:701
CScript GetScriptForMultisig(int nRequired, const std::vector< CPubKey > &keys)
Generate a multisig script.
Definition: solver.cpp:218
unsigned char * begin()
Definition: hash_type.h:18
static const uint256 ONE
Definition: uint256.h:210
std::vector< Byte > ParseHex(std::string_view hex_str)
Like TryParseHex, but returns an empty vector on invalid input.
Definition: strencodings.h:68
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination corresponds to one with an address.
Definition: script.h:125
void Finalize(Span< unsigned char > output)
Definition: hash.h:55
CPubKey GetPubKey() const
Compute the public key from a private key.
Definition: key.cpp:182
TxoutType Solver(const CScript &scriptPubKey, std::vector< std::vector< unsigned char >> &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
Definition: solver.cpp:141
Definition: script.h:161
TaprootBuilder & AddOmitted(int depth, const uint256 &hash)
Like Add(), but for a Merkle node with a given hash to the tree.
Definition: script.h:76
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
Definition: pubkey.h:164
value_type * data()
Definition: prevector.h:533
Basic testing setup.
Definition: setup_common.h:64
constexpr unsigned char * begin()
Definition: uint256.h:115
Definition: script.h:83
CKey GenerateRandomKey(bool compressed) noexcept
Definition: key.cpp:352
constexpr std::array tests
Definition: unitester.cpp:100
Definition: script.h:94
anyone can spend script
std::map< std::pair< std::vector< unsigned char >, int >, std::set< std::vector< unsigned char >, ShortestVectorFirstComparator > > scripts
Map from (script, leaf_version) to (sets of) control blocks.
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a scriptPubKey for the destination.
Definition: addresstype.cpp:49
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
CTxDestination subtype to encode any future Witness version.
Definition: addresstype.h:95
BOOST_AUTO_TEST_SUITE_END()
TaprootBuilder & Finalize(const XOnlyPubKey &internal_key)
Finalize the construction.
An encapsulated public key.
Definition: pubkey.h:33
static const uint256 ZERO
Definition: uint256.h:209
WitnessV1Taproot GetOutput()
Compute scriptPubKey (after Finalize()).
void MakeNewKey(bool fCompressed)
Generate a new private key using a cryptographic PRNG.
Definition: key.cpp:161
""_hex is a compile-time user-defined literal returning a std::array<std::byte>, equivalent to ParseH...
Definition: strencodings.h:427
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
bool IsPayToAnchor() const
Definition: script.cpp:207
TaprootSpendData GetSpendData() const
Compute spending data (after Finalize()).
Definition: messages.h:20
Utility class to construct Taproot outputs from internal key and script tree.
uint160 Hash160(const T1 &in1)
Compute the 160-bit hash an object.
Definition: hash.h:92
std::vector< unsigned char > ToByteVector(const T &in)
Definition: script.h:67
256-bit opaque blob.
Definition: uint256.h:201
static bool ValidDepths(const std::vector< int > &depths)
Check if a list of depths is legal (will lead to IsComplete()).
auto result
Definition: common-types.h:74
Definition: script.h:92
#define BOOST_CHECK_EQUAL(v1, v2)
Definition: object.cpp:18
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:414
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
Definition: addresstype.h:140
TaprootBuilder & Add(int depth, Span< const unsigned char > script, int leaf_version, bool track=true)
Add a new script at a certain depth in the tree.
Definition: script.h:86
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
Definition: hex_base.cpp:29
A reference to a CScript: the Hash160 of its serialization.
Definition: script.h:601
std::string EncodeDestination(const CTxDestination &dest)
Definition: key_io.cpp:294
CScript GetScriptForRawPubKey(const CPubKey &pubKey)
Generate a P2PK script for the given pubkey.
Definition: solver.cpp:213
size_type size() const
Definition: prevector.h:294
Definition: script.h:85
bool IsComplete() const
Return whether there were either no leaves, or the leaves form a Huffman tree.
Definition: script.h:99
An encapsulated private key.
Definition: key.h:34
A hasher class for Bitcoin&#39;s 160-bit hash (SHA-256 + RIPEMD-160).
Definition: hash.h:49
bool IsValid() const
Return true if so far all input was valid.
A hasher class for SHA-256.
Definition: sha256.h:13
Only for Witness versions not already defined above.
void clear()
Definition: script.h:576
CHash160 & Write(Span< const unsigned char > input)
Definition: hash.h:62
BOOST_AUTO_TEST_CASE(dest_default_is_no_dest)
#define BOOST_CHECK(expr)
Definition: object.cpp:17
unspendable OP_RETURN script that carries data